Skip to contentSkip to conversation

Remove some unused struct members

PATCH In review David Sterba 5 participants 10 messages Nov 21, 2023 Btrfs file system

lore
Share & tools
lore

David Sterba

author maintainer
#0 lore raw

cover Remove some unused struct members

Jiri Slaby wrote a tool to find unused struct members [1]. There are some interesting fossils. Comparing that to my hacky coccinelle scripts, it did a much better job.

[1] https://github.com/jirislaby/clang-struct

David Sterba (5):
btrfs: scrub: remove unused scrub_ctx::sectors_per_bio
btrfs: remove unused btrfs_ordered_extent::outstanding_isize
btrfs: raid56: remove unused btrfs_plug_cb::work
btrfs: remove unused definition of tree_entry in extent-io-tree.c
btrfs: remove unused btrfs_root::type

 fs/btrfs/ctree.h          | 2 --
 fs/btrfs/extent-io-tree.c | 6 ------
 fs/btrfs/ordered-data.h   | 7 -------
 fs/btrfs/raid56.c         | 1 -
 fs/btrfs/scrub.c          | 1 -
 5 files changed, 17 deletions(-)
Signature · 1 line
2.42.1
author maintainer
#1 lore raw

PATCH 1/5 btrfs: scrub: remove unused scrub_ctx::sectors_per_bio

The recent scrub rewrite forgot to remove the sectors_per_bio in 6.3 in 13a62fd997f0 ("btrfs: scrub: remove scrub_bio structure"). This was found by tool https://github.com/jirislaby/clang-struct .

---
 fs/btrfs/scrub.c | 1 -
 1 file changed, 1 deletion(-)
fs/btrfs/scrub.c +0 -1
index f62a408671cb..00826644bca8 100644
@@ -192,7 +192,6 @@ struct scrub_ctx {
 	int			cur_stripe;
 	atomic_t		cancel_req;
 	int			readonly;
-	int			sectors_per_bio;
 
 	/* State of IO submission throttling affecting the associated device */
 	ktime_t			throttle_deadline;
Signature · 1 line
2.42.1
author maintainer
#2 lore raw

PATCH 2/5 btrfs: remove unused btrfs_ordered_extent::outstanding_isize

In reply to David Sterba

The whole isize code was deleted in 5.6 3f1c64ce0438 ("btrfs: delete the ordered isize update code"), except the struct member. This was found by tool https://github.com/jirislaby/clang-struct .

---
 fs/btrfs/ordered-data.h | 7 -------
 1 file changed, 7 deletions(-)
fs/btrfs/ordered-data.h +0 -7
index 567a6d3d4712..127ef8bf0ffd 100644
@@ -96,13 +96,6 @@ struct btrfs_ordered_extent {
 	/* number of bytes that still need writing */
 	u64 bytes_left;
 
-	/*
-	 * the end of the ordered extent which is behind it but
-	 * didn't update disk_i_size. Please see the comment of
-	 * btrfs_ordered_update_i_size();
-	 */
-	u64 outstanding_isize;
-
 	/*
 	 * If we get truncated we need to adjust the file extent we enter for
 	 * this ordered extent so that we do not expose stale data.
Signature · 1 line
2.42.1
author maintainer
#3 lore raw

PATCH 3/5 btrfs: raid56: remove unused btrfs_plug_cb::work

In reply to David Sterba

The raid56 changes in 6.2 reworked the IO path to RMW, commit 93723095b5d5 ("btrfs: raid56: switch write path to rmw_rbio()") in particular removed the last use of the work member so it can be removed as well. This was found by tool https://github.com/jirislaby/clang-struct .

---
 fs/btrfs/raid56.c | 1 -
 1 file changed, 1 deletion(-)
fs/btrfs/raid56.c +0 -1
index 3e014b9370a3..90f12c0e88a1 100644
@@ -1549,7 +1549,6 @@ struct btrfs_plug_cb {
 	struct blk_plug_cb cb;
 	struct btrfs_fs_info *info;
 	struct list_head rbio_list;
-	struct work_struct work;
 };
 
 /*
Signature · 1 line
2.42.1
author maintainer
#4 lore raw

PATCH 4/5 btrfs: remove unused definition of tree_entry in extent-io-tree.c

In reply to David Sterba

The declaration was temporarily moved in a4055213bf69 ("btrfs: unexport all the temporary exports for extent-io-tree.c") and then should have been removed in 6.0 in 071d19f5130f ("btrfs: remove struct tree_entry in extent-io-tree.c") but was not. This was found by tool
https://github.com/jirislaby/clang-struct .

---
 fs/btrfs/extent-io-tree.c | 6 ------
 1 file changed, 6 deletions(-)
fs/btrfs/extent-io-tree.c +0 -6
index ea149be28dff..76061245a46b 100644
@@ -87,12 +87,6 @@ static inline void __btrfs_debug_check_extent_io_range(const char *caller,
  */
 static struct lock_class_key file_extent_tree_class;
 
-struct tree_entry {
-	u64 start;
-	u64 end;
-	struct rb_node rb_node;
-};
-
 void extent_io_tree_init(struct btrfs_fs_info *fs_info,
 			 struct extent_io_tree *tree, unsigned int owner)
 {
Signature · 1 line
2.42.1
author maintainer
#5 lore raw

PATCH 5/5 btrfs: remove unused btrfs_root::type

In reply to David Sterba

Looks like the struct member was added in 2007 in 2.6.29 in commit 87ee04eb0f2f ("Btrfs: Add simple stripe size parameter") but hasn't been used at all since. So let's remove it. This was found by tool
https://github.com/jirislaby/clang-struct, then build tested after removing the struct member.

---
 fs/btrfs/ctree.h | 2 --
 1 file changed, 2 deletions(-)
fs/btrfs/ctree.h +0 -2
index 9c0800f5bdcb..54fd4eb92745 100644
@@ -212,8 +212,6 @@ struct btrfs_root {
 
 	u64 last_trans;
 
-	u32 type;
-
 	u64 free_objectid;
 
 	struct btrfs_key defrag_progress;
Signature · 1 line
2.42.1
Reviewed-by on the v1 series
#6 lore raw
In reply to David Sterba
Quoted 3 lines · David Sterba

Jiri Slaby wrote a tool to find unused struct members [1]. There are some interesting fossils. Comparing that to my hacky coccinelle scripts, it did a much better job.

Quoted 2 lines

[1] https://github.com/jirislaby/clang-struct

The tool looks awesome!

Thanks,
Qu

Quoted 15 lines

David Sterba (5):
btrfs: scrub: remove unused scrub_ctx::sectors_per_bio
btrfs: remove unused btrfs_ordered_extent::outstanding_isize
btrfs: raid56: remove unused btrfs_plug_cb::work
btrfs: remove unused definition of tree_entry in extent-io-tree.c
btrfs: remove unused btrfs_root::type

  fs/btrfs/ctree.h          | 2 --
  fs/btrfs/extent-io-tree.c | 6 ------
  fs/btrfs/ordered-data.h   | 7 -------
  fs/btrfs/raid56.c         | 1 -
  fs/btrfs/scrub.c          | 1 -
  5 files changed, 17 deletions(-)
#9 lore raw
In reply to David Sterba
Quoted 4 lines · David Sterba

Jiri Slaby wrote a tool to find unused struct members [1]. There are some interesting fossils. Comparing that to my hacky coccinelle scripts, it did a much better job.

Quoted 8 lines

[1] https://github.com/jirislaby/clang-struct

David Sterba (5):
btrfs: scrub: remove unused scrub_ctx::sectors_per_bio
btrfs: remove unused btrfs_ordered_extent::outstanding_isize
btrfs: raid56: remove unused btrfs_plug_cb::work
btrfs: remove unused definition of tree_entry in extent-io-tree.c
btrfs: remove unused btrfs_root::type

Added to misc-next.