diff mbox series

[v3,02/10] block: introduce a helper to determine metadata bytes from data iter

Message ID 20240823103811.2421-3-anuj20.g@samsung.com
State New
Headers show
Series Read/Write with meta/integrity | expand

Commit Message

Anuj Gupta Aug. 23, 2024, 10:38 a.m. UTC
Introduce a new helper bio_iter_integrity_bytes to determine the number
of metadata bytes corresponding to data iter.

Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
---
 include/linux/blk-integrity.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Christoph Hellwig Aug. 24, 2024, 8:24 a.m. UTC | #1
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Martin K. Petersen Aug. 29, 2024, 3:06 a.m. UTC | #2
Anuj,

> Introduce a new helper bio_iter_integrity_bytes to determine the number
> of metadata bytes corresponding to data iter.

Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
diff mbox series

Patch

diff --git a/include/linux/blk-integrity.h b/include/linux/blk-integrity.h
index de98049b7ded..2ff65c933c50 100644
--- a/include/linux/blk-integrity.h
+++ b/include/linux/blk-integrity.h
@@ -76,6 +76,15 @@  static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,
 	return bio_integrity_intervals(bi, sectors) * bi->tuple_size;
 }
 
+/*
+ * Return the integrity bytes corresponding to data iter
+ */
+static inline unsigned int bio_iter_integrity_bytes(struct blk_integrity *bi,
+						    struct bvec_iter iter)
+{
+	return bio_integrity_bytes(bi, bvec_iter_sectors(iter));
+}
+
 static inline bool blk_integrity_rq(struct request *rq)
 {
 	return rq->cmd_flags & REQ_INTEGRITY;
@@ -132,6 +141,13 @@  static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,
 {
 	return 0;
 }
+
+static inline unsigned int bio_iter_integrity_bytes(struct blk_integrity *bi,
+						    struct bvec_iter iter)
+{
+	return 0;
+}
+
 static inline int blk_integrity_rq(struct request *rq)
 {
 	return 0;