Commit 9ad1927a authored by Keith Busch's avatar Keith Busch Committed by Jens Axboe
Browse files

nvme: always search for namespace head



Even if a namespace reports it is not capable of sharing, search the
subsystem for a matching namespace head. If found, the driver should
reject that namespace since it's coming from an invalid configuration.

Signed-off-by: default avatarKeith Busch <kbusch@kernel.org>
Reviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent ac262508
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -3489,7 +3489,6 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid,
		goto out;

	mutex_lock(&ctrl->subsys->lock);
	if (is_shared)
	head = nvme_find_ns_head(ctrl->subsys, nsid);
	if (!head) {
		head = nvme_alloc_ns_head(ctrl, nsid, &ids);
@@ -3498,6 +3497,14 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid,
			goto out_unlock;
		}
	} else {
		if (!is_shared) {
			dev_err(ctrl->device,
				"Duplicate unshared namespace %d\n",
					nsid);
			ret = -EINVAL;
			nvme_put_ns_head(head);
			goto out_unlock;
		}
		if (!nvme_ns_ids_equal(&head->ids, &ids)) {
			dev_err(ctrl->device,
				"IDs don't match for shared namespace %d\n",