Commit e55179b3 authored by Li Zefan's avatar Li Zefan Committed by Chris Mason

Btrfs: check the nodatasum flag when writing compressed files

If mounting with nodatasum option, we won't csum file data for
general write or direct-io write, and this rule should also be
applied when writing compressed files.
Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 77906a50
...@@ -338,6 +338,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start, ...@@ -338,6 +338,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
u64 first_byte = disk_start; u64 first_byte = disk_start;
struct block_device *bdev; struct block_device *bdev;
int ret; int ret;
int skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM;
WARN_ON(start & ((u64)PAGE_CACHE_SIZE - 1)); WARN_ON(start & ((u64)PAGE_CACHE_SIZE - 1));
cb = kmalloc(compressed_bio_size(root, compressed_len), GFP_NOFS); cb = kmalloc(compressed_bio_size(root, compressed_len), GFP_NOFS);
...@@ -392,8 +393,11 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start, ...@@ -392,8 +393,11 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
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);
ret = btrfs_csum_one_bio(root, inode, bio, start, 1); if (!skip_sum) {
BUG_ON(ret); ret = btrfs_csum_one_bio(root, inode, bio,
start, 1);
BUG_ON(ret);
}
ret = btrfs_map_bio(root, WRITE, bio, 0, 1); ret = btrfs_map_bio(root, WRITE, bio, 0, 1);
BUG_ON(ret); BUG_ON(ret);
...@@ -418,8 +422,10 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start, ...@@ -418,8 +422,10 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
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);
ret = btrfs_csum_one_bio(root, inode, bio, start, 1); if (!skip_sum) {
BUG_ON(ret); ret = btrfs_csum_one_bio(root, inode, bio, start, 1);
BUG_ON(ret);
}
ret = btrfs_map_bio(root, WRITE, bio, 0, 1); ret = btrfs_map_bio(root, WRITE, bio, 0, 1);
BUG_ON(ret); BUG_ON(ret);
......
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