Commit 1496bd49 authored by Christoph Hellwig's avatar Christoph Hellwig

nvme: move nvme_ns_head_ops to multipath.c

Move the multipath block_device_operations to multipath.c, where they
belong.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarKeith Busch <kbusch@kernel.org>
Reviewed-by: default avatarJavier González <javier.gonz@samsung.com>
Reviewed-by: default avatarChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
parent 871ca3ef
...@@ -549,12 +549,12 @@ static void nvme_free_ns_head(struct kref *ref) ...@@ -549,12 +549,12 @@ static void nvme_free_ns_head(struct kref *ref)
kfree(head); kfree(head);
} }
static bool nvme_tryget_ns_head(struct nvme_ns_head *head) bool nvme_tryget_ns_head(struct nvme_ns_head *head)
{ {
return kref_get_unless_zero(&head->ref); return kref_get_unless_zero(&head->ref);
} }
static void nvme_put_ns_head(struct nvme_ns_head *head) void nvme_put_ns_head(struct nvme_ns_head *head)
{ {
kref_put(&head->ref, nvme_free_ns_head); kref_put(&head->ref, nvme_free_ns_head);
} }
...@@ -1511,7 +1511,7 @@ static void nvme_release(struct gendisk *disk, fmode_t mode) ...@@ -1511,7 +1511,7 @@ static void nvme_release(struct gendisk *disk, fmode_t mode)
nvme_put_ns(ns); nvme_put_ns(ns);
} }
static int nvme_getgeo(struct block_device *bdev, struct hd_geometry *geo) int nvme_getgeo(struct block_device *bdev, struct hd_geometry *geo)
{ {
/* some standard values */ /* some standard values */
geo->heads = 1 << 6; geo->heads = 1 << 6;
...@@ -1937,7 +1937,7 @@ static int nvme_pr_release(struct block_device *bdev, u64 key, enum pr_type type ...@@ -1937,7 +1937,7 @@ static int nvme_pr_release(struct block_device *bdev, u64 key, enum pr_type type
return nvme_pr_command(bdev, cdw10, key, 0, nvme_cmd_resv_release); return nvme_pr_command(bdev, cdw10, key, 0, nvme_cmd_resv_release);
} }
static const struct pr_ops nvme_pr_ops = { const struct pr_ops nvme_pr_ops = {
.pr_register = nvme_pr_register, .pr_register = nvme_pr_register,
.pr_reserve = nvme_pr_reserve, .pr_reserve = nvme_pr_reserve,
.pr_release = nvme_pr_release, .pr_release = nvme_pr_release,
...@@ -1978,18 +1978,6 @@ static const struct block_device_operations nvme_bdev_ops = { ...@@ -1978,18 +1978,6 @@ static const struct block_device_operations nvme_bdev_ops = {
}; };
#ifdef CONFIG_NVME_MULTIPATH #ifdef CONFIG_NVME_MULTIPATH
static int nvme_ns_head_open(struct block_device *bdev, fmode_t mode)
{
if (!nvme_tryget_ns_head(bdev->bd_disk->private_data))
return -ENXIO;
return 0;
}
static void nvme_ns_head_release(struct gendisk *disk, fmode_t mode)
{
nvme_put_ns_head(disk->private_data);
}
struct nvme_ctrl *nvme_find_get_live_ctrl(struct nvme_subsystem *subsys) struct nvme_ctrl *nvme_find_get_live_ctrl(struct nvme_subsystem *subsys)
{ {
struct nvme_ctrl *ctrl; struct nvme_ctrl *ctrl;
...@@ -2009,17 +1997,6 @@ struct nvme_ctrl *nvme_find_get_live_ctrl(struct nvme_subsystem *subsys) ...@@ -2009,17 +1997,6 @@ struct nvme_ctrl *nvme_find_get_live_ctrl(struct nvme_subsystem *subsys)
mutex_unlock(&nvme_subsystems_lock); mutex_unlock(&nvme_subsystems_lock);
return ctrl; return ctrl;
} }
const struct block_device_operations nvme_ns_head_ops = {
.owner = THIS_MODULE,
.submit_bio = nvme_ns_head_submit_bio,
.open = nvme_ns_head_open,
.release = nvme_ns_head_release,
.ioctl = nvme_ns_head_ioctl,
.getgeo = nvme_getgeo,
.report_zones = nvme_report_zones,
.pr_ops = &nvme_pr_ops,
};
#endif /* CONFIG_NVME_MULTIPATH */ #endif /* CONFIG_NVME_MULTIPATH */
static int nvme_wait_ready(struct nvme_ctrl *ctrl, u64 cap, bool enabled) static int nvme_wait_ready(struct nvme_ctrl *ctrl, u64 cap, bool enabled)
......
...@@ -294,7 +294,7 @@ static bool nvme_available_path(struct nvme_ns_head *head) ...@@ -294,7 +294,7 @@ static bool nvme_available_path(struct nvme_ns_head *head)
return false; return false;
} }
blk_qc_t nvme_ns_head_submit_bio(struct bio *bio) static blk_qc_t nvme_ns_head_submit_bio(struct bio *bio)
{ {
struct nvme_ns_head *head = bio->bi_bdev->bd_disk->private_data; struct nvme_ns_head *head = bio->bi_bdev->bd_disk->private_data;
struct device *dev = disk_to_dev(head->disk); struct device *dev = disk_to_dev(head->disk);
...@@ -334,6 +334,29 @@ blk_qc_t nvme_ns_head_submit_bio(struct bio *bio) ...@@ -334,6 +334,29 @@ blk_qc_t nvme_ns_head_submit_bio(struct bio *bio)
return ret; return ret;
} }
static int nvme_ns_head_open(struct block_device *bdev, fmode_t mode)
{
if (!nvme_tryget_ns_head(bdev->bd_disk->private_data))
return -ENXIO;
return 0;
}
static void nvme_ns_head_release(struct gendisk *disk, fmode_t mode)
{
nvme_put_ns_head(disk->private_data);
}
const struct block_device_operations nvme_ns_head_ops = {
.owner = THIS_MODULE,
.submit_bio = nvme_ns_head_submit_bio,
.open = nvme_ns_head_open,
.release = nvme_ns_head_release,
.ioctl = nvme_ns_head_ioctl,
.getgeo = nvme_getgeo,
.report_zones = nvme_report_zones,
.pr_ops = &nvme_pr_ops,
};
static void nvme_requeue_work(struct work_struct *work) static void nvme_requeue_work(struct work_struct *work)
{ {
struct nvme_ns_head *head = struct nvme_ns_head *head =
......
...@@ -656,6 +656,8 @@ int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp, u8 csi, ...@@ -656,6 +656,8 @@ int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp, u8 csi,
struct nvme_ns *nvme_get_ns_from_disk(struct gendisk *disk, struct nvme_ns *nvme_get_ns_from_disk(struct gendisk *disk,
struct nvme_ns_head **head, int *srcu_idx); struct nvme_ns_head **head, int *srcu_idx);
void nvme_put_ns_from_disk(struct nvme_ns_head *head, int idx); void nvme_put_ns_from_disk(struct nvme_ns_head *head, int idx);
bool nvme_tryget_ns_head(struct nvme_ns_head *head);
void nvme_put_ns_head(struct nvme_ns_head *head);
struct nvme_ctrl *nvme_find_get_live_ctrl(struct nvme_subsystem *subsys); struct nvme_ctrl *nvme_find_get_live_ctrl(struct nvme_subsystem *subsys);
int nvme_ioctl(struct block_device *bdev, fmode_t mode, int nvme_ioctl(struct block_device *bdev, fmode_t mode,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
...@@ -663,8 +665,10 @@ int nvme_ns_head_ioctl(struct block_device *bdev, fmode_t mode, ...@@ -663,8 +665,10 @@ int nvme_ns_head_ioctl(struct block_device *bdev, fmode_t mode,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
long nvme_dev_ioctl(struct file *file, unsigned int cmd, long nvme_dev_ioctl(struct file *file, unsigned int cmd,
unsigned long arg); unsigned long arg);
int nvme_getgeo(struct block_device *bdev, struct hd_geometry *geo);
extern const struct attribute_group *nvme_ns_id_attr_groups[]; extern const struct attribute_group *nvme_ns_id_attr_groups[];
extern const struct pr_ops nvme_pr_ops;
extern const struct block_device_operations nvme_ns_head_ops; extern const struct block_device_operations nvme_ns_head_ops;
#ifdef CONFIG_NVME_MULTIPATH #ifdef CONFIG_NVME_MULTIPATH
...@@ -688,7 +692,6 @@ void nvme_mpath_stop(struct nvme_ctrl *ctrl); ...@@ -688,7 +692,6 @@ void nvme_mpath_stop(struct nvme_ctrl *ctrl);
bool nvme_mpath_clear_current_path(struct nvme_ns *ns); bool nvme_mpath_clear_current_path(struct nvme_ns *ns);
void nvme_mpath_clear_ctrl_paths(struct nvme_ctrl *ctrl); void nvme_mpath_clear_ctrl_paths(struct nvme_ctrl *ctrl);
struct nvme_ns *nvme_find_path(struct nvme_ns_head *head); struct nvme_ns *nvme_find_path(struct nvme_ns_head *head);
blk_qc_t nvme_ns_head_submit_bio(struct bio *bio);
static inline void nvme_mpath_check_last_path(struct nvme_ns *ns) static inline void nvme_mpath_check_last_path(struct nvme_ns *ns)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment