]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/f2fs/super.c
Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
[karo-tx-linux.git] / fs / f2fs / super.c
index c756923a7302cc6dc144e108a11a4d2ceb5800ed..8f96d9372adebc0d1ccf47545515e44de68b749d 100644 (file)
@@ -514,7 +514,7 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
 {
        struct f2fs_sb_info *sbi = F2FS_SB(root->d_sb);
 
-       if (!(root->d_sb->s_flags & MS_RDONLY) && test_opt(sbi, BG_GC))
+       if (!f2fs_readonly(sbi->sb) && test_opt(sbi, BG_GC))
                seq_printf(seq, ",background_gc=%s", "on");
        else
                seq_printf(seq, ",background_gc=%s", "off");
@@ -542,7 +542,7 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
                seq_puts(seq, ",disable_ext_identify");
        if (test_opt(sbi, INLINE_DATA))
                seq_puts(seq, ",inline_data");
-       if (test_opt(sbi, FLUSH_MERGE))
+       if (!f2fs_readonly(sbi->sb) && test_opt(sbi, FLUSH_MERGE))
                seq_puts(seq, ",flush_merge");
        seq_printf(seq, ",active_logs=%u", sbi->active_logs);
 
@@ -594,6 +594,8 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
        struct f2fs_sb_info *sbi = F2FS_SB(sb);
        struct f2fs_mount_info org_mount_opt;
        int err, active_logs;
+       bool need_restart_gc = false;
+       bool need_stop_gc = false;
 
        sync_filesystem(sb);
 
@@ -611,7 +613,7 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
 
        /*
         * Previous and new state of filesystem is RO,
-        * so no point in checking GC conditions.
+        * so skip checking GC and FLUSH_MERGE conditions.
         */
        if ((sb->s_flags & MS_RDONLY) && (*flags & MS_RDONLY))
                goto skip;
@@ -625,18 +627,40 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
                if (sbi->gc_thread) {
                        stop_gc_thread(sbi);
                        f2fs_sync_fs(sb, 1);
+                       need_restart_gc = true;
                }
        } else if (test_opt(sbi, BG_GC) && !sbi->gc_thread) {
                err = start_gc_thread(sbi);
                if (err)
                        goto restore_opts;
+               need_stop_gc = true;
+       }
+
+       /*
+        * We stop issue flush thread if FS is mounted as RO
+        * or if flush_merge is not passed in mount option.
+        */
+       if ((*flags & MS_RDONLY) || !test_opt(sbi, FLUSH_MERGE)) {
+               destroy_flush_cmd_control(sbi);
+       } else if (test_opt(sbi, FLUSH_MERGE) &&
+                                       !sbi->sm_info->cmd_control_info) {
+               err = create_flush_cmd_control(sbi);
+               if (err)
+                       goto restore_gc;
        }
 skip:
        /* Update the POSIXACL Flag */
         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
                (test_opt(sbi, POSIX_ACL) ? MS_POSIXACL : 0);
        return 0;
-
+restore_gc:
+       if (need_restart_gc) {
+               if (start_gc_thread(sbi))
+                       f2fs_msg(sbi->sb, KERN_WARNING,
+                               "background gc thread is stop");
+       } else if (need_stop_gc) {
+               stop_gc_thread(sbi);
+       }
 restore_opts:
        sbi->mount_opt = org_mount_opt;
        sbi->active_logs = active_logs;
@@ -665,9 +689,7 @@ static struct inode *f2fs_nfs_get_inode(struct super_block *sb,
        struct f2fs_sb_info *sbi = F2FS_SB(sb);
        struct inode *inode;
 
-       if (unlikely(ino < F2FS_ROOT_INO(sbi)))
-               return ERR_PTR(-ESTALE);
-       if (unlikely(ino >= NM_I(sbi)->max_nid))
+       if (check_nid_range(sbi, ino))
                return ERR_PTR(-ESTALE);
 
        /*