diff options
author | Chris Mason <chris.mason@oracle.com> | 2008-04-16 11:14:51 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:04:01 -0400 |
commit | 44b8bd7edda4f63de180d0f7325c9fb704b3806b (patch) | |
tree | 6090e8b70d6a726caed7d4662c311779d1927cf7 /fs/btrfs/inode.c | |
parent | 321aecc65671ae8136bd2ca6879b56f0221f8ac8 (diff) |
Btrfs: Create a work queue for bio writes
This allows checksumming to happen in parallel among many cpus, and
keeps us from bogging down pdflush with the checksumming code.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 7869c0157a1f..457daf725d29 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 | ||
327 | int btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio, | 327 | int __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 | |||
344 | int 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); | ||
352 | mapit: | 364 | mapit: |
353 | return btrfs_map_bio(root, rw, bio, mirror_num); | 365 | return btrfs_map_bio(root, rw, bio, mirror_num); |
354 | } | 366 | } |