Skip to content

Commit e3eec45

Browse files
fdmananagregkh
authored andcommitted
btrfs: always drop log root tree reference in btrfs_replay_log()
[ Upstream commit 2f5b8095ea47b142c56c09755a8b1e14145a2d30 ] Currently we have this odd behaviour: 1) At btrfs_replay_log() we drop the reference of the log root tree if the call to btrfs_recover_log_trees() failed; 2) But if the call to btrfs_recover_log_trees() did not fail, we don't drop the reference in btrfs_replay_log() - we expect that btrfs_recover_log_trees() does it in case it returns success. Let's simplify this and make btrfs_replay_log() always drop the reference on the log root tree, not only this simplifies code as it's what makes sense since it's btrfs_replay_log() who grabbed the reference in the first place. Signed-off-by: Filipe Manana <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 8e36ab6 commit e3eec45

2 files changed

Lines changed: 1 addition & 2 deletions

File tree

fs/btrfs/disk-io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2087,10 +2087,10 @@ static int btrfs_replay_log(struct btrfs_fs_info *fs_info,
20872087

20882088
/* returns with log_tree_root freed on success */
20892089
ret = btrfs_recover_log_trees(log_tree_root);
2090+
btrfs_put_root(log_tree_root);
20902091
if (ret) {
20912092
btrfs_handle_fs_error(fs_info, ret,
20922093
"Failed to recover log tree");
2093-
btrfs_put_root(log_tree_root);
20942094
return ret;
20952095
}
20962096

fs/btrfs/tree-log.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7469,7 +7469,6 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
74697469

74707470
log_root_tree->log_root = NULL;
74717471
clear_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags);
7472-
btrfs_put_root(log_root_tree);
74737472

74747473
return 0;
74757474
error:

0 commit comments

Comments
 (0)