Skip to contentSkip to conversation

Btrfs: remove unused code in __btrfs_unlink_inode

PATCH In review Liu Bo 2 participants 2 messages Sep 12, 2018 Btrfs file system

lore
Share & tools
lore

Liu Bo

author
#0 lore raw

PATCH 1/1 Btrfs: remove unused code in __btrfs_unlink_inode

It might get @leaf and @key in order to do some sanity checks on key's fields, but since we don't check it any more, it's fine to remove the code.

---
 fs/btrfs/inode.c | 4 ----
 1 file changed, 4 deletions(-)
fs/btrfs/inode.c +0 -4
index d3febc3a6bc0..fd64d7ac76f9 100644
@@ -3911,9 +3911,7 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
 	struct btrfs_fs_info *fs_info = root->fs_info;
 	struct btrfs_path *path;
 	int ret = 0;
-	struct extent_buffer *leaf;
 	struct btrfs_dir_item *di;
-	struct btrfs_key key;
 	u64 index;
 	u64 ino = btrfs_ino(inode);
 	u64 dir_ino = btrfs_ino(dir);
@@ -3935,8 +3933,6 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
 		ret = -ENOENT;
 		goto err;
 	}
-	leaf = path->nodes[0];
-	btrfs_dir_item_key_to_cpu(leaf, di, &key);
 	ret = btrfs_delete_one_dir_name(trans, root, path, di);
 	if (ret)
 		goto err;
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 3 lines · Liu Bo

It might get @leaf and @key in order to do some sanity checks on key's fields, but since we don't check it any more, it's fine to remove the code.

This is actually false, leaf and key weren't used for sanity checks. Instead this code was first introduced in 5f39d397dfbe ("Btrfs: Create extent_buffer interface for large blocksizes") and the function was named btrfs_unlink_trans. It later got renamed to __btrfs_unlink_inode and finally commit 16cdcec736cd ("btrfs: implement delayed inode items operation") changed the way inodes are deleted and obviated the need for those two members.

Generally when unused variables are deleted you need to do a bit of archeology and explain how they got to be unused in the changelog.

Quoted 30 lines
---
 fs/btrfs/inode.c | 4 ----
 1 file changed, 4 deletions(-)
fs/btrfs/inode.c +0 -4
index d3febc3a6bc0..fd64d7ac76f9 100644
@@ -3911,9 +3911,7 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
 	struct btrfs_fs_info *fs_info = root->fs_info;
 	struct btrfs_path *path;
 	int ret = 0;
-	struct extent_buffer *leaf;
 	struct btrfs_dir_item *di;
-	struct btrfs_key key;
 	u64 index;
 	u64 ino = btrfs_ino(inode);
 	u64 dir_ino = btrfs_ino(dir);
@@ -3935,8 +3933,6 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
 		ret = -ENOENT;
 		goto err;
 	}
-	leaf = path->nodes[0];
-	btrfs_dir_item_key_to_cpu(leaf, di, &key);
 	ret = btrfs_delete_one_dir_name(trans, root, path, di);
 	if (ret)
 		goto err;