summaryrefslogtreecommitdiffstats
path: root/fs/block_dev.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-07-03 13:34:51 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-07-03 13:34:51 -0400
commitc6b1e36c8fa04a6680c44fe0321d0370400e90b6 (patch)
tree5110f0639bfa803baa8d213cb21efe37beeaf742 /fs/block_dev.c
parent81e3e044897b0875a52953b3fb6241a33428e4f9 (diff)
parenta84ebb837b419787c2ece74efa566c998929cead (diff)
Merge branch 'for-4.13/block' of git://git.kernel.dk/linux-block
Pull core block/IO updates from Jens Axboe: "This is the main pull request for the block layer for 4.13. Not a huge round in terms of features, but there's a lot of churn related to some core cleanups. Note this depends on the UUID tree pull request, that Christoph already sent out. This pull request contains: - A series from Christoph, unifying the error/stats codes in the block layer. We now use blk_status_t everywhere, instead of using different schemes for different places. - Also from Christoph, some cleanups around request allocation and IO scheduler interactions in blk-mq. - And yet another series from Christoph, cleaning up how we handle and do bounce buffering in the block layer. - A blk-mq debugfs series from Bart, further improving on the support we have for exporting internal information to aid debugging IO hangs or stalls. - Also from Bart, a series that cleans up the request initialization differences across types of devices. - A series from Goldwyn Rodrigues, allowing the block layer to return failure if we will block and the user asked for non-blocking. - Patch from Hannes for supporting setting loop devices block size to that of the underlying device. - Two series of patches from Javier, fixing various issues with lightnvm, particular around pblk. - A series from me, adding support for write hints. This comes with NVMe support as well, so applications can help guide data placement on flash to improve performance, latencies, and write amplification. - A series from Ming, improving and hardening blk-mq support for stopping/starting and quiescing hardware queues. - Two pull requests for NVMe updates. Nothing major on the feature side, but lots of cleanups and bug fixes. From the usual crew. - A series from Neil Brown, greatly improving the bio rescue set support. Most notably, this kills the bio rescue work queues, if we don't really need them. - Lots of other little bug fixes that are all over the place" * 'for-4.13/block' of git://git.kernel.dk/linux-block: (217 commits) lightnvm: pblk: set line bitmap check under debug lightnvm: pblk: verify that cache read is still valid lightnvm: pblk: add initialization check lightnvm: pblk: remove target using async. I/Os lightnvm: pblk: use vmalloc for GC data buffer lightnvm: pblk: use right metadata buffer for recovery lightnvm: pblk: schedule if data is not ready lightnvm: pblk: remove unused return variable lightnvm: pblk: fix double-free on pblk init lightnvm: pblk: fix bad le64 assignations nvme: Makefile: remove dead build rule blk-mq: map all HWQ also in hyperthreaded system nvmet-rdma: register ib_client to not deadlock in device removal nvme_fc: fix error recovery on link down. nvmet_fc: fix crashes on bad opcodes nvme_fc: Fix crash when nvme controller connection fails. nvme_fc: replace ioabort msleep loop with completion nvme_fc: fix double calls to nvme_cleanup_cmd() nvme-fabrics: verify that a controller returns the correct NQN nvme: simplify nvme_dev_attrs_are_visible ...
Diffstat (limited to 'fs/block_dev.c')
-rw-r--r--fs/block_dev.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 0a7404ef9335..a7df151f8aba 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -225,6 +225,7 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
225 bio_init(&bio, vecs, nr_pages); 225 bio_init(&bio, vecs, nr_pages);
226 bio.bi_bdev = bdev; 226 bio.bi_bdev = bdev;
227 bio.bi_iter.bi_sector = pos >> 9; 227 bio.bi_iter.bi_sector = pos >> 9;
228 bio.bi_write_hint = iocb->ki_hint;
228 bio.bi_private = current; 229 bio.bi_private = current;
229 bio.bi_end_io = blkdev_bio_end_io_simple; 230 bio.bi_end_io = blkdev_bio_end_io_simple;
230 231
@@ -262,8 +263,8 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
262 if (vecs != inline_vecs) 263 if (vecs != inline_vecs)
263 kfree(vecs); 264 kfree(vecs);
264 265
265 if (unlikely(bio.bi_error)) 266 if (unlikely(bio.bi_status))
266 ret = bio.bi_error; 267 ret = blk_status_to_errno(bio.bi_status);
267 268
268 bio_uninit(&bio); 269 bio_uninit(&bio);
269 270
@@ -291,16 +292,18 @@ static void blkdev_bio_end_io(struct bio *bio)
291 bool should_dirty = dio->should_dirty; 292 bool should_dirty = dio->should_dirty;
292 293
293 if (dio->multi_bio && !atomic_dec_and_test(&dio->ref)) { 294 if (dio->multi_bio && !atomic_dec_and_test(&dio->ref)) {
294 if (bio->bi_error && !dio->bio.bi_error) 295 if (bio->bi_status && !dio->bio.bi_status)
295 dio->bio.bi_error = bio->bi_error; 296 dio->bio.bi_status = bio->bi_status;
296 } else { 297 } else {
297 if (!dio->is_sync) { 298 if (!dio->is_sync) {
298 struct kiocb *iocb = dio->iocb; 299 struct kiocb *iocb = dio->iocb;
299 ssize_t ret = dio->bio.bi_error; 300 ssize_t ret;
300 301
301 if (likely(!ret)) { 302 if (likely(!dio->bio.bi_status)) {
302 ret = dio->size; 303 ret = dio->size;
303 iocb->ki_pos += ret; 304 iocb->ki_pos += ret;
305 } else {
306 ret = blk_status_to_errno(dio->bio.bi_status);
304 } 307 }
305 308
306 dio->iocb->ki_complete(iocb, ret, 0); 309 dio->iocb->ki_complete(iocb, ret, 0);
@@ -337,7 +340,7 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
337 bool is_read = (iov_iter_rw(iter) == READ), is_sync; 340 bool is_read = (iov_iter_rw(iter) == READ), is_sync;
338 loff_t pos = iocb->ki_pos; 341 loff_t pos = iocb->ki_pos;
339 blk_qc_t qc = BLK_QC_T_NONE; 342 blk_qc_t qc = BLK_QC_T_NONE;
340 int ret; 343 int ret = 0;
341 344
342 if ((pos | iov_iter_alignment(iter)) & 345 if ((pos | iov_iter_alignment(iter)) &
343 (bdev_logical_block_size(bdev) - 1)) 346 (bdev_logical_block_size(bdev) - 1))
@@ -361,12 +364,13 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
361 for (;;) { 364 for (;;) {
362 bio->bi_bdev = bdev; 365 bio->bi_bdev = bdev;
363 bio->bi_iter.bi_sector = pos >> 9; 366 bio->bi_iter.bi_sector = pos >> 9;
367 bio->bi_write_hint = iocb->ki_hint;
364 bio->bi_private = dio; 368 bio->bi_private = dio;
365 bio->bi_end_io = blkdev_bio_end_io; 369 bio->bi_end_io = blkdev_bio_end_io;
366 370
367 ret = bio_iov_iter_get_pages(bio, iter); 371 ret = bio_iov_iter_get_pages(bio, iter);
368 if (unlikely(ret)) { 372 if (unlikely(ret)) {
369 bio->bi_error = ret; 373 bio->bi_status = BLK_STS_IOERR;
370 bio_endio(bio); 374 bio_endio(bio);
371 break; 375 break;
372 } 376 }
@@ -415,7 +419,8 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
415 } 419 }
416 __set_current_state(TASK_RUNNING); 420 __set_current_state(TASK_RUNNING);
417 421
418 ret = dio->bio.bi_error; 422 if (!ret)
423 ret = blk_status_to_errno(dio->bio.bi_status);
419 if (likely(!ret)) 424 if (likely(!ret))
420 ret = dio->size; 425 ret = dio->size;
421 426
@@ -439,7 +444,7 @@ blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
439 444
440static __init int blkdev_init(void) 445static __init int blkdev_init(void)
441{ 446{
442 blkdev_dio_pool = bioset_create(4, offsetof(struct blkdev_dio, bio)); 447 blkdev_dio_pool = bioset_create(4, offsetof(struct blkdev_dio, bio), BIOSET_NEED_BVECS);
443 if (!blkdev_dio_pool) 448 if (!blkdev_dio_pool)
444 return -ENOMEM; 449 return -ENOMEM;
445 return 0; 450 return 0;