summaryrefslogtreecommitdiffstats
path: root/block/bio.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 /block/bio.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 'block/bio.c')
-rw-r--r--block/bio.c85
1 files changed, 40 insertions, 45 deletions
diff --git a/block/bio.c b/block/bio.c
index 26b0810fb8ea..1cfcd0df3f30 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -315,8 +315,8 @@ static struct bio *__bio_chain_endio(struct bio *bio)
315{ 315{
316 struct bio *parent = bio->bi_private; 316 struct bio *parent = bio->bi_private;
317 317
318 if (!parent->bi_error) 318 if (!parent->bi_status)
319 parent->bi_error = bio->bi_error; 319 parent->bi_status = bio->bi_status;
320 bio_put(bio); 320 bio_put(bio);
321 return parent; 321 return parent;
322} 322}
@@ -369,6 +369,8 @@ static void punt_bios_to_rescuer(struct bio_set *bs)
369 struct bio_list punt, nopunt; 369 struct bio_list punt, nopunt;
370 struct bio *bio; 370 struct bio *bio;
371 371
372 if (WARN_ON_ONCE(!bs->rescue_workqueue))
373 return;
372 /* 374 /*
373 * In order to guarantee forward progress we must punt only bios that 375 * In order to guarantee forward progress we must punt only bios that
374 * were allocated from this bio_set; otherwise, if there was a bio on 376 * were allocated from this bio_set; otherwise, if there was a bio on
@@ -480,7 +482,8 @@ struct bio *bio_alloc_bioset(gfp_t gfp_mask, unsigned int nr_iovecs,
480 482
481 if (current->bio_list && 483 if (current->bio_list &&
482 (!bio_list_empty(&current->bio_list[0]) || 484 (!bio_list_empty(&current->bio_list[0]) ||
483 !bio_list_empty(&current->bio_list[1]))) 485 !bio_list_empty(&current->bio_list[1])) &&
486 bs->rescue_workqueue)
484 gfp_mask &= ~__GFP_DIRECT_RECLAIM; 487 gfp_mask &= ~__GFP_DIRECT_RECLAIM;
485 488
486 p = mempool_alloc(bs->bio_pool, gfp_mask); 489 p = mempool_alloc(bs->bio_pool, gfp_mask);
@@ -550,7 +553,7 @@ EXPORT_SYMBOL(zero_fill_bio);
550 * 553 *
551 * Description: 554 * Description:
552 * Put a reference to a &struct bio, either one you have gotten with 555 * Put a reference to a &struct bio, either one you have gotten with
553 * bio_alloc, bio_get or bio_clone. The last put of a bio will free it. 556 * bio_alloc, bio_get or bio_clone_*. The last put of a bio will free it.
554 **/ 557 **/
555void bio_put(struct bio *bio) 558void bio_put(struct bio *bio)
556{ 559{
@@ -599,6 +602,7 @@ void __bio_clone_fast(struct bio *bio, struct bio *bio_src)
599 bio->bi_bdev = bio_src->bi_bdev; 602 bio->bi_bdev = bio_src->bi_bdev;
600 bio_set_flag(bio, BIO_CLONED); 603 bio_set_flag(bio, BIO_CLONED);
601 bio->bi_opf = bio_src->bi_opf; 604 bio->bi_opf = bio_src->bi_opf;
605 bio->bi_write_hint = bio_src->bi_write_hint;
602 bio->bi_iter = bio_src->bi_iter; 606 bio->bi_iter = bio_src->bi_iter;
603 bio->bi_io_vec = bio_src->bi_io_vec; 607 bio->bi_io_vec = bio_src->bi_io_vec;
604 608
@@ -682,6 +686,7 @@ struct bio *bio_clone_bioset(struct bio *bio_src, gfp_t gfp_mask,
682 return NULL; 686 return NULL;
683 bio->bi_bdev = bio_src->bi_bdev; 687 bio->bi_bdev = bio_src->bi_bdev;
684 bio->bi_opf = bio_src->bi_opf; 688 bio->bi_opf = bio_src->bi_opf;
689 bio->bi_write_hint = bio_src->bi_write_hint;
685 bio->bi_iter.bi_sector = bio_src->bi_iter.bi_sector; 690 bio->bi_iter.bi_sector = bio_src->bi_iter.bi_sector;
686 bio->bi_iter.bi_size = bio_src->bi_iter.bi_size; 691 bio->bi_iter.bi_size = bio_src->bi_iter.bi_size;
687 692
@@ -924,7 +929,7 @@ static void submit_bio_wait_endio(struct bio *bio)
924{ 929{
925 struct submit_bio_ret *ret = bio->bi_private; 930 struct submit_bio_ret *ret = bio->bi_private;
926 931
927 ret->error = bio->bi_error; 932 ret->error = blk_status_to_errno(bio->bi_status);
928 complete(&ret->event); 933 complete(&ret->event);
929} 934}
930 935
@@ -1823,8 +1828,8 @@ again:
1823 } 1828 }
1824 1829
1825 if (bio->bi_bdev && bio_flagged(bio, BIO_TRACE_COMPLETION)) { 1830 if (bio->bi_bdev && bio_flagged(bio, BIO_TRACE_COMPLETION)) {
1826 trace_block_bio_complete(bdev_get_queue(bio->bi_bdev), 1831 trace_block_bio_complete(bdev_get_queue(bio->bi_bdev), bio,
1827 bio, bio->bi_error); 1832 blk_status_to_errno(bio->bi_status));
1828 bio_clear_flag(bio, BIO_TRACE_COMPLETION); 1833 bio_clear_flag(bio, BIO_TRACE_COMPLETION);
1829 } 1834 }
1830 1835
@@ -1927,9 +1932,29 @@ void bioset_free(struct bio_set *bs)
1927} 1932}
1928EXPORT_SYMBOL(bioset_free); 1933EXPORT_SYMBOL(bioset_free);
1929 1934
1930static struct bio_set *__bioset_create(unsigned int pool_size, 1935/**
1931 unsigned int front_pad, 1936 * bioset_create - Create a bio_set
1932 bool create_bvec_pool) 1937 * @pool_size: Number of bio and bio_vecs to cache in the mempool
1938 * @front_pad: Number of bytes to allocate in front of the returned bio
1939 * @flags: Flags to modify behavior, currently %BIOSET_NEED_BVECS
1940 * and %BIOSET_NEED_RESCUER
1941 *
1942 * Description:
1943 * Set up a bio_set to be used with @bio_alloc_bioset. Allows the caller
1944 * to ask for a number of bytes to be allocated in front of the bio.
1945 * Front pad allocation is useful for embedding the bio inside
1946 * another structure, to avoid allocating extra data to go with the bio.
1947 * Note that the bio must be embedded at the END of that structure always,
1948 * or things will break badly.
1949 * If %BIOSET_NEED_BVECS is set in @flags, a separate pool will be allocated
1950 * for allocating iovecs. This pool is not needed e.g. for bio_clone_fast().
1951 * If %BIOSET_NEED_RESCUER is set, a workqueue is created which can be used to
1952 * dispatch queued requests when the mempool runs out of space.
1953 *
1954 */
1955struct bio_set *bioset_create(unsigned int pool_size,
1956 unsigned int front_pad,
1957 int flags)
1933{ 1958{
1934 unsigned int back_pad = BIO_INLINE_VECS * sizeof(struct bio_vec); 1959 unsigned int back_pad = BIO_INLINE_VECS * sizeof(struct bio_vec);
1935 struct bio_set *bs; 1960 struct bio_set *bs;
@@ -1954,12 +1979,15 @@ static struct bio_set *__bioset_create(unsigned int pool_size,
1954 if (!bs->bio_pool) 1979 if (!bs->bio_pool)
1955 goto bad; 1980 goto bad;
1956 1981
1957 if (create_bvec_pool) { 1982 if (flags & BIOSET_NEED_BVECS) {
1958 bs->bvec_pool = biovec_create_pool(pool_size); 1983 bs->bvec_pool = biovec_create_pool(pool_size);
1959 if (!bs->bvec_pool) 1984 if (!bs->bvec_pool)
1960 goto bad; 1985 goto bad;
1961 } 1986 }
1962 1987
1988 if (!(flags & BIOSET_NEED_RESCUER))
1989 return bs;
1990
1963 bs->rescue_workqueue = alloc_workqueue("bioset", WQ_MEM_RECLAIM, 0); 1991 bs->rescue_workqueue = alloc_workqueue("bioset", WQ_MEM_RECLAIM, 0);
1964 if (!bs->rescue_workqueue) 1992 if (!bs->rescue_workqueue)
1965 goto bad; 1993 goto bad;
@@ -1969,41 +1997,8 @@ bad:
1969 bioset_free(bs); 1997 bioset_free(bs);
1970 return NULL; 1998 return NULL;
1971} 1999}
1972
1973/**
1974 * bioset_create - Create a bio_set
1975 * @pool_size: Number of bio and bio_vecs to cache in the mempool
1976 * @front_pad: Number of bytes to allocate in front of the returned bio
1977 *
1978 * Description:
1979 * Set up a bio_set to be used with @bio_alloc_bioset. Allows the caller
1980 * to ask for a number of bytes to be allocated in front of the bio.
1981 * Front pad allocation is useful for embedding the bio inside
1982 * another structure, to avoid allocating extra data to go with the bio.
1983 * Note that the bio must be embedded at the END of that structure always,
1984 * or things will break badly.
1985 */
1986struct bio_set *bioset_create(unsigned int pool_size, unsigned int front_pad)
1987{
1988 return __bioset_create(pool_size, front_pad, true);
1989}
1990EXPORT_SYMBOL(bioset_create); 2000EXPORT_SYMBOL(bioset_create);
1991 2001
1992/**
1993 * bioset_create_nobvec - Create a bio_set without bio_vec mempool
1994 * @pool_size: Number of bio to cache in the mempool
1995 * @front_pad: Number of bytes to allocate in front of the returned bio
1996 *
1997 * Description:
1998 * Same functionality as bioset_create() except that mempool is not
1999 * created for bio_vecs. Saving some memory for bio_clone_fast() users.
2000 */
2001struct bio_set *bioset_create_nobvec(unsigned int pool_size, unsigned int front_pad)
2002{
2003 return __bioset_create(pool_size, front_pad, false);
2004}
2005EXPORT_SYMBOL(bioset_create_nobvec);
2006
2007#ifdef CONFIG_BLK_CGROUP 2002#ifdef CONFIG_BLK_CGROUP
2008 2003
2009/** 2004/**
@@ -2118,7 +2113,7 @@ static int __init init_bio(void)
2118 bio_integrity_init(); 2113 bio_integrity_init();
2119 biovec_init_slabs(); 2114 biovec_init_slabs();
2120 2115
2121 fs_bio_set = bioset_create(BIO_POOL_SIZE, 0); 2116 fs_bio_set = bioset_create(BIO_POOL_SIZE, 0, BIOSET_NEED_BVECS);
2122 if (!fs_bio_set) 2117 if (!fs_bio_set)
2123 panic("bio: can't allocate bios\n"); 2118 panic("bio: can't allocate bios\n");
2124 2119