Re: [PATCH v18 02/12] Add infrastructure for copy offload in block and request layer.

From: Keith Busch
Date: Wed Dec 13 2023 - 20:11:36 EST


On Wed, Dec 06, 2023 at 03:32:34PM +0530, Kanchan Joshi wrote:
> static inline bool bio_has_data(struct bio *bio)
> {
> - if (bio &&
> - bio->bi_iter.bi_size &&
> - bio_op(bio) != REQ_OP_DISCARD &&
> - bio_op(bio) != REQ_OP_SECURE_ERASE &&
> - bio_op(bio) != REQ_OP_WRITE_ZEROES)
> + if (bio && (bio_op(bio) == REQ_OP_READ || bio_op(bio) == REQ_OP_WRITE))
> return true;

There are other ops besides READ and WRITE that have data, but this is
might be fine by the fact that other ops with data currently don't call
this function.

> diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
> index 7c2316c91cbd..bd821eaa7a02 100644
> --- a/include/linux/blk_types.h
> +++ b/include/linux/blk_types.h
> @@ -393,6 +393,10 @@ enum req_op {
> /* reset all the zone present on the device */
> REQ_OP_ZONE_RESET_ALL = (__force blk_opf_t)17,
>
> + /* copy offload dst and src operation */
> + REQ_OP_COPY_SRC = (__force blk_opf_t)19,

Should this be an even numbered OP? The odd ones are for data
WRITEs.

> + REQ_OP_COPY_DST = (__force blk_opf_t)21,