Skip to contentSkip to conversation

btrfs: restore mount option info messages during mount

PATCH Superseded [email protected] 2 participants 6 messages Jul 28, 2025 – Aug 12, 2025 Btrfs file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: restore mount option info messages during mount

From: Kyoji Ogasawara <[email protected]>

After the fsconfig migration, mount option info messages are no longer displayed during mount operations because btrfs_emit_options() is only called during remount, not during initial mount.

Fix this by calling btrfs_emit_options() in btrfs_fill_super() after open_ctree() succeeds. Additionally, prevent log duplication by ensuring btrfs_check_options() handles validation with warn-level and err-level messages, while btrfs_emit_options() provides info-level messages.

Fixes eddb1a433f26 ("btrfs: add reconfigure callback for fs_context")
---
 fs/btrfs/super.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
fs/btrfs/super.c +5 -4
index a0c65adce1ab..de4e01abc599 100644
@@ -88,6 +88,9 @@ struct btrfs_fs_context {
 	refcount_t refs;
 };
 
+static void btrfs_emit_options(struct btrfs_fs_info *info,
+			       struct btrfs_fs_context *old);
+
 enum {
 	Opt_acl,
 	Opt_clear_cache,
@@ -689,12 +692,9 @@ bool btrfs_check_options(const struct btrfs_fs_info *info,
 
 	if (!test_bit(BTRFS_FS_STATE_REMOUNTING, &info->fs_state)) {
 		if (btrfs_raw_test_opt(*mount_opt, SPACE_CACHE)) {
-			btrfs_info(info, "disk space caching is enabled");
 			btrfs_warn(info,
 "space cache v1 is being deprecated and will be removed in a future release, please use -o space_cache=v2");
 		}
-		if (btrfs_raw_test_opt(*mount_opt, FREE_SPACE_TREE))
-			btrfs_info(info, "using free-space-tree");
 	}
 
 	return ret;
@@ -971,6 +971,8 @@ static int btrfs_fill_super(struct super_block *sb,
 		return err;
 	}
 
+	btrfs_emit_options(fs_info, NULL);
+
 	inode = btrfs_iget(BTRFS_FIRST_FREE_OBJECTID, fs_info->fs_root);
 	if (IS_ERR(inode)) {
 		err = PTR_ERR(inode);
@@ -1428,7 +1430,6 @@ static void btrfs_emit_options(struct btrfs_fs_info *info,
 {
 	btrfs_info_if_set(info, old, NODATASUM, "setting nodatasum");
 	btrfs_info_if_set(info, old, DEGRADED, "allowing degraded mounts");
-	btrfs_info_if_set(info, old, NODATASUM, "setting nodatasum");
 	btrfs_info_if_set(info, old, SSD, "enabling ssd optimizations");
 	btrfs_info_if_set(info, old, SSD_SPREAD, "using spread ssd allocation scheme");
 	btrfs_info_if_set(info, old, NOBARRIER, "turning off barriers");
Signature · 1 line
2.50.1
#1 lore raw
Quoted 5 lines · On Mon, Jul 28, 2025 at 11:07:18AM +0900, [email protected] wrote:

From: Kyoji Ogasawara <[email protected]>

After the fsconfig migration, mount option info messages are no longer displayed during mount operations because btrfs_emit_options() is only called during remount, not during initial mount.

I see messages at first mount that I'd expect to see:

[625.459381] BTRFS info (device vda): first mount of filesystem bca4e1c1-9ca9-441c-8a6a-7004e31763bf
[625.460384] BTRFS info (device vda): using crc32c (crc32c-generic) checksum algorithm
[625.461192] BTRFS info (device vda): using free-space-tree

is there anything specific in your test other than mkfs and mount?

#2 lore raw
Quoted 11 lines
Quoted 3 lines

After the fsconfig migration, mount option info messages are no longer displayed during mount operations because btrfs_emit_options() is only called during remount, not during initial mount.

I see messages at first mount that I'd expect to see:

[625.459381] BTRFS info (device vda): first mount of filesystem bca4e1c1-9ca9-441c-8a6a-7004e31763bf
[625.460384] BTRFS info (device vda): using crc32c (crc32c-generic) checksum algorithm
[625.461192] BTRFS info (device vda): using free-space-tree

is there anything specific in your test other than mkfs and mount?

No, not really. I've only tested the mkfs and mount operations.

#3 lore raw
In reply to [email protected]
Quoted 6 lines · On Mon, Jul 28, 2025 at 11:07:18AM +0900, [email protected] wrote:

From: Kyoji Ogasawara <[email protected]>

After the fsconfig migration, mount option info messages are no longer displayed during mount operations because btrfs_emit_options() is only called during remount, not during initial mount.

Quoted 7 lines

Fix this by calling btrfs_emit_options() in btrfs_fill_super() after open_ctree() succeeds. Additionally, prevent log duplication by ensuring btrfs_check_options() handles validation with warn-level and err-level messages, while btrfs_emit_options() provides info-level messages.

Fixes eddb1a433f26 ("btrfs: add reconfigure callback for fs_context")

You're right, the options are not printed.

Quoted 41 lines
---
 fs/btrfs/super.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
fs/btrfs/super.c +5 -3
index a0c65adce1ab..de4e01abc599 100644
@@ -88,6 +88,9 @@ struct btrfs_fs_context {
 	refcount_t refs;
 };
 
+static void btrfs_emit_options(struct btrfs_fs_info *info,
+			       struct btrfs_fs_context *old);
+
 enum {
 	Opt_acl,
 	Opt_clear_cache,
@@ -689,12 +692,9 @@ bool btrfs_check_options(const struct btrfs_fs_info *info,
 
 	if (!test_bit(BTRFS_FS_STATE_REMOUNTING, &info->fs_state)) {
 		if (btrfs_raw_test_opt(*mount_opt, SPACE_CACHE)) {
-			btrfs_info(info, "disk space caching is enabled");
 			btrfs_warn(info,
 "space cache v1 is being deprecated and will be removed in a future release, please use -o space_cache=v2");
 		}
-		if (btrfs_raw_test_opt(*mount_opt, FREE_SPACE_TREE))
-			btrfs_info(info, "using free-space-tree");
 	}
 
 	return ret;
@@ -971,6 +971,8 @@ static int btrfs_fill_super(struct super_block *sb,
 		return err;
 	}
 
+	btrfs_emit_options(fs_info, NULL);
+
 	inode = btrfs_iget(BTRFS_FIRST_FREE_OBJECTID, fs_info->fs_root);
 	if (IS_ERR(inode)) {
 		err = PTR_ERR(inode);

fs/btrfs/super.c static void btrfs_emit_options(struct btrfs_fs_info *info, · line 1431

Quoted 4 lines
fs/btrfs/super.c +0 -1
@@ -1428,7 +1430,6 @@ static void btrfs_emit_options(struct btrfs_fs_info *info,
 {
 	btrfs_info_if_set(info, old, NODATASUM, "setting nodatasum");
 	btrfs_info_if_set(info, old, DEGRADED, "allowing degraded mounts");
-	btrfs_info_if_set(info, old, NODATASUM, "setting nodatasum");

Shouldn't this rather be NODATACOW? The logic around the option is the same as for NODATASUM, but for some reason NODATACOW is under btrfs_info_if_unset() call.

Quoted 6 lines
fs/btrfs/super.c +0 -0
 	btrfs_info_if_set(info, old, SSD, "enabling ssd optimizations");
 	btrfs_info_if_set(info, old, SSD_SPREAD, "using spread ssd allocation scheme");
 	btrfs_info_if_set(info, old, NOBARRIER, "turning off barriers");
Signature · 1 line
2.50.1
#4 lore raw
Quoted 16 lines

fs/btrfs/super.c static void btrfs_emit_options(struct btrfs_fs_info *info, · line 1431

Quoted 5 lines
fs/btrfs/super.c +0 -1
@@ -1428,7 +1430,6 @@ static void btrfs_emit_options(struct btrfs_fs_info *info,
 {
      btrfs_info_if_set(info, old, NODATASUM, "setting nodatasum");
      btrfs_info_if_set(info, old, DEGRADED, "allowing degraded mounts");
-     btrfs_info_if_set(info, old, NODATASUM, "setting nodatasum");

Shouldn't this rather be NODATACOW? The logic around the option is the same as for NODATASUM, but for some reason NODATACOW is under btrfs_info_if_unset() call.

Quoted 6 lines
fs/btrfs/super.c +0 -1
      btrfs_info_if_set(info, old, SSD, "enabling ssd optimizations");
      btrfs_info_if_set(info, old, SSD_SPREAD, "using spread ssd allocation scheme");
      btrfs_info_if_set(info, old, NOBARRIER, "turning off barriers");
--

2.50.1

Thank you for your suggestion.
I'll update the code to handle NODATASUM similarly to NODATACOW.

=====
btrfs_info_if_set(info, old, NODATASUM, "setting nodatasum"); btrfs_info_if_set(info, old, DEGRADED, "allowing degraded mounts"); btrfs_info_if_set(info, old, NODATACOW, "setting nodatacow");
...
btrfs_info_if_unset(info, old, NODATASUM, "setting datasum"); btrfs_info_if_unset(info, old, NODATACOW, "setting datacow");
=====

Let me know if there's anything else I should consider.

#5 lore raw
Quoted 29 lines · Kyoji Ogasawara
Quoted 16 lines

fs/btrfs/super.c static void btrfs_emit_options(struct btrfs_fs_info *info, · line 1431

Quoted 5 lines
fs/btrfs/super.c +0 -1
@@ -1428,7 +1430,6 @@ static void btrfs_emit_options(struct btrfs_fs_info *info,
 {
      btrfs_info_if_set(info, old, NODATASUM, "setting nodatasum");
      btrfs_info_if_set(info, old, DEGRADED, "allowing degraded mounts");
-     btrfs_info_if_set(info, old, NODATASUM, "setting nodatasum");

Shouldn't this rather be NODATACOW? The logic around the option is the same as for NODATASUM, but for some reason NODATACOW is under btrfs_info_if_unset() call.

Quoted 6 lines
fs/btrfs/super.c +0 -1
      btrfs_info_if_set(info, old, SSD, "enabling ssd optimizations");
      btrfs_info_if_set(info, old, SSD_SPREAD, "using spread ssd allocation scheme");
      btrfs_info_if_set(info, old, NOBARRIER, "turning off barriers");
--

2.50.1

Thank you for your suggestion.
I'll update the code to handle NODATASUM similarly to NODATACOW.

=====
btrfs_info_if_set(info, old, NODATASUM, "setting nodatasum"); btrfs_info_if_set(info, old, DEGRADED, "allowing degraded mounts"); btrfs_info_if_set(info, old, NODATACOW, "setting nodatacow");
...
btrfs_info_if_unset(info, old, NODATASUM, "setting datasum"); btrfs_info_if_unset(info, old, NODATACOW, "setting datacow");
=====

Quoted 1 line

Let me know if there's anything else I should consider.

I haven't seen other problems in the mount options. Please send the fixes as separate patches. Thanks.