Skip to contentSkip to conversation

btrfs: simplify check for zoned NODATASUM writes in btrfs_submit_chunk()

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

lore
Share & tools
lore

Zhen Ni

author
#0 lore raw

PATCH 1/1 btrfs: simplify check for zoned NODATASUM writes in btrfs_submit_chunk()

This function already dereferences 'inode' multiple times earlier, making the additional NULL check at line 840 redundant since the function would have crashed already if inode were NULL.

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 and is guaranteed to be non-NULL.

Simplify the condition for allocating dummy checksums for zoned NODATASUM data by removing the unnecessary 'inode &&' check.

---
 fs/btrfs/bio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/bio.c +1 -1
index fa1d321a2fb8..abe3e5e7c5d9 100644
@@ -837,7 +837,7 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num)
 			if (status)
 				goto fail;
 		} else if (use_append ||
-			   (btrfs_is_zoned(fs_info) && inode &&
+			   (btrfs_is_zoned(fs_info) &&
 			    inode->flags & BTRFS_INODE_NODATASUM)) {
 			ret = btrfs_alloc_dummy_sum(bbio);
 			status = errno_to_blk_status(ret);
Signature · 1 line
2.20.1
#2 lore raw
In reply to Zhen Ni
Quoted 9 lines · Zhen Ni

This function already dereferences 'inode' multiple times earlier, making the additional NULL check at line 840 redundant since the function would have crashed already if inode were NULL.

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 and is guaranteed to be non-NULL.

Quoted 4 lines

Simplify the condition for allocating dummy checksums for zoned NODATASUM data by removing the unnecessary 'inode &&' check.

Added to for-next, thanks.