aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 7869c0157a1..457daf725d2 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -324,13 +324,29 @@ int btrfs_merge_bio_hook(struct page *page, unsigned long offset,
324 return 0; 324 return 0;
325} 325}
326 326
327int btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio, 327int __btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
328 int mirror_num) 328 int mirror_num)
329{ 329{
330 struct btrfs_root *root = BTRFS_I(inode)->root; 330 struct btrfs_root *root = BTRFS_I(inode)->root;
331 struct btrfs_trans_handle *trans; 331 struct btrfs_trans_handle *trans;
332 int ret = 0; 332 int ret = 0;
333 333
334 mutex_lock(&root->fs_info->fs_mutex);
335 trans = btrfs_start_transaction(root, 1);
336 btrfs_set_trans_block_group(trans, inode);
337 btrfs_csum_file_blocks(trans, root, inode, bio);
338 ret = btrfs_end_transaction(trans, root);
339 BUG_ON(ret);
340 mutex_unlock(&root->fs_info->fs_mutex);
341 return btrfs_map_bio(root, rw, bio, mirror_num);
342}
343
344int btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
345 int mirror_num)
346{
347 struct btrfs_root *root = BTRFS_I(inode)->root;
348 int ret = 0;
349
334 if (!(rw & (1 << BIO_RW))) { 350 if (!(rw & (1 << BIO_RW))) {
335 ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0); 351 ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0);
336 BUG_ON(ret); 352 BUG_ON(ret);
@@ -342,13 +358,9 @@ int btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
342 goto mapit; 358 goto mapit;
343 } 359 }
344 360
345 mutex_lock(&root->fs_info->fs_mutex); 361 return btrfs_wq_submit_bio(BTRFS_I(inode)->root->fs_info,
346 trans = btrfs_start_transaction(root, 1); 362 inode, rw, bio, mirror_num,
347 btrfs_set_trans_block_group(trans, inode); 363 __btrfs_submit_bio_hook);
348 btrfs_csum_file_blocks(trans, root, inode, bio);
349 ret = btrfs_end_transaction(trans, root);
350 BUG_ON(ret);
351 mutex_unlock(&root->fs_info->fs_mutex);
352mapit: 364mapit:
353 return btrfs_map_bio(root, rw, bio, mirror_num); 365 return btrfs_map_bio(root, rw, bio, mirror_num);
354} 366}