All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jaegeuk Kim via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
To: Eric Sandeen <sandeen@redhat.com>
Cc: linux-fsdevel@vger.kernel.org, lihongbo22@huawei.com,
	linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH V3 0/7] f2fs: new mount API conversion
Date: Wed, 7 May 2025 21:36:33 +0000	[thread overview]
Message-ID: <aBvSYa-0IxQREIUV@google.com> (raw)
In-Reply-To: <f1674387-66d3-443f-8d48-74d8dfd111f1@redhat.com>

On 05/07, Eric Sandeen wrote:
> On 5/7/25 3:28 PM, Jaegeuk Kim wrote:
> >> But as far as I can tell, at least for the extent cache, remount is handled
> >> properly already (with the hunk above):
> >>
> >> # mkfs/mkfs.f2fs -c /dev/vdc@vdc.file /dev/vdb
> >> # mount /dev/vdb mnt
> >> # mount -o remount,noextent_cache mnt
> >> mount: /root/mnt: mount point not mounted or bad option.
> >>        dmesg(1) may have more information after failed mount system call.
> >> # dmesg | tail -n 1
> >> [60012.364941] F2FS-fs (vdb): device aliasing requires extent cache
> >> #
> >>
> >> I haven't tested with i.e. blkzoned devices though, is there a testcase
> >> that fails for you?
> > I'm worrying about any missing case to check options enabled by default_options.
> > For example, in the case of device_aliasing, we rely on enabling extent_cache
> > by default_options, which was not caught by f2fs_check_opt_consistency.
> > 
> > I was thinking that we'd need a post sanity check.
> 
> I see. If you want a "belt and suspenders" approach and it works for
> you, no argument from me :)

Thanks. :)

I just found that I had to check it's from remount or not. And, this change does
not break my setup having a specific options. Let me queue the series back and
wait for further review from Chao.

---
 fs/f2fs/super.c | 54 +++++++++++++++++++++++++++++++++----------------
 1 file changed, 37 insertions(+), 17 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index d89b9ede221e..0ee783224953 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1412,6 +1412,7 @@ static int f2fs_check_opt_consistency(struct fs_context *fc,
 	}
 
 	if (f2fs_sb_has_device_alias(sbi) &&
+			(ctx->opt_mask & F2FS_MOUNT_READ_EXTENT_CACHE) &&
 			!ctx_test_opt(ctx, F2FS_MOUNT_READ_EXTENT_CACHE)) {
 		f2fs_err(sbi, "device aliasing requires extent cache");
 		return -EINVAL;
@@ -1657,6 +1658,33 @@ static void f2fs_apply_options(struct fs_context *fc, struct super_block *sb)
 	f2fs_apply_quota_options(fc, sb);
 }
 
+static int f2fs_sanity_check_options(struct f2fs_sb_info *sbi, bool remount)
+{
+	if (f2fs_sb_has_device_alias(sbi) &&
+	    !test_opt(sbi, READ_EXTENT_CACHE)) {
+		f2fs_err(sbi, "device aliasing requires extent cache");
+		return -EINVAL;
+	}
+
+	if (!remount)
+		return 0;
+
+#ifdef CONFIG_BLK_DEV_ZONED
+	if (f2fs_sb_has_blkzoned(sbi) &&
+	    sbi->max_open_zones < F2FS_OPTION(sbi).active_logs) {
+		f2fs_err(sbi,
+			"zoned: max open zones %u is too small, need at least %u open zones",
+				 sbi->max_open_zones, F2FS_OPTION(sbi).active_logs);
+		return -EINVAL;
+	}
+#endif
+	if (f2fs_lfs_mode(sbi) && !IS_F2FS_IPU_DISABLE(sbi)) {
+		f2fs_warn(sbi, "LFS is not compatible with IPU");
+		return -EINVAL;
+	}
+	return 0;
+}
+
 static struct inode *f2fs_alloc_inode(struct super_block *sb)
 {
 	struct f2fs_inode_info *fi;
@@ -2616,21 +2644,15 @@ static int __f2fs_remount(struct fs_context *fc, struct super_block *sb)
 	default_options(sbi, true);
 
 	err = f2fs_check_opt_consistency(fc, sb);
-	if (err < 0)
+	if (err)
 		goto restore_opts;
 
 	f2fs_apply_options(fc, sb);
 
-#ifdef CONFIG_BLK_DEV_ZONED
-	if (f2fs_sb_has_blkzoned(sbi) &&
-		sbi->max_open_zones < F2FS_OPTION(sbi).active_logs) {
-		f2fs_err(sbi,
-			"zoned: max open zones %u is too small, need at least %u open zones",
-				 sbi->max_open_zones, F2FS_OPTION(sbi).active_logs);
-		err = -EINVAL;
+	err = f2fs_sanity_check_options(sbi, true);
+	if (err)
 		goto restore_opts;
-	}
-#endif
+
 	/* flush outstanding errors before changing fs state */
 	flush_work(&sbi->s_error_work);
 
@@ -2663,12 +2685,6 @@ static int __f2fs_remount(struct fs_context *fc, struct super_block *sb)
 		}
 	}
 #endif
-	if (f2fs_lfs_mode(sbi) && !IS_F2FS_IPU_DISABLE(sbi)) {
-		err = -EINVAL;
-		f2fs_warn(sbi, "LFS is not compatible with IPU");
-		goto restore_opts;
-	}
-
 	/* disallow enable atgc dynamically */
 	if (no_atgc == !!test_opt(sbi, ATGC)) {
 		err = -EINVAL;
@@ -4808,11 +4824,15 @@ static int f2fs_fill_super(struct super_block *sb, struct fs_context *fc)
 	default_options(sbi, false);
 
 	err = f2fs_check_opt_consistency(fc, sb);
-	if (err < 0)
+	if (err)
 		goto free_sb_buf;
 
 	f2fs_apply_options(fc, sb);
 
+	err = f2fs_sanity_check_options(sbi, false);
+	if (err)
+		goto free_options;
+
 	sb->s_maxbytes = max_file_blocks(NULL) <<
 				le32_to_cpu(raw_super->log_blocksize);
 	sb->s_max_links = F2FS_LINK_MAX;
-- 
2.49.0.1015.ga840276032-goog



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

WARNING: multiple messages have this Message-ID (diff)
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Eric Sandeen <sandeen@redhat.com>
Cc: linux-f2fs-devel@lists.sourceforge.net,
	linux-fsdevel@vger.kernel.org, chao@kernel.org,
	lihongbo22@huawei.com
Subject: Re: [PATCH V3 0/7] f2fs: new mount API conversion
Date: Wed, 7 May 2025 21:36:33 +0000	[thread overview]
Message-ID: <aBvSYa-0IxQREIUV@google.com> (raw)
In-Reply-To: <f1674387-66d3-443f-8d48-74d8dfd111f1@redhat.com>

On 05/07, Eric Sandeen wrote:
> On 5/7/25 3:28 PM, Jaegeuk Kim wrote:
> >> But as far as I can tell, at least for the extent cache, remount is handled
> >> properly already (with the hunk above):
> >>
> >> # mkfs/mkfs.f2fs -c /dev/vdc@vdc.file /dev/vdb
> >> # mount /dev/vdb mnt
> >> # mount -o remount,noextent_cache mnt
> >> mount: /root/mnt: mount point not mounted or bad option.
> >>        dmesg(1) may have more information after failed mount system call.
> >> # dmesg | tail -n 1
> >> [60012.364941] F2FS-fs (vdb): device aliasing requires extent cache
> >> #
> >>
> >> I haven't tested with i.e. blkzoned devices though, is there a testcase
> >> that fails for you?
> > I'm worrying about any missing case to check options enabled by default_options.
> > For example, in the case of device_aliasing, we rely on enabling extent_cache
> > by default_options, which was not caught by f2fs_check_opt_consistency.
> > 
> > I was thinking that we'd need a post sanity check.
> 
> I see. If you want a "belt and suspenders" approach and it works for
> you, no argument from me :)

Thanks. :)

I just found that I had to check it's from remount or not. And, this change does
not break my setup having a specific options. Let me queue the series back and
wait for further review from Chao.

---
 fs/f2fs/super.c | 54 +++++++++++++++++++++++++++++++++----------------
 1 file changed, 37 insertions(+), 17 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index d89b9ede221e..0ee783224953 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1412,6 +1412,7 @@ static int f2fs_check_opt_consistency(struct fs_context *fc,
 	}
 
 	if (f2fs_sb_has_device_alias(sbi) &&
+			(ctx->opt_mask & F2FS_MOUNT_READ_EXTENT_CACHE) &&
 			!ctx_test_opt(ctx, F2FS_MOUNT_READ_EXTENT_CACHE)) {
 		f2fs_err(sbi, "device aliasing requires extent cache");
 		return -EINVAL;
@@ -1657,6 +1658,33 @@ static void f2fs_apply_options(struct fs_context *fc, struct super_block *sb)
 	f2fs_apply_quota_options(fc, sb);
 }
 
+static int f2fs_sanity_check_options(struct f2fs_sb_info *sbi, bool remount)
+{
+	if (f2fs_sb_has_device_alias(sbi) &&
+	    !test_opt(sbi, READ_EXTENT_CACHE)) {
+		f2fs_err(sbi, "device aliasing requires extent cache");
+		return -EINVAL;
+	}
+
+	if (!remount)
+		return 0;
+
+#ifdef CONFIG_BLK_DEV_ZONED
+	if (f2fs_sb_has_blkzoned(sbi) &&
+	    sbi->max_open_zones < F2FS_OPTION(sbi).active_logs) {
+		f2fs_err(sbi,
+			"zoned: max open zones %u is too small, need at least %u open zones",
+				 sbi->max_open_zones, F2FS_OPTION(sbi).active_logs);
+		return -EINVAL;
+	}
+#endif
+	if (f2fs_lfs_mode(sbi) && !IS_F2FS_IPU_DISABLE(sbi)) {
+		f2fs_warn(sbi, "LFS is not compatible with IPU");
+		return -EINVAL;
+	}
+	return 0;
+}
+
 static struct inode *f2fs_alloc_inode(struct super_block *sb)
 {
 	struct f2fs_inode_info *fi;
@@ -2616,21 +2644,15 @@ static int __f2fs_remount(struct fs_context *fc, struct super_block *sb)
 	default_options(sbi, true);
 
 	err = f2fs_check_opt_consistency(fc, sb);
-	if (err < 0)
+	if (err)
 		goto restore_opts;
 
 	f2fs_apply_options(fc, sb);
 
-#ifdef CONFIG_BLK_DEV_ZONED
-	if (f2fs_sb_has_blkzoned(sbi) &&
-		sbi->max_open_zones < F2FS_OPTION(sbi).active_logs) {
-		f2fs_err(sbi,
-			"zoned: max open zones %u is too small, need at least %u open zones",
-				 sbi->max_open_zones, F2FS_OPTION(sbi).active_logs);
-		err = -EINVAL;
+	err = f2fs_sanity_check_options(sbi, true);
+	if (err)
 		goto restore_opts;
-	}
-#endif
+
 	/* flush outstanding errors before changing fs state */
 	flush_work(&sbi->s_error_work);
 
@@ -2663,12 +2685,6 @@ static int __f2fs_remount(struct fs_context *fc, struct super_block *sb)
 		}
 	}
 #endif
-	if (f2fs_lfs_mode(sbi) && !IS_F2FS_IPU_DISABLE(sbi)) {
-		err = -EINVAL;
-		f2fs_warn(sbi, "LFS is not compatible with IPU");
-		goto restore_opts;
-	}
-
 	/* disallow enable atgc dynamically */
 	if (no_atgc == !!test_opt(sbi, ATGC)) {
 		err = -EINVAL;
@@ -4808,11 +4824,15 @@ static int f2fs_fill_super(struct super_block *sb, struct fs_context *fc)
 	default_options(sbi, false);
 
 	err = f2fs_check_opt_consistency(fc, sb);
-	if (err < 0)
+	if (err)
 		goto free_sb_buf;
 
 	f2fs_apply_options(fc, sb);
 
+	err = f2fs_sanity_check_options(sbi, false);
+	if (err)
+		goto free_options;
+
 	sb->s_maxbytes = max_file_blocks(NULL) <<
 				le32_to_cpu(raw_super->log_blocksize);
 	sb->s_max_links = F2FS_LINK_MAX;
-- 
2.49.0.1015.ga840276032-goog


  reply	other threads:[~2025-05-07 21:36 UTC|newest]

Thread overview: 118+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-23 17:08 [f2fs-dev] [PATCH V3 0/7] f2fs: new mount API conversion Eric Sandeen via Linux-f2fs-devel
2025-04-23 17:08 ` Eric Sandeen
2025-04-23 17:08 ` [f2fs-dev] [PATCH V3 1/7] f2fs: Add fs parameter specifications for mount options Eric Sandeen via Linux-f2fs-devel
2025-04-23 17:08   ` Eric Sandeen
2025-05-08  2:40   ` [f2fs-dev] " Hongbo Li via Linux-f2fs-devel
2025-05-08  2:40     ` Hongbo Li
2025-05-08  5:24   ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
2025-05-08  5:24     ` Chao Yu
2025-07-11 16:30   ` [f2fs-dev] " patchwork-bot+f2fs--- via Linux-f2fs-devel
2025-07-11 16:30     ` patchwork-bot+f2fs
2025-04-23 17:08 ` [f2fs-dev] [PATCH V3 2/7] f2fs: move the option parser into handle_mount_opt Eric Sandeen via Linux-f2fs-devel
2025-04-23 17:08   ` Eric Sandeen
2025-05-06 20:24   ` [f2fs-dev] " Jaegeuk Kim via Linux-f2fs-devel
2025-05-06 20:24     ` Jaegeuk Kim
2025-05-08  5:30   ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
2025-05-08  5:30     ` Chao Yu
2025-04-23 17:08 ` [f2fs-dev] [PATCH V3 3/7] f2fs: Allow sbi to be NULL in f2fs_printk Eric Sandeen via Linux-f2fs-devel
2025-04-23 17:08   ` Eric Sandeen
2025-05-08  5:30   ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
2025-05-08  5:30     ` Chao Yu
2025-04-23 17:08 ` [f2fs-dev] [PATCH V3 4/7] f2fs: Add f2fs_fs_context to record the mount options Eric Sandeen via Linux-f2fs-devel
2025-04-23 17:08   ` Eric Sandeen
2025-05-08  6:34   ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
2025-05-08  6:34     ` Chao Yu
2025-04-23 17:08 ` [f2fs-dev] [PATCH V3 5/7] f2fs: separate the options parsing and options checking Eric Sandeen via Linux-f2fs-devel
2025-04-23 17:08   ` Eric Sandeen
2025-05-06 22:01   ` [f2fs-dev] " Jaegeuk Kim via Linux-f2fs-devel
2025-05-06 22:01     ` Jaegeuk Kim
2025-05-06 22:52     ` [f2fs-dev] " Eric Sandeen via Linux-f2fs-devel
2025-05-06 22:52       ` Eric Sandeen
2025-05-06 23:30       ` [f2fs-dev] " Jaegeuk Kim via Linux-f2fs-devel
2025-05-06 23:30         ` Jaegeuk Kim
2025-05-08  8:13   ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
2025-05-08  8:13     ` Chao Yu
2025-05-08 15:52     ` [f2fs-dev] " Eric Sandeen via Linux-f2fs-devel
2025-05-08 15:52       ` Eric Sandeen
2025-05-08 22:11       ` [f2fs-dev] " Eric Sandeen via Linux-f2fs-devel
2025-05-12  3:59         ` Chao Yu via Linux-f2fs-devel
2025-05-12  3:32       ` Chao Yu via Linux-f2fs-devel
2025-05-12  3:32         ` Chao Yu
2025-05-14  1:10         ` [f2fs-dev] " Hongbo Li via Linux-f2fs-devel
2025-05-14  1:10           ` Hongbo Li
2025-05-14  1:03       ` [f2fs-dev] " Hongbo Li via Linux-f2fs-devel
2025-05-14  1:03         ` Hongbo Li
2025-05-13  2:15   ` [f2fs-dev] " Jaegeuk Kim via Linux-f2fs-devel
2025-05-13  2:15     ` Jaegeuk Kim
2025-04-23 17:08 ` [f2fs-dev] [PATCH V3 6/7] f2fs: introduce fs_context_operation structure Eric Sandeen via Linux-f2fs-devel
2025-04-23 17:08   ` Eric Sandeen
2025-05-08  8:14   ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
2025-05-08  8:14     ` Chao Yu
2025-04-23 17:08 ` [f2fs-dev] [PATCH V3 7/7] f2fs: switch to the new mount api Eric Sandeen via Linux-f2fs-devel
2025-04-23 17:08   ` Eric Sandeen
2025-05-08  9:19   ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
2025-05-08  9:19     ` Chao Yu
2025-05-08 15:59     ` [f2fs-dev] " Eric Sandeen via Linux-f2fs-devel
2025-05-08 15:59       ` Eric Sandeen
2025-05-12  3:43       ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
2025-05-12  3:43         ` Chao Yu
2025-05-13  2:19         ` [f2fs-dev] " Eric Sandeen via Linux-f2fs-devel
2025-05-13  2:19           ` Eric Sandeen
2025-05-13  2:48           ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
2025-05-13  2:48             ` Chao Yu
2025-05-13 15:36             ` [f2fs-dev] " Jaegeuk Kim via Linux-f2fs-devel
2025-05-13 15:36               ` Jaegeuk Kim
2025-05-13  8:59   ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
2025-05-13  8:59     ` Chao Yu
2025-05-14  2:33     ` [f2fs-dev] " Hongbo Li via Linux-f2fs-devel
2025-05-14  2:33       ` Hongbo Li
2025-05-14  4:03       ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
2025-05-14  4:03         ` Chao Yu
2025-05-14  6:15         ` [f2fs-dev] " Hongbo Li via Linux-f2fs-devel
2025-05-14  6:15           ` Hongbo Li
2025-05-14 15:30           ` [f2fs-dev] " Jaegeuk Kim via Linux-f2fs-devel
2025-05-14 15:30             ` Jaegeuk Kim
2025-05-14 15:46             ` [f2fs-dev] " Eric Sandeen via Linux-f2fs-devel
2025-05-14 15:46               ` Eric Sandeen
2025-05-15  1:17             ` [f2fs-dev] " Hongbo Li via Linux-f2fs-devel
2025-05-15  1:17               ` Hongbo Li
2025-05-16  2:01             ` [f2fs-dev] " Hongbo Li via Linux-f2fs-devel
2025-05-16  2:01               ` Hongbo Li
2025-05-16 17:35               ` [f2fs-dev] " Jaegeuk Kim via Linux-f2fs-devel
2025-05-16 17:35                 ` Jaegeuk Kim
2025-05-19  2:38                 ` [f2fs-dev] " Hongbo Li via Linux-f2fs-devel
2025-05-19  2:38                   ` Hongbo Li
2025-05-13 16:11   ` [f2fs-dev] " Jaegeuk Kim via Linux-f2fs-devel
2025-05-13 16:11     ` Jaegeuk Kim
2025-05-06  2:18 ` [f2fs-dev] [PATCH V3 0/7] f2fs: new mount API conversion Eric Sandeen via Linux-f2fs-devel
2025-05-06  2:18   ` Eric Sandeen
2025-05-06 16:02   ` [f2fs-dev] " Jaegeuk Kim via Linux-f2fs-devel
2025-05-06 16:02     ` Jaegeuk Kim
2025-05-06 22:53     ` [f2fs-dev] " Eric Sandeen via Linux-f2fs-devel
2025-05-06 22:53       ` Eric Sandeen
2025-05-06 23:55 ` [f2fs-dev] " Ian Kent
2025-05-06 23:55   ` Ian Kent
2025-05-07  0:35 ` [f2fs-dev] " Jaegeuk Kim via Linux-f2fs-devel
2025-05-07  0:35   ` Jaegeuk Kim
2025-05-07  0:51   ` [f2fs-dev] " Eric Sandeen via Linux-f2fs-devel
2025-05-07  0:51     ` Eric Sandeen
2025-05-07  1:23     ` [f2fs-dev] " Jaegeuk Kim via Linux-f2fs-devel
2025-05-07  1:23       ` Jaegeuk Kim
2025-05-07  2:56       ` [f2fs-dev] " Eric Sandeen via Linux-f2fs-devel
2025-05-07  2:56         ` Eric Sandeen
2025-05-07  3:45         ` [f2fs-dev] " Eric Sandeen via Linux-f2fs-devel
2025-05-07  3:45           ` Eric Sandeen
2025-05-07 14:46           ` [f2fs-dev] " Jaegeuk Kim via Linux-f2fs-devel
2025-05-07 14:46             ` Jaegeuk Kim
2025-05-07 17:11             ` [f2fs-dev] " Eric Sandeen via Linux-f2fs-devel
2025-05-07 17:11               ` Eric Sandeen
2025-05-07 19:48               ` [f2fs-dev] " Jaegeuk Kim via Linux-f2fs-devel
2025-05-07 19:48                 ` Jaegeuk Kim
2025-05-07 20:19                 ` [f2fs-dev] " Eric Sandeen via Linux-f2fs-devel
2025-05-07 20:19                   ` Eric Sandeen
2025-05-07 20:28                   ` [f2fs-dev] " Jaegeuk Kim via Linux-f2fs-devel
2025-05-07 20:28                     ` Jaegeuk Kim
2025-05-07 20:46                     ` [f2fs-dev] " Eric Sandeen via Linux-f2fs-devel
2025-05-07 20:46                       ` Eric Sandeen
2025-05-07 21:36                       ` Jaegeuk Kim via Linux-f2fs-devel [this message]
2025-05-07 21:36                         ` Jaegeuk Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aBvSYa-0IxQREIUV@google.com \
    --to=linux-f2fs-devel@lists.sourceforge.net \
    --cc=jaegeuk@kernel.org \
    --cc=lihongbo22@huawei.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=sandeen@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.