Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'nvme-5.16-2021-10-28' of git://git.infradead.org/nvme into for-5.16/drivers

Pull NVMe updates from Christoph:

"nvme updates for Linux 5.16

- support the current discovery subsystem entry (Hannes Reinecke)
- use flex_array_size and struct_size (Len Baker)"

* tag 'nvme-5.16-2021-10-28' of git://git.infradead.org/nvme:
nvmet: use flex_array_size and struct_size
nvmet: register discovery subsystem as 'current'
nvmet: switch check for subsystem type
nvme: add new discovery log page entry definitions

+31 -12
+1 -1
drivers/nvme/host/multipath.c
··· 562 562 return -EINVAL; 563 563 564 564 nr_nsids = le32_to_cpu(desc->nnsids); 565 - nsid_buf_size = nr_nsids * sizeof(__le32); 565 + nsid_buf_size = flex_array_size(desc, nsids, nr_nsids); 566 566 567 567 if (WARN_ON_ONCE(desc->grpid == 0)) 568 568 return -EINVAL;
+1 -1
drivers/nvme/target/admin-cmd.c
··· 264 264 desc->chgcnt = cpu_to_le64(nvmet_ana_chgcnt); 265 265 desc->state = req->port->ana_state[grpid]; 266 266 memset(desc->rsvd17, 0, sizeof(desc->rsvd17)); 267 - return sizeof(struct nvme_ana_group_desc) + count * sizeof(__le32); 267 + return struct_size(desc, nsids, count); 268 268 } 269 269 270 270 static void nvmet_execute_get_log_page_ana(struct nvmet_req *req)
+1
drivers/nvme/target/core.c
··· 1541 1541 subsys->max_qid = NVMET_NR_QUEUES; 1542 1542 break; 1543 1543 case NVME_NQN_DISC: 1544 + case NVME_NQN_CURR: 1544 1545 subsys->max_qid = 0; 1545 1546 break; 1546 1547 default:
+11 -6
drivers/nvme/target/discovery.c
··· 146 146 struct nvmet_ctrl *ctrl = req->sq->ctrl; 147 147 struct nvmet_subsys_link *p; 148 148 struct nvmet_port *r; 149 - size_t entries = 0; 149 + size_t entries = 1; 150 150 151 151 list_for_each_entry(p, &req->port->subsystems, entry) { 152 152 if (!nvmet_host_allowed(p->subsys, ctrl->hostnqn)) ··· 171 171 u32 numrec = 0; 172 172 u16 status = 0; 173 173 void *buffer; 174 + char traddr[NVMF_TRADDR_SIZE]; 174 175 175 176 if (!nvmet_check_transfer_len(req, data_len)) 176 177 return; ··· 204 203 status = NVME_SC_INTERNAL; 205 204 goto out; 206 205 } 207 - 208 206 hdr = buffer; 209 - list_for_each_entry(p, &req->port->subsystems, entry) { 210 - char traddr[NVMF_TRADDR_SIZE]; 211 207 208 + nvmet_set_disc_traddr(req, req->port, traddr); 209 + 210 + nvmet_format_discovery_entry(hdr, req->port, 211 + nvmet_disc_subsys->subsysnqn, 212 + traddr, NVME_NQN_CURR, numrec); 213 + numrec++; 214 + 215 + list_for_each_entry(p, &req->port->subsystems, entry) { 212 216 if (!nvmet_host_allowed(p->subsys, ctrl->hostnqn)) 213 217 continue; 214 218 215 - nvmet_set_disc_traddr(req, req->port, traddr); 216 219 nvmet_format_discovery_entry(hdr, req->port, 217 220 p->subsys->subsysnqn, traddr, 218 221 NVME_NQN_NVME, numrec); ··· 394 389 int __init nvmet_init_discovery(void) 395 390 { 396 391 nvmet_disc_subsys = 397 - nvmet_subsys_alloc(NVME_DISC_SUBSYS_NAME, NVME_NQN_DISC); 392 + nvmet_subsys_alloc(NVME_DISC_SUBSYS_NAME, NVME_NQN_CURR); 398 393 return PTR_ERR_OR_ZERO(nvmet_disc_subsys); 399 394 } 400 395
+1 -1
drivers/nvme/target/nvmet.h
··· 579 579 580 580 static inline bool nvmet_is_disc_subsys(struct nvmet_subsys *subsys) 581 581 { 582 - return subsys->type == NVME_NQN_DISC; 582 + return subsys->type != NVME_NQN_NVME; 583 583 } 584 584 585 585 #ifdef CONFIG_NVME_TARGET_PASSTHRU
+16 -3
include/linux/nvme.h
··· 27 27 #define NVME_NSID_ALL 0xffffffff 28 28 29 29 enum nvme_subsys_type { 30 - NVME_NQN_DISC = 1, /* Discovery type target subsystem */ 31 - NVME_NQN_NVME = 2, /* NVME type target subsystem */ 30 + /* Referral to another discovery type target subsystem */ 31 + NVME_NQN_DISC = 1, 32 + 33 + /* NVME type target subsystem */ 34 + NVME_NQN_NVME = 2, 35 + 36 + /* Current discovery type target subsystem */ 37 + NVME_NQN_CURR = 3, 32 38 }; 33 39 34 40 enum nvme_ctrl_type { ··· 1318 1312 1319 1313 #define MAX_DISC_LOGS 255 1320 1314 1315 + /* Discovery log page entry flags (EFLAGS): */ 1316 + enum { 1317 + NVME_DISC_EFLAGS_EPCSD = (1 << 1), 1318 + NVME_DISC_EFLAGS_DUPRETINFO = (1 << 0), 1319 + }; 1320 + 1321 1321 /* Discovery log page entry */ 1322 1322 struct nvmf_disc_rsp_page_entry { 1323 1323 __u8 trtype; ··· 1333 1321 __le16 portid; 1334 1322 __le16 cntlid; 1335 1323 __le16 asqsz; 1336 - __u8 resv8[22]; 1324 + __le16 eflags; 1325 + __u8 resv10[20]; 1337 1326 char trsvcid[NVMF_TRSVCID_SIZE]; 1338 1327 __u8 resv64[192]; 1339 1328 char subnqn[NVMF_NQN_FIELD_LEN];