From c5bda1c8b13ad7840ae0e8c9a2926df686ba6e06 Mon Sep 17 00:00:00 2001 From: Chao Yu Date: Mon, 8 Jun 2015 13:28:03 +0800 Subject: f2fs: skip committing valid superblock In recovery procedure for superblock, we try to write data of valid superblock into invalid one for recovery, work should be finished here, but then still we will write the valid one with its original data. This operation is not needed. Let's skip doing this unnecessary work. Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim --- fs/f2fs/super.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'fs/f2fs/super.c') diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index d54c54f..a06b0b4 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1043,7 +1043,7 @@ out: return 0; } -int f2fs_commit_super(struct f2fs_sb_info *sbi) +int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover) { struct buffer_head *sbh = sbi->raw_super_buf; sector_t block = sbh->b_blocknr; @@ -1055,7 +1055,9 @@ int f2fs_commit_super(struct f2fs_sb_info *sbi) err = sync_dirty_buffer(sbh); sbh->b_blocknr = block; - if (err) + + /* if we are in recovery path, skip writing valid superblock */ + if (recover || err) goto out; /* write current valid superblock */ @@ -1289,7 +1291,7 @@ try_onemore: /* recover broken superblock */ if (recovery && !f2fs_readonly(sb) && !bdev_read_only(sb->s_bdev)) { f2fs_msg(sb, KERN_INFO, "Recover invalid superblock"); - f2fs_commit_super(sbi); + f2fs_commit_super(sbi, true); } return 0; -- cgit v1.1