aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--block/bio.c12
-rw-r--r--block/blk-core.c30
-rw-r--r--drivers/md/dm.c29
-rw-r--r--drivers/md/raid10.c3
4 files changed, 45 insertions, 29 deletions
diff --git a/block/bio.c b/block/bio.c
index db85c5753a76..655c9016052a 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -372,10 +372,14 @@ static void punt_bios_to_rescuer(struct bio_set *bs)
372 bio_list_init(&punt); 372 bio_list_init(&punt);
373 bio_list_init(&nopunt); 373 bio_list_init(&nopunt);
374 374
375 while ((bio = bio_list_pop(current->bio_list))) 375 while ((bio = bio_list_pop(&current->bio_list[0])))
376 bio_list_add(bio->bi_pool == bs ? &punt : &nopunt, bio); 376 bio_list_add(bio->bi_pool == bs ? &punt : &nopunt, bio);
377 current->bio_list[0] = nopunt;
377 378
378 *current->bio_list = nopunt; 379 bio_list_init(&nopunt);
380 while ((bio = bio_list_pop(&current->bio_list[1])))
381 bio_list_add(bio->bi_pool == bs ? &punt : &nopunt, bio);
382 current->bio_list[1] = nopunt;
379 383
380 spin_lock(&bs->rescue_lock); 384 spin_lock(&bs->rescue_lock);
381 bio_list_merge(&bs->rescue_list, &punt); 385 bio_list_merge(&bs->rescue_list, &punt);
@@ -462,7 +466,9 @@ struct bio *bio_alloc_bioset(gfp_t gfp_mask, int nr_iovecs, struct bio_set *bs)
462 * we retry with the original gfp_flags. 466 * we retry with the original gfp_flags.
463 */ 467 */
464 468
465 if (current->bio_list && !bio_list_empty(current->bio_list)) 469 if (current->bio_list &&
470 (!bio_list_empty(&current->bio_list[0]) ||
471 !bio_list_empty(&current->bio_list[1])))
466 gfp_mask &= ~__GFP_DIRECT_RECLAIM; 472 gfp_mask &= ~__GFP_DIRECT_RECLAIM;
467 473
468 p = mempool_alloc(bs->bio_pool, gfp_mask); 474 p = mempool_alloc(bs->bio_pool, gfp_mask);
diff --git a/block/blk-core.c b/block/blk-core.c
index 27cd46ad2b9e..d1f2801ce836 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1994,7 +1994,14 @@ end_io:
1994 */ 1994 */
1995blk_qc_t generic_make_request(struct bio *bio) 1995blk_qc_t generic_make_request(struct bio *bio)
1996{ 1996{
1997 struct bio_list bio_list_on_stack; 1997 /*
1998 * bio_list_on_stack[0] contains bios submitted by the current
1999 * make_request_fn.
2000 * bio_list_on_stack[1] contains bios that were submitted before
2001 * the current make_request_fn, but that haven't been processed
2002 * yet.
2003 */
2004 struct bio_list bio_list_on_stack[2];
1998 blk_qc_t ret = BLK_QC_T_NONE; 2005 blk_qc_t ret = BLK_QC_T_NONE;
1999 2006
2000 if (!generic_make_request_checks(bio)) 2007 if (!generic_make_request_checks(bio))
@@ -2011,7 +2018,7 @@ blk_qc_t generic_make_request(struct bio *bio)
2011 * should be added at the tail 2018 * should be added at the tail
2012 */ 2019 */
2013 if (current->bio_list) { 2020 if (current->bio_list) {
2014 bio_list_add(current->bio_list, bio); 2021 bio_list_add(&current->bio_list[0], bio);
2015 goto out; 2022 goto out;
2016 } 2023 }
2017 2024
@@ -2030,18 +2037,17 @@ blk_qc_t generic_make_request(struct bio *bio)
2030 * bio_list, and call into ->make_request() again. 2037 * bio_list, and call into ->make_request() again.
2031 */ 2038 */
2032 BUG_ON(bio->bi_next); 2039 BUG_ON(bio->bi_next);
2033 bio_list_init(&bio_list_on_stack); 2040 bio_list_init(&bio_list_on_stack[0]);
2034 current->bio_list = &bio_list_on_stack; 2041 current->bio_list = bio_list_on_stack;
2035 do { 2042 do {
2036 struct request_queue *q = bdev_get_queue(bio->bi_bdev); 2043 struct request_queue *q = bdev_get_queue(bio->bi_bdev);
2037 2044
2038 if (likely(blk_queue_enter(q, false) == 0)) { 2045 if (likely(blk_queue_enter(q, false) == 0)) {
2039 struct bio_list hold;
2040 struct bio_list lower, same; 2046 struct bio_list lower, same;
2041 2047
2042 /* Create a fresh bio_list for all subordinate requests */ 2048 /* Create a fresh bio_list for all subordinate requests */
2043 hold = bio_list_on_stack; 2049 bio_list_on_stack[1] = bio_list_on_stack[0];
2044 bio_list_init(&bio_list_on_stack); 2050 bio_list_init(&bio_list_on_stack[0]);
2045 ret = q->make_request_fn(q, bio); 2051 ret = q->make_request_fn(q, bio);
2046 2052
2047 blk_queue_exit(q); 2053 blk_queue_exit(q);
@@ -2051,19 +2057,19 @@ blk_qc_t generic_make_request(struct bio *bio)
2051 */ 2057 */
2052 bio_list_init(&lower); 2058 bio_list_init(&lower);
2053 bio_list_init(&same); 2059 bio_list_init(&same);
2054 while ((bio = bio_list_pop(&bio_list_on_stack)) != NULL) 2060 while ((bio = bio_list_pop(&bio_list_on_stack[0])) != NULL)
2055 if (q == bdev_get_queue(bio->bi_bdev)) 2061 if (q == bdev_get_queue(bio->bi_bdev))
2056 bio_list_add(&same, bio); 2062 bio_list_add(&same, bio);
2057 else 2063 else
2058 bio_list_add(&lower, bio); 2064 bio_list_add(&lower, bio);
2059 /* now assemble so we handle the lowest level first */ 2065 /* now assemble so we handle the lowest level first */
2060 bio_list_merge(&bio_list_on_stack, &lower); 2066 bio_list_merge(&bio_list_on_stack[0], &lower);
2061 bio_list_merge(&bio_list_on_stack, &same); 2067 bio_list_merge(&bio_list_on_stack[0], &same);
2062 bio_list_merge(&bio_list_on_stack, &hold); 2068 bio_list_merge(&bio_list_on_stack[0], &bio_list_on_stack[1]);
2063 } else { 2069 } else {
2064 bio_io_error(bio); 2070 bio_io_error(bio);
2065 } 2071 }
2066 bio = bio_list_pop(current->bio_list); 2072 bio = bio_list_pop(&bio_list_on_stack[0]);
2067 } while (bio); 2073 } while (bio);
2068 current->bio_list = NULL; /* deactivate */ 2074 current->bio_list = NULL; /* deactivate */
2069 2075
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 628ba001bb3c..e66f4040d84b 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -986,26 +986,29 @@ static void flush_current_bio_list(struct blk_plug_cb *cb, bool from_schedule)
986 struct dm_offload *o = container_of(cb, struct dm_offload, cb); 986 struct dm_offload *o = container_of(cb, struct dm_offload, cb);
987 struct bio_list list; 987 struct bio_list list;
988 struct bio *bio; 988 struct bio *bio;
989 int i;
989 990
990 INIT_LIST_HEAD(&o->cb.list); 991 INIT_LIST_HEAD(&o->cb.list);
991 992
992 if (unlikely(!current->bio_list)) 993 if (unlikely(!current->bio_list))
993 return; 994 return;
994 995
995 list = *current->bio_list; 996 for (i = 0; i < 2; i++) {
996 bio_list_init(current->bio_list); 997 list = current->bio_list[i];
997 998 bio_list_init(&current->bio_list[i]);
998 while ((bio = bio_list_pop(&list))) { 999
999 struct bio_set *bs = bio->bi_pool; 1000 while ((bio = bio_list_pop(&list))) {
1000 if (unlikely(!bs) || bs == fs_bio_set) { 1001 struct bio_set *bs = bio->bi_pool;
1001 bio_list_add(current->bio_list, bio); 1002 if (unlikely(!bs) || bs == fs_bio_set) {
1002 continue; 1003 bio_list_add(&current->bio_list[i], bio);
1004 continue;
1005 }
1006
1007 spin_lock(&bs->rescue_lock);
1008 bio_list_add(&bs->rescue_list, bio);
1009 queue_work(bs->rescue_workqueue, &bs->rescue_work);
1010 spin_unlock(&bs->rescue_lock);
1003 } 1011 }
1004
1005 spin_lock(&bs->rescue_lock);
1006 bio_list_add(&bs->rescue_list, bio);
1007 queue_work(bs->rescue_workqueue, &bs->rescue_work);
1008 spin_unlock(&bs->rescue_lock);
1009 } 1012 }
1010} 1013}
1011 1014
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 55b5e0e77b17..4c4aab02e311 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -941,7 +941,8 @@ static void wait_barrier(struct r10conf *conf)
941 !conf->barrier || 941 !conf->barrier ||
942 (atomic_read(&conf->nr_pending) && 942 (atomic_read(&conf->nr_pending) &&
943 current->bio_list && 943 current->bio_list &&
944 !bio_list_empty(current->bio_list)), 944 (!bio_list_empty(&current->bio_list[0]) ||
945 !bio_list_empty(&current->bio_list[1]))),
945 conf->resync_lock); 946 conf->resync_lock);
946 conf->nr_waiting--; 947 conf->nr_waiting--;
947 if (!conf->nr_waiting) 948 if (!conf->nr_waiting)