nvme: add a nvme_ns_head_multipath helper
Move the multipath gendisk out of #ifdef CONFIG_NVME_MULTIPATH and add a new nvme_ns_head_multipath that uses it to check if a ns_head has a multipath device associated with it. Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com> [hch: added the IS_ENABLED, converted a few existing users] Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Keith Busch <kbusch@kernel.org> Reviewed-by: Javier González <javier.gonz@samsung.com> Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
This commit is contained in:
parent
95d54bd1a4
commit
3089738868
@ -1873,11 +1873,9 @@ static int nvme_open(struct block_device *bdev, fmode_t mode)
|
|||||||
{
|
{
|
||||||
struct nvme_ns *ns = bdev->bd_disk->private_data;
|
struct nvme_ns *ns = bdev->bd_disk->private_data;
|
||||||
|
|
||||||
#ifdef CONFIG_NVME_MULTIPATH
|
|
||||||
/* should never be called due to GENHD_FL_HIDDEN */
|
/* should never be called due to GENHD_FL_HIDDEN */
|
||||||
if (WARN_ON_ONCE(ns->head->disk))
|
if (WARN_ON_ONCE(nvme_ns_head_multipath(ns->head)))
|
||||||
goto fail;
|
goto fail;
|
||||||
#endif
|
|
||||||
if (!kref_get_unless_zero(&ns->kref))
|
if (!kref_get_unless_zero(&ns->kref))
|
||||||
goto fail;
|
goto fail;
|
||||||
if (!try_module_get(ns->ctrl->ops->module))
|
if (!try_module_get(ns->ctrl->ops->module))
|
||||||
@ -2215,8 +2213,7 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_NVME_MULTIPATH
|
if (nvme_ns_head_multipath(ns->head)) {
|
||||||
if (ns->head->disk) {
|
|
||||||
blk_mq_freeze_queue(ns->head->disk->queue);
|
blk_mq_freeze_queue(ns->head->disk->queue);
|
||||||
nvme_update_disk_info(ns->head->disk, ns, id);
|
nvme_update_disk_info(ns->head->disk, ns, id);
|
||||||
blk_stack_limits(&ns->head->disk->queue->limits,
|
blk_stack_limits(&ns->head->disk->queue->limits,
|
||||||
@ -2224,7 +2221,6 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)
|
|||||||
blk_queue_update_readahead(ns->head->disk->queue);
|
blk_queue_update_readahead(ns->head->disk->queue);
|
||||||
blk_mq_unfreeze_queue(ns->head->disk->queue);
|
blk_mq_unfreeze_queue(ns->head->disk->queue);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_unfreeze:
|
out_unfreeze:
|
||||||
|
@ -413,8 +413,8 @@ struct nvme_ns_head {
|
|||||||
bool shared;
|
bool shared;
|
||||||
int instance;
|
int instance;
|
||||||
struct nvme_effects_log *effects;
|
struct nvme_effects_log *effects;
|
||||||
#ifdef CONFIG_NVME_MULTIPATH
|
|
||||||
struct gendisk *disk;
|
struct gendisk *disk;
|
||||||
|
#ifdef CONFIG_NVME_MULTIPATH
|
||||||
struct bio_list requeue_list;
|
struct bio_list requeue_list;
|
||||||
spinlock_t requeue_lock;
|
spinlock_t requeue_lock;
|
||||||
struct work_struct requeue_work;
|
struct work_struct requeue_work;
|
||||||
@ -425,6 +425,11 @@ struct nvme_ns_head {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline bool nvme_ns_head_multipath(struct nvme_ns_head *head)
|
||||||
|
{
|
||||||
|
return IS_ENABLED(CONFIG_NVME_MULTIPATH) && head->disk;
|
||||||
|
}
|
||||||
|
|
||||||
enum nvme_ns_features {
|
enum nvme_ns_features {
|
||||||
NVME_NS_EXT_LBAS = 1 << 0, /* support extended LBA format */
|
NVME_NS_EXT_LBAS = 1 << 0, /* support extended LBA format */
|
||||||
NVME_NS_METADATA_SUPPORTED = 1 << 1, /* support getting generated md */
|
NVME_NS_METADATA_SUPPORTED = 1 << 1, /* support getting generated md */
|
||||||
|
Loading…
Reference in New Issue
Block a user