mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-06 16:49:22 +00:00
nvme: Add helper to send pr command
Move the code that checks for multipath support and sends the pr command to a new helper so it can be used by the reservation report support added in the next patches. Signed-off-by: Mike Christie <michael.christie@oracle.com> Link: https://lore.kernel.org/r/20230407200551.12660-11-michael.christie@oracle.com Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
b668f2f546
commit
f0614790b7
1 changed files with 14 additions and 9 deletions
|
@ -30,7 +30,7 @@ static char nvme_pr_type(enum pr_type type)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nvme_send_ns_head_pr_command(struct block_device *bdev,
|
static int nvme_send_ns_head_pr_command(struct block_device *bdev,
|
||||||
struct nvme_command *c, u8 *data, unsigned int data_len)
|
struct nvme_command *c, void *data, unsigned int data_len)
|
||||||
{
|
{
|
||||||
struct nvme_ns_head *head = bdev->bd_disk->private_data;
|
struct nvme_ns_head *head = bdev->bd_disk->private_data;
|
||||||
int srcu_idx = srcu_read_lock(&head->srcu);
|
int srcu_idx = srcu_read_lock(&head->srcu);
|
||||||
|
@ -46,7 +46,7 @@ static int nvme_send_ns_head_pr_command(struct block_device *bdev,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nvme_send_ns_pr_command(struct nvme_ns *ns, struct nvme_command *c,
|
static int nvme_send_ns_pr_command(struct nvme_ns *ns, struct nvme_command *c,
|
||||||
u8 *data, unsigned int data_len)
|
void *data, unsigned int data_len)
|
||||||
{
|
{
|
||||||
c->common.nsid = cpu_to_le32(ns->head->ns_id);
|
c->common.nsid = cpu_to_le32(ns->head->ns_id);
|
||||||
return nvme_submit_sync_cmd(ns->queue, c, data, data_len);
|
return nvme_submit_sync_cmd(ns->queue, c, data, data_len);
|
||||||
|
@ -74,6 +74,17 @@ static int nvme_sc_to_pr_err(int nvme_sc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int nvme_send_pr_command(struct block_device *bdev,
|
||||||
|
struct nvme_command *c, void *data, unsigned int data_len)
|
||||||
|
{
|
||||||
|
if (IS_ENABLED(CONFIG_NVME_MULTIPATH) &&
|
||||||
|
bdev->bd_disk->fops == &nvme_ns_head_ops)
|
||||||
|
return nvme_send_ns_head_pr_command(bdev, c, data, data_len);
|
||||||
|
|
||||||
|
return nvme_send_ns_pr_command(bdev->bd_disk->private_data, c, data,
|
||||||
|
data_len);
|
||||||
|
}
|
||||||
|
|
||||||
static int nvme_pr_command(struct block_device *bdev, u32 cdw10,
|
static int nvme_pr_command(struct block_device *bdev, u32 cdw10,
|
||||||
u64 key, u64 sa_key, u8 op)
|
u64 key, u64 sa_key, u8 op)
|
||||||
{
|
{
|
||||||
|
@ -87,13 +98,7 @@ static int nvme_pr_command(struct block_device *bdev, u32 cdw10,
|
||||||
c.common.opcode = op;
|
c.common.opcode = op;
|
||||||
c.common.cdw10 = cpu_to_le32(cdw10);
|
c.common.cdw10 = cpu_to_le32(cdw10);
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_NVME_MULTIPATH) &&
|
ret = nvme_send_pr_command(bdev, &c, data, sizeof(data));
|
||||||
bdev->bd_disk->fops == &nvme_ns_head_ops)
|
|
||||||
ret = nvme_send_ns_head_pr_command(bdev, &c, data,
|
|
||||||
sizeof(data));
|
|
||||||
else
|
|
||||||
ret = nvme_send_ns_pr_command(bdev->bd_disk->private_data, &c,
|
|
||||||
data, sizeof(data));
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue