Skip to contentSkip to conversation

btrfs: cleanup messages and error handling during mount

PATCH In review [email protected] 2 participants 5 messages Feb 9 Btrfs file system

lore
Share & tools
lore
#0 lore raw

cover btrfs: cleanup messages and error handling during mount

From: Filipe Manana <[email protected]>

Short and trivial patches, details in the change logs.

Filipe Manana (3):
btrfs: change warning messages to error level in open_ctree()
btrfs: remove redundant warning message in btrfs_check_uuid_tree()
btrfs: remove btrfs_handle_fs_error() after failure to recover log trees

 fs/btrfs/disk-io.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
Signature · 1 line
2.47.2
#1 lore raw

PATCH 1/3 btrfs: change warning messages to error level in open_ctree()

From: Filipe Manana <[email protected]>

Failure to read the fs root results in a mount error, but we log a warning message. Same goes for checking the uuid tree, an error results in a mount failure but we log a warning message. Change the level of the logged messages from warning to error.

---
 fs/btrfs/disk-io.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
fs/btrfs/disk-io.c +2 -3
index 597d78d2dfe1..040c9577e737 100644
@@ -3632,7 +3632,7 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
 	fs_info->fs_root = btrfs_get_fs_root(fs_info, BTRFS_FS_TREE_OBJECTID, true);
 	if (IS_ERR(fs_info->fs_root)) {
 		ret = PTR_ERR(fs_info->fs_root);
-		btrfs_warn(fs_info, "failed to read fs tree: %d", ret);
+		btrfs_err(fs_info, "failed to read fs tree: %d", ret);
 		fs_info->fs_root = NULL;
 		goto fail_qgroup;
 	}
@@ -3653,8 +3653,7 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
 		btrfs_info(fs_info, "checking UUID tree");
 		ret = btrfs_check_uuid_tree(fs_info);
 		if (ret) {
-			btrfs_warn(fs_info,
-				"failed to check the UUID tree: %d", ret);
+			btrfs_err(fs_info, "failed to check the UUID tree: %d", ret);
 			close_ctree(fs_info);
 			return ret;
 		}
Signature · 1 line
2.47.2
#2 lore raw

PATCH 2/3 btrfs: remove redundant warning message in btrfs_check_uuid_tree()

In reply to [email protected]

From: Filipe Manana <[email protected]>

If we fail to start the uuid rescan kthread, btrfs_check_uuid_tree() logs an error message and returns the error to the single caller, open_ctree().

This however is redundant since the caller already logs an error message, which is also more informative since it logs the error code. Some remove the warning message from btrfs_check_uuid_tree() as it doesn't add any value.

---
 fs/btrfs/disk-io.c | 1 -
 1 file changed, 1 deletion(-)
fs/btrfs/disk-io.c +0 -1
index 040c9577e737..cb0bca3f6a05 100644
@@ -2962,7 +2962,6 @@ static int btrfs_check_uuid_tree(struct btrfs_fs_info *fs_info)
 	task = kthread_run(btrfs_uuid_rescan_kthread, fs_info, "btrfs-uuid");
 	if (IS_ERR(task)) {
 		/* fs_info->update_uuid_tree_gen remains 0 in all error case */
-		btrfs_warn(fs_info, "failed to start uuid_rescan task");
 		up(&fs_info->uuid_tree_rescan_sem);
 		return PTR_ERR(task);
 	}
Signature · 1 line
2.47.2
#3 lore raw

PATCH 3/3 btrfs: remove btrfs_handle_fs_error() after failure to recover log trees

In reply to [email protected]

From: Filipe Manana <[email protected]>

There is no need to call btrfs_handle_fs_error() (which we are trying to deprecate) if we fail to recover log trees:

1) Such a failure results in failing the mount immediately;

2) If the recovery started a transaction before failing, it has already aborted the transaction down in the call chain.

So remove the btrfs_handle_fs_error() call, replace it with an error message and assert that the FS is in error state (so that no partial updates are committed due to a transaction that was not aborted).

---
 fs/btrfs/disk-io.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/btrfs/disk-io.c +3 -3
index cb0bca3f6a05..99ce7c1ca53a 100644
@@ -2028,9 +2028,9 @@ static int btrfs_replay_log(struct btrfs_fs_info *fs_info,
 	/* returns with log_tree_root freed on success */
 	ret = btrfs_recover_log_trees(log_tree_root);
 	btrfs_put_root(log_tree_root);
-	if (ret) {
-		btrfs_handle_fs_error(fs_info, ret,
-				      "Failed to recover log tree");
+	if (unlikely(ret)) {
+		ASSERT(BTRFS_FS_ERROR(fs_info) != 0);
+		btrfs_err(fs_info, "failed to recover log trees with error: %d", ret);
 		return ret;
 	}
 
Signature · 1 line
2.47.2
Reviewed-by on the v1 series
#4 lore raw
In reply to [email protected]
Quoted 3 lines · 在 2026/2/10 03:41, [email protected] 写道:

From: Filipe Manana <[email protected]>

Short and trivial patches, details in the change logs.

Thanks,
Qu

Quoted 9 lines

Filipe Manana (3):
btrfs: change warning messages to error level in open_ctree()
btrfs: remove redundant warning message in btrfs_check_uuid_tree()
btrfs: remove btrfs_handle_fs_error() after failure to recover log trees

  fs/btrfs/disk-io.c | 12 +++++-------
  1 file changed, 5 insertions(+), 7 deletions(-)