[PATCH 3/5] nvme: add support for copy offload
Hannes Reinecke
hare at suse.de
Thu May 22 06:54:46 PDT 2025
On 5/22/25 00:31, Keith Busch wrote:
> From: Keith Busch <kbusch at kernel.org>
>
> Register the nvme namespace copy capablities with the request_queue
> limits and implement support for the REQ_OP_COPY operation.
>
> Signed-off-by: Keith Busch <kbusch at kernel.org>
> ---
> drivers/nvme/host/core.c | 61 ++++++++++++++++++++++++++++++++++++++++
> include/linux/nvme.h | 42 ++++++++++++++++++++++++++-
> 2 files changed, 102 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index f69a232a000ac..3134fe85b1abc 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -888,6 +888,52 @@ static blk_status_t nvme_setup_discard(struct nvme_ns *ns, struct request *req,
> return BLK_STS_OK;
> }
>
> +static inline blk_status_t nvme_setup_copy(struct nvme_ns *ns,
> + struct request *req, struct nvme_command *cmnd)
> +{
> + struct nvme_copy_range *range;
> + struct req_iterator iter;
> + struct bio_vec bvec;
> + u16 control = 0;
> + int i = 0;
> +
> + static const size_t alloc_size = sizeof(*range) * NVME_COPY_MAX_RANGES;
> +
> + if (WARN_ON_ONCE(blk_rq_nr_phys_segments(req) >= NVME_COPY_MAX_RANGES))
> + return BLK_STS_IOERR;
> +
> + range = kzalloc(alloc_size, GFP_ATOMIC | __GFP_NOWARN);
> + if (!range)
> + return BLK_STS_RESOURCE;
> +
> + if (req->cmd_flags & REQ_FUA)
> + control |= NVME_RW_FUA;
> + if (req->cmd_flags & REQ_FAILFAST_DEV)
> + control |= NVME_RW_LR;
FAILFAST_DEV? Is that even set anywhere?
Otherwise looks ok.
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare at suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
More information about the Linux-nvme
mailing list