jffs2: Allow setting rp_size to zero during remounting
authorlizhe <lizhe67@huawei.com>
Wed, 14 Oct 2020 06:54:43 +0000 (14:54 +0800)
committerRichard Weinberger <richard@nod.at>
Sun, 13 Dec 2020 20:56:24 +0000 (21:56 +0100)
Set rp_size to zero will be ignore during remounting.

The method to identify whether we input a remounting option of
rp_size is to check if the rp_size input is zero. It can not work
well if we pass "rp_size=0".

This patch add a bool variable "set_rp_size" to fix this problem.

Reported-by: Jubin Zhong <zhongjubin@huawei.com>
Signed-off-by: lizhe <lizhe67@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
fs/jffs2/jffs2_fs_sb.h
fs/jffs2/super.c

index 778275f..5a70917 100644 (file)
@@ -38,6 +38,7 @@ struct jffs2_mount_opts {
         * users. This is implemented simply by means of not allowing the
         * latter users to write to the file system if the amount if the
         * available space is less then 'rp_size'. */
+       bool set_rp_size;
        unsigned int rp_size;
 };
 
index 4fd297b..c523ada 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;
@@ -206,6 +206,7 @@ static int jffs2_parse_param(struct fs_context *fc, struct fs_parameter *param)
                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.set_rp_size = true;
                c->mount_opts.rp_size = opt;
                break;
        default:
@@ -225,8 +226,10 @@ static inline void jffs2_update_mount_opts(struct fs_context *fc)
                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.rp_size)
+       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);
 }