Skip to contentSkip to conversation

btrfs: remove redundant inode NULL check in is_data_bbio()

PATCH In review Zhen Ni 3 participants 3 messages Dec 19, 2025 – Jun 18 Btrfs file system

lore
Share & tools
lore

Zhen Ni

author
#0 lore raw

PATCH 1/1 btrfs: remove redundant inode NULL check in is_data_bbio()

After commit 81cea6cd7041 ("btrfs: remove btrfs_bio::fs_info by extracting it from btrfs_bio::inode"), the btrfs_bio::inode field is mandatory for all btrfs_bio allocations. The NULL check is redundant and can be removed.

---
 fs/btrfs/bio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/bio.c +1 -1
index fa1d321a2fb8..ce649e265b75 100644
@@ -29,7 +29,7 @@ struct btrfs_failed_bio {
 /* Is this a data path I/O that needs storage layer checksum and repair? */
 static inline bool is_data_bbio(const struct btrfs_bio *bbio)
 {
-	return bbio->inode && is_data_inode(bbio->inode);
+	return is_data_inode(bbio->inode);
 }
 
 static bool bbio_has_ordered_extent(const struct btrfs_bio *bbio)
Signature · 1 line
2.20.1
#1 lore raw
Quoted 23 lines · Zhen Ni

After commit 81cea6cd7041 ("btrfs: remove btrfs_bio::fs_info by extracting it from btrfs_bio::inode"), the btrfs_bio::inode field is mandatory for all btrfs_bio allocations. The NULL check is redundant and can be removed.

---
  fs/btrfs/bio.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/bio.c +1 -1
index fa1d321a2fb8..ce649e265b75 100644
@@ -29,7 +29,7 @@ struct btrfs_failed_bio {
  /* Is this a data path I/O that needs storage layer checksum and repair? */
  static inline bool is_datais_data_bbio
 _bbio(const struct btrfs_bio *bbio)
  {
-	return bbio->inode && is_data_inode(bbio->inode);
+	return is_data_inode(bbio->inode);
  }
 
Quoted 1 line

static bool bbio_has_ordered_extent(const struct btrfs_bio *bbio)

But then is_data_bbio() becomes a simple wrapper around is_data_inode() not adding any functionality or documentation. I'd think you scan just replace is_data_bbio(bbio) with is_data_inode(bbio->inode) in all of bio.c

#2 lore raw
In reply to Zhen Ni
Quoted 15 lines · Zhen Ni

After commit 81cea6cd7041 ("btrfs: remove btrfs_bio::fs_info by extracting it from btrfs_bio::inode"), the btrfs_bio::inode field is mandatory for all btrfs_bio allocations. The NULL check is redundant and can be removed.

---
 fs/btrfs/bio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/bio.c +0 -0
index fa1d321a2fb8..ce649e265b75 100644

fs/btrfs/bio.c struct btrfs_failed_bio { · line 32

Quoted 5 lines
fs/btrfs/bio.c +1 -1
@@ -29,7 +29,7 @@ struct btrfs_failed_bio {
 /* Is this a data path I/O that needs storage layer checksum and repair? */
 static inline bool is_data_bbio(const struct btrfs_bio *bbio)
 {
-	return bbio->inode && is_data_inode(bbio->inode);
+	return is_data_inode(bbio->inode);

Removing the 'bbio->inode' check would be good and as Johannes pointed out then is_data_bbio() can be replaced by is_data_inode().

If you're still interested, please send an updated patch with that change. Thanks.