mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-03 06:25:23 -04:00
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
This commit is contained in:
@@ -562,7 +562,7 @@ static int nvme_parse_ana_log(struct nvme_ctrl *ctrl, void *data,
|
||||
return -EINVAL;
|
||||
|
||||
nr_nsids = le32_to_cpu(desc->nnsids);
|
||||
nsid_buf_size = nr_nsids * sizeof(__le32);
|
||||
nsid_buf_size = flex_array_size(desc, nsids, nr_nsids);
|
||||
|
||||
if (WARN_ON_ONCE(desc->grpid == 0))
|
||||
return -EINVAL;
|
||||
|
||||
@@ -264,7 +264,7 @@ static u32 nvmet_format_ana_group(struct nvmet_req *req, u32 grpid,
|
||||
desc->chgcnt = cpu_to_le64(nvmet_ana_chgcnt);
|
||||
desc->state = req->port->ana_state[grpid];
|
||||
memset(desc->rsvd17, 0, sizeof(desc->rsvd17));
|
||||
return sizeof(struct nvme_ana_group_desc) + count * sizeof(__le32);
|
||||
return struct_size(desc, nsids, count);
|
||||
}
|
||||
|
||||
static void nvmet_execute_get_log_page_ana(struct nvmet_req *req)
|
||||
|
||||
@@ -1541,6 +1541,7 @@ struct nvmet_subsys *nvmet_subsys_alloc(const char *subsysnqn,
|
||||
subsys->max_qid = NVMET_NR_QUEUES;
|
||||
break;
|
||||
case NVME_NQN_DISC:
|
||||
case NVME_NQN_CURR:
|
||||
subsys->max_qid = 0;
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -146,7 +146,7 @@ static size_t discovery_log_entries(struct nvmet_req *req)
|
||||
struct nvmet_ctrl *ctrl = req->sq->ctrl;
|
||||
struct nvmet_subsys_link *p;
|
||||
struct nvmet_port *r;
|
||||
size_t entries = 0;
|
||||
size_t entries = 1;
|
||||
|
||||
list_for_each_entry(p, &req->port->subsystems, entry) {
|
||||
if (!nvmet_host_allowed(p->subsys, ctrl->hostnqn))
|
||||
@@ -171,6 +171,7 @@ static void nvmet_execute_disc_get_log_page(struct nvmet_req *req)
|
||||
u32 numrec = 0;
|
||||
u16 status = 0;
|
||||
void *buffer;
|
||||
char traddr[NVMF_TRADDR_SIZE];
|
||||
|
||||
if (!nvmet_check_transfer_len(req, data_len))
|
||||
return;
|
||||
@@ -203,15 +204,19 @@ static void nvmet_execute_disc_get_log_page(struct nvmet_req *req)
|
||||
status = NVME_SC_INTERNAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
hdr = buffer;
|
||||
list_for_each_entry(p, &req->port->subsystems, entry) {
|
||||
char traddr[NVMF_TRADDR_SIZE];
|
||||
|
||||
nvmet_set_disc_traddr(req, req->port, traddr);
|
||||
|
||||
nvmet_format_discovery_entry(hdr, req->port,
|
||||
nvmet_disc_subsys->subsysnqn,
|
||||
traddr, NVME_NQN_CURR, numrec);
|
||||
numrec++;
|
||||
|
||||
list_for_each_entry(p, &req->port->subsystems, entry) {
|
||||
if (!nvmet_host_allowed(p->subsys, ctrl->hostnqn))
|
||||
continue;
|
||||
|
||||
nvmet_set_disc_traddr(req, req->port, traddr);
|
||||
nvmet_format_discovery_entry(hdr, req->port,
|
||||
p->subsys->subsysnqn, traddr,
|
||||
NVME_NQN_NVME, numrec);
|
||||
@@ -389,7 +394,7 @@ u16 nvmet_parse_discovery_cmd(struct nvmet_req *req)
|
||||
int __init nvmet_init_discovery(void)
|
||||
{
|
||||
nvmet_disc_subsys =
|
||||
nvmet_subsys_alloc(NVME_DISC_SUBSYS_NAME, NVME_NQN_DISC);
|
||||
nvmet_subsys_alloc(NVME_DISC_SUBSYS_NAME, NVME_NQN_CURR);
|
||||
return PTR_ERR_OR_ZERO(nvmet_disc_subsys);
|
||||
}
|
||||
|
||||
|
||||
@@ -579,7 +579,7 @@ static inline struct nvmet_subsys *nvmet_req_subsys(struct nvmet_req *req)
|
||||
|
||||
static inline bool nvmet_is_disc_subsys(struct nvmet_subsys *subsys)
|
||||
{
|
||||
return subsys->type == NVME_NQN_DISC;
|
||||
return subsys->type != NVME_NQN_NVME;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_NVME_TARGET_PASSTHRU
|
||||
|
||||
@@ -27,8 +27,14 @@
|
||||
#define NVME_NSID_ALL 0xffffffff
|
||||
|
||||
enum nvme_subsys_type {
|
||||
NVME_NQN_DISC = 1, /* Discovery type target subsystem */
|
||||
NVME_NQN_NVME = 2, /* NVME type target subsystem */
|
||||
/* Referral to another discovery type target subsystem */
|
||||
NVME_NQN_DISC = 1,
|
||||
|
||||
/* NVME type target subsystem */
|
||||
NVME_NQN_NVME = 2,
|
||||
|
||||
/* Current discovery type target subsystem */
|
||||
NVME_NQN_CURR = 3,
|
||||
};
|
||||
|
||||
enum nvme_ctrl_type {
|
||||
@@ -1312,6 +1318,12 @@ struct nvmf_common_command {
|
||||
|
||||
#define MAX_DISC_LOGS 255
|
||||
|
||||
/* Discovery log page entry flags (EFLAGS): */
|
||||
enum {
|
||||
NVME_DISC_EFLAGS_EPCSD = (1 << 1),
|
||||
NVME_DISC_EFLAGS_DUPRETINFO = (1 << 0),
|
||||
};
|
||||
|
||||
/* Discovery log page entry */
|
||||
struct nvmf_disc_rsp_page_entry {
|
||||
__u8 trtype;
|
||||
@@ -1321,7 +1333,8 @@ struct nvmf_disc_rsp_page_entry {
|
||||
__le16 portid;
|
||||
__le16 cntlid;
|
||||
__le16 asqsz;
|
||||
__u8 resv8[22];
|
||||
__le16 eflags;
|
||||
__u8 resv10[20];
|
||||
char trsvcid[NVMF_TRSVCID_SIZE];
|
||||
__u8 resv64[192];
|
||||
char subnqn[NVMF_NQN_FIELD_LEN];
|
||||
|
||||
Reference in New Issue
Block a user