f2fs: skip committing valid superblock
authorChao Yu <chao2.yu@samsung.com>
Mon, 8 Jun 2015 05:28:03 +0000 (13:28 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 8 Jun 2015 18:20:51 +0000 (11:20 -0700)
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 <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/f2fs.h
fs/f2fs/file.c
fs/f2fs/super.c

index 1a0716c369407a1ee47fb4e756f55a45524329be..a8327ed7389873481c560e98c1059406c37661cc 100644 (file)
@@ -1624,7 +1624,7 @@ static inline int f2fs_add_link(struct dentry *dentry, struct inode *inode)
 /*
  * super.c
  */
-int f2fs_commit_super(struct f2fs_sb_info *);
+int f2fs_commit_super(struct f2fs_sb_info *, bool);
 int f2fs_sync_fs(struct super_block *, int);
 extern __printf(3, 4)
 void f2fs_msg(struct super_block *, const char *, const char *, ...);
index 4d42d66acd96cfff6f7b3b2bbdad52f94c2539d0..096e08ca394586448ec60ddb6c26162616811b3e 100644 (file)
@@ -1530,7 +1530,7 @@ static int f2fs_ioc_get_encryption_pwsalt(struct file *filp, unsigned long arg)
        /* update superblock with uuid */
        generate_random_uuid(sbi->raw_super->encrypt_pw_salt);
 
-       err = f2fs_commit_super(sbi);
+       err = f2fs_commit_super(sbi, false);
 
        mnt_drop_write_file(filp);
        if (err) {
index d54c54f6a49d0a1fc20bd8a8582e4e1d5e3926a8..a06b0b46fe6952de875dc36b0c4e90c0ce980c31 100644 (file)
@@ -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;
This page took 0.039086 seconds and 5 git commands to generate.