drbd/0024-compat-test-and-patch-for-queue_limits.features.patch
heming zhao 6ee9ba5898 - Update DRBD version from 9.1.22 to 9.1.23 (boo#1234849)
* Changelog from Linbit:
    9.1.23 (api:genl2/proto:86-101,118-121/transport:18)
    --------
     * Fix a corner case that can happen when DRBD establishes multiple
       connections in parallel, which could lead one connection to end up in
       an inconsistent replication state of WFBitMapT/Established
     * Fix a corner case in which a reconciliation resync ends up in
       WFBitMapT/Established
     * Restrict protocol compatibility to the most recent 8.4 and 9.0 releases
     * Fix a corner case causing a module ref leak on drbd_transport_tcp;
       if it hits, you can not rmmod it
     * rate-limit resync progress while resync is paused
     * resync-target inherits history UUIDs when resync finishes,
       this can prevent unexpected "unrelared data" events later
     * Updated compatibility code for Linux 6.11 and 6.12
  * remove patches which already included in the new version:
     0001-drbd-properly-rate-limit-resync-progress-reports.patch
     0002-drbd-inherit-history-UUIDs-from-sync-source-when-res.patch
     0003-build-compat-fix-line-offset-in-annotation-pragmas-p.patch
     0004-drbd-fix-exposed_uuid-going-backward.patch
     0005-drbd-Proper-locking-around-new_current_uuid-on-a-dis.patch
     0006-build-CycloneDX-fix-bom-ref-add-purl.patch
     0007-build-Another-update-to-the-spdx-files.patch
     0008-build-generate-spdx.json-not-tag-value-format.patch
     0009-compat-fix-gen_patch_names-for-bdev_file_open_by_pat.patch
     0010-compat-fix-nla_nest_start_noflag-test.patch
     0011-compat-fix-blk_alloc_disk-rule.patch
     0012-drbd-remove-const-from-function-return-type.patch
     0013-drbd-don-t-set-max_write_zeroes_sectors-in-decide_on.patch
     0014-drbd-split-out-a-drbd_discard_supported-helper.patch
     0015-drbd-atomically-update-queue-limits-in-drbd_reconsid.patch
     0016-compat-test-and-patch-for-queue_limits_start_update.patch
     0017-compat-specify-which-essential-change-was-not-made.patch
     0018-gen_patch_names-reorder-blk_mode_t.patch
     0019-compat-fix-blk_queue_update_readahead-patch.patch
     0020-compat-test-and-patch-for-que_limits-max_hw_discard_.patch
     0021-compat-fixup-write_zeroes__no_capable.patch
     0022-compat-fixup-queue_flag_discard__yes_present.patch
     0023-drbd-move-flags-to-queue_limits.patch
     0024-compat-test-and-patch-for-queue_limits.features.patch
     0025-drbd-Annotate-struct-fifo_buffer-with-__counted_by.patch
     0026-compat-test-and-patch-for-__counted_by.patch
     0027-drbd-fix-function-cast-warnings-in-state-machine.patch
     0028-Add-missing-documentation-of-peer_device-parameter-t.patch
     0030-drbd-kref_put-path-when-kernel_accept-fails.patch
     0031-build-fix-typo-in-Makefile.spatch.patch
     0032-drbd-open-do-not-delay-open-if-already-Primary.patch
  * removed patch which is not needed anymore:
     boo1231290_fix_drbd_build_error_against_kernel_v6.11.0.patch
     boo1233222_fix_drbd_build_error_against_kernel_v6.11.6.patch
  * update:
     drbd_git_revision
     drbd.spec
  * add upstream patches to align commit d64ebe7eb7df:
     0001-drbd-Fix-memory-leak.patch

OBS-URL: https://build.opensuse.org/package/show/network:ha-clustering:Factory/drbd?expand=0&rev=155
2024-12-27 03:43:25 +00:00

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