Skip to contentSkip to conversation

Btrfs: remove duplicated btrfs_release_path in btrfs_unlink_subvol

PATCH In review Liu Bo 3 participants 5 messages Aug 14, 2018 – Aug 15, 2018 Btrfs file system

lore
Share & tools
lore

Liu Bo

author
#0 lore raw

PATCH 1/1 Btrfs: remove duplicated btrfs_release_path in btrfs_unlink_subvol

The btrfs_release_path() is just useless as path is only used in error handling.

---
 fs/btrfs/inode.c | 1 -
 1 file changed, 1 deletion(-)
fs/btrfs/inode.c +0 -1
index eba61bcb9bb3..5680e9c462a3 100644
@@ -4148,7 +4148,6 @@ static int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
 		btrfs_release_path(path);
 		index = key.offset;
 	}
-	btrfs_release_path(path);
 
 	ret = btrfs_delete_delayed_dir_index(trans, fs_info, BTRFS_I(dir), index);
 	if (ret) {
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 1 line · Liu Bo

The btrfs_release_path() is just useless as path is only used in error handling.

Where is it duplicated? And I don't think it's useless, while the changelog does not explain why and it's not obvious from the context. If the path is locked, then releasing it right after it's not needed makes sense. There are several potentially heavyweight operations between the release and final free.

author
#2 lore raw
Quoted 8 lines · David Sterba
Quoted 1 line · Liu Bo

The btrfs_release_path() is just useless as path is only used in error handling.

Where is it duplicated? And I don't think it's useless, while the changelog does not explain why and it's not obvious from the context. If the path is locked, then releasing it right after it's not needed makes sense. There are several potentially heavyweight operations between the release and final free.

I see, the diff context is a little bit misleading, the logic in btrfs_unlink_subvol() is like,

{
	...
	btrfs_delete_one_dir_name(path);
	btrfs_release_path(path);

	ret = btrfs_del_root_ref(); <<<< path is not used here.
	if (ret < 0) {
	   	btrfs_search_dir_index_item(path);
		btrfs_release_path(path);
	}
	btrfs_release_path(path);   <<<< path has been released anyway.
	...
}

thanks,
-liubo

#3 lore raw
Quoted 4 lines · Liu Bo
Quoted 3 lines · David Sterba
Quoted 1 line · Liu Bo

The btrfs_release_path() is just useless as path is only used in error handling.

Quoted 8 lines
Quoted 5 lines

Where is it duplicated? And I don't think it's useless, while the changelog does not explain why and it's not obvious from the context. If the path is locked, then releasing it right after it's not needed makes sense. There are several potentially heavyweight operations between the release and final free.

I see, the diff context is a little bit misleading, the logic in btrfs_unlink_subvol() is like,

Well, you based you patch on old code, the duplicate btrfs_release_path has been removed in 5b7d687ad5913a56b6a8788435d7a53990b4176d and was in the devel branches since like 2 weeks.

The patch removes the first release while it would could have been the other one to save some cycles when the branch with btrfs_search_dir_index_item is not taken.

#4 lore raw
Quoted 14 lines · David Sterba
Quoted 4 lines · Liu Bo
Quoted 3 lines · David Sterba
Quoted 1 line · Liu Bo

The btrfs_release_path() is just useless as path is only used in error handling.

Quoted 8 lines
Quoted 5 lines

Where is it duplicated? And I don't think it's useless, while the changelog does not explain why and it's not obvious from the context. If the path is locked, then releasing it right after it's not needed makes sense. There are several potentially heavyweight operations between the release and final free.

I see, the diff context is a little bit misleading, the logic in btrfs_unlink_subvol() is like,

Quoted 7 lines

Well, you based you patch on old code, the duplicate btrfs_release_path has been removed in 5b7d687ad5913a56b6a8788435d7a53990b4176d and was in the devel branches since like 2 weeks.

The patch removes the first release while it would could have been the other one to save some cycles when the branch with btrfs_search_dir_index_item is not taken.

Ah I see, sorry for the noise.

thanks,
liubo