Skip to content

Commit b2da197

Browse files
committed
Merge tag 'nvme-6.8-2024-1-10' of git://git.infradead.org/nvme into for-6.8/block
Pull NVMe changes from Keith: "nvme follow-up updates for Linux 6.8 - tcp, fc, and rdma target fixes (Maurizio, Daniel, Hannes, Christoph) - discard fixes and improvements (Christoph) - timeout debug improvements (Keith, Max) - various cleanups (Daniel, Max, Giuxen) - trace event string fixes (Arnd) - shadow doorbell setup on reset fix (William) - a write zeroes quirk for SK Hynix (Jim)" * tag 'nvme-6.8-2024-1-10' of git://git.infradead.org/nvme: (25 commits) nvmet-rdma: avoid circular locking dependency on install_queue() nvmet-tcp: avoid circular locking dependency on install_queue() nvme-pci: set doorbell config before unquiescing nvmet-tcp: Fix the H2C expected PDU len calculation nvme-tcp: enhance timeout kernel log nvme-rdma: enhance timeout kernel log nvme-pci: enhance timeout kernel log nvme: trace: avoid memcpy overflow warning nvmet: re-fix tracing strncpy() warning nvme: introduce nvme_disk_is_ns_head helper nvme-pci: disable write zeroes for SK Hynix BC901 nvmet-fcloop: Remove remote port from list when unlinking nvmet-trace: avoid dereferencing pointer too early nvmet-fc: remove unnecessary bracket nvme: simplify the max_discard_segments calculation nvme: fix max_discard_sectors calculation nvme: also skip discard granularity updates in nvme_config_discard nvme: update the explanation for not updating the limits in nvme_config_discard nvmet-tcp: fix a missing endianess conversion in nvmet_tcp_try_peek_pdu nvme-common: mark nvme_tls_psk_prio static ...
2 parents 748dc0b + 31deaeb commit b2da197

File tree

15 files changed

+146
-88
lines changed

15 files changed

+146
-88
lines changed

drivers/nvme/common/keyring.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static struct key *nvme_tls_psk_lookup(struct key *keyring,
111111
* should be preferred to 'generated' PSKs,
112112
* and SHA-384 should be preferred to SHA-256.
113113
*/
114-
struct nvme_tls_psk_priority_list {
114+
static struct nvme_tls_psk_priority_list {
115115
bool generated;
116116
enum nvme_tcp_tls_cipher cipher;
117117
} nvme_tls_psk_prio[] = {

drivers/nvme/host/core.c

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,28 +1727,36 @@ static void nvme_config_discard(struct nvme_ctrl *ctrl, struct gendisk *disk,
17271727
struct nvme_ns_head *head)
17281728
{
17291729
struct request_queue *queue = disk->queue;
1730-
u32 size = queue_logical_block_size(queue);
1730+
u32 max_discard_sectors;
17311731

1732-
if (ctrl->dmrsl && ctrl->dmrsl <= nvme_sect_to_lba(head, UINT_MAX))
1733-
ctrl->max_discard_sectors =
1734-
nvme_lba_to_sect(head, ctrl->dmrsl);
1735-
1736-
if (ctrl->max_discard_sectors == 0) {
1732+
if (ctrl->dmrsl && ctrl->dmrsl <= nvme_sect_to_lba(head, UINT_MAX)) {
1733+
max_discard_sectors = nvme_lba_to_sect(head, ctrl->dmrsl);
1734+
} else if (ctrl->oncs & NVME_CTRL_ONCS_DSM) {
1735+
max_discard_sectors = UINT_MAX;
1736+
} else {
17371737
blk_queue_max_discard_sectors(queue, 0);
17381738
return;
17391739
}
17401740

17411741
BUILD_BUG_ON(PAGE_SIZE / sizeof(struct nvme_dsm_range) <
17421742
NVME_DSM_MAX_RANGES);
17431743

1744-
queue->limits.discard_granularity = size;
1745-
1746-
/* If discard is already enabled, don't reset queue limits */
1744+
/*
1745+
* If discard is already enabled, don't reset queue limits.
1746+
*
1747+
* This works around the fact that the block layer can't cope well with
1748+
* updating the hardware limits when overridden through sysfs. This is
1749+
* harmless because discard limits in NVMe are purely advisory.
1750+
*/
17471751
if (queue->limits.max_discard_sectors)
17481752
return;
17491753

1750-
blk_queue_max_discard_sectors(queue, ctrl->max_discard_sectors);
1751-
blk_queue_max_discard_segments(queue, ctrl->max_discard_segments);
1754+
blk_queue_max_discard_sectors(queue, max_discard_sectors);
1755+
if (ctrl->dmrl)
1756+
blk_queue_max_discard_segments(queue, ctrl->dmrl);
1757+
else
1758+
blk_queue_max_discard_segments(queue, NVME_DSM_MAX_RANGES);
1759+
queue->limits.discard_granularity = queue_logical_block_size(queue);
17521760

17531761
if (ctrl->quirks & NVME_QUIRK_DEALLOCATE_ZEROES)
17541762
blk_queue_max_write_zeroes_sectors(queue, UINT_MAX);
@@ -2907,14 +2915,6 @@ static int nvme_init_non_mdts_limits(struct nvme_ctrl *ctrl)
29072915
struct nvme_id_ctrl_nvm *id;
29082916
int ret;
29092917

2910-
if (ctrl->oncs & NVME_CTRL_ONCS_DSM) {
2911-
ctrl->max_discard_sectors = UINT_MAX;
2912-
ctrl->max_discard_segments = NVME_DSM_MAX_RANGES;
2913-
} else {
2914-
ctrl->max_discard_sectors = 0;
2915-
ctrl->max_discard_segments = 0;
2916-
}
2917-
29182918
/*
29192919
* Even though NVMe spec explicitly states that MDTS is not applicable
29202920
* to the write-zeroes, we are cautious and limit the size to the
@@ -2944,8 +2944,7 @@ static int nvme_init_non_mdts_limits(struct nvme_ctrl *ctrl)
29442944
if (ret)
29452945
goto free_data;
29462946

2947-
if (id->dmrl)
2948-
ctrl->max_discard_segments = id->dmrl;
2947+
ctrl->dmrl = id->dmrl;
29492948
ctrl->dmrsl = le32_to_cpu(id->dmrsl);
29502949
if (id->wzsl)
29512950
ctrl->max_zeroes_sectors = nvme_mps_to_sectors(ctrl, id->wzsl);

drivers/nvme/host/nvme.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,14 +297,13 @@ struct nvme_ctrl {
297297
u32 max_hw_sectors;
298298
u32 max_segments;
299299
u32 max_integrity_segments;
300-
u32 max_discard_sectors;
301-
u32 max_discard_segments;
302300
u32 max_zeroes_sectors;
303301
#ifdef CONFIG_BLK_DEV_ZONED
304302
u32 max_zone_append;
305303
#endif
306304
u16 crdt[3];
307305
u16 oncs;
306+
u8 dmrl;
308307
u32 dmrsl;
309308
u16 oacs;
310309
u16 sqsize;
@@ -921,6 +920,10 @@ extern struct device_attribute dev_attr_ana_grpid;
921920
extern struct device_attribute dev_attr_ana_state;
922921
extern struct device_attribute subsys_attr_iopolicy;
923922

923+
static inline bool nvme_disk_is_ns_head(struct gendisk *disk)
924+
{
925+
return disk->fops == &nvme_ns_head_ops;
926+
}
924927
#else
925928
#define multipath false
926929
static inline bool nvme_ctrl_use_ana(struct nvme_ctrl *ctrl)
@@ -998,6 +1001,10 @@ static inline void nvme_mpath_start_request(struct request *rq)
9981001
static inline void nvme_mpath_end_request(struct request *rq)
9991002
{
10001003
}
1004+
static inline bool nvme_disk_is_ns_head(struct gendisk *disk)
1005+
{
1006+
return false;
1007+
}
10011008
#endif /* CONFIG_NVME_MULTIPATH */
10021009

10031010
int nvme_revalidate_zones(struct nvme_ns *ns);
@@ -1026,7 +1033,10 @@ static inline int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)
10261033

10271034
static inline struct nvme_ns *nvme_get_ns_from_dev(struct device *dev)
10281035
{
1029-
return dev_to_disk(dev)->private_data;
1036+
struct gendisk *disk = dev_to_disk(dev);
1037+
1038+
WARN_ON(nvme_disk_is_ns_head(disk));
1039+
return disk->private_data;
10301040
}
10311041

10321042
#ifdef CONFIG_NVME_HWMON

drivers/nvme/host/pci.c

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,7 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req)
12841284
struct request *abort_req;
12851285
struct nvme_command cmd = { };
12861286
u32 csts = readl(dev->bar + NVME_REG_CSTS);
1287+
u8 opcode;
12871288

12881289
/* If PCI error recovery process is happening, we cannot reset or
12891290
* the recovery mechanism will surely fail.
@@ -1310,8 +1311,8 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req)
13101311

13111312
if (blk_mq_rq_state(req) != MQ_RQ_IN_FLIGHT) {
13121313
dev_warn(dev->ctrl.device,
1313-
"I/O %d QID %d timeout, completion polled\n",
1314-
req->tag, nvmeq->qid);
1314+
"I/O tag %d (%04x) QID %d timeout, completion polled\n",
1315+
req->tag, nvme_cid(req), nvmeq->qid);
13151316
return BLK_EH_DONE;
13161317
}
13171318

@@ -1327,8 +1328,8 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req)
13271328
fallthrough;
13281329
case NVME_CTRL_DELETING:
13291330
dev_warn_ratelimited(dev->ctrl.device,
1330-
"I/O %d QID %d timeout, disable controller\n",
1331-
req->tag, nvmeq->qid);
1331+
"I/O tag %d (%04x) QID %d timeout, disable controller\n",
1332+
req->tag, nvme_cid(req), nvmeq->qid);
13321333
nvme_req(req)->flags |= NVME_REQ_CANCELLED;
13331334
nvme_dev_disable(dev, true);
13341335
return BLK_EH_DONE;
@@ -1343,10 +1344,12 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req)
13431344
* command was already aborted once before and still hasn't been
13441345
* returned to the driver, or if this is the admin queue.
13451346
*/
1347+
opcode = nvme_req(req)->cmd->common.opcode;
13461348
if (!nvmeq->qid || iod->aborted) {
13471349
dev_warn(dev->ctrl.device,
1348-
"I/O %d QID %d timeout, reset controller\n",
1349-
req->tag, nvmeq->qid);
1350+
"I/O tag %d (%04x) opcode %#x (%s) QID %d timeout, reset controller\n",
1351+
req->tag, nvme_cid(req), opcode,
1352+
nvme_opcode_str(nvmeq->qid, opcode, 0), nvmeq->qid);
13501353
nvme_req(req)->flags |= NVME_REQ_CANCELLED;
13511354
goto disable;
13521355
}
@@ -1362,10 +1365,10 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req)
13621365
cmd.abort.sqid = cpu_to_le16(nvmeq->qid);
13631366

13641367
dev_warn(nvmeq->dev->ctrl.device,
1365-
"I/O %d (%s) QID %d timeout, aborting\n",
1366-
req->tag,
1367-
nvme_get_opcode_str(nvme_req(req)->cmd->common.opcode),
1368-
nvmeq->qid);
1368+
"I/O tag %d (%04x) opcode %#x (%s) QID %d timeout, aborting req_op:%s(%u) size:%u\n",
1369+
req->tag, nvme_cid(req), opcode, nvme_get_opcode_str(opcode),
1370+
nvmeq->qid, blk_op_str(req_op(req)), req_op(req),
1371+
blk_rq_bytes(req));
13691372

13701373
abort_req = blk_mq_alloc_request(dev->ctrl.admin_q, nvme_req_op(&cmd),
13711374
BLK_MQ_REQ_NOWAIT);
@@ -2743,10 +2746,10 @@ static void nvme_reset_work(struct work_struct *work)
27432746
* controller around but remove all namespaces.
27442747
*/
27452748
if (dev->online_queues > 1) {
2749+
nvme_dbbuf_set(dev);
27462750
nvme_unquiesce_io_queues(&dev->ctrl);
27472751
nvme_wait_freeze(&dev->ctrl);
27482752
nvme_pci_update_nr_queues(dev);
2749-
nvme_dbbuf_set(dev);
27502753
nvme_unfreeze(&dev->ctrl);
27512754
} else {
27522755
dev_warn(dev->ctrl.device, "IO queues lost\n");
@@ -3394,6 +3397,8 @@ static const struct pci_device_id nvme_id_table[] = {
33943397
.driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, },
33953398
{ PCI_DEVICE(0x1c5c, 0x174a), /* SK Hynix P31 SSD */
33963399
.driver_data = NVME_QUIRK_BOGUS_NID, },
3400+
{ PCI_DEVICE(0x1c5c, 0x1D59), /* SK Hynix BC901 */
3401+
.driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, },
33973402
{ PCI_DEVICE(0x15b7, 0x2001), /* Sandisk Skyhawk */
33983403
.driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, },
33993404
{ PCI_DEVICE(0x1d97, 0x2263), /* SPCC */

drivers/nvme/host/pr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static int nvme_send_pr_command(struct block_device *bdev,
9898
struct nvme_command *c, void *data, unsigned int data_len)
9999
{
100100
if (IS_ENABLED(CONFIG_NVME_MULTIPATH) &&
101-
bdev->bd_disk->fops == &nvme_ns_head_ops)
101+
nvme_disk_is_ns_head(bdev->bd_disk))
102102
return nvme_send_ns_head_pr_command(bdev, c, data, data_len);
103103

104104
return nvme_send_ns_pr_command(bdev->bd_disk->private_data, c, data,

drivers/nvme/host/rdma.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,9 +1941,14 @@ static enum blk_eh_timer_return nvme_rdma_timeout(struct request *rq)
19411941
struct nvme_rdma_request *req = blk_mq_rq_to_pdu(rq);
19421942
struct nvme_rdma_queue *queue = req->queue;
19431943
struct nvme_rdma_ctrl *ctrl = queue->ctrl;
1944-
1945-
dev_warn(ctrl->ctrl.device, "I/O %d QID %d timeout\n",
1946-
rq->tag, nvme_rdma_queue_idx(queue));
1944+
u8 opcode = req->req.cmd->common.opcode;
1945+
u8 fctype = req->req.cmd->fabrics.fctype;
1946+
int qid = nvme_rdma_queue_idx(queue);
1947+
1948+
dev_warn(ctrl->ctrl.device,
1949+
"I/O tag %d (%04x) opcode %#x (%s) QID %d timeout\n",
1950+
rq->tag, nvme_cid(rq), opcode,
1951+
nvme_opcode_str(qid, opcode, fctype), qid);
19471952

19481953
if (ctrl->ctrl.state != NVME_CTRL_LIVE) {
19491954
/*

drivers/nvme/host/sysfs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ static inline struct nvme_ns_head *dev_to_ns_head(struct device *dev)
3939
{
4040
struct gendisk *disk = dev_to_disk(dev);
4141

42-
if (disk->fops == &nvme_bdev_ops)
43-
return nvme_get_ns_from_dev(dev)->head;
44-
else
42+
if (nvme_disk_is_ns_head(disk))
4543
return disk->private_data;
44+
return nvme_get_ns_from_dev(dev)->head;
4645
}
4746

4847
static ssize_t wwid_show(struct device *dev, struct device_attribute *attr,
@@ -233,7 +232,8 @@ static umode_t nvme_ns_attrs_are_visible(struct kobject *kobj,
233232
}
234233
#ifdef CONFIG_NVME_MULTIPATH
235234
if (a == &dev_attr_ana_grpid.attr || a == &dev_attr_ana_state.attr) {
236-
if (dev_to_disk(dev)->fops != &nvme_bdev_ops) /* per-path attr */
235+
/* per-path attr */
236+
if (nvme_disk_is_ns_head(dev_to_disk(dev)))
237237
return 0;
238238
if (!nvme_ctrl_use_ana(nvme_get_ns_from_dev(dev)->ctrl))
239239
return 0;

drivers/nvme/host/tcp.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,14 +1922,13 @@ static int nvme_tcp_alloc_admin_queue(struct nvme_ctrl *ctrl)
19221922
ctrl->opts->subsysnqn);
19231923
if (!pskid) {
19241924
dev_err(ctrl->device, "no valid PSK found\n");
1925-
ret = -ENOKEY;
1926-
goto out_free_queue;
1925+
return -ENOKEY;
19271926
}
19281927
}
19291928

19301929
ret = nvme_tcp_alloc_queue(ctrl, 0, pskid);
19311930
if (ret)
1932-
goto out_free_queue;
1931+
return ret;
19331932

19341933
ret = nvme_tcp_alloc_async_req(to_tcp_ctrl(ctrl));
19351934
if (ret)
@@ -2426,9 +2425,9 @@ static enum blk_eh_timer_return nvme_tcp_timeout(struct request *rq)
24262425
int qid = nvme_tcp_queue_id(req->queue);
24272426

24282427
dev_warn(ctrl->device,
2429-
"queue %d: timeout cid %#x type %d opcode %#x (%s)\n",
2430-
nvme_tcp_queue_id(req->queue), nvme_cid(rq), pdu->hdr.type,
2431-
opc, nvme_opcode_str(qid, opc, fctype));
2428+
"I/O tag %d (%04x) type %d opcode %#x (%s) QID %d timeout\n",
2429+
rq->tag, nvme_cid(rq), pdu->hdr.type, opc,
2430+
nvme_opcode_str(qid, opc, fctype), qid);
24322431

24332432
if (ctrl->state != NVME_CTRL_LIVE) {
24342433
/*

drivers/nvme/target/fc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ nvmet_fc_match_hostport(struct nvmet_fc_tgtport *tgtport, void *hosthandle)
10311031
list_for_each_entry(host, &tgtport->host_list, host_list) {
10321032
if (host->hosthandle == hosthandle && !host->invalid) {
10331033
if (nvmet_fc_hostport_get(host))
1034-
return (host);
1034+
return host;
10351035
}
10361036
}
10371037

drivers/nvme/target/fcloop.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -995,11 +995,6 @@ fcloop_nport_free(struct kref *ref)
995995
{
996996
struct fcloop_nport *nport =
997997
container_of(ref, struct fcloop_nport, ref);
998-
unsigned long flags;
999-
1000-
spin_lock_irqsave(&fcloop_lock, flags);
1001-
list_del(&nport->nport_list);
1002-
spin_unlock_irqrestore(&fcloop_lock, flags);
1003998

1004999
kfree(nport);
10051000
}
@@ -1357,6 +1352,8 @@ __unlink_remote_port(struct fcloop_nport *nport)
13571352
nport->tport->remoteport = NULL;
13581353
nport->rport = NULL;
13591354

1355+
list_del(&nport->nport_list);
1356+
13601357
return rport;
13611358
}
13621359

0 commit comments

Comments
 (0)