Commit 19b9bdb0 authored by Chris Mason's avatar Chris Mason

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: default avatarChris Mason <chris.mason@oracle.com>
parent cfbc246e
...@@ -833,28 +833,29 @@ int btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio, ...@@ -833,28 +833,29 @@ int btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
{ {
struct btrfs_root *root = BTRFS_I(inode)->root; struct btrfs_root *root = BTRFS_I(inode)->root;
int ret = 0; int ret = 0;
int skip_sum;
ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0); ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0);
BUG_ON(ret); BUG_ON(ret);
if (btrfs_test_opt(root, NODATASUM) || skip_sum = btrfs_test_opt(root, NODATASUM) ||
btrfs_test_flag(inode, NODATASUM)) { btrfs_test_flag(inode, NODATASUM);
goto mapit;
}
if (!(rw & (1 << BIO_RW))) { if (!(rw & (1 << BIO_RW))) {
btrfs_lookup_bio_sums(root, inode, bio); if (!skip_sum)
btrfs_lookup_bio_sums(root, inode, bio);
if (bio_flags & EXTENT_BIO_COMPRESSED) { if (bio_flags & EXTENT_BIO_COMPRESSED)
return btrfs_submit_compressed_read(inode, bio, return btrfs_submit_compressed_read(inode, bio,
mirror_num, bio_flags); mirror_num, bio_flags);
}
goto mapit; goto mapit;
} } else if (!skip_sum) {
return btrfs_wq_submit_bio(BTRFS_I(inode)->root->fs_info, /* we're doing a write, do the async checksumming */
return btrfs_wq_submit_bio(BTRFS_I(inode)->root->fs_info,
inode, rw, bio, mirror_num, inode, rw, bio, mirror_num,
bio_flags, __btrfs_submit_bio_hook); bio_flags, __btrfs_submit_bio_hook);
}
mapit: mapit:
return btrfs_map_bio(root, rw, bio, mirror_num, 0); return btrfs_map_bio(root, rw, bio, mirror_num, 0);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment