diff options
Diffstat (limited to 'drivers/nvme/host/fabrics.c')
-rw-r--r-- | drivers/nvme/host/fabrics.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c index dc996761042f..4eff49174466 100644 --- a/drivers/nvme/host/fabrics.c +++ b/drivers/nvme/host/fabrics.c | |||
@@ -47,8 +47,10 @@ static struct nvmf_host *nvmf_host_add(const char *hostnqn) | |||
47 | 47 | ||
48 | mutex_lock(&nvmf_hosts_mutex); | 48 | mutex_lock(&nvmf_hosts_mutex); |
49 | host = __nvmf_host_find(hostnqn); | 49 | host = __nvmf_host_find(hostnqn); |
50 | if (host) | 50 | if (host) { |
51 | kref_get(&host->ref); | ||
51 | goto out_unlock; | 52 | goto out_unlock; |
53 | } | ||
52 | 54 | ||
53 | host = kmalloc(sizeof(*host), GFP_KERNEL); | 55 | host = kmalloc(sizeof(*host), GFP_KERNEL); |
54 | if (!host) | 56 | if (!host) |
@@ -56,7 +58,7 @@ static struct nvmf_host *nvmf_host_add(const char *hostnqn) | |||
56 | 58 | ||
57 | kref_init(&host->ref); | 59 | kref_init(&host->ref); |
58 | memcpy(host->nqn, hostnqn, NVMF_NQN_SIZE); | 60 | memcpy(host->nqn, hostnqn, NVMF_NQN_SIZE); |
59 | uuid_le_gen(&host->id); | 61 | uuid_be_gen(&host->id); |
60 | 62 | ||
61 | list_add_tail(&host->list, &nvmf_hosts); | 63 | list_add_tail(&host->list, &nvmf_hosts); |
62 | out_unlock: | 64 | out_unlock: |
@@ -73,9 +75,9 @@ static struct nvmf_host *nvmf_host_default(void) | |||
73 | return NULL; | 75 | return NULL; |
74 | 76 | ||
75 | kref_init(&host->ref); | 77 | kref_init(&host->ref); |
76 | uuid_le_gen(&host->id); | 78 | uuid_be_gen(&host->id); |
77 | snprintf(host->nqn, NVMF_NQN_SIZE, | 79 | snprintf(host->nqn, NVMF_NQN_SIZE, |
78 | "nqn.2014-08.org.nvmexpress:NVMf:uuid:%pUl", &host->id); | 80 | "nqn.2014-08.org.nvmexpress:NVMf:uuid:%pUb", &host->id); |
79 | 81 | ||
80 | mutex_lock(&nvmf_hosts_mutex); | 82 | mutex_lock(&nvmf_hosts_mutex); |
81 | list_add_tail(&host->list, &nvmf_hosts); | 83 | list_add_tail(&host->list, &nvmf_hosts); |
@@ -363,7 +365,14 @@ int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl) | |||
363 | cmd.connect.opcode = nvme_fabrics_command; | 365 | cmd.connect.opcode = nvme_fabrics_command; |
364 | cmd.connect.fctype = nvme_fabrics_type_connect; | 366 | cmd.connect.fctype = nvme_fabrics_type_connect; |
365 | cmd.connect.qid = 0; | 367 | cmd.connect.qid = 0; |
366 | cmd.connect.sqsize = cpu_to_le16(ctrl->sqsize); | 368 | |
369 | /* | ||
370 | * fabrics spec sets a minimum of depth 32 for admin queue, | ||
371 | * so set the queue with this depth always until | ||
372 | * justification otherwise. | ||
373 | */ | ||
374 | cmd.connect.sqsize = cpu_to_le16(NVMF_AQ_DEPTH - 1); | ||
375 | |||
367 | /* | 376 | /* |
368 | * Set keep-alive timeout in seconds granularity (ms * 1000) | 377 | * Set keep-alive timeout in seconds granularity (ms * 1000) |
369 | * and add a grace period for controller kato enforcement | 378 | * and add a grace period for controller kato enforcement |
@@ -375,7 +384,7 @@ int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl) | |||
375 | if (!data) | 384 | if (!data) |
376 | return -ENOMEM; | 385 | return -ENOMEM; |
377 | 386 | ||
378 | memcpy(&data->hostid, &ctrl->opts->host->id, sizeof(uuid_le)); | 387 | memcpy(&data->hostid, &ctrl->opts->host->id, sizeof(uuid_be)); |
379 | data->cntlid = cpu_to_le16(0xffff); | 388 | data->cntlid = cpu_to_le16(0xffff); |
380 | strncpy(data->subsysnqn, ctrl->opts->subsysnqn, NVMF_NQN_SIZE); | 389 | strncpy(data->subsysnqn, ctrl->opts->subsysnqn, NVMF_NQN_SIZE); |
381 | strncpy(data->hostnqn, ctrl->opts->host->nqn, NVMF_NQN_SIZE); | 390 | strncpy(data->hostnqn, ctrl->opts->host->nqn, NVMF_NQN_SIZE); |
@@ -434,7 +443,7 @@ int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid) | |||
434 | if (!data) | 443 | if (!data) |
435 | return -ENOMEM; | 444 | return -ENOMEM; |
436 | 445 | ||
437 | memcpy(&data->hostid, &ctrl->opts->host->id, sizeof(uuid_le)); | 446 | memcpy(&data->hostid, &ctrl->opts->host->id, sizeof(uuid_be)); |
438 | data->cntlid = cpu_to_le16(ctrl->cntlid); | 447 | data->cntlid = cpu_to_le16(ctrl->cntlid); |
439 | strncpy(data->subsysnqn, ctrl->opts->subsysnqn, NVMF_NQN_SIZE); | 448 | strncpy(data->subsysnqn, ctrl->opts->subsysnqn, NVMF_NQN_SIZE); |
440 | strncpy(data->hostnqn, ctrl->opts->host->nqn, NVMF_NQN_SIZE); | 449 | strncpy(data->hostnqn, ctrl->opts->host->nqn, NVMF_NQN_SIZE); |