Skip to content

Commit 19b9bdb

Browse files
committed
Btrfs: Fix logic to avoid reading checksums for -o nodatasum,compress
When compression was on, we were improperly ignoring -o nodatasum. This reworks the logic a bit to properly honor all the flags. Signed-off-by: Chris Mason <chris.mason@oracle.com>
1 parent cfbc246 commit 19b9bdb

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

fs/btrfs/inode.c

+11-10
Original file line numberDiff line numberDiff line change
@@ -833,28 +833,29 @@ int btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
833833
{
834834
struct btrfs_root *root = BTRFS_I(inode)->root;
835835
int ret = 0;
836+
int skip_sum;
836837

837838
ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0);
838839
BUG_ON(ret);
839840

840-
if (btrfs_test_opt(root, NODATASUM) ||
841-
btrfs_test_flag(inode, NODATASUM)) {
842-
goto mapit;
843-
}
841+
skip_sum = btrfs_test_opt(root, NODATASUM) ||
842+
btrfs_test_flag(inode, NODATASUM);
844843

845844
if (!(rw & (1 << BIO_RW))) {
846-
btrfs_lookup_bio_sums(root, inode, bio);
845+
if (!skip_sum)
846+
btrfs_lookup_bio_sums(root, inode, bio);
847847

848-
if (bio_flags & EXTENT_BIO_COMPRESSED) {
848+
if (bio_flags & EXTENT_BIO_COMPRESSED)
849849
return btrfs_submit_compressed_read(inode, bio,
850850
mirror_num, bio_flags);
851-
}
852-
853851
goto mapit;
854-
}
855-
return btrfs_wq_submit_bio(BTRFS_I(inode)->root->fs_info,
852+
} else if (!skip_sum) {
853+
/* we're doing a write, do the async checksumming */
854+
return btrfs_wq_submit_bio(BTRFS_I(inode)->root->fs_info,
856855
inode, rw, bio, mirror_num,
857856
bio_flags, __btrfs_submit_bio_hook);
857+
}
858+
858859
mapit:
859860
return btrfs_map_bio(root, rw, bio, mirror_num, 0);
860861
}

0 commit comments

Comments
 (0)