Skip to content

Commit 7503345

Browse files
committed
Merge tag 'block-6.13-20241207' of git://git.kernel.dk/linux
Pull block fixes from Jens Axboe: - NVMe pull request via Keith: - Target fix using incorrect zero buffer (Nilay) - Device specifc deallocate quirk fixes (Christoph, Keith) - Fabrics fix for handling max command target bugs (Maurizio) - Cocci fix usage for kzalloc (Yu-Chen) - DMA size fix for host memory buffer feature (Christoph) - Fabrics queue cleanup fixes (Chunguang) - CPU hotplug ordering fixes - Add missing MODULE_DESCRIPTION for rnull - bcache error value fix - virtio-blk queue freeze fix * tag 'block-6.13-20241207' of git://git.kernel.dk/linux: blk-mq: move cpuhp callback registering out of q->sysfs_lock blk-mq: register cpuhp callback after hctx is added to xarray table virtio-blk: don't keep queue frozen during system suspend nvme-tcp: simplify nvme_tcp_teardown_io_queues() nvme-tcp: no need to quiesce admin_q in nvme_tcp_teardown_io_queues() nvme-rdma: unquiesce admin_q before destroy it nvme-tcp: fix the memleak while create new ctrl failed nvme-pci: don't use dma_alloc_noncontiguous with 0 merge boundary nvmet: replace kmalloc + memset with kzalloc for data allocation nvme-fabrics: handle zero MAXCMD without closing the connection bcache: revert replacing IS_ERR_OR_NULL with IS_ERR again nvme-pci: remove two deallocate zeroes quirks block: rnull: add missing MODULE_DESCRIPTION nvme: don't apply NVME_QUIRK_DEALLOCATE_ZEROES when DSM is not supported nvmet: use kzalloc instead of ZERO_PAGE in nvme_execute_identify_ns_nvm()
2 parents aa0274d + 22465bb commit 7503345

File tree

10 files changed

+123
-47
lines changed

10 files changed

+123
-47
lines changed

block/blk-mq.c

Lines changed: 94 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
static DEFINE_PER_CPU(struct llist_head, blk_cpu_done);
4545
static DEFINE_PER_CPU(call_single_data_t, blk_cpu_csd);
46+
static DEFINE_MUTEX(blk_mq_cpuhp_lock);
4647

4748
static void blk_mq_insert_request(struct request *rq, blk_insert_t flags);
4849
static void blk_mq_request_bypass_insert(struct request *rq,
@@ -3739,13 +3740,91 @@ static int blk_mq_hctx_notify_dead(unsigned int cpu, struct hlist_node *node)
37393740
return 0;
37403741
}
37413742

3742-
static void blk_mq_remove_cpuhp(struct blk_mq_hw_ctx *hctx)
3743+
static void __blk_mq_remove_cpuhp(struct blk_mq_hw_ctx *hctx)
37433744
{
3744-
if (!(hctx->flags & BLK_MQ_F_STACKING))
3745+
lockdep_assert_held(&blk_mq_cpuhp_lock);
3746+
3747+
if (!(hctx->flags & BLK_MQ_F_STACKING) &&
3748+
!hlist_unhashed(&hctx->cpuhp_online)) {
37453749
cpuhp_state_remove_instance_nocalls(CPUHP_AP_BLK_MQ_ONLINE,
37463750
&hctx->cpuhp_online);
3747-
cpuhp_state_remove_instance_nocalls(CPUHP_BLK_MQ_DEAD,
3748-
&hctx->cpuhp_dead);
3751+
INIT_HLIST_NODE(&hctx->cpuhp_online);
3752+
}
3753+
3754+
if (!hlist_unhashed(&hctx->cpuhp_dead)) {
3755+
cpuhp_state_remove_instance_nocalls(CPUHP_BLK_MQ_DEAD,
3756+
&hctx->cpuhp_dead);
3757+
INIT_HLIST_NODE(&hctx->cpuhp_dead);
3758+
}
3759+
}
3760+
3761+
static void blk_mq_remove_cpuhp(struct blk_mq_hw_ctx *hctx)
3762+
{
3763+
mutex_lock(&blk_mq_cpuhp_lock);
3764+
__blk_mq_remove_cpuhp(hctx);
3765+
mutex_unlock(&blk_mq_cpuhp_lock);
3766+
}
3767+
3768+
static void __blk_mq_add_cpuhp(struct blk_mq_hw_ctx *hctx)
3769+
{
3770+
lockdep_assert_held(&blk_mq_cpuhp_lock);
3771+
3772+
if (!(hctx->flags & BLK_MQ_F_STACKING) &&
3773+
hlist_unhashed(&hctx->cpuhp_online))
3774+
cpuhp_state_add_instance_nocalls(CPUHP_AP_BLK_MQ_ONLINE,
3775+
&hctx->cpuhp_online);
3776+
3777+
if (hlist_unhashed(&hctx->cpuhp_dead))
3778+
cpuhp_state_add_instance_nocalls(CPUHP_BLK_MQ_DEAD,
3779+
&hctx->cpuhp_dead);
3780+
}
3781+
3782+
static void __blk_mq_remove_cpuhp_list(struct list_head *head)
3783+
{
3784+
struct blk_mq_hw_ctx *hctx;
3785+
3786+
lockdep_assert_held(&blk_mq_cpuhp_lock);
3787+
3788+
list_for_each_entry(hctx, head, hctx_list)
3789+
__blk_mq_remove_cpuhp(hctx);
3790+
}
3791+
3792+
/*
3793+
* Unregister cpuhp callbacks from exited hw queues
3794+
*
3795+
* Safe to call if this `request_queue` is live
3796+
*/
3797+
static void blk_mq_remove_hw_queues_cpuhp(struct request_queue *q)
3798+
{
3799+
LIST_HEAD(hctx_list);
3800+
3801+
spin_lock(&q->unused_hctx_lock);
3802+
list_splice_init(&q->unused_hctx_list, &hctx_list);
3803+
spin_unlock(&q->unused_hctx_lock);
3804+
3805+
mutex_lock(&blk_mq_cpuhp_lock);
3806+
__blk_mq_remove_cpuhp_list(&hctx_list);
3807+
mutex_unlock(&blk_mq_cpuhp_lock);
3808+
3809+
spin_lock(&q->unused_hctx_lock);
3810+
list_splice(&hctx_list, &q->unused_hctx_list);
3811+
spin_unlock(&q->unused_hctx_lock);
3812+
}
3813+
3814+
/*
3815+
* Register cpuhp callbacks from all hw queues
3816+
*
3817+
* Safe to call if this `request_queue` is live
3818+
*/
3819+
static void blk_mq_add_hw_queues_cpuhp(struct request_queue *q)
3820+
{
3821+
struct blk_mq_hw_ctx *hctx;
3822+
unsigned long i;
3823+
3824+
mutex_lock(&blk_mq_cpuhp_lock);
3825+
queue_for_each_hw_ctx(q, hctx, i)
3826+
__blk_mq_add_cpuhp(hctx);
3827+
mutex_unlock(&blk_mq_cpuhp_lock);
37493828
}
37503829

37513830
/*
@@ -3796,8 +3875,6 @@ static void blk_mq_exit_hctx(struct request_queue *q,
37963875
if (set->ops->exit_hctx)
37973876
set->ops->exit_hctx(hctx, hctx_idx);
37983877

3799-
blk_mq_remove_cpuhp(hctx);
3800-
38013878
xa_erase(&q->hctx_table, hctx_idx);
38023879

38033880
spin_lock(&q->unused_hctx_lock);
@@ -3814,6 +3891,7 @@ static void blk_mq_exit_hw_queues(struct request_queue *q,
38143891
queue_for_each_hw_ctx(q, hctx, i) {
38153892
if (i == nr_queue)
38163893
break;
3894+
blk_mq_remove_cpuhp(hctx);
38173895
blk_mq_exit_hctx(q, set, hctx, i);
38183896
}
38193897
}
@@ -3824,16 +3902,11 @@ static int blk_mq_init_hctx(struct request_queue *q,
38243902
{
38253903
hctx->queue_num = hctx_idx;
38263904

3827-
if (!(hctx->flags & BLK_MQ_F_STACKING))
3828-
cpuhp_state_add_instance_nocalls(CPUHP_AP_BLK_MQ_ONLINE,
3829-
&hctx->cpuhp_online);
3830-
cpuhp_state_add_instance_nocalls(CPUHP_BLK_MQ_DEAD, &hctx->cpuhp_dead);
3831-
38323905
hctx->tags = set->tags[hctx_idx];
38333906

38343907
if (set->ops->init_hctx &&
38353908
set->ops->init_hctx(hctx, set->driver_data, hctx_idx))
3836-
goto unregister_cpu_notifier;
3909+
goto fail;
38373910

38383911
if (blk_mq_init_request(set, hctx->fq->flush_rq, hctx_idx,
38393912
hctx->numa_node))
@@ -3850,8 +3923,7 @@ static int blk_mq_init_hctx(struct request_queue *q,
38503923
exit_hctx:
38513924
if (set->ops->exit_hctx)
38523925
set->ops->exit_hctx(hctx, hctx_idx);
3853-
unregister_cpu_notifier:
3854-
blk_mq_remove_cpuhp(hctx);
3926+
fail:
38553927
return -1;
38563928
}
38573929

@@ -3877,6 +3949,8 @@ blk_mq_alloc_hctx(struct request_queue *q, struct blk_mq_tag_set *set,
38773949
INIT_DELAYED_WORK(&hctx->run_work, blk_mq_run_work_fn);
38783950
spin_lock_init(&hctx->lock);
38793951
INIT_LIST_HEAD(&hctx->dispatch);
3952+
INIT_HLIST_NODE(&hctx->cpuhp_dead);
3953+
INIT_HLIST_NODE(&hctx->cpuhp_online);
38803954
hctx->queue = q;
38813955
hctx->flags = set->flags & ~BLK_MQ_F_TAG_QUEUE_SHARED;
38823956

@@ -4415,6 +4489,12 @@ static void blk_mq_realloc_hw_ctxs(struct blk_mq_tag_set *set,
44154489
xa_for_each_start(&q->hctx_table, j, hctx, j)
44164490
blk_mq_exit_hctx(q, set, hctx, j);
44174491
mutex_unlock(&q->sysfs_lock);
4492+
4493+
/* unregister cpuhp callbacks for exited hctxs */
4494+
blk_mq_remove_hw_queues_cpuhp(q);
4495+
4496+
/* register cpuhp for new initialized hctxs */
4497+
blk_mq_add_hw_queues_cpuhp(q);
44184498
}
44194499

44204500
int blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,

drivers/block/rnull.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ module! {
2828
type: NullBlkModule,
2929
name: "rnull_mod",
3030
author: "Andreas Hindborg",
31+
description: "Rust implementation of the C null block driver",
3132
license: "GPL v2",
3233
}
3334

drivers/block/virtio_blk.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,9 +1586,12 @@ static void virtblk_remove(struct virtio_device *vdev)
15861586
static int virtblk_freeze(struct virtio_device *vdev)
15871587
{
15881588
struct virtio_blk *vblk = vdev->priv;
1589+
struct request_queue *q = vblk->disk->queue;
15891590

15901591
/* Ensure no requests in virtqueues before deleting vqs. */
1591-
blk_mq_freeze_queue(vblk->disk->queue);
1592+
blk_mq_freeze_queue(q);
1593+
blk_mq_quiesce_queue_nowait(q);
1594+
blk_mq_unfreeze_queue(q);
15921595

15931596
/* Ensure we don't receive any more interrupts */
15941597
virtio_reset_device(vdev);
@@ -1612,8 +1615,8 @@ static int virtblk_restore(struct virtio_device *vdev)
16121615
return ret;
16131616

16141617
virtio_device_ready(vdev);
1618+
blk_mq_unquiesce_queue(vblk->disk->queue);
16151619

1616-
blk_mq_unfreeze_queue(vblk->disk->queue);
16171620
return 0;
16181621
}
16191622
#endif

drivers/md/bcache/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1718,7 +1718,7 @@ static CLOSURE_CALLBACK(cache_set_flush)
17181718
if (!IS_ERR_OR_NULL(c->gc_thread))
17191719
kthread_stop(c->gc_thread);
17201720

1721-
if (!IS_ERR(c->root))
1721+
if (!IS_ERR_OR_NULL(c->root))
17221722
list_add(&c->root->list, &c->btree_cache);
17231723

17241724
/*

drivers/nvme/host/core.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,7 +2071,8 @@ static bool nvme_update_disk_info(struct nvme_ns *ns, struct nvme_id_ns *id,
20712071
lim->physical_block_size = min(phys_bs, atomic_bs);
20722072
lim->io_min = phys_bs;
20732073
lim->io_opt = io_opt;
2074-
if (ns->ctrl->quirks & NVME_QUIRK_DEALLOCATE_ZEROES)
2074+
if ((ns->ctrl->quirks & NVME_QUIRK_DEALLOCATE_ZEROES) &&
2075+
(ns->ctrl->oncs & NVME_CTRL_ONCS_DSM))
20752076
lim->max_write_zeroes_sectors = UINT_MAX;
20762077
else
20772078
lim->max_write_zeroes_sectors = ns->ctrl->max_zeroes_sectors;
@@ -3260,8 +3261,9 @@ static int nvme_check_ctrl_fabric_info(struct nvme_ctrl *ctrl, struct nvme_id_ct
32603261
}
32613262

32623263
if (!ctrl->maxcmd) {
3263-
dev_err(ctrl->device, "Maximum outstanding commands is 0\n");
3264-
return -EINVAL;
3264+
dev_warn(ctrl->device,
3265+
"Firmware bug: maximum outstanding commands is 0\n");
3266+
ctrl->maxcmd = ctrl->sqsize + 1;
32653267
}
32663268

32673269
return 0;

drivers/nvme/host/pci.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,6 +2172,7 @@ static int nvme_alloc_host_mem_multi(struct nvme_dev *dev, u64 preferred,
21722172

21732173
static int nvme_alloc_host_mem(struct nvme_dev *dev, u64 min, u64 preferred)
21742174
{
2175+
unsigned long dma_merge_boundary = dma_get_merge_boundary(dev->dev);
21752176
u64 min_chunk = min_t(u64, preferred, PAGE_SIZE * MAX_ORDER_NR_PAGES);
21762177
u64 hmminds = max_t(u32, dev->ctrl.hmminds * 4096, PAGE_SIZE * 2);
21772178
u64 chunk_size;
@@ -2180,7 +2181,7 @@ static int nvme_alloc_host_mem(struct nvme_dev *dev, u64 min, u64 preferred)
21802181
* If there is an IOMMU that can merge pages, try a virtually
21812182
* non-contiguous allocation for a single segment first.
21822183
*/
2183-
if (!(PAGE_SIZE & dma_get_merge_boundary(dev->dev))) {
2184+
if (dma_merge_boundary && (PAGE_SIZE & dma_merge_boundary) == 0) {
21842185
if (!nvme_alloc_host_mem_single(dev, preferred))
21852186
return 0;
21862187
}
@@ -3588,12 +3589,10 @@ static const struct pci_device_id nvme_id_table[] = {
35883589
NVME_QUIRK_DEALLOCATE_ZEROES, },
35893590
{ PCI_VDEVICE(INTEL, 0x0a54), /* Intel P4500/P4600 */
35903591
.driver_data = NVME_QUIRK_STRIPE_SIZE |
3591-
NVME_QUIRK_DEALLOCATE_ZEROES |
35923592
NVME_QUIRK_IGNORE_DEV_SUBNQN |
35933593
NVME_QUIRK_BOGUS_NID, },
35943594
{ PCI_VDEVICE(INTEL, 0x0a55), /* Dell Express Flash P4600 */
3595-
.driver_data = NVME_QUIRK_STRIPE_SIZE |
3596-
NVME_QUIRK_DEALLOCATE_ZEROES, },
3595+
.driver_data = NVME_QUIRK_STRIPE_SIZE, },
35973596
{ PCI_VDEVICE(INTEL, 0xf1a5), /* Intel 600P/P3100 */
35983597
.driver_data = NVME_QUIRK_NO_DEEPEST_PS |
35993598
NVME_QUIRK_MEDIUM_PRIO_SQ |

drivers/nvme/host/rdma.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,13 +1091,7 @@ static int nvme_rdma_setup_ctrl(struct nvme_rdma_ctrl *ctrl, bool new)
10911091
}
10921092
destroy_admin:
10931093
nvme_stop_keep_alive(&ctrl->ctrl);
1094-
nvme_quiesce_admin_queue(&ctrl->ctrl);
1095-
blk_sync_queue(ctrl->ctrl.admin_q);
1096-
nvme_rdma_stop_queue(&ctrl->queues[0]);
1097-
nvme_cancel_admin_tagset(&ctrl->ctrl);
1098-
if (new)
1099-
nvme_remove_admin_tag_set(&ctrl->ctrl);
1100-
nvme_rdma_destroy_admin_queue(ctrl);
1094+
nvme_rdma_teardown_admin_queue(ctrl, new);
11011095
return ret;
11021096
}
11031097

drivers/nvme/host/tcp.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2101,14 +2101,6 @@ static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new)
21012101
return ret;
21022102
}
21032103

2104-
static void nvme_tcp_destroy_admin_queue(struct nvme_ctrl *ctrl, bool remove)
2105-
{
2106-
nvme_tcp_stop_queue(ctrl, 0);
2107-
if (remove)
2108-
nvme_remove_admin_tag_set(ctrl);
2109-
nvme_tcp_free_admin_queue(ctrl);
2110-
}
2111-
21122104
static int nvme_tcp_configure_admin_queue(struct nvme_ctrl *ctrl, bool new)
21132105
{
21142106
int error;
@@ -2163,9 +2155,11 @@ static void nvme_tcp_teardown_admin_queue(struct nvme_ctrl *ctrl,
21632155
blk_sync_queue(ctrl->admin_q);
21642156
nvme_tcp_stop_queue(ctrl, 0);
21652157
nvme_cancel_admin_tagset(ctrl);
2166-
if (remove)
2158+
if (remove) {
21672159
nvme_unquiesce_admin_queue(ctrl);
2168-
nvme_tcp_destroy_admin_queue(ctrl, remove);
2160+
nvme_remove_admin_tag_set(ctrl);
2161+
}
2162+
nvme_tcp_free_admin_queue(ctrl);
21692163
if (ctrl->tls_pskid) {
21702164
dev_dbg(ctrl->device, "Wipe negotiated TLS_PSK %08x\n",
21712165
ctrl->tls_pskid);
@@ -2178,7 +2172,6 @@ static void nvme_tcp_teardown_io_queues(struct nvme_ctrl *ctrl,
21782172
{
21792173
if (ctrl->queue_count <= 1)
21802174
return;
2181-
nvme_quiesce_admin_queue(ctrl);
21822175
nvme_quiesce_io_queues(ctrl);
21832176
nvme_sync_io_queues(ctrl);
21842177
nvme_tcp_stop_io_queues(ctrl);
@@ -2278,7 +2271,7 @@ static int nvme_tcp_setup_ctrl(struct nvme_ctrl *ctrl, bool new)
22782271
}
22792272
destroy_admin:
22802273
nvme_stop_keep_alive(ctrl);
2281-
nvme_tcp_teardown_admin_queue(ctrl, false);
2274+
nvme_tcp_teardown_admin_queue(ctrl, new);
22822275
return ret;
22832276
}
22842277

drivers/nvme/target/admin-cmd.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,13 +902,18 @@ static void nvmet_execute_identify_ctrl_nvm(struct nvmet_req *req)
902902
static void nvme_execute_identify_ns_nvm(struct nvmet_req *req)
903903
{
904904
u16 status;
905+
struct nvme_id_ns_nvm *id;
905906

906907
status = nvmet_req_find_ns(req);
907908
if (status)
908909
goto out;
909910

910-
status = nvmet_copy_to_sgl(req, 0, ZERO_PAGE(0),
911-
NVME_IDENTIFY_DATA_SIZE);
911+
id = kzalloc(sizeof(*id), GFP_KERNEL);
912+
if (!id) {
913+
status = NVME_SC_INTERNAL;
914+
goto out;
915+
}
916+
status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id));
912917
out:
913918
nvmet_req_complete(req, status);
914919
}

drivers/nvme/target/pr.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,12 +828,11 @@ static void nvmet_execute_pr_report(struct nvmet_req *req)
828828
goto out;
829829
}
830830

831-
data = kmalloc(num_bytes, GFP_KERNEL);
831+
data = kzalloc(num_bytes, GFP_KERNEL);
832832
if (!data) {
833833
status = NVME_SC_INTERNAL;
834834
goto out;
835835
}
836-
memset(data, 0, num_bytes);
837836
data->gen = cpu_to_le32(atomic_read(&pr->generation));
838837
data->ptpls = 0;
839838
ctrl_eds = data->regctl_eds;

0 commit comments

Comments
 (0)