Commit 1ae39938 authored by Josef Bacik's avatar Josef Bacik

Btrfs: do not use async submit for small DIO io's

When looking at our DIO performance Chris said that for small IO's doing the
async submit stuff tends to be more overhead than it's worth.  With this on top
of my other fixes I get about a 17-20% speedup doing a sequential dd with 4k
IO's.  Basically if we don't have to split the bio for the map length it's small
enough to be directly submitted, otherwise go back to the async submit.  Thanks,
Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
parent 02f57c7a
...@@ -5957,7 +5957,7 @@ static struct bio *btrfs_dio_bio_alloc(struct block_device *bdev, ...@@ -5957,7 +5957,7 @@ static struct bio *btrfs_dio_bio_alloc(struct block_device *bdev,
static inline int __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode, static inline int __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode,
int rw, u64 file_offset, int skip_sum, int rw, u64 file_offset, int skip_sum,
u32 *csums) u32 *csums, int async_submit)
{ {
int write = rw & REQ_WRITE; int write = rw & REQ_WRITE;
struct btrfs_root *root = BTRFS_I(inode)->root; struct btrfs_root *root = BTRFS_I(inode)->root;
...@@ -5968,13 +5968,24 @@ static inline int __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode, ...@@ -5968,13 +5968,24 @@ static inline int __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode,
if (ret) if (ret)
goto err; goto err;
if (write && !skip_sum) { if (skip_sum)
goto map;
if (write && async_submit) {
ret = btrfs_wq_submit_bio(root->fs_info, ret = btrfs_wq_submit_bio(root->fs_info,
inode, rw, bio, 0, 0, inode, rw, bio, 0, 0,
file_offset, file_offset,
__btrfs_submit_bio_start_direct_io, __btrfs_submit_bio_start_direct_io,
__btrfs_submit_bio_done); __btrfs_submit_bio_done);
goto err; goto err;
} else if (write) {
/*
* If we aren't doing async submit, calculate the csum of the
* bio now.
*/
ret = btrfs_csum_one_bio(root, inode, bio, file_offset, 1);
if (ret)
goto err;
} else if (!skip_sum) { } else if (!skip_sum) {
ret = btrfs_lookup_bio_sums_dio(root, inode, bio, ret = btrfs_lookup_bio_sums_dio(root, inode, bio,
file_offset, csums); file_offset, csums);
...@@ -5982,7 +5993,8 @@ static inline int __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode, ...@@ -5982,7 +5993,8 @@ static inline int __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode,
goto err; goto err;
} }
ret = btrfs_map_bio(root, rw, bio, 0, 1); map:
ret = btrfs_map_bio(root, rw, bio, 0, async_submit);
err: err:
bio_put(bio); bio_put(bio);
return ret; return ret;
...@@ -6004,6 +6016,7 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip, ...@@ -6004,6 +6016,7 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip,
int nr_pages = 0; int nr_pages = 0;
u32 *csums = dip->csums; u32 *csums = dip->csums;
int ret = 0; int ret = 0;
int async_submit = 0;
int write = rw & REQ_WRITE; int write = rw & REQ_WRITE;
map_length = orig_bio->bi_size; map_length = orig_bio->bi_size;
...@@ -6019,6 +6032,7 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip, ...@@ -6019,6 +6032,7 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip,
goto submit; goto submit;
} }
async_submit = 1;
bio = btrfs_dio_bio_alloc(orig_bio->bi_bdev, start_sector, GFP_NOFS); bio = btrfs_dio_bio_alloc(orig_bio->bi_bdev, start_sector, GFP_NOFS);
if (!bio) if (!bio)
return -ENOMEM; return -ENOMEM;
...@@ -6039,7 +6053,7 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip, ...@@ -6039,7 +6053,7 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip,
atomic_inc(&dip->pending_bios); atomic_inc(&dip->pending_bios);
ret = __btrfs_submit_dio_bio(bio, inode, rw, ret = __btrfs_submit_dio_bio(bio, inode, rw,
file_offset, skip_sum, file_offset, skip_sum,
csums); csums, async_submit);
if (ret) { if (ret) {
bio_put(bio); bio_put(bio);
atomic_dec(&dip->pending_bios); atomic_dec(&dip->pending_bios);
...@@ -6078,7 +6092,7 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip, ...@@ -6078,7 +6092,7 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip,
submit: submit:
ret = __btrfs_submit_dio_bio(bio, inode, rw, file_offset, skip_sum, ret = __btrfs_submit_dio_bio(bio, inode, rw, file_offset, skip_sum,
csums); csums, async_submit);
if (!ret) if (!ret)
return 0; return 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