From 2bc7cb7193124d20aa4e1b5dbad0410bfb97a470 Mon Sep 17 00:00:00 2001
From: Michael Jeanson <mjeanson@efficios.com>
Date: Mon, 4 Apr 2022 14:12:13 -0400
Subject: [PATCH 05/10] fix: scsi: block: Remove REQ_OP_WRITE_SAME support
 (v5.18)

See upstream commit :

  commit 73bd66d9c834220579c881a3eb020fd8917075d8
  Author: Christoph Hellwig <hch@lst.de>
  Date:   Wed Feb 9 09:28:28 2022 +0100

    scsi: block: Remove REQ_OP_WRITE_SAME support

    No more users of REQ_OP_WRITE_SAME or drivers implementing it are left,
    so remove the infrastructure.

Upstream-Status: Backport

Change-Id: Ifbff71f79f8b590436fc7cb79f82d90c6e033d84
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
---
 include/instrumentation/events/block.h | 32 ++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/include/instrumentation/events/block.h b/include/instrumentation/events/block.h
index 3e1104d7..050a59a2 100644
--- a/include/instrumentation/events/block.h
+++ b/include/instrumentation/events/block.h
@@ -66,6 +66,37 @@ LTTNG_TRACEPOINT_ENUM(block_rq_type,
 #define lttng_bio_op(bio)	bio_op(bio)
 #define lttng_bio_rw(bio)	((bio)->bi_opf)
 
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,18,0))
+#ifdef CONFIG_LTTNG_EXPERIMENTAL_BITWISE_ENUM
+#define blk_rwbs_ctf_integer(type, rwbs, op, rw, bytes)			      \
+		ctf_enum(block_rq_type, type, rwbs,					      \
+			( (op) == REQ_OP_WRITE ? RWBS_FLAG_WRITE : \
+			( (op) == REQ_OP_DISCARD ? RWBS_FLAG_DISCARD :	      \
+			( (op) == REQ_OP_SECURE_ERASE ? (RWBS_FLAG_DISCARD | RWBS_FLAG_SECURE) : \
+			( (op) == REQ_OP_FLUSH ? RWBS_FLAG_FLUSH :	      \
+			( (op) == REQ_OP_READ ? RWBS_FLAG_READ :	      \
+			( 0 ))))))					      \
+			| ((rw) & REQ_RAHEAD ? RWBS_FLAG_RAHEAD : 0)	      \
+			| ((rw) & REQ_SYNC ? RWBS_FLAG_SYNC : 0)	      \
+			| ((rw) & REQ_META ? RWBS_FLAG_META : 0)	      \
+			| ((rw) & REQ_PREFLUSH ? RWBS_FLAG_PREFLUSH : 0)      \
+			| ((rw) & REQ_FUA ? RWBS_FLAG_FUA : 0))
+#else
+#define blk_rwbs_ctf_integer(type, rwbs, op, rw, bytes)			      \
+		ctf_integer(type, rwbs,					      \
+			( (op) == REQ_OP_WRITE ? RWBS_FLAG_WRITE : \
+			( (op) == REQ_OP_DISCARD ? RWBS_FLAG_DISCARD :	      \
+			( (op) == REQ_OP_SECURE_ERASE ? (RWBS_FLAG_DISCARD | RWBS_FLAG_SECURE) : \
+			( (op) == REQ_OP_FLUSH ? RWBS_FLAG_FLUSH :	      \
+			( (op) == REQ_OP_READ ? RWBS_FLAG_READ :	      \
+			( 0 ))))))					      \
+			| ((rw) & REQ_RAHEAD ? RWBS_FLAG_RAHEAD : 0)	      \
+			| ((rw) & REQ_SYNC ? RWBS_FLAG_SYNC : 0)	      \
+			| ((rw) & REQ_META ? RWBS_FLAG_META : 0)	      \
+			| ((rw) & REQ_PREFLUSH ? RWBS_FLAG_PREFLUSH : 0)      \
+			| ((rw) & REQ_FUA ? RWBS_FLAG_FUA : 0))
+#endif /* CONFIG_LTTNG_EXPERIMENTAL_BITWISE_ENUM */
+#else
 #ifdef CONFIG_LTTNG_EXPERIMENTAL_BITWISE_ENUM
 #define blk_rwbs_ctf_integer(type, rwbs, op, rw, bytes)			      \
 		ctf_enum(block_rq_type, type, rwbs,					      \
@@ -95,6 +126,7 @@ LTTNG_TRACEPOINT_ENUM(block_rq_type,
 			| ((rw) & REQ_PREFLUSH ? RWBS_FLAG_PREFLUSH : 0)      \
 			| ((rw) & REQ_FUA ? RWBS_FLAG_FUA : 0))
 #endif /* CONFIG_LTTNG_EXPERIMENTAL_BITWISE_ENUM */
+#endif
 
 #elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,1,0))
 
-- 
2.19.1

