Skip to content

Commit 949dd32

Browse files
committed
Merge tag 'block-6.15-20250403' of git://git.kernel.dk/linux
Pull more block updates from Jens Axboe: - NVMe pull request via Keith: - PCI endpoint target cleanup (Damien) - Early import for uring_cmd fixed buffer (Caleb) - Multipath documentation and notification improvements (John) - Invalid pci sq doorbell write fix (Maurizio) - Queue init locking fix - Remove dead nsegs parameter from blk_mq_get_new_requests() * tag 'block-6.15-20250403' of git://git.kernel.dk/linux: block: don't grab elevator lock during queue initialization nvme-pci: skip nvme_write_sq_db on empty rqlist nvme-multipath: change the NVME_MULTIPATH config option nvme: update the multipath warning in nvme_init_ns_head nvme/ioctl: move fixed buffer lookup to nvme_uring_cmd_io() nvme/ioctl: move blk_mq_free_request() out of nvme_map_user_request() nvme/ioctl: don't warn on vectorized uring_cmd with fixed buffer nvmet: pci-epf: Keep completion queues mapped block: remove unused nseg parameter
2 parents 7930edc + 01b91bf commit 949dd32

File tree

6 files changed

+94
-84
lines changed

6 files changed

+94
-84
lines changed

block/blk-mq.c

+19-10
Original file line numberDiff line numberDiff line change
@@ -2965,8 +2965,7 @@ static bool blk_mq_attempt_bio_merge(struct request_queue *q,
29652965

29662966
static struct request *blk_mq_get_new_requests(struct request_queue *q,
29672967
struct blk_plug *plug,
2968-
struct bio *bio,
2969-
unsigned int nsegs)
2968+
struct bio *bio)
29702969
{
29712970
struct blk_mq_alloc_data data = {
29722971
.q = q,
@@ -3125,7 +3124,7 @@ void blk_mq_submit_bio(struct bio *bio)
31253124
if (rq) {
31263125
blk_mq_use_cached_rq(rq, plug, bio);
31273126
} else {
3128-
rq = blk_mq_get_new_requests(q, plug, bio, nr_segs);
3127+
rq = blk_mq_get_new_requests(q, plug, bio);
31293128
if (unlikely(!rq)) {
31303129
if (bio->bi_opf & REQ_NOWAIT)
31313130
bio_wouldblock_error(bio);
@@ -4465,14 +4464,12 @@ static struct blk_mq_hw_ctx *blk_mq_alloc_and_init_hctx(
44654464
return NULL;
44664465
}
44674466

4468-
static void blk_mq_realloc_hw_ctxs(struct blk_mq_tag_set *set,
4469-
struct request_queue *q)
4467+
static void __blk_mq_realloc_hw_ctxs(struct blk_mq_tag_set *set,
4468+
struct request_queue *q)
44704469
{
44714470
struct blk_mq_hw_ctx *hctx;
44724471
unsigned long i, j;
44734472

4474-
/* protect against switching io scheduler */
4475-
mutex_lock(&q->elevator_lock);
44764473
for (i = 0; i < set->nr_hw_queues; i++) {
44774474
int old_node;
44784475
int node = blk_mq_get_hctx_node(set, i);
@@ -4505,7 +4502,19 @@ static void blk_mq_realloc_hw_ctxs(struct blk_mq_tag_set *set,
45054502

45064503
xa_for_each_start(&q->hctx_table, j, hctx, j)
45074504
blk_mq_exit_hctx(q, set, hctx, j);
4508-
mutex_unlock(&q->elevator_lock);
4505+
}
4506+
4507+
static void blk_mq_realloc_hw_ctxs(struct blk_mq_tag_set *set,
4508+
struct request_queue *q, bool lock)
4509+
{
4510+
if (lock) {
4511+
/* protect against switching io scheduler */
4512+
mutex_lock(&q->elevator_lock);
4513+
__blk_mq_realloc_hw_ctxs(set, q);
4514+
mutex_unlock(&q->elevator_lock);
4515+
} else {
4516+
__blk_mq_realloc_hw_ctxs(set, q);
4517+
}
45094518

45104519
/* unregister cpuhp callbacks for exited hctxs */
45114520
blk_mq_remove_hw_queues_cpuhp(q);
@@ -4537,7 +4546,7 @@ int blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
45374546

45384547
xa_init(&q->hctx_table);
45394548

4540-
blk_mq_realloc_hw_ctxs(set, q);
4549+
blk_mq_realloc_hw_ctxs(set, q, false);
45414550
if (!q->nr_hw_queues)
45424551
goto err_hctxs;
45434552

@@ -5033,7 +5042,7 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
50335042
fallback:
50345043
blk_mq_update_queue_map(set);
50355044
list_for_each_entry(q, &set->tag_list, tag_set_list) {
5036-
blk_mq_realloc_hw_ctxs(set, q);
5045+
blk_mq_realloc_hw_ctxs(set, q, true);
50375046

50385047
if (q->nr_hw_queues != set->nr_hw_queues) {
50395048
int i = prev_nr_hw_queues;

drivers/nvme/host/Kconfig

+9-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@ config NVME_MULTIPATH
1818
bool "NVMe multipath support"
1919
depends on NVME_CORE
2020
help
21-
This option enables support for multipath access to NVMe
22-
subsystems. If this option is enabled only a single
23-
/dev/nvmeXnY device will show up for each NVMe namespace,
24-
even if it is accessible through multiple controllers.
21+
This option controls support for multipath access to NVMe
22+
subsystems. If this option is enabled support for NVMe multipath
23+
access is included in the kernel. If this option is disabled support
24+
for NVMe multipath access is excluded from the kernel. When this
25+
option is disabled each controller/namespace receives its
26+
own /dev/nvmeXnY device entry and NVMe multipath access is
27+
not supported.
28+
29+
If unsure, say Y.
2530

2631
config NVME_VERBOSE_ERRORS
2732
bool "NVMe verbose error reporting"

drivers/nvme/host/core.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3822,7 +3822,7 @@ static int nvme_init_ns_head(struct nvme_ns *ns, struct nvme_ns_info *info)
38223822
"Found shared namespace %d, but multipathing not supported.\n",
38233823
info->nsid);
38243824
dev_warn_once(ctrl->device,
3825-
"Support for shared namespaces without CONFIG_NVME_MULTIPATH is deprecated and will be removed in Linux 6.0.\n");
3825+
"Shared namespace support requires core_nvme.multipath=Y.\n");
38263826
}
38273827
}
38283828

drivers/nvme/host/ioctl.c

+37-31
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ static struct request *nvme_alloc_user_request(struct request_queue *q,
114114

115115
static int nvme_map_user_request(struct request *req, u64 ubuffer,
116116
unsigned bufflen, void __user *meta_buffer, unsigned meta_len,
117-
struct io_uring_cmd *ioucmd, unsigned int flags,
118-
unsigned int iou_issue_flags)
117+
struct iov_iter *iter, unsigned int flags)
119118
{
120119
struct request_queue *q = req->q;
121120
struct nvme_ns *ns = q->queuedata;
@@ -129,37 +128,23 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer,
129128
if (!nvme_ctrl_sgl_supported(ctrl))
130129
dev_warn_once(ctrl->device, "using unchecked data buffer\n");
131130
if (has_metadata) {
132-
if (!supports_metadata) {
133-
ret = -EINVAL;
134-
goto out;
135-
}
131+
if (!supports_metadata)
132+
return -EINVAL;
133+
136134
if (!nvme_ctrl_meta_sgl_supported(ctrl))
137135
dev_warn_once(ctrl->device,
138136
"using unchecked metadata buffer\n");
139137
}
140138

141-
if (ioucmd && (ioucmd->flags & IORING_URING_CMD_FIXED)) {
142-
struct iov_iter iter;
143-
144-
/* fixedbufs is only for non-vectored io */
145-
if (WARN_ON_ONCE(flags & NVME_IOCTL_VEC)) {
146-
ret = -EINVAL;
147-
goto out;
148-
}
149-
ret = io_uring_cmd_import_fixed(ubuffer, bufflen,
150-
rq_data_dir(req), &iter, ioucmd,
151-
iou_issue_flags);
152-
if (ret < 0)
153-
goto out;
154-
ret = blk_rq_map_user_iov(q, req, NULL, &iter, GFP_KERNEL);
155-
} else {
139+
if (iter)
140+
ret = blk_rq_map_user_iov(q, req, NULL, iter, GFP_KERNEL);
141+
else
156142
ret = blk_rq_map_user_io(req, NULL, nvme_to_user_ptr(ubuffer),
157143
bufflen, GFP_KERNEL, flags & NVME_IOCTL_VEC, 0,
158144
0, rq_data_dir(req));
159-
}
160145

161146
if (ret)
162-
goto out;
147+
return ret;
163148

164149
bio = req->bio;
165150
if (bdev)
@@ -176,8 +161,6 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer,
176161
out_unmap:
177162
if (bio)
178163
blk_rq_unmap_user(bio);
179-
out:
180-
blk_mq_free_request(req);
181164
return ret;
182165
}
183166

@@ -200,9 +183,9 @@ static int nvme_submit_user_cmd(struct request_queue *q,
200183
req->timeout = timeout;
201184
if (ubuffer && bufflen) {
202185
ret = nvme_map_user_request(req, ubuffer, bufflen, meta_buffer,
203-
meta_len, NULL, flags, 0);
186+
meta_len, NULL, flags);
204187
if (ret)
205-
return ret;
188+
goto out_free_req;
206189
}
207190

208191
bio = req->bio;
@@ -218,7 +201,10 @@ static int nvme_submit_user_cmd(struct request_queue *q,
218201

219202
if (effects)
220203
nvme_passthru_end(ctrl, ns, effects, cmd, ret);
204+
return ret;
221205

206+
out_free_req:
207+
blk_mq_free_request(req);
222208
return ret;
223209
}
224210

@@ -469,6 +455,8 @@ static int nvme_uring_cmd_io(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
469455
struct request_queue *q = ns ? ns->queue : ctrl->admin_q;
470456
struct nvme_uring_data d;
471457
struct nvme_command c;
458+
struct iov_iter iter;
459+
struct iov_iter *map_iter = NULL;
472460
struct request *req;
473461
blk_opf_t rq_flags = REQ_ALLOC_CACHE;
474462
blk_mq_req_flags_t blk_flags = 0;
@@ -504,6 +492,20 @@ static int nvme_uring_cmd_io(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
504492
d.metadata_len = READ_ONCE(cmd->metadata_len);
505493
d.timeout_ms = READ_ONCE(cmd->timeout_ms);
506494

495+
if (d.data_len && (ioucmd->flags & IORING_URING_CMD_FIXED)) {
496+
/* fixedbufs is only for non-vectored io */
497+
if (vec)
498+
return -EINVAL;
499+
500+
ret = io_uring_cmd_import_fixed(d.addr, d.data_len,
501+
nvme_is_write(&c) ? WRITE : READ, &iter, ioucmd,
502+
issue_flags);
503+
if (ret < 0)
504+
return ret;
505+
506+
map_iter = &iter;
507+
}
508+
507509
if (issue_flags & IO_URING_F_NONBLOCK) {
508510
rq_flags |= REQ_NOWAIT;
509511
blk_flags = BLK_MQ_REQ_NOWAIT;
@@ -517,11 +519,11 @@ static int nvme_uring_cmd_io(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
517519
req->timeout = d.timeout_ms ? msecs_to_jiffies(d.timeout_ms) : 0;
518520

519521
if (d.data_len) {
520-
ret = nvme_map_user_request(req, d.addr,
521-
d.data_len, nvme_to_user_ptr(d.metadata),
522-
d.metadata_len, ioucmd, vec, issue_flags);
522+
ret = nvme_map_user_request(req, d.addr, d.data_len,
523+
nvme_to_user_ptr(d.metadata), d.metadata_len,
524+
map_iter, vec);
523525
if (ret)
524-
return ret;
526+
goto out_free_req;
525527
}
526528

527529
/* to free bio on completion, as req->bio will be null at that time */
@@ -531,6 +533,10 @@ static int nvme_uring_cmd_io(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
531533
req->end_io = nvme_uring_cmd_end_io;
532534
blk_execute_rq_nowait(req, false);
533535
return -EIOCBQUEUED;
536+
537+
out_free_req:
538+
blk_mq_free_request(req);
539+
return ret;
534540
}
535541

536542
static bool is_ctrl_ioctl(unsigned int cmd)

drivers/nvme/host/pci.c

+3
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,9 @@ static void nvme_submit_cmds(struct nvme_queue *nvmeq, struct rq_list *rqlist)
986986
{
987987
struct request *req;
988988

989+
if (rq_list_empty(rqlist))
990+
return;
991+
989992
spin_lock(&nvmeq->sq_lock);
990993
while ((req = rq_list_pop(rqlist))) {
991994
struct nvme_iod *iod = blk_mq_rq_to_pdu(req);

drivers/nvme/target/pci-epf.c

+25-38
Original file line numberDiff line numberDiff line change
@@ -1264,6 +1264,7 @@ static u16 nvmet_pci_epf_create_cq(struct nvmet_ctrl *tctrl,
12641264
struct nvmet_pci_epf_ctrl *ctrl = tctrl->drvdata;
12651265
struct nvmet_pci_epf_queue *cq = &ctrl->cq[cqid];
12661266
u16 status;
1267+
int ret;
12671268

12681269
if (test_bit(NVMET_PCI_EPF_Q_LIVE, &cq->flags))
12691270
return NVME_SC_QID_INVALID | NVME_STATUS_DNR;
@@ -1298,13 +1299,35 @@ static u16 nvmet_pci_epf_create_cq(struct nvmet_ctrl *tctrl,
12981299
if (status != NVME_SC_SUCCESS)
12991300
goto err;
13001301

1302+
/*
1303+
* Map the CQ PCI address space and since PCI endpoint controllers may
1304+
* return a partial mapping, check that the mapping is large enough.
1305+
*/
1306+
ret = nvmet_pci_epf_mem_map(ctrl->nvme_epf, cq->pci_addr, cq->pci_size,
1307+
&cq->pci_map);
1308+
if (ret) {
1309+
dev_err(ctrl->dev, "Failed to map CQ %u (err=%d)\n",
1310+
cq->qid, ret);
1311+
goto err_internal;
1312+
}
1313+
1314+
if (cq->pci_map.pci_size < cq->pci_size) {
1315+
dev_err(ctrl->dev, "Invalid partial mapping of queue %u\n",
1316+
cq->qid);
1317+
goto err_unmap_queue;
1318+
}
1319+
13011320
set_bit(NVMET_PCI_EPF_Q_LIVE, &cq->flags);
13021321

13031322
dev_dbg(ctrl->dev, "CQ[%u]: %u entries of %zu B, IRQ vector %u\n",
13041323
cqid, qsize, cq->qes, cq->vector);
13051324

13061325
return NVME_SC_SUCCESS;
13071326

1327+
err_unmap_queue:
1328+
nvmet_pci_epf_mem_unmap(ctrl->nvme_epf, &cq->pci_map);
1329+
err_internal:
1330+
status = NVME_SC_INTERNAL | NVME_STATUS_DNR;
13081331
err:
13091332
if (test_and_clear_bit(NVMET_PCI_EPF_Q_IRQ_ENABLED, &cq->flags))
13101333
nvmet_pci_epf_remove_irq_vector(ctrl, cq->vector);
@@ -1322,6 +1345,7 @@ static u16 nvmet_pci_epf_delete_cq(struct nvmet_ctrl *tctrl, u16 cqid)
13221345
cancel_delayed_work_sync(&cq->work);
13231346
nvmet_pci_epf_drain_queue(cq);
13241347
nvmet_pci_epf_remove_irq_vector(ctrl, cq->vector);
1348+
nvmet_pci_epf_mem_unmap(ctrl->nvme_epf, &cq->pci_map);
13251349

13261350
return NVME_SC_SUCCESS;
13271351
}
@@ -1553,36 +1577,6 @@ static void nvmet_pci_epf_free_queues(struct nvmet_pci_epf_ctrl *ctrl)
15531577
ctrl->cq = NULL;
15541578
}
15551579

1556-
static int nvmet_pci_epf_map_queue(struct nvmet_pci_epf_ctrl *ctrl,
1557-
struct nvmet_pci_epf_queue *queue)
1558-
{
1559-
struct nvmet_pci_epf *nvme_epf = ctrl->nvme_epf;
1560-
int ret;
1561-
1562-
ret = nvmet_pci_epf_mem_map(nvme_epf, queue->pci_addr,
1563-
queue->pci_size, &queue->pci_map);
1564-
if (ret) {
1565-
dev_err(ctrl->dev, "Failed to map queue %u (err=%d)\n",
1566-
queue->qid, ret);
1567-
return ret;
1568-
}
1569-
1570-
if (queue->pci_map.pci_size < queue->pci_size) {
1571-
dev_err(ctrl->dev, "Invalid partial mapping of queue %u\n",
1572-
queue->qid);
1573-
nvmet_pci_epf_mem_unmap(nvme_epf, &queue->pci_map);
1574-
return -ENOMEM;
1575-
}
1576-
1577-
return 0;
1578-
}
1579-
1580-
static inline void nvmet_pci_epf_unmap_queue(struct nvmet_pci_epf_ctrl *ctrl,
1581-
struct nvmet_pci_epf_queue *queue)
1582-
{
1583-
nvmet_pci_epf_mem_unmap(ctrl->nvme_epf, &queue->pci_map);
1584-
}
1585-
15861580
static void nvmet_pci_epf_exec_iod_work(struct work_struct *work)
15871581
{
15881582
struct nvmet_pci_epf_iod *iod =
@@ -1746,11 +1740,7 @@ static void nvmet_pci_epf_cq_work(struct work_struct *work)
17461740
struct nvme_completion *cqe;
17471741
struct nvmet_pci_epf_iod *iod;
17481742
unsigned long flags;
1749-
int ret, n = 0;
1750-
1751-
ret = nvmet_pci_epf_map_queue(ctrl, cq);
1752-
if (ret)
1753-
goto again;
1743+
int ret = 0, n = 0;
17541744

17551745
while (test_bit(NVMET_PCI_EPF_Q_LIVE, &cq->flags) && ctrl->link_up) {
17561746

@@ -1797,8 +1787,6 @@ static void nvmet_pci_epf_cq_work(struct work_struct *work)
17971787
n++;
17981788
}
17991789

1800-
nvmet_pci_epf_unmap_queue(ctrl, cq);
1801-
18021790
/*
18031791
* We do not support precise IRQ coalescing time (100ns units as per
18041792
* NVMe specifications). So if we have posted completion entries without
@@ -1807,7 +1795,6 @@ static void nvmet_pci_epf_cq_work(struct work_struct *work)
18071795
if (n)
18081796
nvmet_pci_epf_raise_irq(ctrl, cq, true);
18091797

1810-
again:
18111798
if (ret < 0)
18121799
queue_delayed_work(system_highpri_wq, &cq->work,
18131800
NVMET_PCI_EPF_CQ_RETRY_INTERVAL);

0 commit comments

Comments
 (0)