]> git.karo-electronics.de Git - linux-beck.git/commitdiff
f2fs: give -EINVAL for norecovery and rw mount
authorJaegeuk Kim <jaegeuk@kernel.org>
Wed, 23 Mar 2016 23:12:58 +0000 (16:12 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Fri, 15 Apr 2016 15:49:47 +0000 (08:49 -0700)
Once detecting something to recover, f2fs should stop mounting, given norecovery
and rw mount options.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/f2fs.h
fs/f2fs/recovery.c
fs/f2fs/super.c

index 7cb360e021099c7c89bcc402c78a83ddd2b6eb00..e1c07b60f301140f34f2750429fc27cf3e8f69bd 100644 (file)
@@ -1907,7 +1907,7 @@ void build_gc_manager(struct f2fs_sb_info *);
 /*
  * recovery.c
  */
-int recover_fsync_data(struct f2fs_sb_info *);
+int recover_fsync_data(struct f2fs_sb_info *, bool);
 bool space_for_roll_forward(struct f2fs_sb_info *);
 
 /*
index 011942f94d6494ff5da99a36967b3e8ba8ff6140..2c87c12b6f1c4f1e23d7c63b08d3363fd1b8244e 100644 (file)
@@ -551,12 +551,13 @@ next:
        return err;
 }
 
-int recover_fsync_data(struct f2fs_sb_info *sbi)
+int recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
 {
        struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_WARM_NODE);
        struct list_head inode_list;
        block_t blkaddr;
        int err;
+       int ret = 0;
        bool need_writecp = false;
 
        fsync_entry_slab = f2fs_kmem_cache_create("f2fs_fsync_inode_entry",
@@ -573,11 +574,13 @@ int recover_fsync_data(struct f2fs_sb_info *sbi)
 
        /* step #1: find fsynced inode numbers */
        err = find_fsync_dnodes(sbi, &inode_list);
-       if (err)
+       if (err || list_empty(&inode_list))
                goto out;
 
-       if (list_empty(&inode_list))
+       if (check_only) {
+               ret = 1;
                goto out;
+       }
 
        need_writecp = true;
 
@@ -625,5 +628,5 @@ out:
        } else {
                mutex_unlock(&sbi->cp_mutex);
        }
-       return err;
+       return ret ? ret: err;
 }
index f5fbbfdb3d93d8049bae40ca4263cddbfc8baad3..8f9648ffbbc30499e46c4b9484cee2fce8e6e1c4 100644 (file)
@@ -1562,14 +1562,24 @@ try_onemore:
                if (need_fsck)
                        set_sbi_flag(sbi, SBI_NEED_FSCK);
 
-               err = recover_fsync_data(sbi);
-               if (err) {
+               err = recover_fsync_data(sbi, false);
+               if (err < 0) {
                        need_fsck = true;
                        f2fs_msg(sb, KERN_ERR,
                                "Cannot recover all fsync data errno=%ld", err);
                        goto free_kobj;
                }
+       } else {
+               err = recover_fsync_data(sbi, true);
+
+               if (!f2fs_readonly(sb) && err > 0) {
+                       err = -EINVAL;
+                       f2fs_msg(sb, KERN_ERR,
+                               "Need to recover fsync data");
+                       goto free_kobj;
+               }
        }
+
        /* recover_fsync_data() cleared this already */
        clear_sbi_flag(sbi, SBI_POR_DOING);