All of lore.kernel.org
 help / color / mirror / Atom feed
* (no subject)
@ 2021-09-01  7:52 Zhaolei Dou
  2021-09-01  7:52 ` [PATCH] jffs2:fix no error report when rp_size larger than mtd_size during remounting Zhaolei Dou
  0 siblings, 1 reply; 2+ messages in thread
From: Zhaolei Dou @ 2021-09-01  7:52 UTC (permalink / raw)
  To: dwmw2, richard, jamie, christian.brauner, trix, wangqing, yang.yang29
  Cc: douzhaolei, linux-mtd, wangfangpeng1, zhongjubin, zengweilin


When the value of rp_size is greater than mtd->size, jffs2 can be remounted normally.
It can be easily reproduced with the steps listed below.
1.mount -t jffs2 -o rw,relatime  /dev/mtdblockx /mnt
2.mount -o remount -o rp_size=xxx /mnt


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] jffs2:fix no error report when rp_size larger than mtd_size during remounting
  2021-09-01  7:52 Zhaolei Dou
@ 2021-09-01  7:52 ` Zhaolei Dou
  0 siblings, 0 replies; 2+ messages in thread
From: Zhaolei Dou @ 2021-09-01  7:52 UTC (permalink / raw)
  To: dwmw2, richard, jamie, christian.brauner, trix, wangqing, yang.yang29
  Cc: douzhaolei, linux-mtd, wangfangpeng1, zhongjubin, zengweilin

From: douzhaolei <douzhaolei@huawei.com>

When the value of rp_size is greater than mtd->size,
jffs2 can be remounted normally.
It can be easily reproduced with the steps listed below.
1.mount -t jffs2 -o rw,relatime  /dev/mtdblockx /mnt
2.mount -o remount -o rp_size=xxx /mnt

Signed-off-by: douzhaolei <douzhaolei@huawei.com>
---
 fs/jffs2/super.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
index 81ca58c10b72..727693540a2d 100644
--- a/fs/jffs2/super.c
+++ b/fs/jffs2/super.c
@@ -212,7 +212,7 @@ 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)
+static int 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);
@@ -223,18 +223,29 @@ static inline void jffs2_update_mount_opts(struct fs_context *fc)
 		c->mount_opts.compr = new_c->mount_opts.compr;
 	}
 	if (new_c->mount_opts.set_rp_size) {
+		/* During remounting, compare the values of rp_szie and mtd->size. */
+		if (new_c->mount_opts.rp_size > c->mtd->size) {
+			mutex_unlock(&c->alloc_sem);
+			return invalf(fc, "jffs2: Too large reserve pool specified, max is %llu KB",
+					c->mtd->size / 1024);
+		}
 		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);
+
+	return 0;
 }
 
 static int jffs2_reconfigure(struct fs_context *fc)
 {
 	struct super_block *sb = fc->root->d_sb;
+	int ret;
 
 	sync_filesystem(sb);
-	jffs2_update_mount_opts(fc);
+	ret = jffs2_update_mount_opts(fc);
+	if (ret)
+		return -EINVAL;
 
 	return jffs2_do_remount_fs(sb, fc);
 }
-- 
2.12.3


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-01  8:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-01  7:52 Zhaolei Dou
2021-09-01  7:52 ` [PATCH] jffs2:fix no error report when rp_size larger than mtd_size during remounting Zhaolei Dou

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.