From: Darrick J. Wong <djwong@xxxxxxxxxx> As an umount-time performance enhancement, don't bother to write the group descriptor tables in op_destroy if we know that op_syncfs will do it for us. That only happens if iomap is enabled. Signed-off-by: "Darrick J. Wong" <djwong@xxxxxxxxxx> --- misc/fuse2fs.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index 66baca72ad49d1..3bded0fdd21e2a 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -263,6 +263,7 @@ struct fuse2fs { uint8_t noblkdev; uint8_t can_hardlink; uint8_t iomap_passthrough_options; + uint8_t write_gdt_on_destroy; enum fuse2fs_opstate opstate; int blocklog; @@ -1212,9 +1213,11 @@ static void op_destroy(void *p EXT2FS_ATTR((unused))) if (fs->super->s_error_count) fs->super->s_state |= EXT2_ERROR_FS; ext2fs_mark_super_dirty(fs); - err = ext2fs_set_gdt_csum(fs); - if (err) - translate_error(fs, 0, err); + if (ff->write_gdt_on_destroy) { + err = ext2fs_set_gdt_csum(fs); + if (err) + translate_error(fs, 0, err); + } err = ext2fs_flush2(fs, 0); if (err) @@ -5129,6 +5132,15 @@ static int op_syncfs(const char *path) } } + /* + * When iomap is enabled, the kernel will call syncfs right before + * calling the destroy method. If any syncfs succeeds, then we know + * that there will be a last syncfs and that it will write the GDT, so + * destroy doesn't need to waste time doing that. + */ + if (fuse2fs_iomap_enabled(ff)) + ff->write_gdt_on_destroy = 0; + out_unlock: fuse2fs_finish(ff, ret); return ret; @@ -6631,6 +6643,7 @@ int main(int argc, char *argv[]) .iomap_dev = FUSE_IOMAP_DEV_NULL, #endif .can_hardlink = 1, + .write_gdt_on_destroy = 1, }; errcode_t err; FILE *orig_stderr = stderr;