Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nvme: enable generic interface (/dev/ngXnY) for unknown command sets

Extend nvme_alloc_ns() and nvme_validate_ns() for unknown command-set as
well. Both are made to use a new helper (nvme_update_ns_info_cs_indep)
which is similar to nvme_update_ns_info but performs fewer operations
to get the generic interface up.

Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Joel Granados <j.granados@samsung.com>
Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
[hch: rebased on other refactoring patches]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Javier González <javier.gonz@samsung.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Joel Granados and committed by
Jens Axboe
eb867ee9 1e4ea66a

+34 -7
+34 -7
drivers/nvme/host/core.c
··· 1954 1954 blk_queue_chunk_sectors(ns->queue, iob); 1955 1955 } 1956 1956 1957 + static int nvme_update_ns_info_generic(struct nvme_ns *ns, 1958 + struct nvme_ns_info *info) 1959 + { 1960 + blk_mq_freeze_queue(ns->disk->queue); 1961 + nvme_set_queue_limits(ns->ctrl, ns->queue); 1962 + set_disk_ro(ns->disk, nvme_ns_is_readonly(ns, info)); 1963 + blk_mq_unfreeze_queue(ns->disk->queue); 1964 + 1965 + if (nvme_ns_head_multipath(ns->head)) { 1966 + blk_mq_freeze_queue(ns->head->disk->queue); 1967 + set_disk_ro(ns->head->disk, nvme_ns_is_readonly(ns, info)); 1968 + nvme_mpath_revalidate_paths(ns); 1969 + blk_stack_limits(&ns->head->disk->queue->limits, 1970 + &ns->queue->limits, 0); 1971 + ns->head->disk->flags |= GENHD_FL_HIDDEN; 1972 + blk_mq_unfreeze_queue(ns->head->disk->queue); 1973 + } 1974 + 1975 + /* Hide the block-interface for these devices */ 1976 + ns->disk->flags |= GENHD_FL_HIDDEN; 1977 + set_bit(NVME_NS_READY, &ns->flags); 1978 + 1979 + return 0; 1980 + } 1981 + 1957 1982 static int nvme_update_ns_info_block(struct nvme_ns *ns, 1958 1983 struct nvme_ns_info *info) 1959 1984 { ··· 2048 2023 switch (info->ids.csi) { 2049 2024 case NVME_CSI_ZNS: 2050 2025 if (!IS_ENABLED(CONFIG_BLK_DEV_ZONED)) { 2051 - dev_warn(ns->ctrl->device, 2052 - "nsid %u not supported without CONFIG_BLK_DEV_ZONED\n", 2026 + dev_info(ns->ctrl->device, 2027 + "block device for nsid %u not supported without CONFIG_BLK_DEV_ZONED\n", 2053 2028 info->nsid); 2054 - return -ENODEV; 2029 + return nvme_update_ns_info_generic(ns, info); 2055 2030 } 2056 2031 return nvme_update_ns_info_block(ns, info); 2057 2032 case NVME_CSI_NVM: 2058 2033 return nvme_update_ns_info_block(ns, info); 2059 2034 default: 2060 - dev_warn(ns->ctrl->device, "unknown csi %u for nsid %u\n", 2061 - info->ids.csi, info->nsid); 2062 - return -ENODEV; 2035 + dev_info(ns->ctrl->device, 2036 + "block device for nsid %u not supported (csi %u)\n", 2037 + info->nsid, info->ids.csi); 2038 + return nvme_update_ns_info_generic(ns, info); 2063 2039 } 2064 2040 } 2065 2041 ··· 4367 4341 * data structure to find all the generic information that is needed to 4368 4342 * set up a namespace. If not fall back to the legacy version. 4369 4343 */ 4370 - if (ctrl->cap & NVME_CAP_CRMS_CRIMS) { 4344 + if ((ctrl->cap & NVME_CAP_CRMS_CRIMS) || 4345 + (info.ids.csi != NVME_CSI_NVM && info.ids.csi != NVME_CSI_ZNS)) { 4371 4346 if (nvme_ns_info_from_id_cs_indep(ctrl, &info)) 4372 4347 return; 4373 4348 } else {