diff options
Diffstat (limited to 'fs/direct-io.c')
-rw-r--r-- | fs/direct-io.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/fs/direct-io.c b/fs/direct-io.c index 85882f6ba5f7..ac5f164170e3 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c | |||
@@ -325,12 +325,16 @@ void dio_end_io(struct bio *bio, int error) | |||
325 | } | 325 | } |
326 | EXPORT_SYMBOL_GPL(dio_end_io); | 326 | EXPORT_SYMBOL_GPL(dio_end_io); |
327 | 327 | ||
328 | static int | 328 | static void |
329 | dio_bio_alloc(struct dio *dio, struct block_device *bdev, | 329 | dio_bio_alloc(struct dio *dio, struct block_device *bdev, |
330 | sector_t first_sector, int nr_vecs) | 330 | sector_t first_sector, int nr_vecs) |
331 | { | 331 | { |
332 | struct bio *bio; | 332 | struct bio *bio; |
333 | 333 | ||
334 | /* | ||
335 | * bio_alloc() is guaranteed to return a bio when called with | ||
336 | * __GFP_WAIT and we request a valid number of vectors. | ||
337 | */ | ||
334 | bio = bio_alloc(GFP_KERNEL, nr_vecs); | 338 | bio = bio_alloc(GFP_KERNEL, nr_vecs); |
335 | 339 | ||
336 | bio->bi_bdev = bdev; | 340 | bio->bi_bdev = bdev; |
@@ -342,7 +346,6 @@ dio_bio_alloc(struct dio *dio, struct block_device *bdev, | |||
342 | 346 | ||
343 | dio->bio = bio; | 347 | dio->bio = bio; |
344 | dio->logical_offset_in_bio = dio->cur_page_fs_offset; | 348 | dio->logical_offset_in_bio = dio->cur_page_fs_offset; |
345 | return 0; | ||
346 | } | 349 | } |
347 | 350 | ||
348 | /* | 351 | /* |
@@ -583,8 +586,9 @@ static int dio_new_bio(struct dio *dio, sector_t start_sector) | |||
583 | goto out; | 586 | goto out; |
584 | sector = start_sector << (dio->blkbits - 9); | 587 | sector = start_sector << (dio->blkbits - 9); |
585 | nr_pages = min(dio->pages_in_io, bio_get_nr_vecs(dio->map_bh.b_bdev)); | 588 | nr_pages = min(dio->pages_in_io, bio_get_nr_vecs(dio->map_bh.b_bdev)); |
589 | nr_pages = min(nr_pages, BIO_MAX_PAGES); | ||
586 | BUG_ON(nr_pages <= 0); | 590 | BUG_ON(nr_pages <= 0); |
587 | ret = dio_bio_alloc(dio, dio->map_bh.b_bdev, sector, nr_pages); | 591 | dio_bio_alloc(dio, dio->map_bh.b_bdev, sector, nr_pages); |
588 | dio->boundary = 0; | 592 | dio->boundary = 0; |
589 | out: | 593 | out: |
590 | return ret; | 594 | return ret; |
@@ -641,11 +645,11 @@ static int dio_send_cur_page(struct dio *dio) | |||
641 | /* | 645 | /* |
642 | * See whether this new request is contiguous with the old. | 646 | * See whether this new request is contiguous with the old. |
643 | * | 647 | * |
644 | * Btrfs cannot handl having logically non-contiguous requests | 648 | * Btrfs cannot handle having logically non-contiguous requests |
645 | * submitted. For exmple if you have | 649 | * submitted. For example if you have |
646 | * | 650 | * |
647 | * Logical: [0-4095][HOLE][8192-12287] | 651 | * Logical: [0-4095][HOLE][8192-12287] |
648 | * Phyiscal: [0-4095] [4096-8181] | 652 | * Physical: [0-4095] [4096-8191] |
649 | * | 653 | * |
650 | * We cannot submit those pages together as one BIO. So if our | 654 | * We cannot submit those pages together as one BIO. So if our |
651 | * current logical offset in the file does not equal what would | 655 | * current logical offset in the file does not equal what would |
@@ -1106,11 +1110,8 @@ direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode, | |||
1106 | ((rw & READ) || (dio->result == dio->size))) | 1110 | ((rw & READ) || (dio->result == dio->size))) |
1107 | ret = -EIOCBQUEUED; | 1111 | ret = -EIOCBQUEUED; |
1108 | 1112 | ||
1109 | if (ret != -EIOCBQUEUED) { | 1113 | if (ret != -EIOCBQUEUED) |
1110 | /* All IO is now issued, send it on its way */ | ||
1111 | blk_run_address_space(inode->i_mapping); | ||
1112 | dio_await_completion(dio); | 1114 | dio_await_completion(dio); |
1113 | } | ||
1114 | 1115 | ||
1115 | /* | 1116 | /* |
1116 | * Sync will always be dropping the final ref and completing the | 1117 | * Sync will always be dropping the final ref and completing the |
@@ -1172,7 +1173,7 @@ __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, | |||
1172 | struct dio *dio; | 1173 | struct dio *dio; |
1173 | 1174 | ||
1174 | if (rw & WRITE) | 1175 | if (rw & WRITE) |
1175 | rw = WRITE_ODIRECT_PLUG; | 1176 | rw = WRITE_ODIRECT; |
1176 | 1177 | ||
1177 | if (bdev) | 1178 | if (bdev) |
1178 | bdev_blkbits = blksize_bits(bdev_logical_block_size(bdev)); | 1179 | bdev_blkbits = blksize_bits(bdev_logical_block_size(bdev)); |