OSDN Git Service

f2fs: disallow switching io_bits option during remount
authorChao Yu <yuchao0@huawei.com>
Fri, 12 Jul 2019 08:57:00 +0000 (16:57 +0800)
committer0ranko0P <ranko0p@outlook.com>
Tue, 24 Dec 2019 20:42:23 +0000 (04:42 +0800)
If IO alignment feature is turned on after remount, we didn't
initialize mempool of it, it turns out we will encounter panic
during IO submission due to access NULL mempool pointer.

This feature should be set only at mount time, so simply deny
configuring during remount.

This fixes bug reported in bugzilla:

https://bugzilla.kernel.org/show_bug.cgi?id=204135

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/super.c

index 8494bd3..a46450c 100644 (file)
@@ -1528,6 +1528,7 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
        bool need_stop_gc = false;
        bool no_extent_cache = !test_opt(sbi, EXTENT_CACHE);
        bool disable_checkpoint = test_opt(sbi, DISABLE_CHECKPOINT);
+       bool no_io_align = !F2FS_IO_ALIGNED(sbi);
        bool checkpoint_changed;
 #ifdef CONFIG_QUOTA
        int i, j;
@@ -1607,6 +1608,12 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
                goto restore_opts;
        }
 
+       if (no_io_align == !!F2FS_IO_ALIGNED(sbi)) {
+               err = -EINVAL;
+               f2fs_warn(sbi, "switch io_bits option is not allowed");
+               goto restore_opts;
+       }
+
        if ((*flags & MS_RDONLY) && test_opt(sbi, DISABLE_CHECKPOINT)) {
                err = -EINVAL;
                f2fs_warn(sbi, "disabling checkpoint not compatible with read-only");