]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
nvme: check namespace head shared property
authorKeith Busch <kbusch@kernel.org>
Thu, 9 Apr 2020 16:09:02 +0000 (09:09 -0700)
committerJens Axboe <axboe@kernel.dk>
Sat, 9 May 2020 22:18:35 +0000 (16:18 -0600)
Reject a new shared namespace if a duplicate unshared namespace exists.

Signed-off-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/nvme/host/core.c
drivers/nvme/host/nvme.h

index 6093c8baf80992dae84224ef12c696e962183720..6437f2273785a3c66416fdc69b11f3e4700165be 100644 (file)
@@ -3496,8 +3496,9 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid,
                        ret = PTR_ERR(head);
                        goto out_unlock;
                }
+               head->shared = is_shared;
        } else {
-               if (!is_shared) {
+               if (!is_shared || !head->shared) {
                        dev_err(ctrl->device,
                                "Duplicate unshared namespace %d\n",
                                        nsid);
index 36f44b79bb3bd3aae7d08cb44a926bea23bf4a4e..6222439a077653a1c1bce86fbfb1065fa6e8a6a7 100644 (file)
@@ -352,6 +352,7 @@ struct nvme_ns_head {
        struct nvme_ns_ids      ids;
        struct list_head        entry;
        struct kref             ref;
+       bool                    shared;
        int                     instance;
 #ifdef CONFIG_NVME_MULTIPATH
        struct gendisk          *disk;