diff options
| -rw-r--r-- | fs/btrfs/inode.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 4a238d676e5b..149c77fd1eb5 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
| @@ -6006,13 +6006,6 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip, | |||
| 6006 | int ret = 0; | 6006 | int ret = 0; |
| 6007 | int write = rw & REQ_WRITE; | 6007 | int write = rw & REQ_WRITE; |
| 6008 | 6008 | ||
| 6009 | bio = btrfs_dio_bio_alloc(orig_bio->bi_bdev, start_sector, GFP_NOFS); | ||
| 6010 | if (!bio) | ||
| 6011 | return -ENOMEM; | ||
| 6012 | bio->bi_private = dip; | ||
| 6013 | bio->bi_end_io = btrfs_end_dio_bio; | ||
| 6014 | atomic_inc(&dip->pending_bios); | ||
| 6015 | |||
| 6016 | map_length = orig_bio->bi_size; | 6009 | map_length = orig_bio->bi_size; |
| 6017 | ret = btrfs_map_block(map_tree, READ, start_sector << 9, | 6010 | ret = btrfs_map_block(map_tree, READ, start_sector << 9, |
| 6018 | &map_length, NULL, 0); | 6011 | &map_length, NULL, 0); |
| @@ -6021,6 +6014,18 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip, | |||
| 6021 | return -EIO; | 6014 | return -EIO; |
| 6022 | } | 6015 | } |
| 6023 | 6016 | ||
| 6017 | if (map_length >= orig_bio->bi_size) { | ||
| 6018 | bio = orig_bio; | ||
| 6019 | goto submit; | ||
| 6020 | } | ||
| 6021 | |||
| 6022 | bio = btrfs_dio_bio_alloc(orig_bio->bi_bdev, start_sector, GFP_NOFS); | ||
| 6023 | if (!bio) | ||
| 6024 | return -ENOMEM; | ||
| 6025 | bio->bi_private = dip; | ||
| 6026 | bio->bi_end_io = btrfs_end_dio_bio; | ||
| 6027 | atomic_inc(&dip->pending_bios); | ||
| 6028 | |||
| 6024 | while (bvec <= (orig_bio->bi_io_vec + orig_bio->bi_vcnt - 1)) { | 6029 | while (bvec <= (orig_bio->bi_io_vec + orig_bio->bi_vcnt - 1)) { |
| 6025 | if (unlikely(map_length < submit_len + bvec->bv_len || | 6030 | if (unlikely(map_length < submit_len + bvec->bv_len || |
| 6026 | bio_add_page(bio, bvec->bv_page, bvec->bv_len, | 6031 | bio_add_page(bio, bvec->bv_page, bvec->bv_len, |
| @@ -6071,6 +6076,7 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip, | |||
| 6071 | } | 6076 | } |
| 6072 | } | 6077 | } |
| 6073 | 6078 | ||
| 6079 | submit: | ||
| 6074 | ret = __btrfs_submit_dio_bio(bio, inode, rw, file_offset, skip_sum, | 6080 | ret = __btrfs_submit_dio_bio(bio, inode, rw, file_offset, skip_sum, |
| 6075 | csums); | 6081 | csums); |
| 6076 | if (!ret) | 6082 | if (!ret) |
