Skip to content

Commit 403eb8a

Browse files
fdmananagregkh
authored andcommitted
btrfs: always drop log root tree reference in btrfs_replay_log()
[ Upstream commit 2f5b809 ] 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 <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 500784a commit 403eb8a

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

fs/btrfs/disk-io.c

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

21012101
/* returns with log_tree_root freed on success */
21022102
ret = btrfs_recover_log_trees(log_tree_root);
2103+
btrfs_put_root(log_tree_root);
21032104
if (ret) {
21042105
btrfs_handle_fs_error(fs_info, ret,
21052106
"Failed to recover log tree");
2106-
btrfs_put_root(log_tree_root);
21072107
return ret;
21082108
}
21092109

fs/btrfs/tree-log.c

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

74587458
log_root_tree->log_root = NULL;
74597459
clear_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags);
7460-
btrfs_put_root(log_root_tree);
74617460

74627461
return 0;
74637462
error:

0 commit comments

Comments
 (0)