diff mbox series

[PATCHv3,02/10] block: provide helper for nr_integrity_segments

Message ID 20240904152605.4055570-3-kbusch@meta.com
State New
Headers show
Series block integrity merging and counting | expand

Commit Message

Keith Busch Sept. 4, 2024, 3:25 p.m. UTC
From: Keith Busch <kbusch@kernel.org>

This way drivers that want this value don't need to concern themselves
with the CONFIG_BLK_DEV_INTEGRITY setting.

Signed-off-by: Keith Busch <kbusch@kernel.org>
---
 include/linux/blk-mq.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Christoph Hellwig Sept. 10, 2024, 3:30 p.m. UTC | #1
On Wed, Sep 04, 2024 at 08:25:57AM -0700, Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
> 
> This way drivers that want this value don't need to concern themselves
> with the CONFIG_BLK_DEV_INTEGRITY setting.

Looks ok:

Reviewed-by: Christoph Hellwig <hch@lst.de>

Although I wonder if we should simply define the field unconditionally
given that it is only 2 bytes wide and packs nicely.
Keith Busch Sept. 10, 2024, 3:39 p.m. UTC | #2
On Tue, Sep 10, 2024 at 05:30:46PM +0200, Christoph Hellwig wrote:
> On Wed, Sep 04, 2024 at 08:25:57AM -0700, Keith Busch wrote:
> > From: Keith Busch <kbusch@kernel.org>
> > 
> > This way drivers that want this value don't need to concern themselves
> > with the CONFIG_BLK_DEV_INTEGRITY setting.
> 
> Looks ok:
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> 
> Although I wonder if we should simply define the field unconditionally
> given that it is only 2 bytes wide and packs nicely.

Good idea, I didn't consider that. Various parts become cleaner if it's
unconditionally part of the request. I'll try it out.

BTW, just want to mention the the return value here is unreliable until
patch 10. I've reworked the series so that appears first to avoid a
bisect hazard. The end result is the same though, so I didn't want to
spam the mailing list with a v2 just yet.
diff mbox series

Patch

diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 8d304b1d16b15..3984aad9bf64a 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -228,6 +228,18 @@  static inline unsigned short req_get_ioprio(struct request *req)
 	return req->ioprio;
 }
 
+#ifdef CONFIG_BLK_DEV_INTEGRITY
+static inline unsigned short blk_rq_integrity_segments(struct request *rq)
+{
+	return rq->nr_integrity_segments;
+}
+#else
+static inline unsigned short blk_rq_integrity_segments(struct request *rq)
+{
+	return 0;
+}
+#endif
+
 #define rq_data_dir(rq)		(op_is_write(req_op(rq)) ? WRITE : READ)
 
 #define rq_dma_dir(rq) \