nvme: introduce nvme_disk_is_ns_head helper
authorGuixin Liu <kanie@linux.alibaba.com>
Wed, 27 Dec 2023 09:31:06 +0000 (17:31 +0800)
committerKeith Busch <kbusch@kernel.org>
Fri, 5 Jan 2024 21:15:41 +0000 (13:15 -0800)
commitbafd590910d00327decb3937e77f6f11c3e80e4b
treebfd836536611315ee1bc662340ef85c46639dd1a
parentbd029a02ce46e77e4d553140b039f93cf78ee8c1
nvme: introduce nvme_disk_is_ns_head helper

We currently rely on gendisk's file operations (fops) to distinguish
between a namespace head (ns_head) and a regular namespace. To enhance
code readability, introduce a helper function.
Additionally, we must ensure that the device is not an ns_head before
calling nvme_get_ns_from_dev(). To enforce this, add a WARN_ON check
within the nvme_get_ns_from_dev().

Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Liu Song <liusong@linux.alibaba.com>
[include fix: https://lore.kernel.org/oe-kbuild-all/202401031943.0N72Tkji-lkp@intel.com/]
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/host/nvme.h
drivers/nvme/host/pr.c
drivers/nvme/host/sysfs.c