[PATCH 2/2] erofs-utils: lazy write directory data

Gao Xiang hsiangkao at linux.alibaba.com
Fri Mar 17 19:50:09 AEDT 2023


Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
 include/erofs/cache.h | 11 ++++++-----
 lib/inode.c           |  9 +++++----
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/include/erofs/cache.h b/include/erofs/cache.h
index 1461305..d07a3cb 100644
--- a/include/erofs/cache.h
+++ b/include/erofs/cache.h
@@ -19,13 +19,14 @@ struct erofs_buffer_head;
 struct erofs_buffer_block;
 
 #define DATA		0
-#define META		1
+#define DIRA		1
+#define META		2
 /* including inline xattrs, extent */
-#define INODE		2
+#define INODE		3
 /* shared xattrs */
-#define XATTR		3
+#define XATTR		4
 /* device table */
-#define DEVT		4
+#define DEVT		5
 
 struct erofs_bhops {
 	bool (*preflush)(struct erofs_buffer_head *bh);
@@ -54,7 +55,7 @@ struct erofs_buffer_block {
 
 static inline const int get_alignsize(int type, int *type_ret)
 {
-	if (type == DATA)
+	if (type == DATA || type == DIRA)
 		return erofs_blksiz();
 
 	if (type == INODE) {
diff --git a/lib/inode.c b/lib/inode.c
index ff17295..6fb8ecb 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -142,7 +142,8 @@ struct erofs_dentry *erofs_d_alloc(struct erofs_inode *parent,
 
 /* allocate main data for a inode */
 static int __allocate_inode_bh_data(struct erofs_inode *inode,
-				    unsigned long nblocks)
+				    unsigned long nblocks,
+				    int type)
 {
 	struct erofs_buffer_head *bh;
 	int ret;
@@ -305,7 +306,7 @@ static int erofs_write_dir_file(struct erofs_inode *dir)
 	q = used = blkno = 0;
 
 	/* allocate dir main data */
-	ret = __allocate_inode_bh_data(dir, erofs_blknr(dir->i_size));
+	ret = __allocate_inode_bh_data(dir, erofs_blknr(dir->i_size), DIRA);
 	if (ret)
 		return ret;
 
@@ -353,7 +354,7 @@ static int erofs_write_file_from_buffer(struct erofs_inode *inode, char *buf)
 
 	inode->datalayout = EROFS_INODE_FLAT_INLINE;
 
-	ret = __allocate_inode_bh_data(inode, nblocks);
+	ret = __allocate_inode_bh_data(inode, nblocks, DATA);
 	if (ret)
 		return ret;
 
@@ -386,7 +387,7 @@ static int write_uncompressed_file_from_fd(struct erofs_inode *inode, int fd)
 	inode->datalayout = EROFS_INODE_FLAT_INLINE;
 	nblocks = inode->i_size / erofs_blksiz();
 
-	ret = __allocate_inode_bh_data(inode, nblocks);
+	ret = __allocate_inode_bh_data(inode, nblocks, DATA);
 	if (ret)
 		return ret;
 
-- 
2.24.4



More information about the Linux-erofs mailing list