Skip to content

Commit 24bc3ea

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.dk/linux-block
Pull block layer fixes from Jens Axboe: "Three small fixes for 4.4 final. Specifically: - The segment issue fix from Junichi, where the old IO path does a bio limit split before potentially bouncing the pages. We need to do that in the right order, to ensure that limitations are met. - A NVMe surprise removal IO hang fix from Keith. - A use-after-free in null_blk, introduced by a previous patch in this series. From Mike Krinkin" * 'for-linus' of git://git.kernel.dk/linux-block: null_blk: fix use-after-free error block: ensure to split after potentially bouncing a bio NVMe: IO ending fixes on surprise removal
2 parents 0bee6ec + e827120 commit 24bc3ea

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

block/blk-core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,15 +1689,15 @@ static blk_qc_t blk_queue_bio(struct request_queue *q, struct bio *bio)
16891689
struct request *req;
16901690
unsigned int request_count = 0;
16911691

1692-
blk_queue_split(q, &bio, q->bio_split);
1693-
16941692
/*
16951693
* low level driver can indicate that it wants pages above a
16961694
* certain limit bounced to low memory (ie for highmem, or even
16971695
* ISA dma in theory)
16981696
*/
16991697
blk_queue_bounce(q, &bio);
17001698

1699+
blk_queue_split(q, &bio, q->bio_split);
1700+
17011701
if (bio_integrity_enabled(bio) && bio_integrity_prep(bio)) {
17021702
bio->bi_error = -EIO;
17031703
bio_endio(bio);

drivers/block/null_blk.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ static void end_cmd(struct nullb_cmd *cmd)
219219
{
220220
struct request_queue *q = NULL;
221221

222+
if (cmd->rq)
223+
q = cmd->rq->q;
224+
222225
switch (queue_mode) {
223226
case NULL_Q_MQ:
224227
blk_mq_end_request(cmd->rq, 0);
@@ -232,9 +235,6 @@ static void end_cmd(struct nullb_cmd *cmd)
232235
goto free_cmd;
233236
}
234237

235-
if (cmd->rq)
236-
q = cmd->rq->q;
237-
238238
/* Restart queue if needed, as we are freeing a tag */
239239
if (q && !q->mq_ops && blk_queue_stopped(q)) {
240240
unsigned long flags;

drivers/nvme/host/pci.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2540,8 +2540,17 @@ static void nvme_ns_remove(struct nvme_ns *ns)
25402540
{
25412541
bool kill = nvme_io_incapable(ns->dev) && !blk_queue_dying(ns->queue);
25422542

2543-
if (kill)
2543+
if (kill) {
25442544
blk_set_queue_dying(ns->queue);
2545+
2546+
/*
2547+
* The controller was shutdown first if we got here through
2548+
* device removal. The shutdown may requeue outstanding
2549+
* requests. These need to be aborted immediately so
2550+
* del_gendisk doesn't block indefinitely for their completion.
2551+
*/
2552+
blk_mq_abort_requeue_list(ns->queue);
2553+
}
25452554
if (ns->disk->flags & GENHD_FL_UP)
25462555
del_gendisk(ns->disk);
25472556
if (kill || !blk_queue_dying(ns->queue)) {
@@ -2977,6 +2986,15 @@ static void nvme_dev_remove(struct nvme_dev *dev)
29772986
{
29782987
struct nvme_ns *ns, *next;
29792988

2989+
if (nvme_io_incapable(dev)) {
2990+
/*
2991+
* If the device is not capable of IO (surprise hot-removal,
2992+
* for example), we need to quiesce prior to deleting the
2993+
* namespaces. This will end outstanding requests and prevent
2994+
* attempts to sync dirty data.
2995+
*/
2996+
nvme_dev_shutdown(dev);
2997+
}
29802998
list_for_each_entry_safe(ns, next, &dev->namespaces, list)
29812999
nvme_ns_remove(ns);
29823000
}

0 commit comments

Comments
 (0)