Skip to content

Commit 326ac2c

Browse files
committed
Merge tag 'nvme-6.3-2022-03-01' of git://git.infradead.org/nvme into for-6.3/block
Pull NVMe fixes from Christoph: "nvme fixes for Linux 6.3 - don't access released socket during error recovery (Akinobu Mita) - bring back auto-removal of deleted namespaces during sequential scan (Christoph Hellwig) - fix an error code in nvme_auth_process_dhchap_challenge (Dan Carpenter) - show well known discovery name (Daniel Wagner) - add a missing endianess conversion in effects masking (Keith Busch)" * tag 'nvme-6.3-2022-03-01' of git://git.infradead.org/nvme: nvme-fabrics: show well known discovery name nvme-tcp: don't access released socket during error recovery nvme-auth: fix an error code in nvme_auth_process_dhchap_challenge() nvme: bring back auto-removal of deleted namespaces during sequential scan nvme: fix sparse warning on effects masking
2 parents e33b936 + 26a57cb commit 326ac2c

File tree

4 files changed

+28
-20
lines changed

4 files changed

+28
-20
lines changed

drivers/nvme/host/auth.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ static int nvme_auth_process_dhchap_challenge(struct nvme_ctrl *ctrl,
254254
chap->qid, ret, gid_name);
255255
chap->status = NVME_AUTH_DHCHAP_FAILURE_DHGROUP_UNUSABLE;
256256
chap->dh_tfm = NULL;
257-
return -ret;
257+
return ret;
258258
}
259259
dev_dbg(ctrl->device, "qid %d: selected DH group %s\n",
260260
chap->qid, gid_name);

drivers/nvme/host/core.c

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ struct nvme_ns_info {
3838
bool is_shared;
3939
bool is_readonly;
4040
bool is_ready;
41+
bool is_removed;
4142
};
4243

4344
unsigned int admin_timeout = 60;
@@ -1402,16 +1403,8 @@ static int nvme_identify_ns(struct nvme_ctrl *ctrl, unsigned nsid,
14021403
error = nvme_submit_sync_cmd(ctrl->admin_q, &c, *id, sizeof(**id));
14031404
if (error) {
14041405
dev_warn(ctrl->device, "Identify namespace failed (%d)\n", error);
1405-
goto out_free_id;
1406+
kfree(*id);
14061407
}
1407-
1408-
error = NVME_SC_INVALID_NS | NVME_SC_DNR;
1409-
if ((*id)->ncap == 0) /* namespace not allocated or attached */
1410-
goto out_free_id;
1411-
return 0;
1412-
1413-
out_free_id:
1414-
kfree(*id);
14151408
return error;
14161409
}
14171410

@@ -1425,6 +1418,13 @@ static int nvme_ns_info_from_identify(struct nvme_ctrl *ctrl,
14251418
ret = nvme_identify_ns(ctrl, info->nsid, &id);
14261419
if (ret)
14271420
return ret;
1421+
1422+
if (id->ncap == 0) {
1423+
/* namespace not allocated or attached */
1424+
info->is_removed = true;
1425+
return -ENODEV;
1426+
}
1427+
14281428
info->anagrpid = id->anagrpid;
14291429
info->is_shared = id->nmic & NVME_NS_NMIC_SHARED;
14301430
info->is_readonly = id->nsattr & NVME_NS_ATTR_RO;
@@ -3104,7 +3104,7 @@ static void nvme_init_known_nvm_effects(struct nvme_ctrl *ctrl)
31043104
* Rather than blindly freezing the IO queues for this effect that
31053105
* doesn't even apply to IO, mask it off.
31063106
*/
3107-
log->acs[nvme_admin_security_recv] &= ~NVME_CMD_EFFECTS_CSE_MASK;
3107+
log->acs[nvme_admin_security_recv] &= cpu_to_le32(~NVME_CMD_EFFECTS_CSE_MASK);
31083108

31093109
log->iocs[nvme_cmd_write] |= cpu_to_le32(NVME_CMD_EFFECTS_LBCC);
31103110
log->iocs[nvme_cmd_write_zeroes] |= cpu_to_le32(NVME_CMD_EFFECTS_LBCC);
@@ -4429,6 +4429,7 @@ static void nvme_scan_ns(struct nvme_ctrl *ctrl, unsigned nsid)
44294429
{
44304430
struct nvme_ns_info info = { .nsid = nsid };
44314431
struct nvme_ns *ns;
4432+
int ret;
44324433

44334434
if (nvme_identify_ns_descs(ctrl, &info))
44344435
return;
@@ -4445,19 +4446,19 @@ static void nvme_scan_ns(struct nvme_ctrl *ctrl, unsigned nsid)
44454446
* set up a namespace. If not fall back to the legacy version.
44464447
*/
44474448
if ((ctrl->cap & NVME_CAP_CRMS_CRIMS) ||
4448-
(info.ids.csi != NVME_CSI_NVM && info.ids.csi != NVME_CSI_ZNS)) {
4449-
if (nvme_ns_info_from_id_cs_indep(ctrl, &info))
4450-
return;
4451-
} else {
4452-
if (nvme_ns_info_from_identify(ctrl, &info))
4453-
return;
4454-
}
4449+
(info.ids.csi != NVME_CSI_NVM && info.ids.csi != NVME_CSI_ZNS))
4450+
ret = nvme_ns_info_from_id_cs_indep(ctrl, &info);
4451+
else
4452+
ret = nvme_ns_info_from_identify(ctrl, &info);
4453+
4454+
if (info.is_removed)
4455+
nvme_ns_remove_by_nsid(ctrl, nsid);
44554456

44564457
/*
44574458
* Ignore the namespace if it is not ready. We will get an AEN once it
44584459
* becomes ready and restart the scan.
44594460
*/
4460-
if (!info.is_ready)
4461+
if (ret || !info.is_ready)
44614462
return;
44624463

44634464
ns = nvme_find_get_ns(ctrl, nsid);

drivers/nvme/host/fabrics.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ nvmf_ctlr_matches_baseopts(struct nvme_ctrl *ctrl,
189189

190190
static inline char *nvmf_ctrl_subsysnqn(struct nvme_ctrl *ctrl)
191191
{
192-
if (!ctrl->subsys)
192+
if (!ctrl->subsys ||
193+
!strcmp(ctrl->opts->subsysnqn, NVME_DISC_SUBSYS_NAME))
193194
return ctrl->opts->subsysnqn;
194195
return ctrl->subsys->subnqn;
195196
}

drivers/nvme/host/tcp.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2489,13 +2489,19 @@ static int nvme_tcp_get_address(struct nvme_ctrl *ctrl, char *buf, int size)
24892489

24902490
len = nvmf_get_address(ctrl, buf, size);
24912491

2492+
mutex_lock(&queue->queue_lock);
2493+
2494+
if (!test_bit(NVME_TCP_Q_LIVE, &queue->flags))
2495+
goto done;
24922496
ret = kernel_getsockname(queue->sock, (struct sockaddr *)&src_addr);
24932497
if (ret > 0) {
24942498
if (len > 0)
24952499
len--; /* strip trailing newline */
24962500
len += scnprintf(buf + len, size - len, "%ssrc_addr=%pISc\n",
24972501
(len) ? "," : "", &src_addr);
24982502
}
2503+
done:
2504+
mutex_unlock(&queue->queue_lock);
24992505

25002506
return len;
25012507
}

0 commit comments

Comments
 (0)