From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, NeilBrown <neilb@suse.com>,
Jens Axboe <axboe@fb.com>,
Jack Wang <jinpu.wang@profitbricks.com>
Subject: [PATCH 4.9 69/72] blk: Ensure users for current->bio_list can see the full list.
Date: Thu, 6 Apr 2017 10:38:56 +0200 [thread overview]
Message-ID: <20170406083622.985819972@linuxfoundation.org> (raw)
In-Reply-To: <20170406083619.775985942@linuxfoundation.org>
4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: NeilBrown <neilb@suse.com>
commit f5fe1b51905df7cfe4fdfd85c5fb7bc5b71a094f upstream.
Commit 79bd99596b73 ("blk: improve order of bio handling in generic_make_request()")
changed current->bio_list so that it did not contain *all* of the
queued bios, but only those submitted by the currently running
make_request_fn.
There are two places which walk the list and requeue selected bios,
and others that check if the list is empty. These are no longer
correct.
So redefine current->bio_list to point to an array of two lists, which
contain all queued bios, and adjust various code to test or walk both
lists.
Signed-off-by: NeilBrown <neilb@suse.com>
Fixes: 79bd99596b73 ("blk: improve order of bio handling in generic_make_request()")
Signed-off-by: Jens Axboe <axboe@fb.com>
Cc: Jack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
block/bio.c | 12 +++++++++---
block/blk-core.c | 30 ++++++++++++++++++------------
drivers/md/dm.c | 29 ++++++++++++++++-------------
drivers/md/raid10.c | 3 ++-
4 files changed, 45 insertions(+), 29 deletions(-)
--- a/block/bio.c
+++ b/block/bio.c
@@ -372,10 +372,14 @@ static void punt_bios_to_rescuer(struct
bio_list_init(&punt);
bio_list_init(&nopunt);
- while ((bio = bio_list_pop(current->bio_list)))
+ while ((bio = bio_list_pop(¤t->bio_list[0])))
bio_list_add(bio->bi_pool == bs ? &punt : &nopunt, bio);
+ current->bio_list[0] = nopunt;
- *current->bio_list = nopunt;
+ bio_list_init(&nopunt);
+ while ((bio = bio_list_pop(¤t->bio_list[1])))
+ bio_list_add(bio->bi_pool == bs ? &punt : &nopunt, bio);
+ current->bio_list[1] = nopunt;
spin_lock(&bs->rescue_lock);
bio_list_merge(&bs->rescue_list, &punt);
@@ -462,7 +466,9 @@ struct bio *bio_alloc_bioset(gfp_t gfp_m
* we retry with the original gfp_flags.
*/
- if (current->bio_list && !bio_list_empty(current->bio_list))
+ if (current->bio_list &&
+ (!bio_list_empty(¤t->bio_list[0]) ||
+ !bio_list_empty(¤t->bio_list[1])))
gfp_mask &= ~__GFP_DIRECT_RECLAIM;
p = mempool_alloc(bs->bio_pool, gfp_mask);
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1994,7 +1994,14 @@ end_io:
*/
blk_qc_t generic_make_request(struct bio *bio)
{
- struct bio_list bio_list_on_stack;
+ /*
+ * bio_list_on_stack[0] contains bios submitted by the current
+ * make_request_fn.
+ * bio_list_on_stack[1] contains bios that were submitted before
+ * the current make_request_fn, but that haven't been processed
+ * yet.
+ */
+ struct bio_list bio_list_on_stack[2];
blk_qc_t ret = BLK_QC_T_NONE;
if (!generic_make_request_checks(bio))
@@ -2011,7 +2018,7 @@ blk_qc_t generic_make_request(struct bio
* should be added at the tail
*/
if (current->bio_list) {
- bio_list_add(current->bio_list, bio);
+ bio_list_add(¤t->bio_list[0], bio);
goto out;
}
@@ -2030,18 +2037,17 @@ blk_qc_t generic_make_request(struct bio
* bio_list, and call into ->make_request() again.
*/
BUG_ON(bio->bi_next);
- bio_list_init(&bio_list_on_stack);
- current->bio_list = &bio_list_on_stack;
+ bio_list_init(&bio_list_on_stack[0]);
+ current->bio_list = bio_list_on_stack;
do {
struct request_queue *q = bdev_get_queue(bio->bi_bdev);
if (likely(blk_queue_enter(q, false) == 0)) {
- struct bio_list hold;
struct bio_list lower, same;
/* Create a fresh bio_list for all subordinate requests */
- hold = bio_list_on_stack;
- bio_list_init(&bio_list_on_stack);
+ bio_list_on_stack[1] = bio_list_on_stack[0];
+ bio_list_init(&bio_list_on_stack[0]);
ret = q->make_request_fn(q, bio);
blk_queue_exit(q);
@@ -2051,19 +2057,19 @@ blk_qc_t generic_make_request(struct bio
*/
bio_list_init(&lower);
bio_list_init(&same);
- while ((bio = bio_list_pop(&bio_list_on_stack)) != NULL)
+ while ((bio = bio_list_pop(&bio_list_on_stack[0])) != NULL)
if (q == bdev_get_queue(bio->bi_bdev))
bio_list_add(&same, bio);
else
bio_list_add(&lower, bio);
/* now assemble so we handle the lowest level first */
- bio_list_merge(&bio_list_on_stack, &lower);
- bio_list_merge(&bio_list_on_stack, &same);
- bio_list_merge(&bio_list_on_stack, &hold);
+ bio_list_merge(&bio_list_on_stack[0], &lower);
+ bio_list_merge(&bio_list_on_stack[0], &same);
+ bio_list_merge(&bio_list_on_stack[0], &bio_list_on_stack[1]);
} else {
bio_io_error(bio);
}
- bio = bio_list_pop(current->bio_list);
+ bio = bio_list_pop(&bio_list_on_stack[0]);
} while (bio);
current->bio_list = NULL; /* deactivate */
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -986,26 +986,29 @@ static void flush_current_bio_list(struc
struct dm_offload *o = container_of(cb, struct dm_offload, cb);
struct bio_list list;
struct bio *bio;
+ int i;
INIT_LIST_HEAD(&o->cb.list);
if (unlikely(!current->bio_list))
return;
- list = *current->bio_list;
- bio_list_init(current->bio_list);
-
- while ((bio = bio_list_pop(&list))) {
- struct bio_set *bs = bio->bi_pool;
- if (unlikely(!bs) || bs == fs_bio_set) {
- bio_list_add(current->bio_list, bio);
- continue;
+ for (i = 0; i < 2; i++) {
+ list = current->bio_list[i];
+ bio_list_init(¤t->bio_list[i]);
+
+ while ((bio = bio_list_pop(&list))) {
+ struct bio_set *bs = bio->bi_pool;
+ if (unlikely(!bs) || bs == fs_bio_set) {
+ bio_list_add(¤t->bio_list[i], bio);
+ continue;
+ }
+
+ spin_lock(&bs->rescue_lock);
+ bio_list_add(&bs->rescue_list, bio);
+ queue_work(bs->rescue_workqueue, &bs->rescue_work);
+ spin_unlock(&bs->rescue_lock);
}
-
- spin_lock(&bs->rescue_lock);
- bio_list_add(&bs->rescue_list, bio);
- queue_work(bs->rescue_workqueue, &bs->rescue_work);
- spin_unlock(&bs->rescue_lock);
}
}
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -941,7 +941,8 @@ static void wait_barrier(struct r10conf
!conf->barrier ||
(atomic_read(&conf->nr_pending) &&
current->bio_list &&
- !bio_list_empty(current->bio_list)),
+ (!bio_list_empty(¤t->bio_list[0]) ||
+ !bio_list_empty(¤t->bio_list[1]))),
conf->resync_lock);
conf->nr_waiting--;
if (!conf->nr_waiting)
next prev parent reply other threads:[~2017-04-06 9:17 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-06 8:37 [PATCH 4.9 00/72] 4.9.21-stable review Greg Kroah-Hartman
2017-04-06 8:37 ` [PATCH 4.9 01/72] libceph: force GFP_NOIO for socket allocations Greg Kroah-Hartman
2017-04-06 8:37 ` [PATCH 4.9 02/72] xen/setup: Dont relocate p2m over existing one Greg Kroah-Hartman
2017-04-06 8:37 ` [PATCH 4.9 03/72] xfs: only update mount/resv fields on success in __xfs_ag_resv_init Greg Kroah-Hartman
2017-04-06 8:37 ` [PATCH 4.9 04/72] xfs: use per-AG reservations for the finobt Greg Kroah-Hartman
2017-04-06 8:37 ` [PATCH 4.9 05/72] xfs: pull up iolock from xfs_free_eofblocks() Greg Kroah-Hartman
2017-04-06 8:37 ` [PATCH 4.9 06/72] xfs: sync eofblocks scans under iolock are livelock prone Greg Kroah-Hartman
2017-04-06 8:37 ` [PATCH 4.9 07/72] xfs: fix eofblocks race with file extending async dio writes Greg Kroah-Hartman
2017-04-06 8:37 ` [PATCH 4.9 08/72] xfs: fix toctou race when locking an inode to access the data map Greg Kroah-Hartman
2017-04-06 8:37 ` [PATCH 4.9 09/72] xfs: fail _dir_open when readahead fails Greg Kroah-Hartman
2017-04-06 8:37 ` [PATCH 4.9 10/72] xfs: filter out obviously bad btree pointers Greg Kroah-Hartman
2017-04-06 8:37 ` [PATCH 4.9 11/72] xfs: check for obviously bad level values in the bmbt root Greg Kroah-Hartman
2017-04-06 8:37 ` [PATCH 4.9 12/72] xfs: verify free block header fields Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 13/72] xfs: allow unwritten extents in the CoW fork Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 14/72] xfs: mark speculative prealloc CoW fork extents unwritten Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 15/72] xfs: reset b_first_retry_time when clear the retry status of xfs_buf_t Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 16/72] xfs: update ctime and mtime on clone destinatation inodes Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 17/72] xfs: reject all unaligned direct writes to reflinked files Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 18/72] xfs: dont fail xfs_extent_busy allocation Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 19/72] xfs: handle indlen shortage on delalloc extent merge Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 20/72] xfs: split indlen reservations fairly when under reserved Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 21/72] xfs: fix uninitialized variable in _reflink_convert_cow Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 22/72] xfs: dont reserve blocks for right shift transactions Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 23/72] xfs: Use xfs_icluster_size_fsb() to calculate inode chunk alignment Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 24/72] xfs: tune down agno asserts in the bmap code Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 25/72] xfs: only reclaim unwritten COW extents periodically Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 26/72] xfs: fix and streamline error handling in xfs_end_io Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 27/72] xfs: Use xfs_icluster_size_fsb() to calculate inode alignment mask Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 28/72] xfs: use iomap new flag for newly allocated delalloc blocks Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 29/72] xfs: try any AG when allocating the first btree block when reflinking Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 30/72] scsi: sg: check length passed to SG_NEXT_CMD_LEN Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 31/72] scsi: libsas: fix ata xfer length Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 32/72] scsi: scsi_dh_alua: Check scsi_device_get() return value Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 33/72] scsi: scsi_dh_alua: Ensure that alua_activate() calls the completion function Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 35/72] ALSA: seq: Fix race during FIFO resize Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 36/72] ALSA: hda - fix a problem for lineout on a Dell AIO machine Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 37/72] ASoC: atmel-classd: fix audio clock rate Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 38/72] ASoC: Intel: Skylake: fix invalid memory access due to wrong reference of pointer Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 39/72] HID: wacom: Dont add ghost interface as shared data Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 40/72] mmc: sdhci: Disable runtime pm when the sdio_irq is enabled Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 41/72] mmc: sdhci-of-at91: fix MMC_DDR_52 timing selection Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 42/72] NFSv4.1 fix infinite loop on IO BAD_STATEID error Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 43/72] nfsd: map the ENOKEY to nfserr_perm for avoiding warning Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 44/72] parisc: Clean up fixup routines for get_user()/put_user() Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 45/72] parisc: Avoid stalled CPU warnings after system shutdown Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 46/72] parisc: Fix access fault handling in pa_memcpy() Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 47/72] ACPI: Fix incompatibility with mcount-based function graph tracing Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 48/72] ACPI: Do not create a platform_device for IOAPIC/IOxAPIC Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 49/72] tty/serial: atmel: fix race condition (TX+DMA) Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 50/72] tty/serial: atmel: fix TX path in atmel_console_write() Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 51/72] USB: fix linked-list corruption in rh_call_control() Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 54/72] KVM: kvm_io_bus_unregister_dev() should never fail Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 56/72] drm/vc4: Allocate the right amount of space for boot-time CRTC state Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 57/72] drm/etnaviv: (re-)protect fence allocation with GPU mutex Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 58/72] x86/mm/KASLR: Exclude EFI region from KASLR VA space randomization Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 59/72] x86/mce: Fix copy/paste error in exception table entries Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 61/72] mm: rmap: fix huge file mmap accounting in the memcg stats Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 62/72] mm, hugetlb: use pte_present() instead of pmd_present() in follow_huge_pmd() Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 64/72] qla2xxx: Allow vref count to timeout on vport delete Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 66/72] MIPS: Lantiq: Fix cascaded IRQ setup Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 67/72] mm: workingset: fix premature shadow node shrinking with cgroups Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 68/72] blk: improve order of bio handling in generic_make_request() Greg Kroah-Hartman
2017-04-06 8:38 ` Greg Kroah-Hartman [this message]
2017-04-06 8:38 ` [PATCH 4.9 70/72] padata: avoid race in reordering Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 71/72] nvme/core: Fix race kicking freed request_queue Greg Kroah-Hartman
2017-04-06 8:38 ` [PATCH 4.9 72/72] nvme/pci: Disable on removal when disconnected Greg Kroah-Hartman
2017-04-06 17:46 ` [PATCH 4.9 00/72] 4.9.21-stable review Shuah Khan
2017-04-06 21:52 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170406083622.985819972@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=axboe@fb.com \
--cc=jinpu.wang@profitbricks.com \
--cc=linux-kernel@vger.kernel.org \
--cc=neilb@suse.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).