diff options
author | David Sterba <dsterba@suse.com> | 2024-03-22 01:18:24 +0100 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2024-03-22 01:19:47 +0100 |
commit | 3172d27fb9727991a06928844d4a1bddfa215fb2 (patch) | |
tree | ce049996dba5b812d01ee633d669d5ebc4905550 | |
parent | 682f676eb38fe10e3335225c27dbae2291d138e9 (diff) | |
download | btrfs-progs-3172d27fb9727991a06928844d4a1bddfa215fb2.tar.gz |
btrfs-progs: mkfs: make transaction start and commit errors verbose
Use the templated error message for transaction failures, use the same
pattern assigning the ret and errno.
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | mkfs/main.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/mkfs/main.c b/mkfs/main.c index c9c8ee5f..a467795d 100644 --- a/mkfs/main.c +++ b/mkfs/main.c @@ -165,6 +165,10 @@ static int create_metadata_block_groups(struct btrfs_root *root, bool mixed, root->fs_info->system_allocs = 0; ret = btrfs_commit_transaction(trans, root); + if (ret) { + errno = -ret; + error_msg(ERROR_MSG_COMMIT_TRANS, "%m"); + } err: return ret; } @@ -687,8 +691,13 @@ static int cleanup_temp_chunks(struct btrfs_fs_info *fs_info, key.objectid = found_key.objectid + found_key.offset; } out: - if (trans) - btrfs_commit_transaction(trans, root); + if (trans) { + ret = btrfs_commit_transaction(trans, root); + if (ret) { + errno = -ret; + error_msg(ERROR_MSG_COMMIT_TRANS, "%m"); + } + } btrfs_release_path(&path); return ret; } @@ -1111,8 +1120,12 @@ static int setup_raid_stripe_tree_root(struct btrfs_fs_info *fs_info) int ret; trans = btrfs_start_transaction(fs_info->tree_root, 0); - if (IS_ERR(trans)) - return PTR_ERR(trans); + if (IS_ERR(trans)) { + ret = PTR_ERR(trans); + errno = -ret; + error_msg(ERROR_MSG_START_TRANS, "%m"); + return ret; + } stripe_root = btrfs_create_tree(trans, fs_info, &key); if (IS_ERR(stripe_root)) { @@ -1124,8 +1137,11 @@ static int setup_raid_stripe_tree_root(struct btrfs_fs_info *fs_info) add_root_to_dirty_list(stripe_root); ret = btrfs_commit_transaction(trans, fs_info->tree_root); - if (ret) + if (ret) { + errno = -ret; + error_msg(ERROR_MSG_COMMIT_TRANS, "%m"); return ret; + } return 0; } |