Skip to content

Commit 580b203

Browse files
committed
Merge tag 'block-6.14-20250313' of git://git.kernel.dk/linux
Pull block fixes from Jens Axboe: - NVMe pull request via Keith: - Concurrent pci error and hotplug handling fix (Keith) - Endpoint function fixes (Damien) - Fix for a regression introduced in this cycle with error checking for batched request completions (Shin'ichiro) * tag 'block-6.14-20250313' of git://git.kernel.dk/linux: block: change blk_mq_add_to_batch() third argument type to bool nvme: move error logging from nvme_end_req() to __nvme_end_req() nvmet: pci-epf: Do not add an IRQ vector if not needed nvmet: pci-epf: Set NVMET_PCI_EPF_Q_LIVE when a queue is fully created nvme-pci: fix stuck reset on concurrent DPC and HP
2 parents 83158b2 + a938135 commit 580b203

File tree

7 files changed

+54
-32
lines changed

7 files changed

+54
-32
lines changed

drivers/block/null_blk/main.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1549,8 +1549,8 @@ static int null_poll(struct blk_mq_hw_ctx *hctx, struct io_comp_batch *iob)
15491549
cmd = blk_mq_rq_to_pdu(req);
15501550
cmd->error = null_process_cmd(cmd, req_op(req), blk_rq_pos(req),
15511551
blk_rq_sectors(req));
1552-
if (!blk_mq_add_to_batch(req, iob, (__force int) cmd->error,
1553-
blk_mq_end_request_batch))
1552+
if (!blk_mq_add_to_batch(req, iob, cmd->error != BLK_STS_OK,
1553+
blk_mq_end_request_batch))
15541554
blk_mq_end_request(req, cmd->error);
15551555
nr++;
15561556
}

drivers/block/virtio_blk.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -1207,11 +1207,12 @@ static int virtblk_poll(struct blk_mq_hw_ctx *hctx, struct io_comp_batch *iob)
12071207

12081208
while ((vbr = virtqueue_get_buf(vq->vq, &len)) != NULL) {
12091209
struct request *req = blk_mq_rq_from_pdu(vbr);
1210+
u8 status = virtblk_vbr_status(vbr);
12101211

12111212
found++;
12121213
if (!blk_mq_complete_request_remote(req) &&
1213-
!blk_mq_add_to_batch(req, iob, virtblk_vbr_status(vbr),
1214-
virtblk_complete_batch))
1214+
!blk_mq_add_to_batch(req, iob, status != VIRTIO_BLK_S_OK,
1215+
virtblk_complete_batch))
12151216
virtblk_request_done(req);
12161217
}
12171218

drivers/nvme/host/apple.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,8 @@ static inline void apple_nvme_handle_cqe(struct apple_nvme_queue *q,
599599
}
600600

601601
if (!nvme_try_complete_req(req, cqe->status, cqe->result) &&
602-
!blk_mq_add_to_batch(req, iob, nvme_req(req)->status,
602+
!blk_mq_add_to_batch(req, iob,
603+
nvme_req(req)->status != NVME_SC_SUCCESS,
603604
apple_nvme_complete_batch))
604605
apple_nvme_complete_rq(req);
605606
}

drivers/nvme/host/core.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,12 @@ static inline void nvme_end_req_zoned(struct request *req)
431431

432432
static inline void __nvme_end_req(struct request *req)
433433
{
434+
if (unlikely(nvme_req(req)->status && !(req->rq_flags & RQF_QUIET))) {
435+
if (blk_rq_is_passthrough(req))
436+
nvme_log_err_passthru(req);
437+
else
438+
nvme_log_error(req);
439+
}
434440
nvme_end_req_zoned(req);
435441
nvme_trace_bio_complete(req);
436442
if (req->cmd_flags & REQ_NVME_MPATH)
@@ -441,12 +447,6 @@ void nvme_end_req(struct request *req)
441447
{
442448
blk_status_t status = nvme_error_status(nvme_req(req)->status);
443449

444-
if (unlikely(nvme_req(req)->status && !(req->rq_flags & RQF_QUIET))) {
445-
if (blk_rq_is_passthrough(req))
446-
nvme_log_err_passthru(req);
447-
else
448-
nvme_log_error(req);
449-
}
450450
__nvme_end_req(req);
451451
blk_mq_end_request(req, status);
452452
}

drivers/nvme/host/pci.c

+15-3
Original file line numberDiff line numberDiff line change
@@ -1130,8 +1130,9 @@ static inline void nvme_handle_cqe(struct nvme_queue *nvmeq,
11301130

11311131
trace_nvme_sq(req, cqe->sq_head, nvmeq->sq_tail);
11321132
if (!nvme_try_complete_req(req, cqe->status, cqe->result) &&
1133-
!blk_mq_add_to_batch(req, iob, nvme_req(req)->status,
1134-
nvme_pci_complete_batch))
1133+
!blk_mq_add_to_batch(req, iob,
1134+
nvme_req(req)->status != NVME_SC_SUCCESS,
1135+
nvme_pci_complete_batch))
11351136
nvme_pci_complete_rq(req);
11361137
}
11371138

@@ -1411,17 +1412,28 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req)
14111412
struct nvme_dev *dev = nvmeq->dev;
14121413
struct request *abort_req;
14131414
struct nvme_command cmd = { };
1415+
struct pci_dev *pdev = to_pci_dev(dev->dev);
14141416
u32 csts = readl(dev->bar + NVME_REG_CSTS);
14151417
u8 opcode;
14161418

1419+
/*
1420+
* Shutdown the device immediately if we see it is disconnected. This
1421+
* unblocks PCIe error handling if the nvme driver is waiting in
1422+
* error_resume for a device that has been removed. We can't unbind the
1423+
* driver while the driver's error callback is waiting to complete, so
1424+
* we're relying on a timeout to break that deadlock if a removal
1425+
* occurs while reset work is running.
1426+
*/
1427+
if (pci_dev_is_disconnected(pdev))
1428+
nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_DELETING);
14171429
if (nvme_state_terminal(&dev->ctrl))
14181430
goto disable;
14191431

14201432
/* If PCI error recovery process is happening, we cannot reset or
14211433
* the recovery mechanism will surely fail.
14221434
*/
14231435
mb();
1424-
if (pci_channel_offline(to_pci_dev(dev->dev)))
1436+
if (pci_channel_offline(pdev))
14251437
return BLK_EH_RESET_TIMER;
14261438

14271439
/*

drivers/nvme/target/pci-epf.c

+14-14
Original file line numberDiff line numberDiff line change
@@ -1265,15 +1265,12 @@ static u16 nvmet_pci_epf_create_cq(struct nvmet_ctrl *tctrl,
12651265
struct nvmet_pci_epf_queue *cq = &ctrl->cq[cqid];
12661266
u16 status;
12671267

1268-
if (test_and_set_bit(NVMET_PCI_EPF_Q_LIVE, &cq->flags))
1268+
if (test_bit(NVMET_PCI_EPF_Q_LIVE, &cq->flags))
12691269
return NVME_SC_QID_INVALID | NVME_STATUS_DNR;
12701270

12711271
if (!(flags & NVME_QUEUE_PHYS_CONTIG))
12721272
return NVME_SC_INVALID_QUEUE | NVME_STATUS_DNR;
12731273

1274-
if (flags & NVME_CQ_IRQ_ENABLED)
1275-
set_bit(NVMET_PCI_EPF_Q_IRQ_ENABLED, &cq->flags);
1276-
12771274
cq->pci_addr = pci_addr;
12781275
cq->qid = cqid;
12791276
cq->depth = qsize + 1;
@@ -1290,24 +1287,27 @@ static u16 nvmet_pci_epf_create_cq(struct nvmet_ctrl *tctrl,
12901287
cq->qes = ctrl->io_cqes;
12911288
cq->pci_size = cq->qes * cq->depth;
12921289

1293-
cq->iv = nvmet_pci_epf_add_irq_vector(ctrl, vector);
1294-
if (!cq->iv) {
1295-
status = NVME_SC_INTERNAL | NVME_STATUS_DNR;
1296-
goto err;
1290+
if (flags & NVME_CQ_IRQ_ENABLED) {
1291+
cq->iv = nvmet_pci_epf_add_irq_vector(ctrl, vector);
1292+
if (!cq->iv)
1293+
return NVME_SC_INTERNAL | NVME_STATUS_DNR;
1294+
set_bit(NVMET_PCI_EPF_Q_IRQ_ENABLED, &cq->flags);
12971295
}
12981296

12991297
status = nvmet_cq_create(tctrl, &cq->nvme_cq, cqid, cq->depth);
13001298
if (status != NVME_SC_SUCCESS)
13011299
goto err;
13021300

1301+
set_bit(NVMET_PCI_EPF_Q_LIVE, &cq->flags);
1302+
13031303
dev_dbg(ctrl->dev, "CQ[%u]: %u entries of %zu B, IRQ vector %u\n",
13041304
cqid, qsize, cq->qes, cq->vector);
13051305

13061306
return NVME_SC_SUCCESS;
13071307

13081308
err:
1309-
clear_bit(NVMET_PCI_EPF_Q_IRQ_ENABLED, &cq->flags);
1310-
clear_bit(NVMET_PCI_EPF_Q_LIVE, &cq->flags);
1309+
if (test_and_clear_bit(NVMET_PCI_EPF_Q_IRQ_ENABLED, &cq->flags))
1310+
nvmet_pci_epf_remove_irq_vector(ctrl, cq->vector);
13111311
return status;
13121312
}
13131313

@@ -1333,7 +1333,7 @@ static u16 nvmet_pci_epf_create_sq(struct nvmet_ctrl *tctrl,
13331333
struct nvmet_pci_epf_queue *sq = &ctrl->sq[sqid];
13341334
u16 status;
13351335

1336-
if (test_and_set_bit(NVMET_PCI_EPF_Q_LIVE, &sq->flags))
1336+
if (test_bit(NVMET_PCI_EPF_Q_LIVE, &sq->flags))
13371337
return NVME_SC_QID_INVALID | NVME_STATUS_DNR;
13381338

13391339
if (!(flags & NVME_QUEUE_PHYS_CONTIG))
@@ -1355,7 +1355,7 @@ static u16 nvmet_pci_epf_create_sq(struct nvmet_ctrl *tctrl,
13551355

13561356
status = nvmet_sq_create(tctrl, &sq->nvme_sq, sqid, sq->depth);
13571357
if (status != NVME_SC_SUCCESS)
1358-
goto out_clear_bit;
1358+
return status;
13591359

13601360
sq->iod_wq = alloc_workqueue("sq%d_wq", WQ_UNBOUND,
13611361
min_t(int, sq->depth, WQ_MAX_ACTIVE), sqid);
@@ -1365,15 +1365,15 @@ static u16 nvmet_pci_epf_create_sq(struct nvmet_ctrl *tctrl,
13651365
goto out_destroy_sq;
13661366
}
13671367

1368+
set_bit(NVMET_PCI_EPF_Q_LIVE, &sq->flags);
1369+
13681370
dev_dbg(ctrl->dev, "SQ[%u]: %u entries of %zu B\n",
13691371
sqid, qsize, sq->qes);
13701372

13711373
return NVME_SC_SUCCESS;
13721374

13731375
out_destroy_sq:
13741376
nvmet_sq_destroy(&sq->nvme_sq);
1375-
out_clear_bit:
1376-
clear_bit(NVMET_PCI_EPF_Q_LIVE, &sq->flags);
13771377
return status;
13781378
}
13791379

include/linux/blk-mq.h

+12-4
Original file line numberDiff line numberDiff line change
@@ -852,20 +852,28 @@ static inline bool blk_mq_is_reserved_rq(struct request *rq)
852852
return rq->rq_flags & RQF_RESV;
853853
}
854854

855-
/*
855+
/**
856+
* blk_mq_add_to_batch() - add a request to the completion batch
857+
* @req: The request to add to batch
858+
* @iob: The batch to add the request
859+
* @is_error: Specify true if the request failed with an error
860+
* @complete: The completaion handler for the request
861+
*
856862
* Batched completions only work when there is no I/O error and no special
857863
* ->end_io handler.
864+
*
865+
* Return: true when the request was added to the batch, otherwise false
858866
*/
859867
static inline bool blk_mq_add_to_batch(struct request *req,
860-
struct io_comp_batch *iob, int ioerror,
868+
struct io_comp_batch *iob, bool is_error,
861869
void (*complete)(struct io_comp_batch *))
862870
{
863871
/*
864872
* Check various conditions that exclude batch processing:
865873
* 1) No batch container
866874
* 2) Has scheduler data attached
867875
* 3) Not a passthrough request and end_io set
868-
* 4) Not a passthrough request and an ioerror
876+
* 4) Not a passthrough request and failed with an error
869877
*/
870878
if (!iob)
871879
return false;
@@ -874,7 +882,7 @@ static inline bool blk_mq_add_to_batch(struct request *req,
874882
if (!blk_rq_is_passthrough(req)) {
875883
if (req->end_io)
876884
return false;
877-
if (ioerror < 0)
885+
if (is_error)
878886
return false;
879887
}
880888

0 commit comments

Comments
 (0)