]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: simplify check for zoned NODATASUM writes in btrfs_submit_chunk()
authorZhen Ni <zhen.ni@easystack.cn>
Fri, 19 Dec 2025 07:36:49 +0000 (15:36 +0800)
committerDavid Sterba <dsterba@suse.com>
Tue, 3 Feb 2026 06:50:26 +0000 (07:50 +0100)
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.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Zhen Ni <zhen.ni@easystack.cn>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/bio.c

index e4d382d3a7aeacbfc119037dfe43ba44b83a48a5..a12446aa0fbf7ad6c4329c8303bf20933390be1e 100644 (file)
@@ -836,8 +836,7 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num)
                        if (status)
                                goto fail;
                } else if (bbio->can_use_append ||
-                          (btrfs_is_zoned(fs_info) && inode &&
-                           inode->flags & BTRFS_INODE_NODATASUM)) {
+                          (btrfs_is_zoned(fs_info) && inode->flags & BTRFS_INODE_NODATASUM)) {
                        ret = btrfs_alloc_dummy_sum(bbio);
                        status = errno_to_blk_status(ret);
                        if (status)