Re: [PATCH v20 07/12] nvme: add copy offload support

Christoph Hellwig
2024-06-01T06:22:24Z

On Mon, May 20, 2024 at 03:50:20PM +0530, Nitesh Shetty wrote:
> + if (blk_rq_nr_phys_segments(req) != BLK_COPY_MAX_SEGMENTS)
> + return BLK_STS_IOERR;

This sounds like BLK_COPY_MAX_SEGMENTS is misnamed. Right now this is
not a max segments, but the exact number of segments required.

> /*
> * Recommended frequency for KATO commands per NVMe 1.4 section 7.12.1:
> - *
> + *

Please submit this whitespace fix separately.

> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index 8b1edb46880a..1c5974bb23d5 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -1287,6 +1287,7 @@ static inline unsigned int bdev_discard_granularity(struct block_device *bdev)
>
> /* maximum copy offload length, this is set to 128MB based on current testing */
> #define BLK_COPY_MAX_BYTES (1 << 27)
> +#define BLK_COPY_MAX_SEGMENTS 2

... and this doesn't belong into a NVMe patch. I'd also expect that
the block layer would verify this before sending of the request to the driver.

> diff --git a/include/linux/nvme.h b/include/linux/nvme.h
> index 425573202295..5275a0962a02 100644
> --- a/include/linux/nvme.h
> +++ b/include/linux/nvme.h

Note that we've usually kept adding new protocol bits to nvme.h separate
from the implementation in the host or target code.