Skip to content

Commit 1880df2

Browse files
committed
Merge tag 'block-6.16-20250704' of git://git.kernel.dk/linux
Pull block fixes from Jens Axboe: - NVMe fixes via Christoph: - fix incorrect cdw15 value in passthru error logging (Alok Tiwari) - fix memory leak of bio integrity in nvmet (Dmitry Bogdanov) - refresh visible attrs after being checked (Eugen Hristev) - fix suspicious RCU usage warning in the multipath code (Geliang Tang) - correctly account for namespace head reference counter (Nilay Shroff) - Fix for a regression introduced in ublk in this cycle, where it would attempt to queue a canceled request. - brd RCU sleeping fix, also introduced in this cycle. Bare bones fix, should be improved upon for the next release. * tag 'block-6.16-20250704' of git://git.kernel.dk/linux: brd: fix sleeping function called from invalid context in brd_insert_page() ublk: don't queue request if the associated uring_cmd is canceled nvme-multipath: fix suspicious RCU usage warning nvme-pci: refresh visible attrs after being checked nvmet: fix memory leak of bio integrity nvme: correctly account for namespace head reference counter nvme: Fix incorrect cdw15 value in passthru error logging
2 parents 482deed + 75ef7b8 commit 1880df2

File tree

6 files changed

+38
-13
lines changed

6 files changed

+38
-13
lines changed

drivers/block/brd.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,15 @@ static struct page *brd_insert_page(struct brd_device *brd, sector_t sector,
6464

6565
rcu_read_unlock();
6666
page = alloc_page(gfp | __GFP_ZERO | __GFP_HIGHMEM);
67-
rcu_read_lock();
68-
if (!page)
67+
if (!page) {
68+
rcu_read_lock();
6969
return ERR_PTR(-ENOMEM);
70+
}
7071

7172
xa_lock(&brd->brd_pages);
7273
ret = __xa_cmpxchg(&brd->brd_pages, sector >> PAGE_SECTORS_SHIFT, NULL,
7374
page, gfp);
75+
rcu_read_lock();
7476
if (ret) {
7577
xa_unlock(&brd->brd_pages);
7678
__free_page(page);

drivers/block/ublk_drv.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,15 +1442,16 @@ static void ublk_queue_rqs(struct rq_list *rqlist)
14421442
struct ublk_queue *this_q = req->mq_hctx->driver_data;
14431443
struct ublk_io *this_io = &this_q->ios[req->tag];
14441444

1445+
if (ublk_prep_req(this_q, req, true) != BLK_STS_OK) {
1446+
rq_list_add_tail(&requeue_list, req);
1447+
continue;
1448+
}
1449+
14451450
if (io && !ublk_belong_to_same_batch(io, this_io) &&
14461451
!rq_list_empty(&submit_list))
14471452
ublk_queue_cmd_list(io, &submit_list);
14481453
io = this_io;
1449-
1450-
if (ublk_prep_req(this_q, req, true) == BLK_STS_OK)
1451-
rq_list_add_tail(&submit_list, req);
1452-
else
1453-
rq_list_add_tail(&requeue_list, req);
1454+
rq_list_add_tail(&submit_list, req);
14541455
}
14551456

14561457
if (!rq_list_empty(&submit_list))

drivers/nvme/host/core.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ static void nvme_log_err_passthru(struct request *req)
386386
nr->cmd->common.cdw12,
387387
nr->cmd->common.cdw13,
388388
nr->cmd->common.cdw14,
389-
nr->cmd->common.cdw14);
389+
nr->cmd->common.cdw15);
390390
}
391391

392392
enum nvme_disposition {
@@ -4086,6 +4086,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info)
40864086
struct nvme_ns *ns;
40874087
struct gendisk *disk;
40884088
int node = ctrl->numa_node;
4089+
bool last_path = false;
40894090

40904091
ns = kzalloc_node(sizeof(*ns), GFP_KERNEL, node);
40914092
if (!ns)
@@ -4178,9 +4179,22 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info)
41784179
out_unlink_ns:
41794180
mutex_lock(&ctrl->subsys->lock);
41804181
list_del_rcu(&ns->siblings);
4181-
if (list_empty(&ns->head->list))
4182+
if (list_empty(&ns->head->list)) {
41824183
list_del_init(&ns->head->entry);
4184+
/*
4185+
* If multipath is not configured, we still create a namespace
4186+
* head (nshead), but head->disk is not initialized in that
4187+
* case. As a result, only a single reference to nshead is held
4188+
* (via kref_init()) when it is created. Therefore, ensure that
4189+
* we do not release the reference to nshead twice if head->disk
4190+
* is not present.
4191+
*/
4192+
if (ns->head->disk)
4193+
last_path = true;
4194+
}
41834195
mutex_unlock(&ctrl->subsys->lock);
4196+
if (last_path)
4197+
nvme_put_ns_head(ns->head);
41844198
nvme_put_ns_head(ns->head);
41854199
out_cleanup_disk:
41864200
put_disk(disk);

drivers/nvme/host/multipath.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,8 +690,8 @@ static void nvme_remove_head(struct nvme_ns_head *head)
690690
nvme_cdev_del(&head->cdev, &head->cdev_device);
691691
synchronize_srcu(&head->srcu);
692692
del_gendisk(head->disk);
693-
nvme_put_ns_head(head);
694693
}
694+
nvme_put_ns_head(head);
695695
}
696696

697697
static void nvme_remove_head_work(struct work_struct *work)
@@ -1200,7 +1200,8 @@ void nvme_mpath_add_sysfs_link(struct nvme_ns_head *head)
12001200
*/
12011201
srcu_idx = srcu_read_lock(&head->srcu);
12021202

1203-
list_for_each_entry_rcu(ns, &head->list, siblings) {
1203+
list_for_each_entry_srcu(ns, &head->list, siblings,
1204+
srcu_read_lock_held(&head->srcu)) {
12041205
/*
12051206
* Ensure that ns path disk node is already added otherwise we
12061207
* may get invalid kobj name for target
@@ -1291,6 +1292,9 @@ void nvme_mpath_remove_disk(struct nvme_ns_head *head)
12911292
{
12921293
bool remove = false;
12931294

1295+
if (!head->disk)
1296+
return;
1297+
12941298
mutex_lock(&head->subsys->lock);
12951299
/*
12961300
* We are called when all paths have been removed, and at that point

drivers/nvme/host/pci.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2101,8 +2101,6 @@ static void nvme_map_cmb(struct nvme_dev *dev)
21012101
if ((dev->cmbsz & (NVME_CMBSZ_WDS | NVME_CMBSZ_RDS)) ==
21022102
(NVME_CMBSZ_WDS | NVME_CMBSZ_RDS))
21032103
pci_p2pmem_publish(pdev, true);
2104-
2105-
nvme_update_attrs(dev);
21062104
}
21072105

21082106
static int nvme_set_host_mem(struct nvme_dev *dev, u32 bits)
@@ -3010,6 +3008,8 @@ static void nvme_reset_work(struct work_struct *work)
30103008
if (result < 0)
30113009
goto out;
30123010

3011+
nvme_update_attrs(dev);
3012+
30133013
result = nvme_setup_io_queues(dev);
30143014
if (result)
30153015
goto out;
@@ -3343,6 +3343,8 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
33433343
if (result < 0)
33443344
goto out_disable;
33453345

3346+
nvme_update_attrs(dev);
3347+
33463348
result = nvme_setup_io_queues(dev);
33473349
if (result)
33483350
goto out_disable;

drivers/nvme/target/nvmet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,8 @@ static inline void nvmet_req_bio_put(struct nvmet_req *req, struct bio *bio)
867867
{
868868
if (bio != &req->b.inline_bio)
869869
bio_put(bio);
870+
else
871+
bio_uninit(bio);
870872
}
871873

872874
#ifdef CONFIG_NVME_TARGET_TCP_TLS

0 commit comments

Comments
 (0)