drbd/0020-compat-test-and-patch-for-que_limits-max_hw_discard_.patch
2025-01-08 07:34:16 +00:00

58 lines
2.4 KiB
Diff

From f2a779276e7b0918c8592da8254a044c291f1778 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?=
<christoph.boehmwalder@linbit.com>
Date: Thu, 29 Aug 2024 16:15:27 +0200
Subject: [PATCH 20/32] compat: test and patch for
que_limits->max_hw_discard_sectors
---
.../queue_limits__no_has_max_hw_discard_sectors.cocci | 5 +++++
drbd/drbd-kernel-compat/gen_patch_names.c | 3 +++
.../tests/queue_limits_has_max_hw_discard_sectors.c | 8 ++++++++
3 files changed, 16 insertions(+)
create mode 100644 drbd/drbd-kernel-compat/cocci/queue_limits__no_has_max_hw_discard_sectors.cocci
create mode 100644 drbd/drbd-kernel-compat/tests/queue_limits_has_max_hw_discard_sectors.c
diff --git a/drbd/drbd-kernel-compat/cocci/queue_limits__no_has_max_hw_discard_sectors.cocci b/drbd/drbd-kernel-compat/cocci/queue_limits__no_has_max_hw_discard_sectors.cocci
new file mode 100644
index 000000000000..bf96b80a003d
--- /dev/null
+++ b/drbd/drbd-kernel-compat/cocci/queue_limits__no_has_max_hw_discard_sectors.cocci
@@ -0,0 +1,5 @@
+@@
+struct queue_limits lim;
+@@
+- lim.max_hw_discard_sectors
++ lim.max_discard_sectors
diff --git a/drbd/drbd-kernel-compat/gen_patch_names.c b/drbd/drbd-kernel-compat/gen_patch_names.c
index 6f62ea5827b7..5abc32725daf 100644
--- a/drbd/drbd-kernel-compat/gen_patch_names.c
+++ b/drbd/drbd-kernel-compat/gen_patch_names.c
@@ -296,6 +296,9 @@ int main(int argc, char **argv)
patch(1, "write_zeroes", true, false,
COMPAT_HAVE_REQ_OP_WRITE_ZEROES, "capable");
+ patch(1, "queue_limits", true, false,
+ COMPAT_QUEUE_LIMITS_HAS_MAX_HW_DISCARD_SECTORS, "has_max_hw_discard_sectors");
+
patch(1, "bio_bi_opf", true, false,
COMPAT_HAVE_BIO_BI_OPF, "present");
diff --git a/drbd/drbd-kernel-compat/tests/queue_limits_has_max_hw_discard_sectors.c b/drbd/drbd-kernel-compat/tests/queue_limits_has_max_hw_discard_sectors.c
new file mode 100644
index 000000000000..5dcf9c48667b
--- /dev/null
+++ b/drbd/drbd-kernel-compat/tests/queue_limits_has_max_hw_discard_sectors.c
@@ -0,0 +1,8 @@
+/* { "version": "v6.9-rc1", "commit": "4f563a64732dabb2677c7d1232a8f714a18b41b3", "comment": "lim.max_hw_discard_sectors was added", "author": "Christoph Hellwig <hch@lst.de>", "date": "Tue Feb 13 08:34:16 2024 +0100" } */
+
+#include <linux/blkdev.h>
+
+int foo(struct queue_limits *lim)
+{
+ return lim->max_hw_discard_sectors;
+}
--
2.35.3