Merge tag 'for-5.11/dm-fix' of git://git.kernel.org/pub/scm/linux/kernel/git/device...
[linux-2.6-microblaze.git] / fs / jffs2 / super.c
index 05d7878..81ca58c 100644 (file)
@@ -88,7 +88,7 @@ static int jffs2_show_options(struct seq_file *s, struct dentry *root)
 
        if (opts->override_compr)
                seq_printf(s, ",compr=%s", jffs2_compr_name(opts->compr));
-       if (opts->rp_size)
+       if (opts->set_rp_size)
                seq_printf(s, ",rp_size=%u", opts->rp_size / 1024);
 
        return 0;
@@ -202,11 +202,8 @@ static int jffs2_parse_param(struct fs_context *fc, struct fs_parameter *param)
        case Opt_rp_size:
                if (result.uint_32 > UINT_MAX / 1024)
                        return invalf(fc, "jffs2: rp_size unrepresentable");
-               opt = result.uint_32 * 1024;
-               if (opt > c->mtd->size)
-                       return invalf(fc, "jffs2: Too large reserve pool specified, max is %llu KB",
-                                     c->mtd->size / 1024);
-               c->mount_opts.rp_size = opt;
+               c->mount_opts.rp_size = result.uint_32 * 1024;
+               c->mount_opts.set_rp_size = true;
                break;
        default:
                return -EINVAL;
@@ -215,11 +212,30 @@ static int jffs2_parse_param(struct fs_context *fc, struct fs_parameter *param)
        return 0;
 }
 
+static inline void jffs2_update_mount_opts(struct fs_context *fc)
+{
+       struct jffs2_sb_info *new_c = fc->s_fs_info;
+       struct jffs2_sb_info *c = JFFS2_SB_INFO(fc->root->d_sb);
+
+       mutex_lock(&c->alloc_sem);
+       if (new_c->mount_opts.override_compr) {
+               c->mount_opts.override_compr = new_c->mount_opts.override_compr;
+               c->mount_opts.compr = new_c->mount_opts.compr;
+       }
+       if (new_c->mount_opts.set_rp_size) {
+               c->mount_opts.set_rp_size = new_c->mount_opts.set_rp_size;
+               c->mount_opts.rp_size = new_c->mount_opts.rp_size;
+       }
+       mutex_unlock(&c->alloc_sem);
+}
+
 static int jffs2_reconfigure(struct fs_context *fc)
 {
        struct super_block *sb = fc->root->d_sb;
 
        sync_filesystem(sb);
+       jffs2_update_mount_opts(fc);
+
        return jffs2_do_remount_fs(sb, fc);
 }
 
@@ -249,6 +265,10 @@ static int jffs2_fill_super(struct super_block *sb, struct fs_context *fc)
        c->mtd = sb->s_mtd;
        c->os_priv = sb;
 
+       if (c->mount_opts.rp_size > c->mtd->size)
+               return invalf(fc, "jffs2: Too large reserve pool specified, max is %llu KB",
+                             c->mtd->size / 1024);
+
        /* Initialize JFFS2 superblock locks, the further initialization will
         * be done later */
        mutex_init(&c->alloc_sem);