192 lines
6.8 KiB
Diff
192 lines
6.8 KiB
Diff
|
From 3c18af1a3e8d67833e3ea8a2d38408501c9ee6be Mon Sep 17 00:00:00 2001
|
||
|
From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?=
|
||
|
<christoph.boehmwalder@linbit.com>
|
||
|
Date: Thu, 5 Sep 2024 13:05:59 +0200
|
||
|
Subject: [PATCH 24/32] compat: test and patch for queue_limits.features
|
||
|
|
||
|
And fixup compat patches that rely on blk_queue_write_cache being there.
|
||
|
Match to disk->private_data = ... instead.
|
||
|
---
|
||
|
.../blk_queue_make_request__yes_present.cocci | 3 ++-
|
||
|
.../blk_queue_merge_bvec__yes_present.cocci | 21 +++++++++++-----
|
||
|
.../cocci/congested_fn__yes_present.cocci | 3 ++-
|
||
|
.../queue_limits_features__no_present.cocci | 25 +++++++++++++++++++
|
||
|
drbd/drbd-kernel-compat/gen_patch_names.c | 15 ++++++-----
|
||
|
.../tests/queue_limits_has_features.c | 8 ++++++
|
||
|
6 files changed, 61 insertions(+), 14 deletions(-)
|
||
|
create mode 100644 drbd/drbd-kernel-compat/cocci/queue_limits_features__no_present.cocci
|
||
|
create mode 100644 drbd/drbd-kernel-compat/tests/queue_limits_has_features.c
|
||
|
|
||
|
diff --git a/drbd/drbd-kernel-compat/cocci/blk_queue_make_request__yes_present.cocci b/drbd/drbd-kernel-compat/cocci/blk_queue_make_request__yes_present.cocci
|
||
|
index 63c65d21cb32..665e10cbaa1a 100644
|
||
|
--- a/drbd/drbd-kernel-compat/cocci/blk_queue_make_request__yes_present.cocci
|
||
|
+++ b/drbd/drbd-kernel-compat/cocci/blk_queue_make_request__yes_present.cocci
|
||
|
@@ -5,12 +5,13 @@ identifier make_request_fn;
|
||
|
+ blk_alloc_queue(GFP_KERNEL)
|
||
|
|
||
|
@@
|
||
|
+struct gendisk *disk;
|
||
|
identifier rm_blk_alloc_queue.make_request_fn;
|
||
|
@@
|
||
|
drbd_create_device(...)
|
||
|
{
|
||
|
...
|
||
|
+ disk->private_data = ...;
|
||
|
+ blk_queue_make_request(q, make_request_fn);
|
||
|
- blk_queue_write_cache(...);
|
||
|
...
|
||
|
}
|
||
|
diff --git a/drbd/drbd-kernel-compat/cocci/blk_queue_merge_bvec__yes_present.cocci b/drbd/drbd-kernel-compat/cocci/blk_queue_merge_bvec__yes_present.cocci
|
||
|
index d4c0d85810e8..bedb09f8b375 100644
|
||
|
--- a/drbd/drbd-kernel-compat/cocci/blk_queue_merge_bvec__yes_present.cocci
|
||
|
+++ b/drbd/drbd-kernel-compat/cocci/blk_queue_merge_bvec__yes_present.cocci
|
||
|
@@ -1,10 +1,10 @@
|
||
|
-@@
|
||
|
+@ add_drbd_merge_bvec_definition @
|
||
|
identifier ws;
|
||
|
@@
|
||
|
+extern int drbd_merge_bvec(struct request_queue *, struct bvec_merge_data *, struct bio_vec *);
|
||
|
extern void do_submit(struct work_struct *ws);
|
||
|
|
||
|
-@@
|
||
|
+@ add_drbd_merge_bvec @
|
||
|
@@
|
||
|
+/* This is called by bio_add_page().
|
||
|
+ *
|
||
|
@@ -44,9 +44,10 @@ extern void do_submit(struct work_struct *ws);
|
||
|
do_submit(...)
|
||
|
{ ... }
|
||
|
|
||
|
-@@
|
||
|
+@ add_blk_queue_merge_bvec @
|
||
|
symbol true;
|
||
|
identifier q, resource, dev;
|
||
|
+struct gendisk *disk;
|
||
|
@@
|
||
|
drbd_create_device(...)
|
||
|
{
|
||
|
@@ -68,9 +69,17 @@ struct request_queue *q;
|
||
|
// also want to store it in queuedata for the compat.
|
||
|
dev->rq_queue = q;
|
||
|
+ q->queuedata = dev;
|
||
|
-<...
|
||
|
-blk_queue_write_cache(q, true, true);
|
||
|
+...
|
||
|
+disk->private_data = ...;
|
||
|
+ blk_queue_merge_bvec(q, drbd_merge_bvec);
|
||
|
-...>
|
||
|
+...
|
||
|
}
|
||
|
|
||
|
+@ script:python depends on !(add_drbd_merge_bvec_definition && add_drbd_merge_bvec && add_blk_queue_merge_bvec) @
|
||
|
+@@
|
||
|
+import sys
|
||
|
+print('ERROR: A rule making an essential change was not executed! (blk_queue_merge_bvec)', file=sys.stderr)
|
||
|
+print('ERROR: This would not show up as a compiler error, but would still break DRBD.', file=sys.stderr)
|
||
|
+print('ERROR: As a precaution, the build will be aborted here.', file=sys.stderr)
|
||
|
+sys.exit(1)
|
||
|
+
|
||
|
diff --git a/drbd/drbd-kernel-compat/cocci/congested_fn__yes_present.cocci b/drbd/drbd-kernel-compat/cocci/congested_fn__yes_present.cocci
|
||
|
index d0b55c3dffbf..a697311af6bd 100644
|
||
|
--- a/drbd/drbd-kernel-compat/cocci/congested_fn__yes_present.cocci
|
||
|
+++ b/drbd/drbd-kernel-compat/cocci/congested_fn__yes_present.cocci
|
||
|
@@ -63,14 +63,15 @@ drbd_cleanup(...)
|
||
|
|
||
|
@@
|
||
|
identifier dev;
|
||
|
+struct gendisk *disk;
|
||
|
@@
|
||
|
drbd_create_device(...)
|
||
|
{
|
||
|
...
|
||
|
struct drbd_device *dev;
|
||
|
...
|
||
|
+ disk->private_data = ...;
|
||
|
+ q->backing_dev_info->congested_fn = drbd_congested;
|
||
|
+ q->backing_dev_info->congested_data = dev;
|
||
|
- blk_queue_write_cache(...);
|
||
|
...
|
||
|
}
|
||
|
diff --git a/drbd/drbd-kernel-compat/cocci/queue_limits_features__no_present.cocci b/drbd/drbd-kernel-compat/cocci/queue_limits_features__no_present.cocci
|
||
|
new file mode 100644
|
||
|
index 000000000000..b9017351302b
|
||
|
--- /dev/null
|
||
|
+++ b/drbd/drbd-kernel-compat/cocci/queue_limits_features__no_present.cocci
|
||
|
@@ -0,0 +1,25 @@
|
||
|
+// NOTE this actually encompasses three patches:
|
||
|
+// 1122c0c1 block: move cache control settings out of queue->flags
|
||
|
+// bd4a633b block: move the nonrot flag to queue_limits
|
||
|
+// 1a02f3a7 block: move the stable_writes flag to queue_limits
|
||
|
+//
|
||
|
+// They add "BLK_FEAT_WRITE_CACHE | BLK_FEAT_FUA", "BLK_FEAT_ROTATIONAL", and
|
||
|
+// "BLK_FEAT_STABLE_WRITES", respectively.
|
||
|
+// Since these commits are all from the same series, just patch them together.
|
||
|
+@@
|
||
|
+expression e;
|
||
|
+struct gendisk *disk;
|
||
|
+identifier lim;
|
||
|
+@@
|
||
|
+-struct queue_limits lim = {
|
||
|
+- .features = e,
|
||
|
+-};
|
||
|
+...
|
||
|
+blk_alloc_disk(
|
||
|
+- &lim
|
||
|
++ NULL
|
||
|
+ , ...)
|
||
|
+...
|
||
|
+disk->private_data = ...;
|
||
|
++ blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, disk->queue);
|
||
|
++ blk_queue_write_cache(disk->queue, true, true);
|
||
|
diff --git a/drbd/drbd-kernel-compat/gen_patch_names.c b/drbd/drbd-kernel-compat/gen_patch_names.c
|
||
|
index 5abc32725daf..cc3bad2d84e4 100644
|
||
|
--- a/drbd/drbd-kernel-compat/gen_patch_names.c
|
||
|
+++ b/drbd/drbd-kernel-compat/gen_patch_names.c
|
||
|
@@ -153,6 +153,9 @@ int main(int argc, char **argv)
|
||
|
patch(1, "blk_cleanup_disk", false, true,
|
||
|
COMPAT_HAVE_BLK_CLEANUP_DISK, "present");
|
||
|
|
||
|
+ patch(1, "queue_limits_features", true, false,
|
||
|
+ COMPAT_QUEUE_LIMITS_HAS_FEATURES, "present");
|
||
|
+
|
||
|
patch(1, "blk_alloc_disk", true, false,
|
||
|
COMPAT_BLK_ALLOC_DISK_TAKES_QUEUE_LIMITS, "takes_queue_limits");
|
||
|
#if !defined(COMPAT_BLK_ALLOC_DISK_TAKES_QUEUE_LIMITS)
|
||
|
@@ -267,13 +270,13 @@ int main(int argc, char **argv)
|
||
|
patch(1, "security_netlink_recv", false, true,
|
||
|
COMPAT_HAVE_SECURITY_NETLINK_RECV, "present");
|
||
|
|
||
|
-#if defined(COMPAT_HAVE_QUEUE_FLAG_STABLE_WRITES)
|
||
|
- /* in versions >=5.9, there is QUEUE_FLAG_STABLE_WRITES */
|
||
|
-#else
|
||
|
- /* for <5.9 but >=3.9, fall back to BDI_CAP_STABLE_WRITES */
|
||
|
+ /*
|
||
|
+ * >= 6.10: BLK_FEAT_STABLE_WRITES
|
||
|
+ * 5.9-6.10: QUEUE_FLAG_STABLE_WRITES
|
||
|
+ * <5.9: BDI_CAP_STABLE_WRITES
|
||
|
+ */
|
||
|
patch(1, "queue_flag_stable_writes", true, false,
|
||
|
- NO, "present");
|
||
|
-#endif
|
||
|
+ COMPAT_HAVE_QUEUE_FLAG_STABLE_WRITES, "present");
|
||
|
|
||
|
patch(1, "queue_flag_discard", false, true,
|
||
|
COMPAT_HAVE_QUEUE_FLAG_DISCARD, "present");
|
||
|
diff --git a/drbd/drbd-kernel-compat/tests/queue_limits_has_features.c b/drbd/drbd-kernel-compat/tests/queue_limits_has_features.c
|
||
|
new file mode 100644
|
||
|
index 000000000000..e566a34bdda6
|
||
|
--- /dev/null
|
||
|
+++ b/drbd/drbd-kernel-compat/tests/queue_limits_has_features.c
|
||
|
@@ -0,0 +1,8 @@
|
||
|
+/* { "version": "v6.10", "commit": "1122c0c1cc71f740fa4d5f14f239194e06a1d5e7", "comment": "features field was introduced", "author": "Christoph Hellwig <hch@lst.de>", "date": "Mon Jun 17 08:04:40 2024 +0200" } */
|
||
|
+
|
||
|
+#include <linux/blkdev.h>
|
||
|
+
|
||
|
+unsigned int foo(struct queue_limits lim)
|
||
|
+{
|
||
|
+ return lim.features;
|
||
|
+}
|
||
|
--
|
||
|
2.35.3
|
||
|
|