ext2fs: avoid re-reading inode multiple times
PATCH 1/1 ext2fs: avoid re-reading inode multiple times
Reduce the number of times that the inode is read from storage. Factor ext2fs_xattrs_read() into a new ext2fs_xattrs_read_inode() function that can accept an in-memory inode, and call that from within ext2fs_xattrs_read() and in e2fsck_pass1() when the inode is already available.
Similarly, in e2fsck_pass4() avoid re-reading the inode multiple times in disconnect_inode(), check_ea_inode(), and in the main function body if possible.
--- e2fsck/pass1.c | 9 ++++--- e2fsck/pass4.c | 47 +++++++++++++++++++++-------------- lib/ext2fs/ext2fs.h | 2 ++ lib/ext2fs/ext_attr.c | 57 +++++++++++++++++++++++++------------------ 4 files changed, 70 insertions(+), 45 deletions(-)
e2fsck/pass1.c +6 -3
@@ -911,6 +911,7 @@ static void reserve_block_for_lnf_repair(e2fsck_t ctx) }static errcode_t get_inline_data_ea_size (ext2_filsys fs,ext2_ino_t ino, +struct ext2_inode *inode,size_t *sz) {void *p;
@@ -921,7 +922,8 @@ static errcode_t get_inline_data_ea_size(ext2_filsys fs, ext2_ino_t ino,if (retval)return retval; - retval =ext2fs_xattrs_read (handle); + retval =ext2fs_xattrs_read_inode (handle, + (struct ext2_inode_large *)inode);if (retval) goto err;
@@ -1508,7 +1510,8 @@ void e2fsck_pass1(e2fsck_t ctx) (ino >= EXT2_FIRST_INODE(fs->super))) {size_t size =0 ; - pctx.errcode =get_inline_data_ea_size (fs, ino, &size); + pctx.errcode =get_inline_data_ea_size (fs, ino, inode, + &size);if (!pctx.errcode &&fix_problem (ctx,PR_1_INLINE_DATA_FEATURE , &pctx)) {ext2fs_set_feature_inline_data (sb);
@@ -1531,7 +1534,7 @@ void e2fsck_pass1(e2fsck_t ctx) flags = fs->flags;if (failed_csum) fs->flags |=EXT2_FLAG_IGNORE_CSUM_ERRORS ; - err =get_inline_data_ea_size (fs, ino, &size); + err =get_inline_data_ea_size (fs, ino, inode, &size); fs->flags = (flags &EXT2_FLAG_IGNORE_CSUM_ERRORS ) | (fs->flags & ~EXT2_FLAG_IGNORE_CSUM_ERRORS );
e2fsck/pass4.c +29 -18
100 lines not on this page · raw message
lib/ext2fs/ext2fs.h +2 -0
@@ -1276,6 +1276,8 @@ extern errcode_t ext2fs_adjust_ea_refcount3(ext2_filsys fs, blk64_t blk, ext2_ino_t inum);errcode_t ext2fs_xattrs_write (struct ext2_xattr_handle *handle);errcode_t ext2fs_xattrs_read (struct ext2_xattr_handle *handle); +errcode_t ext2fs_xattrs_read_inode (struct ext2_xattr_handle *handle, +struct ext2_inode_large *inode); errcode_t ext2fs_xattrs_iterate(struct ext2_xattr_handle *h, int (*func)(char *name, char *value, size_t value_len, void *data),
lib/ext2fs/ext_attr.c +33 -24
87 lines not on this page · raw message
Signature · 1 line
2.25.1
Theodore Ts'o
AppliedQuoted 11 lines · Andreas Dilger
Reduce the number of times that the inode is read from storage. Factor
ext2fs_xattrs_read()into a newext2fs_xattrs_read_inode()function that can accept an in-memory inode, and call that from withinext2fs_xattrs_read()and ine2fsck_pass1()when the inode is already available.Similarly, in
e2fsck_pass4()avoid re-reading the inode multiple times indisconnect_inode(),check_ea_inode(), and in the main function body if possible.Signed-off-by Andreas Dilger <[email protected]>
Applied, although I needed to add this initialization patch to avoid a "make check" failure.
lib/ext2fs/ext_attr.c +1 -1
@@ -998,7 +998,7 @@ errcode_t ext2fs_xattrs_read_inode(struct ext2_xattr_handle *handle,char *start, *block_buf =NULL ;blk64_t blk;size_t i; -errcode_t err; +errcode_t err =0 ;EXT2_CHECK_MAGIC (handle,EXT2_ET_MAGIC_EA_HANDLE );
- Ted