Btrfs: Write bio checksumming outside the FS mutex
This significantly improves streaming write performance by allowing
concurrency in the data checksumming.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 457daf72..3e1f21c 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -330,14 +330,23 @@
struct btrfs_root *root = BTRFS_I(inode)->root;
struct btrfs_trans_handle *trans;
int ret = 0;
+ char *sums = NULL;
+
+ ret = btrfs_csum_one_bio(root, bio, &sums);
+ BUG_ON(ret);
mutex_lock(&root->fs_info->fs_mutex);
trans = btrfs_start_transaction(root, 1);
+
btrfs_set_trans_block_group(trans, inode);
- btrfs_csum_file_blocks(trans, root, inode, bio);
+ btrfs_csum_file_blocks(trans, root, inode, bio, sums);
+
ret = btrfs_end_transaction(trans, root);
BUG_ON(ret);
mutex_unlock(&root->fs_info->fs_mutex);
+
+ kfree(sums);
+
return btrfs_map_bio(root, rw, bio, mirror_num);
}