Skip to content

Commit 2f5b809

Browse files
fdmananakdave
authored andcommitted
btrfs: always drop log root tree reference in btrfs_replay_log()
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>
1 parent 4b7699f commit 2f5b809

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
@@ -2088,10 +2088,10 @@ static int btrfs_replay_log(struct btrfs_fs_info *fs_info,
20882088

20892089
/* returns with log_tree_root freed on success */
20902090
ret = btrfs_recover_log_trees(log_tree_root);
2091+
btrfs_put_root(log_tree_root);
20912092
if (ret) {
20922093
btrfs_handle_fs_error(fs_info, ret,
20932094
"Failed to recover log tree");
2094-
btrfs_put_root(log_tree_root);
20952095
return ret;
20962096
}
20972097

fs/btrfs/tree-log.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7586,7 +7586,6 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
75867586
return ret;
75877587

75887588
clear_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags);
7589-
btrfs_put_root(log_root_tree);
75907589

75917590
return 0;
75927591
error:

0 commit comments

Comments
 (0)