Indicate to the ublk server when an incoming request has integrity data
by setting UBLK_IO_F_INTEGRITY in the ublksrv_io_desc's op_flags field.

Signed-off-by: Caleb Sander Mateos <[email protected]>
Reviewed-by: Ming Lei <[email protected]>
---
 drivers/block/ublk_drv.c      | 3 +++
 include/uapi/linux/ublk_cmd.h | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index 066c6ae062a0..2b0a9720921d 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -1120,10 +1120,13 @@ static inline unsigned int ublk_req_build_flags(struct 
request *req)
                flags |= UBLK_IO_F_NOUNMAP;
 
        if (req->cmd_flags & REQ_SWAP)
                flags |= UBLK_IO_F_SWAP;
 
+       if (blk_integrity_rq(req))
+               flags |= UBLK_IO_F_INTEGRITY;
+
        return flags;
 }
 
 static blk_status_t ublk_setup_iod(struct ublk_queue *ubq, struct request *req)
 {
diff --git a/include/uapi/linux/ublk_cmd.h b/include/uapi/linux/ublk_cmd.h
index a54c47832fa2..c1103ad5925b 100644
--- a/include/uapi/linux/ublk_cmd.h
+++ b/include/uapi/linux/ublk_cmd.h
@@ -412,10 +412,12 @@ struct ublksrv_ctrl_dev_info {
  *
  * ublk server has to check this flag if UBLK_AUTO_BUF_REG_FALLBACK is
  * passed in.
  */
 #define                UBLK_IO_F_NEED_REG_BUF          (1U << 17)
+/* Request has an integrity data buffer */
+#define                UBLK_IO_F_INTEGRITY             (1UL << 18)
 
 /*
  * io cmd is described by this structure, and stored in share memory, indexed
  * by request tag.
  *
-- 
2.45.2


Reply via email to