Skip to contentSkip to conversation

btrfs: remove some unused and pointless code

PATCH In review [email protected] 3 participants 6 messages Apr 3, 2024 Btrfs file system

lore
Share & tools
lore
#0 lore raw

cover btrfs: remove some unused and pointless code

From: Filipe Manana <[email protected]>

Details in the change logs. Trivial changes.

Filipe Manana (3):
btrfs: remove pointless return value assignment at btrfs_finish_one_ordered()
btrfs: remove list emptyness check at warn_about_uncommitted_trans()
btrfs: remove no longer used btrfs_clone_chunk_map()

 fs/btrfs/disk-io.c |  3 ---
 fs/btrfs/inode.c   |  1 -
 fs/btrfs/volumes.c | 15 ---------------
 fs/btrfs/volumes.h |  1 -
 4 files changed, 20 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/3 btrfs: remove pointless return value assignment at btrfs_finish_one_ordered()

From: Filipe Manana <[email protected]>

At btrfs_finish_one_ordered() it's pointless to assign 0 to the 'ret' variable because if it has a non-zero value (error), we have already jumped to the 'out' label. So remove that redundant assignment.

---
 fs/btrfs/inode.c | 1 -
 1 file changed, 1 deletion(-)
fs/btrfs/inode.c +0 -1
index c6f2b5d1dee1..94ac20e62e13 100644
@@ -3185,7 +3185,6 @@ int btrfs_finish_one_ordered(struct btrfs_ordered_extent *ordered_extent)
 		btrfs_abort_transaction(trans, ret);
 		goto out;
 	}
-	ret = 0;
 out:
 	clear_extent_bit(&inode->io_tree, start, end, clear_bits,
 			 &cached_state);
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/3 btrfs: remove list emptyness check at warn_about_uncommitted_trans()

In reply to [email protected]

From: Filipe Manana <[email protected]>

At warn_about_uncommitted_trans(), there's no need to check if the list is empty and return, because list_for_each_entry_safe() is safe to call for an empty list, it simply does nothing. So remove the check.

---
 fs/btrfs/disk-io.c | 3 ---
 1 file changed, 3 deletions(-)
fs/btrfs/disk-io.c +0 -3
index 5a35c2c0bbc9..0474e9b6d302 100644
@@ -4182,9 +4182,6 @@ static void warn_about_uncommitted_trans(struct btrfs_fs_info *fs_info)
 	struct btrfs_transaction *tmp;
 	bool found = false;
 
-	if (list_empty(&fs_info->trans_list))
-		return;
-
 	/*
 	 * This function is only called at the very end of close_ctree(),
 	 * thus no other running transaction, no need to take trans_lock.
Signature · 1 line
2.43.0
#3 lore raw

PATCH 3/3 btrfs: remove no longer used btrfs_clone_chunk_map()

In reply to [email protected]

From: Filipe Manana <[email protected]>

There are no more users of btrfs_clone_chunk_map(), the last one (and only one ever) was removed in commit 1ec17ef59168 ("btrfs: zoned: fix use-after-free in do_zone_finish()"). So remove btrfs_clone_chunk_map().

---
 fs/btrfs/volumes.c | 15 ---------------
 fs/btrfs/volumes.h |  1 -
 2 files changed, 16 deletions(-)
fs/btrfs/volumes.c +0 -15
index f15591f3e54f..a3dc88e420d1 100644
@@ -5614,21 +5614,6 @@ struct btrfs_chunk_map *btrfs_alloc_chunk_map(int num_stripes, gfp_t gfp)
 	return map;
 }
 
-struct btrfs_chunk_map *btrfs_clone_chunk_map(struct btrfs_chunk_map *map, gfp_t gfp)
-{
-	const int size = btrfs_chunk_map_size(map->num_stripes);
-	struct btrfs_chunk_map *clone;
-
-	clone = kmemdup(map, size, gfp);
-	if (!clone)
-		return NULL;
-
-	refcount_set(&clone->refs, 1);
-	RB_CLEAR_NODE(&clone->rb_node);
-
-	return clone;
-}
-
 static struct btrfs_block_group *create_chunk(struct btrfs_trans_handle *trans,
 			struct alloc_chunk_ctl *ctl,
 			struct btrfs_device_info *devices_info)
fs/btrfs/volumes.h +0 -1
index 93854609a4d5..cf555f5b47ce 100644
@@ -743,7 +743,6 @@ struct btrfs_chunk_map *btrfs_alloc_chunk_map(int num_stripes, gfp_t gfp);
 int btrfs_add_chunk_map(struct btrfs_fs_info *fs_info, struct btrfs_chunk_map *map);
 #endif
 
-struct btrfs_chunk_map *btrfs_clone_chunk_map(struct btrfs_chunk_map *map, gfp_t gfp);
 struct btrfs_chunk_map *btrfs_find_chunk_map(struct btrfs_fs_info *fs_info,
 					     u64 logical, u64 length);
 struct btrfs_chunk_map *btrfs_find_chunk_map_nolock(struct btrfs_fs_info *fs_info,
Signature · 1 line
2.43.0
Reviewed-by on the v1 series
#4 lore raw
In reply to [email protected]
Quoted 8 lines · On Wed, Apr 03, 2024 at 01:05:45PM +0100, [email protected] wrote:

From: Filipe Manana <[email protected]>

Details in the change logs. Trivial changes.

Filipe Manana (3):
btrfs: remove pointless return value assignment at btrfs_finish_one_ordered()
btrfs: remove list emptyness check at warn_about_uncommitted_trans()
btrfs: remove no longer used btrfs_clone_chunk_map()

Reviewed-by on the v1 series
#5 lore raw
In reply to [email protected]
Quoted 8 lines · 在 2024/4/3 22:35, [email protected] 写道:

From: Filipe Manana <[email protected]>

Details in the change logs. Trivial changes.

Filipe Manana (3):
btrfs: remove pointless return value assignment at btrfs_finish_one_ordered()
btrfs: remove list emptyness check at warn_about_uncommitted_trans()
btrfs: remove no longer used btrfs_clone_chunk_map()

Thanks,
Qu

Quoted 7 lines
  fs/btrfs/disk-io.c |  3 ---
  fs/btrfs/inode.c   |  1 -
  fs/btrfs/volumes.c | 15 ---------------
  fs/btrfs/volumes.h |  1 -
  4 files changed, 20 deletions(-)