diff --git a/0001-drbd-allow-transports-to-take-additional-krefs-on-a-.patch b/0001-drbd-allow-transports-to-take-additional-krefs-on-a-.patch deleted file mode 100644 index a0b8893..0000000 --- a/0001-drbd-allow-transports-to-take-additional-krefs-on-a-.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 0dda200877d1b801fba948a5948f321bee1a75a9 Mon Sep 17 00:00:00 2001 -From: Philipp Reisner -Date: Fri, 1 Sep 2023 08:03:01 +0200 -Subject: [PATCH 01/20] drbd: allow transports to take additional krefs on a - listener - -by making the drbd_listener_destroy() available to the transports. - -heming.zhao@suse.com -- For compiling drbd, I modified this patch. please differ with upstream - to find changes. - ---- - drbd/drbd_transport.c | 3 ++- - 1 files changed, 2 insertions(+), 1 deletions(-) - -diff --git a/drbd/drbd_transport.c b/drbd/drbd_transport.c -index d1ec5724dec6..416a50499046 100644 ---- a/drbd/drbd_transport.c -+++ b/drbd/drbd_transport.c -@@ -223,7 +223,7 @@ int drbd_get_listener(struct drbd_transport *transport, struct drbd_path *path, - return err; - } - --static void drbd_listener_destroy(struct kref *kref) -+void drbd_listener_destroy(struct kref *kref) - { - struct drbd_listener *listener = container_of(kref, struct drbd_listener, kref); - struct drbd_resource *resource = listener->resource; -@@ -331,3 +331,4 @@ EXPORT_SYMBOL_GPL(drbd_find_path_by_addr); - EXPORT_SYMBOL_GPL(drbd_stream_send_timed_out); - EXPORT_SYMBOL_GPL(drbd_should_abort_listening); - EXPORT_SYMBOL_GPL(drbd_path_event); -+EXPORT_SYMBOL_GPL(drbd_listener_destroy); --- -2.35.3 - diff --git a/0001-drbd-properly-rate-limit-resync-progress-reports.patch b/0001-drbd-properly-rate-limit-resync-progress-reports.patch new file mode 100644 index 0000000..c4c70ee --- /dev/null +++ b/0001-drbd-properly-rate-limit-resync-progress-reports.patch @@ -0,0 +1,119 @@ +From aab03bfc73a62f95011316545a5c0fbb4817741b Mon Sep 17 00:00:00 2001 +From: Lars Ellenberg +Date: Wed, 14 Aug 2024 11:49:42 +0200 +Subject: [PATCH 01/32] drbd: properly rate-limit resync progress reports + +A peer_device in "paused" sync would have flooded the "drbd events2" +generic netlink broadcast with "resync progress reports", +if it cleared significant out-of-sync bits, +as is the case with application writes, +or several peers syncing from the same sync source +and having a "paused sync" replication state between themselves. + +If you have "many" such resources, this storm may even overflow receive buffers. +At most one progress report every three seconds should be enough, +and is what was intended. + +Use a new "last progress report time stamp" to throttle +advancing resync progress marks and progress report broadcasts. +--- + drbd/drbd_actlog.c | 35 +++++++++++++++++++++++------------ + drbd/drbd_int.h | 1 + + drbd/drbd_receiver.c | 1 + + drbd/drbd_state.c | 2 ++ + 4 files changed, 27 insertions(+), 12 deletions(-) + +diff --git a/drbd/drbd_actlog.c b/drbd/drbd_actlog.c +index b96560843878..646dcb29e1d9 100644 +--- a/drbd/drbd_actlog.c ++++ b/drbd/drbd_actlog.c +@@ -1020,19 +1020,30 @@ static bool update_rs_extent(struct drbd_peer_device *peer_device, + + void drbd_advance_rs_marks(struct drbd_peer_device *peer_device, unsigned long still_to_go) + { +- unsigned long now = jiffies; +- unsigned long last = peer_device->rs_mark_time[peer_device->rs_last_mark]; +- int next = (peer_device->rs_last_mark + 1) % DRBD_SYNC_MARKS; +- if (time_after_eq(now, last + DRBD_SYNC_MARK_STEP)) { +- if (peer_device->rs_mark_left[peer_device->rs_last_mark] != still_to_go && +- peer_device->repl_state[NOW] != L_PAUSED_SYNC_T && +- peer_device->repl_state[NOW] != L_PAUSED_SYNC_S) { +- peer_device->rs_mark_time[next] = now; +- peer_device->rs_mark_left[next] = still_to_go; +- peer_device->rs_last_mark = next; +- } +- drbd_peer_device_post_work(peer_device, RS_PROGRESS); ++ unsigned long now; ++ int next; ++ ++ /* report progress and advance marks only if we made progress */ ++ if (peer_device->rs_mark_left[peer_device->rs_last_mark] == still_to_go) ++ return; ++ ++ /* report progress and advance marks at most once every DRBD_SYNC_MARK_STEP (3 seconds) */ ++ now = jiffies; ++ if (!time_after_eq(now, peer_device->rs_last_progress_report_ts + DRBD_SYNC_MARK_STEP)) ++ return; ++ ++ /* Do not advance marks if we are "paused" */ ++ if (peer_device->repl_state[NOW] != L_PAUSED_SYNC_T && ++ peer_device->repl_state[NOW] != L_PAUSED_SYNC_S) { ++ next = (peer_device->rs_last_mark + 1) % DRBD_SYNC_MARKS; ++ peer_device->rs_mark_time[next] = now; ++ peer_device->rs_mark_left[next] = still_to_go; ++ peer_device->rs_last_mark = next; + } ++ ++ /* But still report progress even if paused. */ ++ peer_device->rs_last_progress_report_ts = now; ++ drbd_peer_device_post_work(peer_device, RS_PROGRESS); + } + + /* It is called lazy update, so don't do write-out too often. */ +diff --git a/drbd/drbd_int.h b/drbd/drbd_int.h +index 49bd7b0c407c..c18407899f59 100644 +--- a/drbd/drbd_int.h ++++ b/drbd/drbd_int.h +@@ -1285,6 +1285,7 @@ struct drbd_peer_device { + unsigned long rs_paused; + /* skipped because csum was equal [unit BM_BLOCK_SIZE] */ + unsigned long rs_same_csum; ++ unsigned long rs_last_progress_report_ts; + #define DRBD_SYNC_MARKS 8 + #define DRBD_SYNC_MARK_STEP (3*HZ) + /* block not up-to-date at mark [unit BM_BLOCK_SIZE] */ +diff --git a/drbd/drbd_receiver.c b/drbd/drbd_receiver.c +index 19634f6423bd..ee54cf3ac116 100644 +--- a/drbd/drbd_receiver.c ++++ b/drbd/drbd_receiver.c +@@ -3409,6 +3409,7 @@ static int receive_DataRequest(struct drbd_connection *connection, struct packet + peer_device->ov_skipped = 0; + peer_device->rs_total = ov_left; + peer_device->rs_last_writeout = now; ++ peer_device->rs_last_progress_report_ts = now; + for (i = 0; i < DRBD_SYNC_MARKS; i++) { + peer_device->rs_mark_left[i] = ov_left; + peer_device->rs_mark_time[i] = now; +diff --git a/drbd/drbd_state.c b/drbd/drbd_state.c +index be1de8f0653b..44f55ee5c939 100644 +--- a/drbd/drbd_state.c ++++ b/drbd/drbd_state.c +@@ -2483,6 +2483,7 @@ static void initialize_resync_progress_marks(struct drbd_peer_device *peer_devic + unsigned long now = jiffies; + int i; + ++ peer_device->rs_last_progress_report_ts = now; + for (i = 0; i < DRBD_SYNC_MARKS; i++) { + peer_device->rs_mark_left[i] = tw; + peer_device->rs_mark_time[i] = now; +@@ -2730,6 +2731,7 @@ static void finish_state_change(struct drbd_resource *resource, const char *tag) + peer_device->ov_last_skipped_size = 0; + peer_device->ov_last_skipped_start = 0; + peer_device->rs_last_writeout = now; ++ peer_device->rs_last_progress_report_ts = now; + for (i = 0; i < DRBD_SYNC_MARKS; i++) { + peer_device->rs_mark_left[i] = peer_device->rs_total; + peer_device->rs_mark_time[i] = now; +-- +2.35.3 + diff --git a/0002-drbd-improve-decision-about-marking-a-failed-disk-Ou.patch b/0002-drbd-improve-decision-about-marking-a-failed-disk-Ou.patch deleted file mode 100644 index ab4595c..0000000 --- a/0002-drbd-improve-decision-about-marking-a-failed-disk-Ou.patch +++ /dev/null @@ -1,65 +0,0 @@ -From f2cd05b8d60d27f43b07175b92ef4c2a69b8e3a2 Mon Sep 17 00:00:00 2001 -From: Joel Colledge -Date: Wed, 6 Sep 2023 15:49:44 +0200 -Subject: [PATCH 02/20] drbd: improve decision about marking a failed disk - Outdated - -Sometimes it is possible to update the metadata even after our disk has -failed. We were too eager to remove the MDF_WAS_UP_TO_DATE flag in this -case. - -Firstly, we used the "NOW" states, so would mark our metadata Outdated -if we were a Primary with UpToDate data and no peers, and our disk -failed. Use the "NEW" states instead. - -Secondly, do not consider peers that are disconnecting, because they -will not see that our disk state is Failed, and so will outdate -themselves. We do not want to outdate both nodes in this situation. ---- - drbd/drbd_state.c | 18 ++++++++++++++---- - 1 file changed, 14 insertions(+), 4 deletions(-) - -diff --git a/drbd/drbd_state.c b/drbd/drbd_state.c -index 7e6e3477893d..8b60afeb097b 100644 ---- a/drbd/drbd_state.c -+++ b/drbd/drbd_state.c -@@ -2489,15 +2489,24 @@ static void initialize_resync(struct drbd_peer_device *peer_device) - /* Is there a primary with access to up to date data known */ - static bool primary_and_data_present(struct drbd_device *device) - { -- bool up_to_date_data = device->disk_state[NOW] == D_UP_TO_DATE; -- bool primary = device->resource->role[NOW] == R_PRIMARY; -+ bool up_to_date_data = device->disk_state[NEW] == D_UP_TO_DATE; -+ struct drbd_resource *resource = device->resource; -+ bool primary = resource->role[NEW] == R_PRIMARY; - struct drbd_peer_device *peer_device; - - for_each_peer_device(peer_device, device) { -- if (peer_device->connection->peer_role[NOW] == R_PRIMARY) -+ struct drbd_connection *connection = peer_device->connection; -+ -+ /* Do not consider the peer if we are disconnecting. */ -+ if (resource->remote_state_change && -+ drbd_twopc_between_peer_and_me(connection) && -+ resource->twopc_reply.is_disconnect) -+ continue; -+ -+ if (connection->peer_role[NEW] == R_PRIMARY) - primary = true; - -- if (peer_device->disk_state[NOW] == D_UP_TO_DATE) -+ if (peer_device->disk_state[NEW] == D_UP_TO_DATE) - up_to_date_data = true; - } - -@@ -4808,6 +4817,7 @@ change_cluster_wide_state(bool (*change)(struct change_context *, enum change_ph - } else if (context->mask.conn == conn_MASK && context->val.conn == C_DISCONNECTING) { - reply->target_reachable_nodes = NODE_MASK(context->target_node_id); - reply->reachable_nodes &= ~reply->target_reachable_nodes; -+ reply->is_disconnect = 1; - } else { - reply->target_reachable_nodes = reply->reachable_nodes; - } --- -2.35.3 - diff --git a/0002-drbd-inherit-history-UUIDs-from-sync-source-when-res.patch b/0002-drbd-inherit-history-UUIDs-from-sync-source-when-res.patch new file mode 100644 index 0000000..364c74c --- /dev/null +++ b/0002-drbd-inherit-history-UUIDs-from-sync-source-when-res.patch @@ -0,0 +1,60 @@ +From f6613104a37c1d43cb50fd619afccba370db47a0 Mon Sep 17 00:00:00 2001 +From: Joel Colledge +Date: Tue, 20 Aug 2024 12:28:09 +0100 +Subject: [PATCH 02/32] drbd: inherit history UUIDs from sync source when + resync finishes + +This prevents unexpected "unrelated data" or "split-brain" situations +from occurring later. For example with nodes A, B and C: +* A diskless, B, C with disk, all connected, on UUID X +* Down B +* Write on C, new UUID Y generated +* Add disk on A, resyncs from C +* Down C +* Up B, connects to A, should resync from A + +Without this change, "unrelated data" or "split-brain" occurs between A +and B. +Node A has current UUID Y, but knows nothing about X. +Node B has current UUID X, but knows nothing about Y. + +This scenario is also possible with "quorum majority". + +Fix this by adding the history and bitmap UUIDs from the sync source +into the history on the sync target when a resync finishes. In the above +scenario, this adds the UUID X into the history on A and so has the +effect that a full sync from A to B occurs in the final step. +--- + drbd/drbd_main.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/drbd/drbd_main.c b/drbd/drbd_main.c +index 7968be7c4c3f..862438885f35 100644 +--- a/drbd/drbd_main.c ++++ b/drbd/drbd_main.c +@@ -5030,11 +5030,22 @@ u64 drbd_uuid_resync_finished(struct drbd_peer_device *peer_device) __must_hold( + { + struct drbd_device *device = peer_device->device; + unsigned long flags; ++ int i; + u64 ss_nz_bm; /* sync_source has non zero bitmap for. expressed as nodemask */ + u64 pwcu; /* peers with current uuid */ + u64 newer; + + spin_lock_irqsave(&device->ldev->md.uuid_lock, flags); ++ // Inherit history from the sync source ++ for (i = 0; i < ARRAY_SIZE(peer_device->history_uuids); i++) ++ _drbd_uuid_push_history(device, peer_device->history_uuids[i] & ~UUID_PRIMARY); ++ ++ // Inherit history in bitmap UUIDs from the sync source ++ for (i = 0; i < DRBD_PEERS_MAX; i++) ++ if (peer_device->bitmap_uuids[i] != -1) ++ _drbd_uuid_push_history(device, ++ peer_device->bitmap_uuids[i] & ~UUID_PRIMARY); ++ + ss_nz_bm = __test_bitmap_slots_of_peer(peer_device); + pwcu = peers_with_current_uuid(device, peer_device->current_uuid); + +-- +2.35.3 + diff --git a/0003-build-compat-fix-line-offset-in-annotation-pragmas-p.patch b/0003-build-compat-fix-line-offset-in-annotation-pragmas-p.patch new file mode 100644 index 0000000..cbe6c49 --- /dev/null +++ b/0003-build-compat-fix-line-offset-in-annotation-pragmas-p.patch @@ -0,0 +1,36 @@ +From d6f2b71109f6a589fbc3d5c571c840a6bd142943 Mon Sep 17 00:00:00 2001 +From: Lars Ellenberg +Date: Thu, 22 Aug 2024 16:05:25 +0200 +Subject: [PATCH 03/32] build,compat: fix line offset in annotation pragmas + pointing to patched sources + +I forgot to update the "new position" by the two output pragma lines +for each non-context to context line transition per chunk. + +Offsets would accumultate within the chunk, but reset with the next chunk. + +Pragmas pointing into the "patched" file would be off by two lines +(per such transition within a chunk), pointing to some line 2 (4,6,8) lines +above the actual offending line. + +Noticed during recent compat work when the backward compat cocci rules +where still incomplete. +--- + .../annotate-diff-with-original-file-position-pragmas.pl | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drbd/drbd-kernel-compat/annotate-diff-with-original-file-position-pragmas.pl b/drbd/drbd-kernel-compat/annotate-diff-with-original-file-position-pragmas.pl +index c28265e6dd9d..de95689a6ef0 100644 +--- a/drbd/drbd-kernel-compat/annotate-diff-with-original-file-position-pragmas.pl ++++ b/drbd/drbd-kernel-compat/annotate-diff-with-original-file-position-pragmas.pl +@@ -91,6 +91,7 @@ m{^--- (?:\./)?(\S+)$} and do { + $chunk .= qq{+# $. "$patch_name"\n}; + $chunk .= qq{+# $o_pos "$ABS_NAME"\n}; + $n_count += 2; ++ $n_pos += 2; + $extra_ncount += 2; + $file_line_context_points_to_orig = 1; + $state = ' '; +-- +2.35.3 + diff --git a/0003-drbd-fix-error-path-in-drbd_get_listener.patch b/0003-drbd-fix-error-path-in-drbd_get_listener.patch deleted file mode 100644 index cdfef55..0000000 --- a/0003-drbd-fix-error-path-in-drbd_get_listener.patch +++ /dev/null @@ -1,32 +0,0 @@ -From fbfb92d11e64daec167b24521c715ceab505b55d Mon Sep 17 00:00:00 2001 -From: Philipp Reisner -Date: Thu, 7 Sep 2023 10:36:29 +0200 -Subject: [PATCH 03/20] drbd: fix error path in drbd_get_listener() - -When initializing a listener fails do not access the fields of the -listener struct after giving up the reference. ---- - drbd/drbd_transport.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/drbd/drbd_transport.c b/drbd/drbd_transport.c -index 416a50499046..2aefd71ee395 100644 ---- a/drbd/drbd_transport.c -+++ b/drbd/drbd_transport.c -@@ -207,11 +207,11 @@ int drbd_get_listener(struct drbd_transport *transport, struct drbd_path *path, - - if (needs_init) { - err = init_listener(transport, addr, &init_net, listener); -+ listener->err = err; -+ complete_all(&listener->ready); - if (err) - drbd_put_listener(path); - -- listener->err = err; -- complete_all(&listener->ready); - return err; - } - --- -2.35.3 - diff --git a/0004-drbd-build-fix-spurious-re-build-attempt-of-compat.p.patch b/0004-drbd-build-fix-spurious-re-build-attempt-of-compat.p.patch deleted file mode 100644 index 84d3199..0000000 --- a/0004-drbd-build-fix-spurious-re-build-attempt-of-compat.p.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 67ac093d6dc176fd6a3bf0c7f5a3ad046d48f558 Mon Sep 17 00:00:00 2001 -From: Lars Ellenberg -Date: Wed, 6 Sep 2023 14:38:32 +0200 -Subject: [PATCH 04/20] drbd: build: fix spurious re-build attempt of - compat.patch - -Patching changed the timestamp of the patched files, -which are pre-requisites for generating the patch. - -The second build after extracting the tarball -would try to regenerate the patch file. - -Exclude generated *.mod.c from "to-be-patched" files for spatch. -Reset timestamp of patched files to that of the patch file, instead of current time. ---- - drbd/Kbuild | 1 + - drbd/Makefile | 2 +- - 2 files changed, 2 insertions(+), 1 deletion(-) - -diff --git a/drbd/Kbuild b/drbd/Kbuild -index 1576dc19e1da..073469ae4191 100644 ---- a/drbd/Kbuild -+++ b/drbd/Kbuild -@@ -110,6 +110,7 @@ filechk_compat.h = cat $(obj)/compat.$(KERNELVERSION).h - $(src)/.compat_patches_applied: $(src)/drbd-kernel-compat/compat.patch - @$(kecho) ' PATCH' - @patch -d $(src) -p0 --batch --forward --reject-file=- < $(src)/drbd-kernel-compat/compat.patch -+ @cd $(src) && p=drbd-kernel-compat/compat.patch && sed -ne 's/^--- //p' < $$p | xargs -r -- touch -r $$p - @cp -d $(src)/drbd-kernel-compat/compat.patch $(src)/.compat_patches_applied - - $(src)/drbd-kernel-compat/compat.patch: $(obj)/compat.h -diff --git a/drbd/Makefile b/drbd/Makefile -index 09a1efbf7fe1..ecdff04b9808 100644 ---- a/drbd/Makefile -+++ b/drbd/Makefile -@@ -170,7 +170,7 @@ else - compat_headers := $(wildcard drbd-kernel-compat/cocci_cache/*/compat.h) - compat_patches := $(patsubst %.h,%.patch,$(compat_headers)) - -- sources := $(filter-out drbd_strings.c drbd_buildtag.c,$(wildcard *.c)) -+ sources := $(filter-out drbd_strings.c drbd_buildtag.c drbd%.mod.c,$(wildcard *.c)) - sources += $(wildcard drbd-headers/linux/*.h) - - $(compat_patches): $(sources) --- -2.35.3 - diff --git a/0004-drbd-fix-exposed_uuid-going-backward.patch b/0004-drbd-fix-exposed_uuid-going-backward.patch new file mode 100644 index 0000000..0d5529c --- /dev/null +++ b/0004-drbd-fix-exposed_uuid-going-backward.patch @@ -0,0 +1,57 @@ +From 2f464b8e8235efe2c5d972cf8054dcc2010b100e Mon Sep 17 00:00:00 2001 +From: Philipp Reisner +Date: Wed, 14 Aug 2024 17:42:44 +0200 +Subject: [PATCH 04/32] drbd: fix exposed_uuid going backward + +When a diskless node in the primary role creates a new current UUID, +it sends it all its UpToDate peers and sets it as its own exposed +UUID. If there is only one UpToDate node in the secondary role and it +sends its current UUID to the diskless primary at about the same time, +then with the following state change, through the function +ensure_expose_data_uuid(), the diskless primary sets its exposed_uuid +back to the previous one. + +Avoid this problem by not accepting a current_uuid update from a peer +when I am primary (authoritative), and I have told the peer the latest +update, and that peer is already on that latest (authoritative) value. +--- + drbd/drbd_main.c | 1 + + drbd/drbd_receiver.c | 10 +++++++++- + 2 files changed, 10 insertions(+), 1 deletion(-) + +diff --git a/drbd/drbd_main.c b/drbd/drbd_main.c +index 862438885f35..bc3283b045c9 100644 +--- a/drbd/drbd_main.c ++++ b/drbd/drbd_main.c +@@ -1484,6 +1484,7 @@ int drbd_send_current_uuid(struct drbd_peer_device *peer_device, u64 current_uui + if (!p) + return -EIO; + ++ peer_device->comm_current_uuid = current_uuid; + p->uuid = cpu_to_be64(current_uuid); + p->weak_nodes = cpu_to_be64(weak_nodes); + return drbd_send_command(peer_device, P_CURRENT_UUID, DATA_STREAM); +diff --git a/drbd/drbd_receiver.c b/drbd/drbd_receiver.c +index ee54cf3ac116..985fac8e69b3 100644 +--- a/drbd/drbd_receiver.c ++++ b/drbd/drbd_receiver.c +@@ -5815,7 +5815,15 @@ static int receive_uuids110(struct drbd_connection *connection, struct packet_in + peer_md = device->ldev->md.peers; + spin_lock_irq(&device->ldev->md.uuid_lock); + } +- peer_device->current_uuid = be64_to_cpu(p->current_uuid); ++ ++ if (device->resource->role[NOW] != R_PRIMARY || ++ device->disk_state[NOW] != D_DISKLESS || ++ (peer_device->current_uuid & ~UUID_PRIMARY) != ++ (device->exposed_data_uuid & ~UUID_PRIMARY) || ++ (peer_device->comm_current_uuid & ~UUID_PRIMARY) != ++ (device->exposed_data_uuid & ~UUID_PRIMARY)) ++ peer_device->current_uuid = be64_to_cpu(p->current_uuid); ++ + peer_device->dirty_bits = be64_to_cpu(p->dirty_bits); + peer_device->uuid_flags = be64_to_cpu(p->uuid_flags); + if (peer_device->uuid_flags & UUID_FLAG_HAS_UNALLOC) { +-- +2.35.3 + diff --git a/0005-drbd-Proper-locking-around-new_current_uuid-on-a-dis.patch b/0005-drbd-Proper-locking-around-new_current_uuid-on-a-dis.patch new file mode 100644 index 0000000..715c789 --- /dev/null +++ b/0005-drbd-Proper-locking-around-new_current_uuid-on-a-dis.patch @@ -0,0 +1,39 @@ +From c7384276634be7c5b49ef0b8d7fa064927a207f8 Mon Sep 17 00:00:00 2001 +From: Philipp Reisner +Date: Wed, 14 Aug 2024 19:42:40 +0200 +Subject: [PATCH 05/32] drbd: Proper locking around new_current_uuid on a + diskless + +Like the current UUID of a diskful node, changing the exposed_uuid of +a diskless node needs to be serialized with the UUID exchange when +establishing new connections. +--- + drbd/drbd_main.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/drbd/drbd_main.c b/drbd/drbd_main.c +index bc3283b045c9..2792b9896271 100644 +--- a/drbd/drbd_main.c ++++ b/drbd/drbd_main.c +@@ -4827,7 +4827,10 @@ void drbd_uuid_new_current(struct drbd_device *device, bool forced) + current_uuid |= UUID_PRIMARY; + else + current_uuid &= ~UUID_PRIMARY; ++ ++ down_write(&device->uuid_sem); + drbd_uuid_set_exposed(device, current_uuid, false); ++ downgrade_write(&device->uuid_sem); + drbd_info(device, "sending new current UUID: %016llX\n", current_uuid); + + weak_nodes = drbd_weak_nodes_device(device); +@@ -4837,6 +4840,7 @@ void drbd_uuid_new_current(struct drbd_device *device, bool forced) + peer_device->current_uuid = current_uuid; + } + } ++ up_read(&device->uuid_sem); + } + } + +-- +2.35.3 + diff --git a/0005-drbd-log-error-code-when-thread-fails-to-start.patch b/0005-drbd-log-error-code-when-thread-fails-to-start.patch deleted file mode 100644 index fd971ec..0000000 --- a/0005-drbd-log-error-code-when-thread-fails-to-start.patch +++ /dev/null @@ -1,28 +0,0 @@ -From a98c818bd33920fd5189cdd8f5d81850ad4a945b Mon Sep 17 00:00:00 2001 -From: Joel Colledge -Date: Thu, 7 Sep 2023 17:32:56 +0200 -Subject: [PATCH 05/20] drbd: log error code when thread fails to start - ---- - drbd/drbd_main.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/drbd/drbd_main.c b/drbd/drbd_main.c -index 38f728f3da73..810df864f60b 100644 ---- a/drbd/drbd_main.c -+++ b/drbd/drbd_main.c -@@ -642,9 +642,9 @@ int drbd_thread_start(struct drbd_thread *thi) - - if (IS_ERR(nt)) { - if (connection) -- drbd_err(connection, "Couldn't start thread\n"); -+ drbd_err(connection, "Couldn't start thread: %ld\n", PTR_ERR(nt)); - else -- drbd_err(resource, "Couldn't start thread\n"); -+ drbd_err(resource, "Couldn't start thread: %ld\n", PTR_ERR(nt)); - - return false; - } --- -2.35.3 - diff --git a/0006-build-CycloneDX-fix-bom-ref-add-purl.patch b/0006-build-CycloneDX-fix-bom-ref-add-purl.patch new file mode 100644 index 0000000..da2eb46 --- /dev/null +++ b/0006-build-CycloneDX-fix-bom-ref-add-purl.patch @@ -0,0 +1,43 @@ +From 18795749745baa4b8b37cb56eb12a57a7bd55da7 Mon Sep 17 00:00:00 2001 +From: Roland Kammerer +Date: Tue, 27 Aug 2024 09:08:31 +0200 +Subject: [PATCH 06/32] build: CycloneDX: fix bom-ref, add purl + +--- + Makefile | 4 ++-- + drbd-kmod.cdx.json.in | 1 + + 2 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/Makefile b/Makefile +index 83a2ed8a42f7..3f58568cc138 100644 +--- a/Makefile ++++ b/Makefile +@@ -238,11 +238,11 @@ drbd-kmod_rhel.spdx drbd-kmod_sles.spdx: + # only call this wrapper from drbd-kmod.cdx.json + .PHONY: cdx-sub + cdx-sub: +- cat $(CDX_FILE).in | jq --args '.metadata.timestamp = "$(CDX_DATE)" | .metadata.component.version = "$(FDIST_VERSION)" | .metadata.component."bom-ref" = "https://github.com/LINBIT/drbd/releases/tag/drbd-$(FDIST_VERSION)"' > $(CDX_FILE) ++ cat $(CDX_FILE).in | jq --args '.metadata.timestamp = "$(CDX_DATE)" | .metadata.component.version = "$(FDIST_VERSION)" | .metadata.component."bom-ref" = "$(PURL)" | .metadata.component.purl = "$(PURL)"' > $(CDX_FILE) + + .PHONY: drbd-kmod.cdx.json + drbd-kmod.cdx.json: +- $(MAKE) -s cdx-sub CDX_DATE="$$(date --utc +%FT%TZ)" CDX_FILE="$@" ++ $(MAKE) -s cdx-sub CDX_DATE="$$(date --utc +%FT%TZ)" PURL="pkg:github/LINBIT/drbd@drbd-$(FDIST_VERSION)" CDX_FILE="$@" + ! grep -q __PLACEHOLDER__ $@ + + # update of .filelist is forced: +diff --git a/drbd-kmod.cdx.json.in b/drbd-kmod.cdx.json.in +index f7a4c4a46aa6..ab4e05a43187 100644 +--- a/drbd-kmod.cdx.json.in ++++ b/drbd-kmod.cdx.json.in +@@ -18,6 +18,7 @@ + "name": "kmod-drbd", + "version": "__PLACEHOLDER__", + "bom-ref": "__PLACEHOLDER__", ++ "purl": "__PLACEHOLDER__", + "licenses": [ + { + "licenses": { +-- +2.35.3 + diff --git a/0006-drbd-log-numeric-value-of-drbd_state_rv-as-well-as-s.patch b/0006-drbd-log-numeric-value-of-drbd_state_rv-as-well-as-s.patch deleted file mode 100644 index f340c97..0000000 --- a/0006-drbd-log-numeric-value-of-drbd_state_rv-as-well-as-s.patch +++ /dev/null @@ -1,82 +0,0 @@ -From 8c2c783a09d81f0a725e7a3ae48be4ceb2d79a63 Mon Sep 17 00:00:00 2001 -From: Joel Colledge -Date: Fri, 8 Sep 2023 11:26:01 +0200 -Subject: [PATCH 06/20] drbd: log numeric value of drbd_state_rv as well as - string form - -"Auto-promote failed: ?" was seen in a log. Logging the numeric value of -the state change return value gives us more information about what -happened in such a case. ---- - drbd/drbd_main.c | 8 ++++---- - drbd/drbd_receiver.c | 6 +++--- - drbd/drbd_state.c | 3 ++- - 3 files changed, 9 insertions(+), 8 deletions(-) - -diff --git a/drbd/drbd_main.c b/drbd/drbd_main.c -index 810df864f60b..e26cf7e2b008 100644 ---- a/drbd/drbd_main.c -+++ b/drbd/drbd_main.c -@@ -2698,8 +2698,8 @@ static int drbd_open(struct block_device *bdev, fmode_t mode) - if (resource->role[NOW] == R_SECONDARY) { - rv = try_to_promote(device, timeout, (mode & FMODE_NDELAY)); - if (rv < SS_SUCCESS) -- drbd_info(resource, "Auto-promote failed: %s\n", -- drbd_set_st_err_str(rv)); -+ drbd_info(resource, "Auto-promote failed: %s (%d)\n", -+ drbd_set_st_err_str(rv), rv); - } - } else if ((mode & FMODE_NDELAY) == 0) { - /* Double check peers -@@ -2856,8 +2856,8 @@ static void drbd_release(struct gendisk *gd, fmode_t mode) - !test_bit(EXPLICIT_PRIMARY, &resource->flags)) { - rv = drbd_set_role(resource, R_SECONDARY, false, NULL); - if (rv < SS_SUCCESS) -- drbd_warn(resource, "Auto-demote failed: %s\n", -- drbd_set_st_err_str(rv)); -+ drbd_warn(resource, "Auto-demote failed: %s (%d)\n", -+ drbd_set_st_err_str(rv), rv); - } - } - -diff --git a/drbd/drbd_receiver.c b/drbd/drbd_receiver.c -index 95cf7ac36762..2162d13cb25e 100644 ---- a/drbd/drbd_receiver.c -+++ b/drbd/drbd_receiver.c -@@ -983,8 +983,8 @@ static int connect_work(struct drbd_work *work, int cancel) - drbd_send_disconnect(connection); - apply_local_state_change(connection, OUTDATE_DISKS_AND_DISCONNECT, force_demote); - } else { -- drbd_info(connection, "Failure to connect %d %s; retrying\n", -- rv, drbd_set_st_err_str(rv)); -+ drbd_info(connection, "Failure to connect: %s (%d); retrying\n", -+ drbd_set_st_err_str(rv), rv); - change_cstate(connection, C_NETWORK_FAILURE, CS_HARD); - } - -@@ -6107,7 +6107,7 @@ out: - } - - if (rv < SS_SUCCESS) { -- drbd_err(resource, "State change failed: %s\n", drbd_set_st_err_str(rv)); -+ drbd_err(resource, "State change failed: %s (%d)\n", drbd_set_st_err_str(rv), rv); - if (rv == SS_PRIMARY_READER) - log_openers(resource); - } -diff --git a/drbd/drbd_state.c b/drbd/drbd_state.c -index 8b60afeb097b..23eab7f867aa 100644 ---- a/drbd/drbd_state.c -+++ b/drbd/drbd_state.c -@@ -791,7 +791,8 @@ static enum drbd_state_rv ___end_state_change(struct drbd_resource *resource, st - rv = try_state_change(resource); - if (rv < SS_SUCCESS) { - if (flags & CS_VERBOSE) { -- drbd_err(resource, "State change failed: %s\n", drbd_set_st_err_str(rv)); -+ drbd_err(resource, "State change failed: %s (%d)\n", -+ drbd_set_st_err_str(rv), rv); - print_state_change(resource, "Failed: "); - } - goto out; --- -2.35.3 - diff --git a/0007-build-Another-update-to-the-spdx-files.patch b/0007-build-Another-update-to-the-spdx-files.patch new file mode 100644 index 0000000..7fc54f9 --- /dev/null +++ b/0007-build-Another-update-to-the-spdx-files.patch @@ -0,0 +1,51 @@ +From c4dd27cc69b99e13d4117fa348f968cf2199db6b Mon Sep 17 00:00:00 2001 +From: Philipp Reisner +Date: Wed, 28 Aug 2024 18:43:31 +0200 +Subject: [PATCH 07/32] build: Another update to the spdx files + +Some enterprise customers require these files to contain a +"PackageCopyrightText" tag. Apart from that they require the +SPDX in JSON format. That will come in another commit. +--- + Makefile | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/Makefile b/Makefile +index 3f58568cc138..80c20d24ab54 100644 +--- a/Makefile ++++ b/Makefile +@@ -205,6 +205,8 @@ PackageSupplier: Organization: LINBIT HA-Solutions GmbH + PackageDownloadLocation: https://github.com/LINBIT/drbd + FilesAnalyzed: false + PackageLicenseDeclared: GPL-2.0-only ++PackageCopyrightText: 2001-2008, LINBIT Information Technologies GmbH ++2008-$(SPDX_YEAR), LINBIT HA-Solutions GmbH + Relationship: SPDXRef-DOCUMENT DESCRIBES SPDXRef-Package-$(SPDX_PKG_NAME) + endef + +@@ -219,6 +221,7 @@ drbd-kmod_rhel.spdx drbd-kmod_sles.spdx: + SPDX_DATE="$$(date --utc +%FT%TZ)"; \ + SPDX_UUID="$$(cat /proc/sys/kernel/random/uuid)"; \ + SPDX_VERSION="$(REL_VERSION)"; \ ++ SPDX_YEAR="$$(date --utc +%Y)"; \ + case "$@" in \ + drbd-kmod_rhel.spdx) SPDX_PKG_NAME=kmod-drbd;; \ + drbd-kmod_sles.spdx) SPDX_PKG_NAME=drbd-kmp-default;; \ +@@ -228,11 +231,13 @@ drbd-kmod_rhel.spdx drbd-kmod_sles.spdx: + test -n "$$SPDX_DATE"; \ + test -n "$$SPDX_UUID"; \ + test -n "$$SPDX_VERSION"; \ ++ test -n "$$SPDX_YEAR"; \ + $(MAKE) spdx-file SPDX_UUID="$$SPDX_UUID" \ + SPDX_DATE="$$SPDX_DATE" \ + SPDX_FILE_TMP="$@.tmp" \ + SPDX_PKG_NAME="$$SPDX_PKG_NAME" \ +- SPDX_VERSION="$$SPDX_VERSION"; \ ++ SPDX_VERSION="$$SPDX_VERSION" \ ++ SPDX_YEAR="$$SPDX_YEAR"; \ + mv $@.tmp $@; ) + + # only call this wrapper from drbd-kmod.cdx.json +-- +2.35.3 + diff --git a/0007-drbd-stop-defining-__KERNEL_SYSCALLS__.patch b/0007-drbd-stop-defining-__KERNEL_SYSCALLS__.patch deleted file mode 100644 index a5a7b4f..0000000 --- a/0007-drbd-stop-defining-__KERNEL_SYSCALLS__.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 15cf257c277020e1ba76eff7aa99ed08d44f7d3c Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Moritz=20=22WanzenBug=22=20Wanzenb=C3=B6ck?= - -Date: Fri, 8 Sep 2023 11:45:48 +0200 -Subject: [PATCH 07/20] drbd: stop defining __KERNEL_SYSCALLS__ - -See also upstream Linux kernel commit -d519df00938e ("drbd: stop defining __KERNEL_SYSCALLS__") - -Original message: - -__KERNEL_SYSCALLS__ hasn't been needed since Linux 2.6.19 so stop -defining it. ---- - drbd/drbd_main.c | 1 - - drbd/drbd_receiver.c | 1 - - 2 files changed, 2 deletions(-) - -diff --git a/drbd/drbd_main.c b/drbd/drbd_main.c -index e26cf7e2b008..ccf0f72829db 100644 ---- a/drbd/drbd_main.c -+++ b/drbd/drbd_main.c -@@ -36,7 +36,6 @@ - #include - #include - #include --#define __KERNEL_SYSCALLS__ - #include - #include - #include -diff --git a/drbd/drbd_receiver.c b/drbd/drbd_receiver.c -index 2162d13cb25e..2e2ed4699a94 100644 ---- a/drbd/drbd_receiver.c -+++ b/drbd/drbd_receiver.c -@@ -26,7 +26,6 @@ - #include - #include - #include --#define __KERNEL_SYSCALLS__ - #include - #include - #include --- -2.35.3 - diff --git a/0008-build-generate-spdx.json-not-tag-value-format.patch b/0008-build-generate-spdx.json-not-tag-value-format.patch new file mode 100644 index 0000000..6d3c19e --- /dev/null +++ b/0008-build-generate-spdx.json-not-tag-value-format.patch @@ -0,0 +1,235 @@ +From ca3589743378a7750b9e6a8e19b904d57986cce4 Mon Sep 17 00:00:00 2001 +From: Lars Ellenberg +Date: Wed, 28 Aug 2024 20:00:36 +0200 +Subject: [PATCH 08/32] build: generate spdx.json, not "tag value" format + +Generates .spdx.json files in SPDX-json format instead of tag/value. +This appears to be more machine friendly. + +Use jq with "null" input and \(env.) string interpolation in templates. + +Move all this to a new ./sbom/ subdirectory. +--- + Makefile | 74 ++----------------- + sbom/Makefile | 24 ++++++ + .../drbd-kmod.cdx.json.in | 8 +- + sbom/drbd-kmod.spdx.json.in | 32 ++++++++ + 4 files changed, 68 insertions(+), 70 deletions(-) + create mode 100644 sbom/Makefile + rename drbd-kmod.cdx.json.in => sbom/drbd-kmod.cdx.json.in (84%) + create mode 100644 sbom/drbd-kmod.spdx.json.in + +diff --git a/Makefile b/Makefile +index 80c20d24ab54..37ffcd777d09 100644 +--- a/Makefile ++++ b/Makefile +@@ -92,6 +92,8 @@ ifndef FDIST_VERSION + FDIST_VERSION := $(DIST_VERSION) + endif + ++export REL_VERSION FDIST_VERSION ++ + all: module tools + + .PHONY: all tools module +@@ -189,76 +191,15 @@ drbd/.drbd_git_revision: FORCE + @echo >&2 "Need a git checkout to regenerate $@"; test -s $@ + endif + +-export define SPDX_TEMPLATE +-SPDXVersion: SPDX-2.3 +-DataLicense: CC0-1.0 +-SPDXID: SPDXRef-DOCUMENT +-DocumentName: drbd kernel module SBOM (software bill of materials) +-DocumentNamespace: https://linbit.org/spdx-docs/drbd-kmod-$(SPDX_VERSION)-$(SPDX_UUID) +-Creator: Person: Philipp Reisner (philipp.reisner@linbit.com) +-Created: $(SPDX_DATE) +- +-PackageName: $(SPDX_PKG_NAME) +-SPDXID: SPDXRef-Package-$(SPDX_PKG_NAME) +-PackageVersion: $(SPDX_VERSION) +-PackageSupplier: Organization: LINBIT HA-Solutions GmbH +-PackageDownloadLocation: https://github.com/LINBIT/drbd +-FilesAnalyzed: false +-PackageLicenseDeclared: GPL-2.0-only +-PackageCopyrightText: 2001-2008, LINBIT Information Technologies GmbH +-2008-$(SPDX_YEAR), LINBIT HA-Solutions GmbH +-Relationship: SPDXRef-DOCUMENT DESCRIBES SPDXRef-Package-$(SPDX_PKG_NAME) +-endef +- +-# only call this wrapper from drbd-kmod_{sles,rhel}.spdx +-.PHONY: spdx-file +-spdx-file: +- @echo "$$SPDX_TEMPLATE" > $(SPDX_FILE_TMP) +- +-.PHONY: drbd-kmod_rhel.spdx drbd-kmod_sles.spdx +-drbd-kmod_rhel.spdx drbd-kmod_sles.spdx: +- @set -e; ( truncate -s0 $@.tmp; \ +- SPDX_DATE="$$(date --utc +%FT%TZ)"; \ +- SPDX_UUID="$$(cat /proc/sys/kernel/random/uuid)"; \ +- SPDX_VERSION="$(REL_VERSION)"; \ +- SPDX_YEAR="$$(date --utc +%Y)"; \ +- case "$@" in \ +- drbd-kmod_rhel.spdx) SPDX_PKG_NAME=kmod-drbd;; \ +- drbd-kmod_sles.spdx) SPDX_PKG_NAME=drbd-kmp-default;; \ +- *) false;; \ +- esac; \ +- test -n "$$SPDX_TEMPLATE"; \ +- test -n "$$SPDX_DATE"; \ +- test -n "$$SPDX_UUID"; \ +- test -n "$$SPDX_VERSION"; \ +- test -n "$$SPDX_YEAR"; \ +- $(MAKE) spdx-file SPDX_UUID="$$SPDX_UUID" \ +- SPDX_DATE="$$SPDX_DATE" \ +- SPDX_FILE_TMP="$@.tmp" \ +- SPDX_PKG_NAME="$$SPDX_PKG_NAME" \ +- SPDX_VERSION="$$SPDX_VERSION" \ +- SPDX_YEAR="$$SPDX_YEAR"; \ +- mv $@.tmp $@; ) +- +-# only call this wrapper from drbd-kmod.cdx.json +-.PHONY: cdx-sub +-cdx-sub: +- cat $(CDX_FILE).in | jq --args '.metadata.timestamp = "$(CDX_DATE)" | .metadata.component.version = "$(FDIST_VERSION)" | .metadata.component."bom-ref" = "$(PURL)" | .metadata.component.purl = "$(PURL)"' > $(CDX_FILE) +- +-.PHONY: drbd-kmod.cdx.json +-drbd-kmod.cdx.json: +- $(MAKE) -s cdx-sub CDX_DATE="$$(date --utc +%FT%TZ)" PURL="pkg:github/LINBIT/drbd@drbd-$(FDIST_VERSION)" CDX_FILE="$@" +- ! grep -q __PLACEHOLDER__ $@ +- + # update of .filelist is forced: + .fdist_version: FORCE + @test -s $@ && test "$$(cat $@)" = "$(FDIST_VERSION)" || echo "$(FDIST_VERSION)" > $@ + + .filelist: .fdist_version FORCE + @$(GIT) ls-files --recurse -- ':!:.git*' $(if $(PRESERVE_DEBIAN),,':!:debian') > $@.new ++ @test -s $@.new # assert there is something in .filelist.new now + @mkdir -p drbd/drbd-kernel-compat/cocci_cache/ + @find drbd/drbd-kernel-compat/cocci_cache/ -type f -not -path '*/\.*' >> $@.new +- @test -s $@.new # assert there is something in .filelist.new now + @mv $@.new $@ + @echo "./.filelist updated." + +@@ -273,9 +214,10 @@ drbd-kmod.cdx.json: + comma := , + backslash_comma := \, + escape_comma = $(subst $(comma),$(backslash_comma),$(1)) +-tgz-extra-files := \ +- .fdist_version drbd/.drbd_git_revision .filelist \ +- drbd-kmod_rhel.spdx drbd-kmod_sles.spdx drbd-kmod.cdx.json ++tgz-extra-files := .fdist_version drbd/.drbd_git_revision .filelist ++tgz-extra-files += sbom/drbd-kmod_rhel.spdx.json ++tgz-extra-files += sbom/drbd-kmod_sles.spdx.json ++tgz-extra-files += sbom/drbd-kmod.cdx.json + tgz: + test -s .filelist # .filelist must be present + test -n "$(FDIST_VERSION)" # FDIST_VERSION must be known +@@ -318,7 +260,7 @@ debrelease: + tarball: + $(MAKE) distclean + $(MAKE) check-submods check_all_committed drbd/.drbd_git_revision +- $(MAKE) drbd-kmod_rhel.spdx drbd-kmod_sles.spdx drbd-kmod.cdx.json ++ $(MAKE) -C sbom drbd-kmod_rhel.spdx.json drbd-kmod_sles.spdx.json drbd-kmod.cdx.json + $(MAKE) .filelist + $(MAKE) tgz + +diff --git a/sbom/Makefile b/sbom/Makefile +new file mode 100644 +index 000000000000..757f57e4db60 +--- /dev/null ++++ b/sbom/Makefile +@@ -0,0 +1,24 @@ ++ ++# we inherit some variables from our "parent" Makefile ++THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST)) ++$(foreach v,REL_VERSION FDIST_VERSION,$(if $($(v)),,$(error "Do not use this Makefile ($(THIS_MAKEFILE)) directly! ($(v) missing)))) ++ ++all: drbd-kmod.cdx.json drbd-kmod_rhel.spdx.json drbd-kmod_sles.spdx.json ++ ++export SPDX_VERSION SPDX_DATE SPDX_YEAR SPDX_UUID SPDX_PKG_NAME ++SPDX_VERSION:=$(REL_VERSION) ++SPDX_DATE:=$(shell date --utc +%FT%TZ) ++SPDX_YEAR:=$(firstword $(subst -, ,$(SPDX_DATE))) ++drbd-kmod_rhel.spdx.json drbd-kmod_sles.spdx.json: SPDX_UUID:=$(shell cat /proc/sys/kernel/random/uuid) ++drbd-kmod_rhel.spdx.json: SPDX_PKG_NAME:=kmod-drbd ++drbd-kmod_sles.spdx.json: SPDX_PKG_NAME:=drbd-kmp-default ++drbd-kmod_rhel.spdx.json drbd-kmod_sles.spdx.json: FORCE ++ @rm -f $@; jq -n -f drbd-kmod.spdx.json.in > $@.tmp && mv $@.tmp $@ ++ ++# uses: ++# SPDX_DATE from above and FDIST_VERSION from parent Makefile ++drbd-kmod.cdx.json: FORCE ++ @rm -f $@; jq -n -f drbd-kmod.cdx.json.in > $@.tmp && mv $@.tmp $@ ++ ++.PHONY: FORCE ++FORCE: +diff --git a/drbd-kmod.cdx.json.in b/sbom/drbd-kmod.cdx.json.in +similarity index 84% +rename from drbd-kmod.cdx.json.in +rename to sbom/drbd-kmod.cdx.json.in +index ab4e05a43187..99858e8b9b43 100644 +--- a/drbd-kmod.cdx.json.in ++++ b/sbom/drbd-kmod.cdx.json.in +@@ -2,7 +2,7 @@ + "bomFormat": "CycloneDX", + "specVersion": "1.5", + "metadata": { +- "timestamp": "__PLACEHOLDER__", ++ "timestamp": "\(env.SPDX_DATE)", + "authors": [ + { + "name": "Philipp Reisner", +@@ -16,9 +16,9 @@ + "component": { + "type": "application", + "name": "kmod-drbd", +- "version": "__PLACEHOLDER__", +- "bom-ref": "__PLACEHOLDER__", +- "purl": "__PLACEHOLDER__", ++ "version": "\(env.FDIST_VERSION)", ++ "bom-ref": "pkg:github/LINBIT/drbd@drbd-\(env.FDIST_VERSION)", ++ "purl": "pkg:github/LINBIT/drbd@drbd-\(env.FDIST_VERSION)", + "licenses": [ + { + "licenses": { +diff --git a/sbom/drbd-kmod.spdx.json.in b/sbom/drbd-kmod.spdx.json.in +new file mode 100644 +index 000000000000..07c1003f8834 +--- /dev/null ++++ b/sbom/drbd-kmod.spdx.json.in +@@ -0,0 +1,32 @@ ++{ ++ "SPDXID": "SPDXRef-DOCUMENT", ++ "spdxVersion": "SPDX-2.3", ++ "creationInfo": { ++ "created": "\(env.SPDX_DATE)", ++ "creators": [ ++ "Person: Philipp Reisner (philipp.reisner@linbit.com)" ++ ] ++ }, ++ "name": "drbd kernel module SBOM (software bill of materials)", ++ "dataLicense": "CC0-1.0", ++ "documentNamespace": "https://linbit.org/spdx-docs/drbd-kmod-\(env.SPDX_VERSION)-\(env.SPDX_UUID)", ++ "packages": [ ++ { ++ "SPDXID": "SPDXRef-Package-\(env.SPDX_PKG_NAME)", ++ "copyrightText": "2001-2008, LINBIT Information Technologies GmbH\n2008-\(env.SPDX_YEAR), LINBIT HA-Solutions GmbH", ++ "downloadLocation": "https://github.com/LINBIT/drbd", ++ "filesAnalyzed": false, ++ "licenseDeclared": "GPL-2.0-only", ++ "name": "\(env.SPDX_PKG_NAME)", ++ "supplier": "Organization: LINBIT HA-Solutions GmbH", ++ "versionInfo": "\(env.SPDX_VERSION)" ++ } ++ ], ++ "relationships": [ ++ { ++ "spdxElementId": "SPDXRef-DOCUMENT", ++ "relationshipType": "DESCRIBES", ++ "relatedSpdxElement": "SPDXRef-Package-\(env.SPDX_PKG_NAME)" ++ } ++ ] ++} +-- +2.35.3 + diff --git a/0008-compat-block-introduce-holder-ops.patch b/0008-compat-block-introduce-holder-ops.patch deleted file mode 100644 index 53fa4d9..0000000 --- a/0008-compat-block-introduce-holder-ops.patch +++ /dev/null @@ -1,80 +0,0 @@ -From c34a13c3df85352124e94456f81e3d4ba4f52440 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Moritz=20=22WanzenBug=22=20Wanzenb=C3=B6ck?= - -Date: Fri, 8 Sep 2023 12:20:10 +0200 -Subject: [PATCH 08/20] compat: block: introduce holder ops - -See also upstream Linux kernel commit -0718afd47f70 ("block: introduce holder ops") - -Original message: - -Add a new blk_holder_ops structure, which is passed to blkdev_get_by_* and -installed in the block_device for exclusive claims. It will be used to -allow the block layer to call back into the user of the block device for -thing like notification of a removed device or a device resize. ---- - .../cocci/blkdev_get_by_path__no_has_holder_ops.cocci | 6 ++++++ - drbd/drbd-kernel-compat/gen_patch_names.c | 3 +++ - .../tests/blkdev_get_by_path_has_holder_ops.c | 7 +++++++ - drbd/drbd_nl.c | 3 ++- - 4 files changed, 18 insertions(+), 1 deletion(-) - create mode 100644 drbd/drbd-kernel-compat/cocci/blkdev_get_by_path__no_has_holder_ops.cocci - create mode 100644 drbd/drbd-kernel-compat/tests/blkdev_get_by_path_has_holder_ops.c - -diff --git a/drbd/drbd-kernel-compat/cocci/blkdev_get_by_path__no_has_holder_ops.cocci b/drbd/drbd-kernel-compat/cocci/blkdev_get_by_path__no_has_holder_ops.cocci -new file mode 100644 -index 000000000000..050d89e6fe0d ---- /dev/null -+++ b/drbd/drbd-kernel-compat/cocci/blkdev_get_by_path__no_has_holder_ops.cocci -@@ -0,0 +1,6 @@ -+@@ -+expression path, mode, holder, ops; -+@@ -+ blkdev_get_by_path(path, mode, holder -+- , ops -+ ) -diff --git a/drbd/drbd-kernel-compat/gen_patch_names.c b/drbd/drbd-kernel-compat/gen_patch_names.c -index 959bbc351e1b..7071a0a4c5ec 100644 ---- a/drbd/drbd-kernel-compat/gen_patch_names.c -+++ b/drbd/drbd-kernel-compat/gen_patch_names.c -@@ -556,6 +556,9 @@ int main(int argc, char **argv) - patch(1, "__bio_add_page", true, false, - COMPAT_HAVE___BIO_ADD_PAGE, "present"); - -+ patch(1, "blkdev_get_by_path", true, false, -+ COMPAT_BLKDEV_GET_BY_PATH_HAS_HOLDER_OPS, "has_holder_ops"); -+ - /* #define BLKDEV_ISSUE_ZEROOUT_EXPORTED */ - /* #define BLKDEV_ZERO_NOUNMAP */ - -diff --git a/drbd/drbd-kernel-compat/tests/blkdev_get_by_path_has_holder_ops.c b/drbd/drbd-kernel-compat/tests/blkdev_get_by_path_has_holder_ops.c -new file mode 100644 -index 000000000000..02a560782f37 ---- /dev/null -+++ b/drbd/drbd-kernel-compat/tests/blkdev_get_by_path_has_holder_ops.c -@@ -0,0 +1,7 @@ -+/* { "version": "v6.5-rc1", "commit": "0718afd47f70cf46877c39c25d06b786e1a3f36c", "comment": "block: introduce holder ops", "author": "Christoph Hellwig ", "date": "Thu Jun 1 11:44:52 2023 +0200" } */ -+#include -+ -+struct block_device *foo(const char *bdev_path, struct blk_holder_ops *ops) -+{ -+ return blkdev_get_by_path(bdev_path, 0, NULL, ops); -+} -diff --git a/drbd/drbd_nl.c b/drbd/drbd_nl.c -index 0fc1d84a996f..0a67bfa4ca52 100644 ---- a/drbd/drbd_nl.c -+++ b/drbd/drbd_nl.c -@@ -2560,7 +2560,8 @@ static struct block_device *open_backing_dev(struct drbd_device *device, - const char *bdev_path, void *claim_ptr) - { - struct block_device *bdev = blkdev_get_by_path(bdev_path, -- FMODE_READ | FMODE_WRITE | FMODE_EXCL, claim_ptr); -+ FMODE_READ | FMODE_WRITE | FMODE_EXCL, -+ claim_ptr, NULL); - if (IS_ERR(bdev)) { - drbd_err(device, "open(\"%s\") failed with %ld\n", - bdev_path, PTR_ERR(bdev)); --- -2.35.3 - diff --git a/0009-compat-fix-gen_patch_names-for-bdev_file_open_by_pat.patch b/0009-compat-fix-gen_patch_names-for-bdev_file_open_by_pat.patch new file mode 100644 index 0000000..12dfbab --- /dev/null +++ b/0009-compat-fix-gen_patch_names-for-bdev_file_open_by_pat.patch @@ -0,0 +1,49 @@ +From 98325293e7d64ffae0e5e70620c5040ab0c76179 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= + +Date: Tue, 13 Aug 2024 12:23:52 +0200 +Subject: [PATCH 09/32] compat: fix gen_patch_names for bdev_file_open_by_path + +--- + drbd/drbd-kernel-compat/gen_patch_names.c | 12 +++++------- + 1 file changed, 5 insertions(+), 7 deletions(-) + +diff --git a/drbd/drbd-kernel-compat/gen_patch_names.c b/drbd/drbd-kernel-compat/gen_patch_names.c +index a9781bbd04e5..7549ee39afb7 100644 +--- a/drbd/drbd-kernel-compat/gen_patch_names.c ++++ b/drbd/drbd-kernel-compat/gen_patch_names.c +@@ -564,14 +564,17 @@ int main(int argc, char **argv) + patch(1, "__bio_add_page", true, false, + COMPAT_HAVE___BIO_ADD_PAGE, "present"); + ++ /* blkdev_put is oldest, then bdev_open_by_path, then bdev_file_open_by_path */ + patch(1, "bdev_file_open_by_path", true, false, + COMPAT_HAVE_BDEV_FILE_OPEN_BY_PATH, "present"); +- + #if !defined(COMPAT_HAVE_BDEV_FILE_OPEN_BY_PATH) ++ /* middle ground: bdev_open_by_path */ + patch(1, "bdev_open_by_path", true, false, + COMPAT_HAVE_BDEV_OPEN_BY_PATH, "present"); +- + # if !defined(COMPAT_HAVE_BDEV_OPEN_BY_PATH) ++ /* old: blkdev_get_by_* and blkdev_put */ ++ patch(1, "blkdev_put", true, false, ++ COMPAT_BLKDEV_PUT_HAS_HOLDER, "has_holder"); + patch(1, "blkdev_get_by_path", true, false, + COMPAT_BLKDEV_GET_BY_PATH_HAS_HOLDER_OPS, "has_holder_ops"); + # endif +@@ -586,11 +589,6 @@ int main(int argc, char **argv) + patch(1, "blk_mode_t", true, false, + COMPAT_HAVE_BLK_MODE_T, "present"); + +-#if !defined(COMPAT_HAVE_BDEV_OPEN_BY_PATH) +- patch(1, "blkdev_put", true, false, +- COMPAT_BLKDEV_PUT_HAS_HOLDER, "has_holder"); +-#endif +- + patch(1, "genl_info_userhdr", true, false, + COMPAT_HAVE_GENL_INFO_USERHDR, "present"); + +-- +2.35.3 + diff --git a/0009-drbd-reduce-net_ee-not-empty-info-to-a-dynamic-debug.patch b/0009-drbd-reduce-net_ee-not-empty-info-to-a-dynamic-debug.patch deleted file mode 100644 index 4f59585..0000000 --- a/0009-drbd-reduce-net_ee-not-empty-info-to-a-dynamic-debug.patch +++ /dev/null @@ -1,45 +0,0 @@ -From fc7b1ad2c422e4148d6419f1eec56189a7a578ac Mon Sep 17 00:00:00 2001 -From: Joel Colledge -Date: Fri, 1 Sep 2023 11:04:49 +0200 -Subject: [PATCH 09/20] drbd: reduce "net_ee not empty" info to a dynamic debug - print - -This situation is known and harmless. No need to print a worrying -"killed N entries" message when it occurs. - -A similar comment explaining that this is harmless was introduced in -commit: -31e0f1250f17 on disconnect, just give up all references on pages from net_ee - -But the comment got lost in some refactoring: -0b220db6109e drbd: move {active,read,sync,done}_ee lists from device to connection - -Bring the comment back, slightly simplified. ---- - drbd/drbd_receiver.c | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -diff --git a/drbd/drbd_receiver.c b/drbd/drbd_receiver.c -index 2e2ed4699a94..223353b1081c 100644 ---- a/drbd/drbd_receiver.c -+++ b/drbd/drbd_receiver.c -@@ -8664,9 +8664,15 @@ static void conn_disconnect(struct drbd_connection *connection) - i = drbd_free_peer_reqs(connection, &connection->sync_ee); - if (i) - drbd_info(connection, "sync_ee not empty, killed %u entries\n", i); -+ -+ /* -+ * tcp_close and release of sendpage pages can be deferred. We don't -+ * care for exactly when the network stack does its put_page(), but -+ * release our reference on these pages right here. -+ */ - i = drbd_free_peer_reqs(connection, &connection->net_ee); - if (i) -- drbd_info(connection, "net_ee not empty, killed %u entries\n", i); -+ dynamic_drbd_dbg(connection, "net_ee not empty, killed %u entries\n", i); - - cleanup_unacked_peer_requests(connection); - cleanup_peer_ack_list(connection); --- -2.35.3 - diff --git a/boo1230635_01-compat-fix-nla_nest_start_noflag-test.patch b/0010-compat-fix-nla_nest_start_noflag-test.patch similarity index 95% rename from boo1230635_01-compat-fix-nla_nest_start_noflag-test.patch rename to 0010-compat-fix-nla_nest_start_noflag-test.patch index b1b3e36..6cdfbd6 100644 --- a/boo1230635_01-compat-fix-nla_nest_start_noflag-test.patch +++ b/0010-compat-fix-nla_nest_start_noflag-test.patch @@ -2,7 +2,7 @@ From f6078aa51ed5b776eb2f646553872d576c404c60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= Date: Tue, 13 Aug 2024 12:40:27 +0200 -Subject: [PATCH] compat: fix nla_nest_start_noflag test +Subject: [PATCH 10/32] compat: fix nla_nest_start_noflag test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit diff --git a/0010-drbd-do-not-send-P_CURRENT_UUID-to-DRBD-8-peer-when-.patch b/0010-drbd-do-not-send-P_CURRENT_UUID-to-DRBD-8-peer-when-.patch deleted file mode 100644 index 20d3297..0000000 --- a/0010-drbd-do-not-send-P_CURRENT_UUID-to-DRBD-8-peer-when-.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 1b94c10250c7d37423ba894457c40d9799025a93 Mon Sep 17 00:00:00 2001 -From: Joel Colledge -Date: Mon, 11 Sep 2023 09:20:24 +0200 -Subject: [PATCH 10/20] drbd: do not send P_CURRENT_UUID to DRBD 8 peer when - our disk fails - -DRBD 8 does not understand P_CURRENT_UUID. Skip the peer in -diskfull_peers_need_new_cur_uuid() to avoid sending such a packet. - -This is valid because the DRBD 8 peer generates a new UUID itself when -our disk fails. - -This prevents failures of the form: - -drbd res: Unexpected data packet Unknown (0x0044) -drbd res: peer( Primary -> Unknown ) conn( Connected -> ProtocolError ) pdsk( Failed -> DUnknown ) ---- - drbd/drbd_main.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/drbd/drbd_main.c b/drbd/drbd_main.c -index ccf0f72829db..e6ed1185c710 100644 ---- a/drbd/drbd_main.c -+++ b/drbd/drbd_main.c -@@ -4614,6 +4614,9 @@ static bool diskfull_peers_need_new_cur_uuid(struct drbd_device *device) - - rcu_read_lock(); - for_each_peer_device_rcu(peer_device, device) { -+ if (peer_device->connection->agreed_pro_version < 110) -+ continue; -+ - /* Only an up-to-date peer persists a new current uuid! */ - if (peer_device->disk_state[NOW] < D_UP_TO_DATE) - continue; --- -2.35.3 - diff --git a/0011-compat-block-pass-a-gendisk-to-open.patch b/0011-compat-block-pass-a-gendisk-to-open.patch deleted file mode 100644 index a5b00ee..0000000 --- a/0011-compat-block-pass-a-gendisk-to-open.patch +++ /dev/null @@ -1,129 +0,0 @@ -From b993152e80676f5b9ce583c9471b630cbd0675d7 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Moritz=20=22WanzenBug=22=20Wanzenb=C3=B6ck?= - -Date: Fri, 8 Sep 2023 15:09:47 +0200 -Subject: [PATCH 11/20] compat: block: pass a gendisk to ->open - -See also upstream Linux kernel commit -d32e2bf83791 ("block: pass a gendisk to ->open") - -Original message: - -->open is only called on the whole device. Make that explicit by -passing a gendisk instead of the block_device. ---- - ...ice_operations_open__no_takes_gendisk.cocci | 18 ++++++++++++++++++ - drbd/drbd-kernel-compat/gen_patch_names.c | 3 +++ - ...lock_device_operations_open_takes_gendisk.c | 17 +++++++++++++++++ - drbd/drbd_main.c | 10 +++++----- - 4 files changed, 43 insertions(+), 5 deletions(-) - create mode 100644 drbd/drbd-kernel-compat/cocci/block_device_operations_open__no_takes_gendisk.cocci - create mode 100644 drbd/drbd-kernel-compat/tests/block_device_operations_open_takes_gendisk.c - -diff --git a/drbd/drbd-kernel-compat/cocci/block_device_operations_open__no_takes_gendisk.cocci b/drbd/drbd-kernel-compat/cocci/block_device_operations_open__no_takes_gendisk.cocci -new file mode 100644 -index 000000000000..2ba2856da9db ---- /dev/null -+++ b/drbd/drbd-kernel-compat/cocci/block_device_operations_open__no_takes_gendisk.cocci -@@ -0,0 +1,18 @@ -+@ drbd_open_arg @ -+identifier gd; -+fresh identifier bdev = "" ## "bdev"; -+@@ -+ drbd_open( -+- struct gendisk *gd, -++ struct block_device *bdev, -+ ... ) { -+<... -+( -+- gd->part0 -++ bdev -+| -+- gd -++ bdev->bd_disk -+) -+...> -+} -diff --git a/drbd/drbd-kernel-compat/gen_patch_names.c b/drbd/drbd-kernel-compat/gen_patch_names.c -index 7071a0a4c5ec..6e4f06d9a3a7 100644 ---- a/drbd/drbd-kernel-compat/gen_patch_names.c -+++ b/drbd/drbd-kernel-compat/gen_patch_names.c -@@ -559,6 +559,9 @@ int main(int argc, char **argv) - patch(1, "blkdev_get_by_path", true, false, - COMPAT_BLKDEV_GET_BY_PATH_HAS_HOLDER_OPS, "has_holder_ops"); - -+ patch(1, "block_device_operations_open", true, false, -+ COMPAT_BLOCK_DEVICE_OPERATIONS_OPEN_TAKES_GENDISK, "takes_gendisk"); -+ - /* #define BLKDEV_ISSUE_ZEROOUT_EXPORTED */ - /* #define BLKDEV_ZERO_NOUNMAP */ - -diff --git a/drbd/drbd-kernel-compat/tests/block_device_operations_open_takes_gendisk.c b/drbd/drbd-kernel-compat/tests/block_device_operations_open_takes_gendisk.c -new file mode 100644 -index 000000000000..d5f20fd569fb ---- /dev/null -+++ b/drbd/drbd-kernel-compat/tests/block_device_operations_open_takes_gendisk.c -@@ -0,0 +1,17 @@ -+/* { "version": "v6.5-rc1", "commit": "d32e2bf83791727a84ad5d3e3d713e82f9adbe30", "comment": "block: pass a gendisk to ->open", "author": "Christoph Hellwig ", "date": "Thu Jun 8 13:02:36 2023 +0200" } */ -+#include -+ -+#ifndef __same_type -+# define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) -+#endif -+ -+int foo_open(struct gendisk *disk, unsigned int mode) -+{ -+ return 0; -+} -+ -+void foo(void) -+{ -+ struct block_device_operations ops; -+ BUILD_BUG_ON(!(__same_type(ops.open, &foo_open))); -+} -diff --git a/drbd/drbd_main.c b/drbd/drbd_main.c -index e6ed1185c710..53cb4c9e7db3 100644 ---- a/drbd/drbd_main.c -+++ b/drbd/drbd_main.c -@@ -52,7 +52,7 @@ - #include "drbd_meta_data.h" - #include "drbd_dax_pmem.h" - --static int drbd_open(struct block_device *bdev, fmode_t mode); -+static int drbd_open(struct gendisk *gd, fmode_t mode); - static void drbd_release(struct gendisk *gd, fmode_t mode); - static void md_sync_timer_fn(struct timer_list *t); - static int w_bitmap_io(struct drbd_work *w, int unused); -@@ -2646,9 +2646,9 @@ out: - spin_unlock(&device->openers_lock); - } - --static int drbd_open(struct block_device *bdev, fmode_t mode) -+static int drbd_open(struct gendisk *gd, fmode_t mode) - { -- struct drbd_device *device = bdev->bd_disk->private_data; -+ struct drbd_device *device = gd->private_data; - struct drbd_resource *resource = device->resource; - long timeout = resource->res_opts.auto_promote_timeout * HZ / 10; - enum ioc_rv r; -@@ -2664,7 +2664,7 @@ static int drbd_open(struct block_device *bdev, fmode_t mode) - - /* Fail read-write open early, - * in case someone explicitly set us read-only (blockdev --setro) */ -- if (bdev_read_only(bdev) && (mode & FMODE_WRITE)) -+ if (bdev_read_only(gd->part0) && (mode & FMODE_WRITE)) - return -EACCES; - - if (resource->fail_io[NOW]) -@@ -2740,7 +2740,7 @@ out: - - mutex_unlock(&resource->open_release); - if (err) { -- drbd_release(bdev->bd_disk, mode); -+ drbd_release(gd, mode); - if (err == -EAGAIN && !(mode & FMODE_NDELAY)) - err = -EMEDIUMTYPE; - } --- -2.35.3 - diff --git a/0011-compat-fix-blk_alloc_disk-rule.patch b/0011-compat-fix-blk_alloc_disk-rule.patch new file mode 100644 index 0000000..0f838a2 --- /dev/null +++ b/0011-compat-fix-blk_alloc_disk-rule.patch @@ -0,0 +1,29 @@ +From 32b84f7b4d071312e5e812eab6b26e4aad2899e4 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= + +Date: Mon, 19 Aug 2024 16:19:47 +0200 +Subject: [PATCH 11/32] compat: fix blk_alloc_disk rule + +--- + drbd/drbd-kernel-compat/gen_patch_names.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drbd/drbd-kernel-compat/gen_patch_names.c b/drbd/drbd-kernel-compat/gen_patch_names.c +index 7549ee39afb7..c21a43b39488 100644 +--- a/drbd/drbd-kernel-compat/gen_patch_names.c ++++ b/drbd/drbd-kernel-compat/gen_patch_names.c +@@ -155,9 +155,10 @@ int main(int argc, char **argv) + + 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) + patch(1, "blk_alloc_disk", true, false, + COMPAT_HAVE_BLK_ALLOC_DISK, "present"); ++#endif + + /*******************************************************************************/ + /* +-- +2.35.3 + diff --git a/0012-drbd-Restore-DATA_CORKED-and-CONTROL_CORKED-bits.patch b/0012-drbd-Restore-DATA_CORKED-and-CONTROL_CORKED-bits.patch deleted file mode 100644 index 343fbe5..0000000 --- a/0012-drbd-Restore-DATA_CORKED-and-CONTROL_CORKED-bits.patch +++ /dev/null @@ -1,67 +0,0 @@ -From 88bf7f95dc359f4901f08ac8fb8ffc7dfceca9c1 Mon Sep 17 00:00:00 2001 -From: Philipp Reisner -Date: Wed, 13 Sep 2023 17:50:37 +0200 -Subject: [PATCH 12/20] drbd: Restore DATA_CORKED and CONTROL_CORKED bits - -They were removed with 9072e1d1b6b3 in January 2022. - -Since then, the CONTROL_CORKED mapped onto C_UNREGISTERED. - -I think that had a negligible impact because C_UNREGISTERED indicates -if a connection was deleted before. It is no longer connected when it -is time to delete a connection. Therefore, the corking code can not -set that double-used bit. - -The other user of C_UNREGISTERED is when iterating over connections. A -wrongly set C_UNREGISTERED causes another iteration over the -connections list - no further harm. - -Still, I am fixing this by allocating dedicated bits for corking in -the flags word. ---- - drbd/drbd_debugfs.c | 2 ++ - drbd/drbd_int.h | 2 ++ - drbd/drbd_main.c | 1 + - 3 files changed, 5 insertions(+) - -diff --git a/drbd/drbd_debugfs.c b/drbd/drbd_debugfs.c -index 778a995018d7..b8e4f2cde426 100644 ---- a/drbd/drbd_debugfs.c -+++ b/drbd/drbd_debugfs.c -@@ -839,6 +839,8 @@ static int connection_debug_show(struct seq_file *m, void *ignored) - pretty_print_bit(CONN_DRY_RUN); - pretty_print_bit(DISCONNECT_EXPECTED); - pretty_print_bit(BARRIER_ACK_PENDING); -+ pretty_print_bit(DATA_CORKED); -+ pretty_print_bit(CONTROL_CORKED); - pretty_print_bit(C_UNREGISTERED); - pretty_print_bit(RECONNECT); - pretty_print_bit(CONN_DISCARD_MY_DATA); -diff --git a/drbd/drbd_int.h b/drbd/drbd_int.h -index 17be90e7d8fa..4f3228d5a4d1 100644 ---- a/drbd/drbd_int.h -+++ b/drbd/drbd_int.h -@@ -755,6 +755,8 @@ enum connection_flag { - DISCONNECT_EXPECTED, - BARRIER_ACK_PENDING, - CORKED, -+ DATA_CORKED = CORKED, /* used as computed value CORKED + DATA_STREAM */ -+ CONTROL_CORKED, /* used as computed value CORKED + CONTROL_STREAM */ - C_UNREGISTERED, - RECONNECT, - CONN_DISCARD_MY_DATA, -diff --git a/drbd/drbd_main.c b/drbd/drbd_main.c -index 53cb4c9e7db3..6bb618909aa0 100644 ---- a/drbd/drbd_main.c -+++ b/drbd/drbd_main.c -@@ -1039,6 +1039,7 @@ int __send_command(struct drbd_connection *connection, int vnr, - struct drbd_send_buffer *sbuf = &connection->send_buffer[drbd_stream]; - struct drbd_transport *transport = &connection->transport; - struct drbd_transport_ops *tr_ops = transport->ops; -+ /* CORKED + drbd_stream is either DATA_CORKED or CONTROL_CORKED */ - bool corked = test_bit(CORKED + drbd_stream, &connection->flags); - bool flush = stream_and_flags & SFLAG_FLUSH; - int err; --- -2.35.3 - diff --git a/0012-drbd-remove-const-from-function-return-type.patch b/0012-drbd-remove-const-from-function-return-type.patch new file mode 100644 index 0000000..336b702 --- /dev/null +++ b/0012-drbd-remove-const-from-function-return-type.patch @@ -0,0 +1,29 @@ +From 392743b95ab0aaff13d5c91eaaab5ae24388384f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= + +Date: Tue, 13 Aug 2024 12:29:35 +0200 +Subject: [PATCH 12/32] drbd: remove const from function return type + +Linux 6.10 enables some compiler flag that errors out with: + +error: type qualifiers ignored on function return type +--- + drbd/drbd_receiver.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drbd/drbd_receiver.c b/drbd/drbd_receiver.c +index 985fac8e69b3..1b9f80de6f41 100644 +--- a/drbd/drbd_receiver.c ++++ b/drbd/drbd_receiver.c +@@ -272,7 +272,7 @@ static const char *drbd_sync_rule_str(enum sync_rule rule) + return sync_rule_names[rule]; + } + +-static const struct sync_descriptor strategy_descriptor(enum sync_strategy strategy) ++static struct sync_descriptor strategy_descriptor(enum sync_strategy strategy) + { + if (strategy < 0 || strategy > ARRAY_SIZE(sync_descriptors)) { + WARN_ON(true); +-- +2.35.3 + diff --git a/0013-drbd-don-t-set-max_write_zeroes_sectors-in-decide_on.patch b/0013-drbd-don-t-set-max_write_zeroes_sectors-in-decide_on.patch new file mode 100644 index 0000000..fb30d2f --- /dev/null +++ b/0013-drbd-don-t-set-max_write_zeroes_sectors-in-decide_on.patch @@ -0,0 +1,39 @@ +From 3672388dc75cbcdb5f3821b5f4354b55333004f5 Mon Sep 17 00:00:00 2001 +From: Christoph Hellwig +Date: Wed, 6 Mar 2024 15:03:30 +0100 +Subject: [PATCH 13/32] drbd: don't set max_write_zeroes_sectors in + decide_on_discard_support +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +fixup_write_zeroes always overrides the max_write_zeroes_sectors value +a little further down the callchain, so don't bother to setup a limit +in decide_on_discard_support. + +Signed-off-by: Christoph Hellwig +Reviewed-by: Philipp Reisner +Reviewed-by: Lars Ellenberg +Tested-by: Christoph Böhmwalder +Link: https://lore.kernel.org/r/20240306140332.623759-6-philipp.reisner@linbit.com +Signed-off-by: Jens Axboe +Signed-off-by: Christoph Böhmwalder +--- + drbd/drbd_nl.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/drbd/drbd_nl.c b/drbd/drbd_nl.c +index ef315e02f437..a0c3534d8996 100644 +--- a/drbd/drbd_nl.c ++++ b/drbd/drbd_nl.c +@@ -2070,7 +2070,6 @@ static void decide_on_discard_support(struct drbd_device *device, + blk_queue_discard_granularity(q, 512); + max_discard_sectors = drbd_max_discard_sectors(device->resource); + blk_queue_max_discard_sectors(q, max_discard_sectors); +- blk_queue_max_write_zeroes_sectors(q, max_discard_sectors); + return; + + not_supported: +-- +2.35.3 + diff --git a/0013-drbd-remove-unused-extern-for-conn_try_outdate_peer.patch b/0013-drbd-remove-unused-extern-for-conn_try_outdate_peer.patch deleted file mode 100644 index 9d3a99b..0000000 --- a/0013-drbd-remove-unused-extern-for-conn_try_outdate_peer.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 9e087399533445e3df60a34f26a1e6a285b0504a Mon Sep 17 00:00:00 2001 -From: Joel Colledge -Date: Tue, 12 Sep 2023 16:36:43 +0200 -Subject: [PATCH 13/20] drbd: remove unused extern for conn_try_outdate_peer() - ---- - drbd/drbd_int.h | 1 - - drbd/drbd_nl.c | 2 +- - 2 files changed, 1 insertion(+), 2 deletions(-) - -diff --git a/drbd/drbd_int.h b/drbd/drbd_int.h -index 4f3228d5a4d1..f6e7c3ac2629 100644 ---- a/drbd/drbd_int.h -+++ b/drbd/drbd_int.h -@@ -1932,7 +1932,6 @@ extern void drbd_reconsider_queue_parameters(struct drbd_device *device, - struct drbd_backing_dev *bdev); - extern bool barrier_pending(struct drbd_resource *resource); - extern enum drbd_state_rv drbd_set_role(struct drbd_resource *, enum drbd_role, bool, struct sk_buff *); --extern bool conn_try_outdate_peer(struct drbd_connection *connection); - extern void conn_try_outdate_peer_async(struct drbd_connection *connection); - extern int drbd_maybe_khelper(struct drbd_device *, struct drbd_connection *, char *); - extern int drbd_create_peer_device_default_config(struct drbd_peer_device *peer_device); -diff --git a/drbd/drbd_nl.c b/drbd/drbd_nl.c -index 0a67bfa4ca52..cb5cdb184824 100644 ---- a/drbd/drbd_nl.c -+++ b/drbd/drbd_nl.c -@@ -768,7 +768,7 @@ static bool intentional_diskless(struct drbd_resource *resource) - return intentional_diskless; - } - --bool conn_try_outdate_peer(struct drbd_connection *connection) -+static bool conn_try_outdate_peer(struct drbd_connection *connection) - { - struct drbd_resource *resource = connection->resource; - unsigned long last_reconnect_jif; --- -2.35.3 - diff --git a/0014-drbd-include-source-of-state-change-in-log.patch b/0014-drbd-include-source-of-state-change-in-log.patch deleted file mode 100644 index 8d215ce..0000000 --- a/0014-drbd-include-source-of-state-change-in-log.patch +++ /dev/null @@ -1,1480 +0,0 @@ -From d6bbb1b1635b9912d77d1a26aba3f380a2ed986d Mon Sep 17 00:00:00 2001 -From: Joel Colledge -Date: Mon, 11 Sep 2023 16:45:27 +0200 -Subject: [PATCH 14/20] drbd: include source of state change in log - -This is useful for understanding why a state change occurs. In -particular, whether it was triggered by userspace. ---- - drbd/drbd_int.h | 10 ++-- - drbd/drbd_main.c | 12 ++--- - drbd/drbd_nl.c | 103 ++++++++++++++++++++------------------ - drbd/drbd_receiver.c | 77 +++++++++++++++------------- - drbd/drbd_req.c | 6 +-- - drbd/drbd_sender.c | 25 ++++++---- - drbd/drbd_state.c | 116 ++++++++++++++++++++++++------------------- - drbd/drbd_state.h | 40 +++++++++++---- - 8 files changed, 224 insertions(+), 165 deletions(-) - -diff --git a/drbd/drbd_int.h b/drbd/drbd_int.h -index f6e7c3ac2629..b705f26e71a4 100644 ---- a/drbd/drbd_int.h -+++ b/drbd/drbd_int.h -@@ -1876,7 +1876,8 @@ extern void drbd_destroy_resource(struct kref *kref); - - extern void drbd_destroy_device(struct kref *kref); - --extern int set_resource_options(struct drbd_resource *resource, struct res_opts *res_opts); -+extern int set_resource_options(struct drbd_resource *resource, struct res_opts *res_opts, -+ const char *tag); - extern struct drbd_connection *drbd_create_connection(struct drbd_resource *resource, - struct drbd_transport_class *tc); - extern void drbd_transport_shutdown(struct drbd_connection *connection, enum drbd_tr_free_op op); -@@ -1931,7 +1932,9 @@ extern void resync_after_online_grow(struct drbd_peer_device *); - extern void drbd_reconsider_queue_parameters(struct drbd_device *device, - struct drbd_backing_dev *bdev); - extern bool barrier_pending(struct drbd_resource *resource); --extern enum drbd_state_rv drbd_set_role(struct drbd_resource *, enum drbd_role, bool, struct sk_buff *); -+extern enum drbd_state_rv -+drbd_set_role(struct drbd_resource *resource, enum drbd_role role, bool force, const char *tag, -+ struct sk_buff *reply_skb); - extern void conn_try_outdate_peer_async(struct drbd_connection *connection); - extern int drbd_maybe_khelper(struct drbd_device *, struct drbd_connection *, char *); - extern int drbd_create_peer_device_default_config(struct drbd_peer_device *peer_device); -@@ -1943,7 +1946,8 @@ extern int drbd_worker(struct drbd_thread *thi); - enum drbd_ret_code drbd_resync_after_valid(struct drbd_device *device, int o_minor); - void drbd_resync_after_changed(struct drbd_device *device); - extern bool drbd_stable_sync_source_present(struct drbd_peer_device *, enum which_state); --extern void drbd_start_resync(struct drbd_peer_device *, enum drbd_repl_state); -+extern void drbd_start_resync(struct drbd_peer_device *peer_device, enum drbd_repl_state side, -+ const char *tag); - extern void resume_next_sg(struct drbd_device *device); - extern void suspend_other_sg(struct drbd_device *device); - extern void drbd_resync_finished(struct drbd_peer_device *, enum drbd_disk_state); -diff --git a/drbd/drbd_main.c b/drbd/drbd_main.c -index 6bb618909aa0..4b0b967c2c97 100644 ---- a/drbd/drbd_main.c -+++ b/drbd/drbd_main.c -@@ -2505,7 +2505,7 @@ static int try_to_promote(struct drbd_device *device, long timeout, bool ndelay) - unsigned long start = jiffies; - long t; - -- rv = drbd_set_role(resource, R_PRIMARY, false, NULL); -+ rv = drbd_set_role(resource, R_PRIMARY, false, "auto-promote", NULL); - timeout -= jiffies - start; - - if (ndelay || rv >= SS_SUCCESS || timeout <= 0) { -@@ -2854,7 +2854,7 @@ static void drbd_release(struct gendisk *gd, fmode_t mode) - open_rw_cnt == 0 && - resource->role[NOW] == R_PRIMARY && - !test_bit(EXPLICIT_PRIMARY, &resource->flags)) { -- rv = drbd_set_role(resource, R_SECONDARY, false, NULL); -+ rv = drbd_set_role(resource, R_SECONDARY, false, "auto-demote", NULL); - if (rv < SS_SUCCESS) - drbd_warn(resource, "Auto-demote failed: %s (%d)\n", - drbd_set_st_err_str(rv), rv); -@@ -2866,7 +2866,7 @@ static void drbd_release(struct gendisk *gd, fmode_t mode) - - begin_state_change(resource, &irq_flags, CS_VERBOSE); - resource->fail_io[NEW] = false; -- end_state_change(resource, &irq_flags); -+ end_state_change(resource, &irq_flags, "release"); - } - - /* if the open counts are 0, we free the whole list, otherwise we remove the specific pid */ -@@ -3349,7 +3349,7 @@ static void wake_all_device_misc(struct drbd_resource *resource) - rcu_read_unlock(); - } - --int set_resource_options(struct drbd_resource *resource, struct res_opts *res_opts) -+int set_resource_options(struct drbd_resource *resource, struct res_opts *res_opts, const char *tag) - { - struct drbd_connection *connection; - cpumask_var_t new_cpu_mask; -@@ -3414,7 +3414,7 @@ int set_resource_options(struct drbd_resource *resource, struct res_opts *res_op - - if (force_state_recalc) { - begin_state_change(resource, &irq_flags, CS_VERBOSE | CS_FORCE_RECALC); -- end_state_change(resource, &irq_flags); -+ end_state_change(resource, &irq_flags, tag); - } - - if (wake_device_misc) -@@ -3491,7 +3491,7 @@ struct drbd_resource *drbd_create_resource(const char *name, - } - resource->pp_vacant = page_pool_count; - -- if (set_resource_options(resource, res_opts)) -+ if (set_resource_options(resource, res_opts, "create-resource")) - goto fail_free_pages; - - list_add_tail_rcu(&resource->resources, &drbd_resources); -diff --git a/drbd/drbd_nl.c b/drbd/drbd_nl.c -index cb5cdb184824..b7e9e43312f9 100644 ---- a/drbd/drbd_nl.c -+++ b/drbd/drbd_nl.c -@@ -768,7 +768,7 @@ static bool intentional_diskless(struct drbd_resource *resource) - return intentional_diskless; - } - --static bool conn_try_outdate_peer(struct drbd_connection *connection) -+static bool conn_try_outdate_peer(struct drbd_connection *connection, const char *tag) - { - struct drbd_resource *resource = connection->resource; - unsigned long last_reconnect_jif; -@@ -792,7 +792,7 @@ static bool conn_try_outdate_peer(struct drbd_connection *connection) - !(disk_state == D_DISKLESS && intentional_diskless(resource))) { - begin_state_change_locked(resource, CS_VERBOSE | CS_HARD); - __change_io_susp_fencing(connection, false); -- end_state_change_locked(resource); -+ end_state_change_locked(resource, tag); - read_unlock_irq(&resource->state_rwlock); - return false; - } -@@ -862,7 +862,7 @@ static bool conn_try_outdate_peer(struct drbd_connection *connection) - goto abort; - } - -- end_state_change(resource, &irq_flags); -+ end_state_change(resource, &irq_flags, tag); - - goto out; - abort: -@@ -875,7 +875,7 @@ static int _try_outdate_peer_async(void *data) - { - struct drbd_connection *connection = (struct drbd_connection *)data; - -- conn_try_outdate_peer(connection); -+ conn_try_outdate_peer(connection, "outdate-async"); - - kref_debug_put(&connection->kref_debug, 4); - kref_put(&connection->kref, drbd_destroy_connection); -@@ -1014,7 +1014,8 @@ static bool wait_up_to_date(struct drbd_resource *resource) - } - - enum drbd_state_rv --drbd_set_role(struct drbd_resource *resource, enum drbd_role role, bool force, struct sk_buff *reply_skb) -+drbd_set_role(struct drbd_resource *resource, enum drbd_role role, bool force, const char *tag, -+ struct sk_buff *reply_skb) - { - struct drbd_device *device; - int vnr, try = 0; -@@ -1042,7 +1043,7 @@ retry: - err_str = NULL; - } - rv = stable_state_change(resource, -- change_role(resource, role, flags, &err_str)); -+ change_role(resource, role, flags, tag, &err_str)); - - if (rv == SS_TIMEOUT || rv == SS_CONCURRENT_ST_CHG) { - long timeout = twopc_retry_timeout(resource, try); -@@ -1104,7 +1105,7 @@ retry: - if (device->disk_state[NOW] != D_CONSISTENT) - continue; - -- if (conn_try_outdate_peer(connection)) -+ if (conn_try_outdate_peer(connection, tag)) - fenced_peers = true; - else - any_fencing_failed = true; -@@ -1140,7 +1141,7 @@ retry: - - up(&resource->state_sem); /* Allow connect while fencing */ - for_each_connection_ref(connection, im, resource) { -- bool outdated_peer = conn_try_outdate_peer(connection); -+ bool outdated_peer = conn_try_outdate_peer(connection, tag); - if (!outdated_peer && force) { - drbd_warn(connection, "Forced into split brain situation!\n"); - flags |= CS_FP_LOCAL_UP_TO_DATE; -@@ -1331,7 +1332,9 @@ int drbd_adm_set_role(struct sk_buff *skb, struct genl_info *info) - new_role = info->genlhdr->cmd == DRBD_ADM_PRIMARY ? R_PRIMARY : R_SECONDARY; - rv = drbd_set_role(adm_ctx.resource, - new_role, -- parms.force, adm_ctx.reply_skb); -+ parms.force, -+ new_role == R_PRIMARY ? "primary" : "secondary", -+ adm_ctx.reply_skb); - - if (new_role == R_PRIMARY) { - if (rv >= SS_SUCCESS) -@@ -3093,7 +3096,7 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info) - drbd_flush_workqueue(&resource->work); - - rv = stable_state_change(resource, -- change_disk_state(device, D_ATTACHING, CS_VERBOSE | CS_SERIALIZE, NULL)); -+ change_disk_state(device, D_ATTACHING, CS_VERBOSE | CS_SERIALIZE, "attach", NULL)); - retcode = (enum drbd_ret_code)rv; - if (rv >= SS_SUCCESS) - update_resource_dagtag(resource, nbc); -@@ -3353,8 +3356,8 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info) - - /* change_disk_state uses disk_state_from_md(device); in case D_NEGOTIATING not - necessary, and falls back to a local state change */ -- rv = stable_state_change(resource, -- change_disk_state(device, D_NEGOTIATING, CS_VERBOSE | CS_SERIALIZE, NULL)); -+ rv = stable_state_change(resource, change_disk_state(device, -+ D_NEGOTIATING, CS_VERBOSE | CS_SERIALIZE, "attach", NULL)); - - if (rv < SS_SUCCESS) { - if (rv == SS_CW_FAILED_BY_PEER) -@@ -3385,7 +3388,7 @@ int drbd_adm_attach(struct sk_buff *skb, struct genl_info *info) - force_diskless_dec: - put_ldev(device); - force_diskless: -- change_disk_state(device, D_DISKLESS, CS_HARD, NULL); -+ change_disk_state(device, D_DISKLESS, CS_HARD, "attach", NULL); - fail: - mutex_unlock_cond(&resource->conf_update, &have_conf_update); - drbd_backing_dev_free(device, nbc); -@@ -3406,7 +3409,7 @@ static enum drbd_disk_state get_disk_state(struct drbd_device *device) - } - - static int adm_detach(struct drbd_device *device, bool force, bool intentional_diskless, -- struct sk_buff *reply_skb) -+ const char *tag, struct sk_buff *reply_skb) - { - const char *err_str = NULL; - int ret, retcode; -@@ -3414,7 +3417,7 @@ static int adm_detach(struct drbd_device *device, bool force, bool intentional_d - device->device_conf.intentional_diskless = intentional_diskless; - if (force) { - set_bit(FORCE_DETACH, &device->flags); -- change_disk_state(device, D_DETACHING, CS_HARD, NULL); -+ change_disk_state(device, D_DETACHING, CS_HARD, tag, NULL); - retcode = SS_SUCCESS; - goto out; - } -@@ -3422,7 +3425,7 @@ static int adm_detach(struct drbd_device *device, bool force, bool intentional_d - drbd_suspend_io(device, READ_AND_WRITE); /* so no-one is stuck in drbd_al_begin_io */ - retcode = stable_state_change(device->resource, - change_disk_state(device, D_DETACHING, -- CS_VERBOSE | CS_WAIT_COMPLETE | CS_SERIALIZE, &err_str)); -+ CS_VERBOSE | CS_WAIT_COMPLETE | CS_SERIALIZE, tag, &err_str)); - /* D_DETACHING will transition to DISKLESS. */ - drbd_resume_io(device); - ret = wait_event_interruptible(device->misc_wait, -@@ -3473,7 +3476,7 @@ int drbd_adm_detach(struct sk_buff *skb, struct genl_info *info) - - mutex_lock(&adm_ctx.resource->adm_mutex); - retcode = (enum drbd_ret_code)adm_detach(adm_ctx.device, parms.force_detach, -- parms.intentional_diskless_detach, adm_ctx.reply_skb); -+ parms.intentional_diskless_detach, "detach", adm_ctx.reply_skb); - mutex_unlock(&adm_ctx.resource->adm_mutex); - - out: -@@ -4385,7 +4388,7 @@ int drbd_adm_connect(struct sk_buff *skb, struct genl_info *info) - drbd_md_mark_dirty(device); - } - -- rv = change_cstate(connection, C_UNCONNECTED, CS_VERBOSE); -+ rv = change_cstate_tag(connection, C_UNCONNECTED, CS_VERBOSE, "connect", NULL); - drbd_adm_finish(&adm_ctx, info, rv); - return 0; - out: -@@ -4535,7 +4538,7 @@ int drbd_open_ro_count(struct drbd_resource *resource) - } - - static enum drbd_state_rv conn_try_disconnect(struct drbd_connection *connection, bool force, -- struct sk_buff *reply_skb) -+ const char *tag, struct sk_buff *reply_skb) - { - struct drbd_resource *resource = connection->resource; - enum drbd_conn_state cstate; -@@ -4545,7 +4548,7 @@ static enum drbd_state_rv conn_try_disconnect(struct drbd_connection *connection - long t; - - repeat: -- rv = change_cstate_es(connection, C_DISCONNECTING, flags, &err_str); -+ rv = change_cstate_tag(connection, C_DISCONNECTING, flags, tag, &err_str); - switch (rv) { - case SS_CW_FAILED_BY_PEER: - case SS_NEED_CONNECTION: -@@ -4571,7 +4574,7 @@ static enum drbd_state_rv conn_try_disconnect(struct drbd_connection *connection - break; - case SS_IS_DISKLESS: - case SS_LOWER_THAN_OUTDATED: -- rv = change_cstate(connection, C_DISCONNECTING, CS_HARD); -+ rv = change_cstate_tag(connection, C_DISCONNECTING, CS_HARD, tag, NULL); - break; - case SS_NO_QUORUM: - if (!(flags & CS_VERBOSE)) { -@@ -4597,7 +4600,7 @@ static enum drbd_state_rv conn_try_disconnect(struct drbd_connection *connection - - /* this can only be called immediately after a successful - * peer_try_disconnect, within the same resource->adm_mutex */ --static void del_connection(struct drbd_connection *connection) -+static void del_connection(struct drbd_connection *connection, const char *tag) - { - struct drbd_resource *resource = connection->resource; - struct drbd_peer_device *peer_device; -@@ -4619,7 +4622,7 @@ static void del_connection(struct drbd_connection *connection) - * after drbd_receiver() returned. Typically, we should be - * C_STANDALONE already, now, and this becomes a no-op. - */ -- rv2 = change_cstate(connection, C_STANDALONE, CS_VERBOSE | CS_HARD); -+ rv2 = change_cstate_tag(connection, C_STANDALONE, CS_VERBOSE | CS_HARD, tag, NULL); - if (rv2 < SS_SUCCESS) - drbd_err(connection, - "unexpected rv2=%d in del_connection()\n", -@@ -4654,6 +4657,7 @@ static int adm_disconnect(struct sk_buff *skb, struct genl_info *info, bool dest - struct drbd_connection *connection; - enum drbd_state_rv rv; - enum drbd_ret_code retcode; -+ const char *tag = destroy ? "del-peer" : "disconnect"; - - retcode = drbd_adm_prepare(&adm_ctx, skb, info, DRBD_ADM_NEED_CONNECTION); - if (!adm_ctx.reply_skb) -@@ -4671,10 +4675,10 @@ static int adm_disconnect(struct sk_buff *skb, struct genl_info *info, bool dest - - connection = adm_ctx.connection; - mutex_lock(&adm_ctx.resource->adm_mutex); -- rv = conn_try_disconnect(connection, parms.force_disconnect, adm_ctx.reply_skb); -+ rv = conn_try_disconnect(connection, parms.force_disconnect, tag, adm_ctx.reply_skb); - if (rv >= SS_SUCCESS && destroy) { - mutex_lock(&connection->resource->conf_update); -- del_connection(connection); -+ del_connection(connection, tag); - mutex_unlock(&connection->resource->conf_update); - } - if (rv < SS_SUCCESS) -@@ -4721,10 +4725,10 @@ void resync_after_online_grow(struct drbd_peer_device *peer_device) - - if (!sync_source && connection->agreed_pro_version < 110) { - stable_change_repl_state(peer_device, L_WF_SYNC_UUID, -- CS_VERBOSE | CS_SERIALIZE); -+ CS_VERBOSE | CS_SERIALIZE, "online-grow"); - return; - } -- drbd_start_resync(peer_device, sync_source ? L_SYNC_SOURCE : L_SYNC_TARGET); -+ drbd_start_resync(peer_device, sync_source ? L_SYNC_SOURCE : L_SYNC_TARGET, "online-grow"); - } - - sector_t drbd_local_max_size(struct drbd_device *device) __must_hold(local) -@@ -4956,7 +4960,7 @@ int drbd_adm_resource_opts(struct sk_buff *skb, struct genl_info *info) - goto fail; - } - -- err = set_resource_options(adm_ctx.resource, &res_opts); -+ err = set_resource_options(adm_ctx.resource, &res_opts, "resource-options"); - if (err) { - retcode = ERR_INVALID_REQUEST; - if (err == -ENOMEM) -@@ -4976,11 +4980,11 @@ static enum drbd_state_rv invalidate_resync(struct drbd_peer_device *peer_device - - drbd_flush_workqueue(&peer_device->connection->sender_work); - -- rv = change_repl_state(peer_device, L_STARTING_SYNC_T, CS_SERIALIZE); -+ rv = change_repl_state(peer_device, L_STARTING_SYNC_T, CS_SERIALIZE, "invalidate"); - - if (rv < SS_SUCCESS && rv != SS_NEED_CONNECTION) - rv = stable_change_repl_state(peer_device, L_STARTING_SYNC_T, -- CS_VERBOSE | CS_SERIALIZE); -+ CS_VERBOSE | CS_SERIALIZE, "invalidate"); - - wait_event_interruptible(resource->state_wait, - peer_device->repl_state[NOW] != L_STARTING_SYNC_T); -@@ -5005,7 +5009,7 @@ static enum drbd_state_rv invalidate_no_resync(struct drbd_device *device) __mus - } - } - __change_disk_state(device, D_INCONSISTENT); -- rv = end_state_change(resource, &irq_flags); -+ rv = end_state_change(resource, &irq_flags, "invalidate"); - - if (rv >= SS_SUCCESS) { - drbd_bitmap_io(device, &drbd_bmio_set_all_n_write, -@@ -5080,7 +5084,8 @@ int drbd_adm_invalidate(struct sk_buff *skb, struct genl_info *info) - retcode = invalidate_resync(sync_from_peer_device); - } else { - retcode = change_repl_state(sync_from_peer_device, L_WF_BITMAP_T, -- CS_VERBOSE | CS_CLUSTER_WIDE | CS_WAIT_COMPLETE | CS_SERIALIZE); -+ CS_VERBOSE | CS_CLUSTER_WIDE | CS_WAIT_COMPLETE | -+ CS_SERIALIZE, "invalidate"); - } - } else { - int retry = 3; -@@ -5103,7 +5108,8 @@ int drbd_adm_invalidate(struct sk_buff *skb, struct genl_info *info) - } - retcode = change_repl_state(peer_device, L_WF_BITMAP_T, - CS_VERBOSE | CS_CLUSTER_WIDE | -- CS_WAIT_COMPLETE | CS_SERIALIZE); -+ CS_WAIT_COMPLETE | CS_SERIALIZE, -+ "invalidate"); - } - if (retcode >= SS_SUCCESS) - goto out; -@@ -5140,13 +5146,15 @@ static int full_sync_from_peer(struct drbd_peer_device *peer_device) - struct drbd_resource *resource = device->resource; - int retcode; /* enum drbd_ret_code rsp. enum drbd_state_rv */ - -- retcode = stable_change_repl_state(peer_device, L_STARTING_SYNC_S, CS_SERIALIZE); -+ retcode = stable_change_repl_state(peer_device, L_STARTING_SYNC_S, CS_SERIALIZE, -+ "invalidate-remote"); - if (retcode < SS_SUCCESS) { - if (retcode == SS_NEED_CONNECTION && resource->role[NOW] == R_PRIMARY) { - /* The peer will get a resync upon connect anyways. - * Just make that into a full resync. */ - retcode = change_peer_disk_state(peer_device, D_INCONSISTENT, -- CS_VERBOSE | CS_WAIT_COMPLETE | CS_SERIALIZE); -+ CS_VERBOSE | CS_WAIT_COMPLETE | CS_SERIALIZE, -+ "invalidate-remote"); - if (retcode >= SS_SUCCESS) { - if (drbd_bitmap_io(device, &drbd_bmio_set_susp_al, - "set_n_write from invalidate_peer", -@@ -5155,7 +5163,7 @@ static int full_sync_from_peer(struct drbd_peer_device *peer_device) - } - } else { - retcode = stable_change_repl_state(peer_device, L_STARTING_SYNC_S, -- CS_VERBOSE | CS_SERIALIZE); -+ CS_VERBOSE | CS_SERIALIZE, "invalidate-remote"); - } - } - -@@ -5214,7 +5222,8 @@ int drbd_adm_invalidate_peer(struct sk_buff *skb, struct genl_info *info) - retcode = full_sync_from_peer(peer_device); - } else { - retcode = change_repl_state(peer_device, L_WF_BITMAP_S, -- CS_VERBOSE | CS_CLUSTER_WIDE | CS_WAIT_COMPLETE | CS_SERIALIZE); -+ CS_VERBOSE | CS_CLUSTER_WIDE | CS_WAIT_COMPLETE | CS_SERIALIZE, -+ "invalidate-remote"); - } - drbd_resume_io(device); - -@@ -5329,7 +5338,7 @@ int drbd_adm_resume_io(struct sk_buff *skb, struct genl_info *info) - __change_io_susp_fencing(connection, false); - - __change_io_susp_quorum(resource, false); -- retcode = end_state_change(resource, &irq_flags); -+ retcode = end_state_change(resource, &irq_flags, "resume-io"); - drbd_resume_io(device); - mutex_unlock(&adm_ctx.resource->adm_mutex); - drbd_adm_finish(&adm_ctx, info, retcode); -@@ -5348,7 +5357,7 @@ int drbd_adm_outdate(struct sk_buff *skb, struct genl_info *info) - - retcode = stable_state_change(adm_ctx.device->resource, - change_disk_state(adm_ctx.device, D_OUTDATED, -- CS_VERBOSE | CS_WAIT_COMPLETE | CS_SERIALIZE, NULL)); -+ CS_VERBOSE | CS_WAIT_COMPLETE | CS_SERIALIZE, "outdate", NULL)); - - mutex_unlock(&adm_ctx.resource->adm_mutex); - drbd_adm_finish(&adm_ctx, info, retcode); -@@ -6010,7 +6019,7 @@ int drbd_adm_start_ov(struct sk_buff *skb, struct genl_info *info) - drbd_suspend_io(device, READ_AND_WRITE); - wait_event(device->misc_wait, !atomic_read(&device->pending_bitmap_work.n)); - rv = stable_change_repl_state(peer_device, -- L_VERIFY_S, CS_VERBOSE | CS_WAIT_COMPLETE | CS_SERIALIZE); -+ L_VERIFY_S, CS_VERBOSE | CS_WAIT_COMPLETE | CS_SERIALIZE, "verify"); - drbd_resume_io(device); - - mutex_unlock(&adm_ctx.resource->adm_mutex); -@@ -6082,7 +6091,7 @@ int drbd_adm_new_c_uuid(struct sk_buff *skb, struct genl_info *info) - unsigned long irq_flags; - begin_state_change(device->resource, &irq_flags, CS_VERBOSE); - __change_disk_state(device, D_UP_TO_DATE); -- end_state_change(device->resource, &irq_flags); -+ end_state_change(device->resource, &irq_flags, "new-c-uuid"); - - for_each_peer_device(peer_device, device) { - if (NODE_MASK(peer_device->node_id) & nodes) { -@@ -6122,7 +6131,7 @@ int drbd_adm_new_c_uuid(struct sk_buff *skb, struct genl_info *info) - if (NODE_MASK(peer_device->node_id) & diskful) - __change_peer_disk_state(peer_device, D_UP_TO_DATE); - } -- end_state_change(device->resource, &irq_flags); -+ end_state_change(device->resource, &irq_flags, "new-c-uuid"); - } - - drbd_md_sync_if_dirty(device); -@@ -6353,7 +6362,7 @@ static enum drbd_ret_code adm_del_minor(struct drbd_device *device) - - for_each_peer_device_ref(peer_device, im, device) - stable_change_repl_state(peer_device, L_OFF, -- CS_VERBOSE | CS_WAIT_COMPLETE); -+ CS_VERBOSE | CS_WAIT_COMPLETE, "del-minor"); - - /* If drbd_ldev_destroy() is pending, wait for it to run before - * unregistering the device. */ -@@ -6465,7 +6474,7 @@ int drbd_adm_down(struct sk_buff *skb, struct genl_info *info) - mutex_lock(&resource->adm_mutex); - set_bit(DOWN_IN_PROGRESS, &resource->flags); - /* demote */ -- retcode = drbd_set_role(resource, R_SECONDARY, false, adm_ctx.reply_skb); -+ retcode = drbd_set_role(resource, R_SECONDARY, false, "down", adm_ctx.reply_skb); - if (retcode < SS_SUCCESS) { - opener_info(adm_ctx.resource, adm_ctx.reply_skb, retcode); - goto out; -@@ -6474,10 +6483,10 @@ int drbd_adm_down(struct sk_buff *skb, struct genl_info *info) - for_each_connection_ref(connection, im, resource) { - retcode = SS_SUCCESS; - if (connection->cstate[NOW] > C_STANDALONE) -- retcode = conn_try_disconnect(connection, 0, adm_ctx.reply_skb); -+ retcode = conn_try_disconnect(connection, 0, "down", adm_ctx.reply_skb); - if (retcode >= SS_SUCCESS) { - mutex_lock(&resource->conf_update); -- del_connection(connection); -+ del_connection(connection, "down"); - mutex_unlock(&resource->conf_update); - } else { - kref_debug_put(&connection->kref_debug, 13); -@@ -6491,7 +6500,7 @@ int drbd_adm_down(struct sk_buff *skb, struct genl_info *info) - idr_for_each_entry(&resource->devices, device, i) { - kref_get(&device->kref); - rcu_read_unlock(); -- retcode = adm_detach(device, 0, 0, adm_ctx.reply_skb); -+ retcode = adm_detach(device, 0, 0, "down", adm_ctx.reply_skb); - mutex_lock(&resource->conf_update); - ret = adm_del_minor(device); - mutex_unlock(&resource->conf_update); -diff --git a/drbd/drbd_receiver.c b/drbd/drbd_receiver.c -index 223353b1081c..0c3ab0fd486c 100644 ---- a/drbd/drbd_receiver.c -+++ b/drbd/drbd_receiver.c -@@ -920,7 +920,7 @@ static void apply_local_state_change(struct drbd_connection *connection, enum ao - resource->role[NEW] = R_SECONDARY; - } - } -- end_state_change(resource, &irq_flags); -+ end_state_change(resource, &irq_flags, "connect-failed"); - } - - static int connect_work(struct drbd_work *work, int cancel) -@@ -945,8 +945,9 @@ static int connect_work(struct drbd_work *work, int cancel) - rv = SS_CONCURRENT_ST_CHG; - break; - } -- rv = change_cstate(connection, C_CONNECTED, CS_SERIALIZE | -- CS_ALREADY_SERIALIZED | CS_VERBOSE | CS_DONT_RETRY); -+ rv = change_cstate_tag(connection, C_CONNECTED, CS_SERIALIZE | -+ CS_ALREADY_SERIALIZED | CS_VERBOSE | CS_DONT_RETRY, -+ "connected", NULL); - up(&resource->state_sem); - if (rv != SS_PRIMARY_READER) - break; -@@ -1011,7 +1012,8 @@ static bool conn_connect(struct drbd_connection *connection) - start: - have_mutex = false; - clear_bit(DISCONNECT_EXPECTED, &connection->flags); -- if (change_cstate(connection, C_CONNECTING, CS_VERBOSE) < SS_SUCCESS) { -+ if (change_cstate_tag(connection, C_CONNECTING, CS_VERBOSE, "connecting", NULL) -+ < SS_SUCCESS) { - /* We do not have a network config. */ - return false; - } -@@ -3697,7 +3699,8 @@ static enum sync_strategy drbd_asb_recover_1p(struct drbd_peer_device *peer_devi - /* drbd_change_state() does not sleep while in SS_IN_TRANSIENT_STATE, - * we might be here in L_OFF which is transient. - * we do not need to wait for the after state change work either. */ -- rv2 = change_role(resource, R_SECONDARY, CS_VERBOSE, NULL); -+ rv2 = change_role(resource, R_SECONDARY, CS_VERBOSE, -+ "after-sb-1pri", NULL); - if (rv2 != SS_SUCCESS) { - drbd_maybe_khelper(device, connection, "pri-lost-after-sb"); - } else { -@@ -3750,7 +3753,8 @@ static enum sync_strategy drbd_asb_recover_2p(struct drbd_peer_device *peer_devi - /* drbd_change_state() does not sleep while in SS_IN_TRANSIENT_STATE, - * we might be here in L_OFF which is transient. - * we do not need to wait for the after state change work either. */ -- rv2 = change_role(device->resource, R_SECONDARY, CS_VERBOSE, NULL); -+ rv2 = change_role(device->resource, R_SECONDARY, CS_VERBOSE, -+ "after-sb-2pri", NULL); - if (rv2 != SS_SUCCESS) { - drbd_maybe_khelper(device, connection, "pri-lost-after-sb"); - } else { -@@ -5500,6 +5504,7 @@ static void drbd_resync(struct drbd_peer_device *peer_device, - enum sync_rule rule; - int peer_node_id; - enum drbd_state_rv rv; -+ const char *tag = reason == AFTER_UNSTABLE ? "after-unstable" : "diskless-primary"; - - strategy = drbd_handshake(peer_device, &rule, &peer_node_id, reason == DISKLESS_PRIMARY); - if (strategy == SPLIT_BRAIN_AUTO_RECOVER && reason == AFTER_UNSTABLE) -@@ -5529,11 +5534,11 @@ static void drbd_resync(struct drbd_peer_device *peer_device, - as well. */ - drbd_info(peer_device, "Upgrading local disk to %s after unstable/weak (and no resync).\n", - drbd_disk_str(peer_disk_state)); -- change_disk_state(peer_device->device, peer_disk_state, CS_VERBOSE, NULL); -+ change_disk_state(peer_device->device, peer_disk_state, CS_VERBOSE, tag, NULL); - return; - } - -- rv = change_repl_state(peer_device, new_repl_state, CS_VERBOSE); -+ rv = change_repl_state(peer_device, new_repl_state, CS_VERBOSE, tag); - if ((rv == SS_NOTHING_TO_DO || rv == SS_RESYNC_RUNNING) && - (new_repl_state == L_WF_BITMAP_S || new_repl_state == L_WF_BITMAP_T)) { - /* Those events might happen very quickly. In case we are still processing -@@ -5633,7 +5638,7 @@ static int __receive_uuids(struct drbd_peer_device *peer_device, u64 node_mask) - begin_state_change(device->resource, &irq_flags, CS_VERBOSE); - __change_disk_state(device, D_UP_TO_DATE); - __change_peer_disk_state(peer_device, D_UP_TO_DATE); -- end_state_change(device->resource, &irq_flags); -+ end_state_change(device->resource, &irq_flags, "skip-initial-sync"); - updated_uuids = 1; - propagate_skip_initial_to_diskless(device); - } -@@ -5668,7 +5673,7 @@ static int __receive_uuids(struct drbd_peer_device *peer_device, u64 node_mask) - if (device->disk_state[NOW] == D_DISKLESS && uuid_match && - peer_device->disk_state[NOW] == D_CONSISTENT) { - drbd_info(peer_device, "Peer is on same UUID now\n"); -- change_peer_disk_state(peer_device, D_UP_TO_DATE, CS_VERBOSE); -+ change_peer_disk_state(peer_device, D_UP_TO_DATE, CS_VERBOSE, "receive-uuids"); - } - - if (updated_uuids) -@@ -5855,7 +5860,7 @@ static void check_resync_source(struct drbd_device *device, u64 weak_nodes) - return; - abort: - drbd_info(peer_device, "My sync source became a weak node, aborting resync!\n"); -- change_repl_state(peer_device, L_ESTABLISHED, CS_VERBOSE); -+ change_repl_state(peer_device, L_ESTABLISHED, CS_VERBOSE, "abort-resync"); - drbd_flush_workqueue(&device->resource->work); - - wait_event_interruptible(device->misc_wait, -@@ -6091,7 +6096,7 @@ retry: - - if (is_connect && connection->agreed_pro_version >= 117) - apply_connect(connection, (flags & CS_PREPARED) && !abort); -- rv = end_state_change(resource, &irq_flags); -+ rv = end_state_change(resource, &irq_flags, "remote"); - out: - - if ((rv == SS_NO_UP_TO_DATE_DISK && resource->role[NOW] != R_PRIMARY) || -@@ -6144,7 +6149,7 @@ change_peer_device_state(struct drbd_peer_device *peer_device, - rv = __change_connection_state(connection, mask, val, flags); - if (rv < SS_SUCCESS) - goto fail; -- rv = end_state_change(connection->resource, &irq_flags); -+ rv = end_state_change(connection->resource, &irq_flags, "remote"); - out: - return rv; - fail: -@@ -6375,7 +6380,7 @@ far_away_change(struct drbd_connection *connection, - } - - /* even if no outdate happens, CS_FORCE_RECALC might be set here */ -- return end_state_change(resource, &irq_flags); -+ return end_state_change(resource, &irq_flags, "far-away"); - } - - static void handle_neighbor_demotion(struct drbd_connection *connection, -@@ -6630,17 +6635,18 @@ cont: - /* peer is secondary */ - resync = L_SYNC_SOURCE; - } -- drbd_start_resync(peer_device, resync); -+ drbd_start_resync(peer_device, resync, "resize"); - } else { - if (tr->diskful_primary_nodes & NODE_MASK(peer_device->node_id)) -- drbd_start_resync(peer_device, L_SYNC_TARGET); -+ drbd_start_resync(peer_device, L_SYNC_TARGET, -+ "resize"); - /* else no resync */ - } - } else { - if (resource->twopc_parent_nodes & NODE_MASK(peer_device->node_id)) -- drbd_start_resync(peer_device, L_SYNC_TARGET); -+ drbd_start_resync(peer_device, L_SYNC_TARGET, "resize"); - else if (nodes_to_reach & NODE_MASK(peer_device->node_id)) -- drbd_start_resync(peer_device, L_SYNC_SOURCE); -+ drbd_start_resync(peer_device, L_SYNC_SOURCE, "resize"); - /* else no resync */ - } - } -@@ -7101,7 +7107,7 @@ void drbd_try_to_get_resynced(struct drbd_device *device) - peer_device = best_peer_device; - - if (best_strategy == NO_SYNC) { -- change_disk_state(device, D_UP_TO_DATE, CS_VERBOSE, NULL); -+ change_disk_state(device, D_UP_TO_DATE, CS_VERBOSE, "get-resync", NULL); - } else if (peer_device) { - drbd_resync(peer_device, DISKLESS_PRIMARY); - drbd_send_uuids(peer_device, UUID_FLAG_RESYNC | UUID_FLAG_DISKLESS_PRIMARY, 0); -@@ -7225,7 +7231,7 @@ static void diskless_with_peers_different_current_uuids(struct drbd_peer_device - CS_VERBOSE | CS_HARD | CS_FS_IGN_OPENERS); - resource->role[NEW] = R_SECONDARY; - /* resource->fail_io[NEW] gets set via CS_FS_IGN_OPENERS */ -- end_state_change(resource, &irq_flags); -+ end_state_change(resource, &irq_flags, "peer-state"); - } - set_bit(CONN_HANDSHAKE_RETRY, &connection->flags); - } else if (data_successor && resource->role[NOW] == R_SECONDARY) { -@@ -7278,7 +7284,7 @@ static int receive_state(struct drbd_connection *connection, struct packet_info - if (peer_state.role == R_SECONDARY) { - begin_state_change(resource, &irq_flags, CS_HARD | CS_VERBOSE); - __change_peer_role(connection, R_SECONDARY); -- rv = end_state_change(resource, &irq_flags); -+ rv = end_state_change(resource, &irq_flags, "peer-state"); - if (rv < SS_SUCCESS) - goto fail; - } -@@ -7374,7 +7380,7 @@ static int receive_state(struct drbd_connection *connection, struct packet_info - /* Start resync after AHEAD/BEHIND */ - if (connection->agreed_pro_version >= 110 && - peer_state.conn == L_SYNC_SOURCE && old_peer_state.conn == L_BEHIND) { -- drbd_start_resync(peer_device, L_SYNC_TARGET); -+ drbd_start_resync(peer_device, L_SYNC_TARGET, "resync-after-behind"); - return 0; - } - -@@ -7519,7 +7525,7 @@ static int receive_state(struct drbd_connection *connection, struct packet_info - begin_state_change(resource, &irq_flags, CS_HARD); - __change_cstate(connection, C_PROTOCOL_ERROR); - __change_io_susp_user(resource, false); -- end_state_change(resource, &irq_flags); -+ end_state_change(resource, &irq_flags, "abort-connect"); - return -EIO; - } - -@@ -7581,7 +7587,7 @@ static int receive_state(struct drbd_connection *connection, struct packet_info - if (repl_state[OLD] < L_ESTABLISHED && repl_state[NEW] >= L_ESTABLISHED) - resource->state_change_flags |= CS_HARD; - -- rv = end_state_change(resource, &irq_flags); -+ rv = end_state_change(resource, &irq_flags, "peer-state"); - new_repl_state = peer_device->repl_state[NOW]; - - if (rv < SS_SUCCESS) -@@ -7635,7 +7641,7 @@ static int receive_sync_uuid(struct drbd_connection *connection, struct packet_i - _drbd_uuid_set_bitmap(peer_device, 0UL); - - drbd_print_uuids(peer_device, "updated sync uuid"); -- drbd_start_resync(peer_device, L_SYNC_TARGET); -+ drbd_start_resync(peer_device, L_SYNC_TARGET, "peer-sync-uuid"); - - put_ldev(device); - } else -@@ -7935,17 +7941,18 @@ static int receive_bitmap(struct drbd_connection *connection, struct packet_info - /* We have entered drbd_start_resync() since starting the bitmap exchange. */ - drbd_warn(peer_device, "Received bitmap more than once; ignoring\n"); - } else if (repl_state == L_WF_BITMAP_S) { -- drbd_start_resync(peer_device, L_SYNC_SOURCE); -+ drbd_start_resync(peer_device, L_SYNC_SOURCE, "receive-bitmap"); - } else if (repl_state == L_WF_BITMAP_T) { - if (connection->agreed_pro_version < 110) { - enum drbd_state_rv rv; - - /* Omit CS_WAIT_COMPLETE and CS_SERIALIZE with this state - * transition to avoid deadlocks. */ -- rv = stable_change_repl_state(peer_device, L_WF_SYNC_UUID, CS_VERBOSE); -+ rv = stable_change_repl_state(peer_device, L_WF_SYNC_UUID, CS_VERBOSE, -+ "receive-bitmap"); - D_ASSERT(device, rv == SS_SUCCESS); - } else { -- drbd_start_resync(peer_device, L_SYNC_TARGET); -+ drbd_start_resync(peer_device, L_SYNC_TARGET, "receive-bitmap"); - } - } else { - /* admin may have requested C_DISCONNECTING, -@@ -8139,7 +8146,7 @@ static int receive_peer_dagtag(struct drbd_connection *connection, struct packet - __change_repl_state(peer_device, new_repl_state); - set_bit(RECONCILIATION_RESYNC, &peer_device->flags); - } -- rv = end_state_change(resource, &irq_flags); -+ rv = end_state_change(resource, &irq_flags, "receive-peer-dagtag"); - if (rv == SS_SUCCESS) - drbd_info(connection, "Reconciliation resync because \'%s\' disappeared. (o=%d)\n", - lost_peer->transport.net_conf->name, (int)dagtag_offset); -@@ -8248,7 +8255,8 @@ static int receive_current_uuid(struct drbd_connection *connection, struct packe - if (resource->remote_state_change) - set_bit(OUTDATE_ON_2PC_COMMIT, &device->flags); - else -- change_disk_state(device, D_OUTDATED, CS_VERBOSE, NULL); -+ change_disk_state(device, D_OUTDATED, CS_VERBOSE, -+ "receive-current-uuid", NULL); - } - put_ldev(device); - } else if (device->disk_state[NOW] == D_DISKLESS && resource->role[NOW] == R_PRIMARY) { -@@ -8328,7 +8336,7 @@ static int receive_rs_deallocated(struct drbd_connection *connection, struct pac - - static int receive_disconnect(struct drbd_connection *connection, struct packet_info *pi) - { -- change_cstate(connection, C_DISCONNECTING, CS_HARD); -+ change_cstate_tag(connection, C_DISCONNECTING, CS_HARD, "receive-disconnect", NULL); - return 0; - } - -@@ -8594,7 +8602,7 @@ static void conn_disconnect(struct drbd_connection *connection) - * Usually we should be in some network failure state already, - * but just in case we are not, we fix it up here. - */ -- change_cstate(connection, C_NETWORK_FAILURE, CS_HARD); -+ change_cstate_tag(connection, C_NETWORK_FAILURE, CS_HARD, "disconnected", NULL); - - del_connect_timer(connection); - -@@ -8707,10 +8715,11 @@ static void conn_disconnect(struct drbd_connection *connection) - /* drbd_receiver() has to be restarted after it returns */ - drbd_thread_restart_nowait(&connection->receiver); - } -- end_state_change(resource, &irq_flags); -+ end_state_change(resource, &irq_flags, "disconnected"); - - if (oc == C_DISCONNECTING) -- change_cstate(connection, C_STANDALONE, CS_VERBOSE | CS_HARD | CS_LOCAL_ONLY); -+ change_cstate_tag(connection, C_STANDALONE, CS_VERBOSE | CS_HARD | CS_LOCAL_ONLY, -+ "disconnected", NULL); - } - - /* -diff --git a/drbd/drbd_req.c b/drbd/drbd_req.c -index af2ae66f51b5..41950e46ec27 100644 ---- a/drbd/drbd_req.c -+++ b/drbd/drbd_req.c -@@ -2688,7 +2688,7 @@ void request_timer_fn(struct timer_list *t) - continue; - begin_state_change(resource, &irq_flags, CS_VERBOSE | CS_HARD); - __change_cstate(connection, C_TIMEOUT); -- end_state_change(resource, &irq_flags); -+ end_state_change(resource, &irq_flags, "timeout"); - kref_put(&connection->kref, drbd_destroy_connection); - } - -@@ -2723,7 +2723,7 @@ void drbd_handle_io_error_(struct drbd_device *device, - if (device->disk_state[NOW] > D_INCONSISTENT) { - begin_state_change_locked(device->resource, CS_HARD); - __change_disk_state(device, D_INCONSISTENT); -- end_state_change_locked(device->resource); -+ end_state_change_locked(device->resource, "local-io-error"); - } - break; - } -@@ -2740,7 +2740,7 @@ void drbd_handle_io_error_(struct drbd_device *device, - if (device->disk_state[NOW] > D_FAILED) { - begin_state_change_locked(device->resource, CS_HARD); - __change_disk_state(device, D_FAILED); -- end_state_change_locked(device->resource); -+ end_state_change_locked(device->resource, "local-io-error"); - drbd_err(device, - "Local IO failed in %s. Detaching...\n", where); - } -diff --git a/drbd/drbd_sender.c b/drbd/drbd_sender.c -index 93a460dae190..0beeb5f3cb54 100644 ---- a/drbd/drbd_sender.c -+++ b/drbd/drbd_sender.c -@@ -472,7 +472,7 @@ int w_resync_timer(struct drbd_work *w, int cancel) - unsigned long irq_flags; - begin_state_change(resource, &irq_flags, 0); - peer_device->resync_active[NEW] = false; -- end_state_change(resource, &irq_flags); -+ end_state_change(resource, &irq_flags, "resync-inactive"); - } - break; - } -@@ -1155,7 +1155,7 @@ static void resync_again(struct drbd_device *device, u64 source_m, u64 target_m) - peer_device->resync_again--; - begin_state_change_locked(device->resource, CS_VERBOSE); - __change_repl_state(peer_device, new_repl_state); -- end_state_change_locked(device->resource); -+ end_state_change_locked(device->resource, "resync-again"); - } - } - } -@@ -1225,7 +1225,7 @@ found: - } - - drbd_send_uuids(peer_device, 0, 0); -- drbd_start_resync(peer_device, L_SYNC_TARGET); -+ drbd_start_resync(peer_device, L_SYNC_TARGET, "resync-from-primary"); - } - - static void queue_resync_finished(struct drbd_peer_device *peer_device, enum drbd_disk_state new_peer_disk_state) -@@ -1428,7 +1428,7 @@ void drbd_resync_finished(struct drbd_peer_device *peer_device, - } - - out_unlock: -- end_state_change_locked(device->resource); -+ end_state_change_locked(device->resource, "resync-finished"); - - put_ldev(device); - -@@ -1920,7 +1920,8 @@ static bool drbd_pause_after(struct drbd_device *device) - if (!__drbd_may_sync_now(other_peer_device)) - __change_resync_susp_dependency(other_peer_device, true); - } -- if (end_state_change_locked(other_device->resource) != SS_NOTHING_TO_DO) -+ if (end_state_change_locked(other_device->resource, "resync-after") != -+ SS_NOTHING_TO_DO) - changed = true; - } - rcu_read_unlock(); -@@ -1957,7 +1958,8 @@ static bool drbd_resume_next(struct drbd_device *device) - __drbd_may_sync_now(other_peer_device)) - __change_resync_susp_dependency(other_peer_device, false); - } -- if (end_state_change_locked(other_device->resource) != SS_NOTHING_TO_DO) -+ if (end_state_change_locked(other_device->resource, "resync-after") != -+ SS_NOTHING_TO_DO) - changed = true; - } - rcu_read_unlock(); -@@ -2125,7 +2127,7 @@ static void do_start_resync(struct drbd_peer_device *peer_device) - return; - } - -- drbd_start_resync(peer_device, peer_device->start_resync_side); -+ drbd_start_resync(peer_device, peer_device->start_resync_side, "postponed-resync"); - clear_bit(AHEAD_TO_SYNC_SOURCE, &peer_device->flags); - } - -@@ -2149,7 +2151,7 @@ static void handle_congestion(struct drbd_peer_device *peer_device) - else if (on_congestion == OC_DISCONNECT) - __change_cstate(peer_device->connection, C_DISCONNECTING); - } -- end_state_change(resource, &irq_flags); -+ end_state_change(resource, &irq_flags, "congestion"); - } - rcu_read_unlock(); - -@@ -2163,7 +2165,8 @@ static void handle_congestion(struct drbd_peer_device *peer_device) - * This function might bring you directly into one of the - * C_PAUSED_SYNC_* states. - */ --void drbd_start_resync(struct drbd_peer_device *peer_device, enum drbd_repl_state side) -+void drbd_start_resync(struct drbd_peer_device *peer_device, enum drbd_repl_state side, -+ const char *tag) - { - struct drbd_device *device = peer_device->device; - struct drbd_connection *connection = peer_device->connection; -@@ -2258,7 +2261,7 @@ skip_helper: - init_resync_stable_bits(peer_device); - finished_resync_pdsk = peer_device->resync_finished_pdsk; - peer_device->resync_finished_pdsk = D_UNKNOWN; -- r = end_state_change_locked(device->resource); -+ r = end_state_change_locked(device->resource, tag); - repl_state = peer_device->repl_state[NOW]; - - if (repl_state < L_ESTABLISHED) -@@ -2339,7 +2342,7 @@ static void go_diskless(struct drbd_device *device) - } - - drbd_md_sync_if_dirty(device); -- change_disk_state(device, D_DISKLESS, CS_HARD, NULL); -+ change_disk_state(device, D_DISKLESS, CS_HARD, "go-diskless", NULL); - } - - static int do_md_sync(struct drbd_device *device) -diff --git a/drbd/drbd_state.c b/drbd/drbd_state.c -index 23eab7f867aa..22cd134be962 100644 ---- a/drbd/drbd_state.c -+++ b/drbd/drbd_state.c -@@ -74,8 +74,8 @@ struct change_disk_state_context { - static bool lost_contact_to_peer_data(enum drbd_disk_state *peer_disk_state); - static bool peer_returns_diskless(struct drbd_peer_device *peer_device, - enum drbd_disk_state os, enum drbd_disk_state ns); --static void print_state_change(struct drbd_resource *resource, const char *prefix); --static void finish_state_change(struct drbd_resource *); -+static void print_state_change(struct drbd_resource *resource, const char *prefix, const char *tag); -+static void finish_state_change(struct drbd_resource *, const char *tag); - static int w_after_state_change(struct drbd_work *w, int unused); - static enum drbd_state_rv is_valid_soft_transition(struct drbd_resource *); - static enum drbd_state_rv is_valid_transition(struct drbd_resource *resource); -@@ -774,7 +774,7 @@ static void queue_after_state_change_work(struct drbd_resource *resource, - } - - static enum drbd_state_rv ___end_state_change(struct drbd_resource *resource, struct completion *done, -- enum drbd_state_rv rv) -+ enum drbd_state_rv rv, const char *tag) - { - enum chg_state_flags flags = resource->state_change_flags; - struct drbd_connection *connection; -@@ -793,14 +793,14 @@ static enum drbd_state_rv ___end_state_change(struct drbd_resource *resource, st - if (flags & CS_VERBOSE) { - drbd_err(resource, "State change failed: %s (%d)\n", - drbd_set_st_err_str(rv), rv); -- print_state_change(resource, "Failed: "); -+ print_state_change(resource, "Failed: ", tag); - } - goto out; - } - if (flags & CS_PREPARE) - goto out; - -- finish_state_change(resource); -+ finish_state_change(resource, tag); - update_members(resource); - - /* Check whether we are establishing a connection before applying the change. */ -@@ -939,9 +939,9 @@ void begin_state_change_locked(struct drbd_resource *resource, enum chg_state_fl - __begin_state_change(resource); - } - --enum drbd_state_rv end_state_change_locked(struct drbd_resource *resource) -+enum drbd_state_rv end_state_change_locked(struct drbd_resource *resource, const char *tag) - { -- return ___end_state_change(resource, NULL, SS_SUCCESS); -+ return ___end_state_change(resource, NULL, SS_SUCCESS, tag); - } - - void begin_state_change(struct drbd_resource *resource, unsigned long *irq_flags, enum chg_state_flags flags) -@@ -952,7 +952,8 @@ void begin_state_change(struct drbd_resource *resource, unsigned long *irq_flags - - static enum drbd_state_rv __end_state_change(struct drbd_resource *resource, - unsigned long *irq_flags, -- enum drbd_state_rv rv) -+ enum drbd_state_rv rv, -+ const char *tag) - { - enum chg_state_flags flags = resource->state_change_flags; - struct completion __done, *done = NULL; -@@ -961,26 +962,27 @@ static enum drbd_state_rv __end_state_change(struct drbd_resource *resource, - done = &__done; - init_completion(done); - } -- rv = ___end_state_change(resource, done, rv); -+ rv = ___end_state_change(resource, done, rv, tag); - __state_change_unlock(resource, irq_flags, rv >= SS_SUCCESS ? done : NULL); - return rv; - } - --enum drbd_state_rv end_state_change(struct drbd_resource *resource, unsigned long *irq_flags) -+enum drbd_state_rv end_state_change(struct drbd_resource *resource, unsigned long *irq_flags, -+ const char *tag) - { -- return __end_state_change(resource, irq_flags, SS_SUCCESS); -+ return __end_state_change(resource, irq_flags, SS_SUCCESS, tag); - } - - void abort_state_change(struct drbd_resource *resource, unsigned long *irq_flags) - { - resource->state_change_flags &= ~CS_VERBOSE; -- __end_state_change(resource, irq_flags, SS_UNKNOWN_ERROR); -+ __end_state_change(resource, irq_flags, SS_UNKNOWN_ERROR, NULL); - } - - void abort_state_change_locked(struct drbd_resource *resource) - { - resource->state_change_flags &= ~CS_VERBOSE; -- ___end_state_change(resource, NULL, SS_UNKNOWN_ERROR); -+ ___end_state_change(resource, NULL, SS_UNKNOWN_ERROR, NULL); - } - - static void begin_remote_state_change(struct drbd_resource *resource, unsigned long *irq_flags) -@@ -1159,15 +1161,19 @@ static int scnprintf_io_suspend_flags(char *buffer, size_t size, - return b - buffer; - } - --static void print_state_change(struct drbd_resource *resource, const char *prefix) -+static void print_state_change(struct drbd_resource *resource, const char *prefix, const char *tag) - { - char buffer[150], *b, *end = buffer + sizeof(buffer); -+ char tag_buffer[30] = ""; - struct drbd_connection *connection; - struct drbd_device *device; - enum drbd_role *role = resource->role; - bool *fail_io = resource->fail_io; - int vnr; - -+ if (tag) -+ scnprintf(tag_buffer, 30, " [%s]", tag); -+ - b = buffer; - if (role[OLD] != role[NEW]) - b += scnprintf(b, end - b, "role( %s -> %s ) ", -@@ -1186,7 +1192,7 @@ static void print_state_change(struct drbd_resource *resource, const char *prefi - fail_io[NEW] ? "yes" : "no"); - if (b != buffer) { - *(b-1) = 0; -- drbd_info(resource, "%s%s\n", prefix, buffer); -+ drbd_info(resource, "%s%s%s\n", prefix, buffer, tag_buffer); - } - - for_each_connection(connection, resource) { -@@ -1205,7 +1211,7 @@ static void print_state_change(struct drbd_resource *resource, const char *prefi - - if (b != buffer) { - *(b-1) = 0; -- drbd_info(connection, "%s%s\n", prefix, buffer); -+ drbd_info(connection, "%s%s%s\n", prefix, buffer, tag_buffer); - } - } - -@@ -1225,7 +1231,7 @@ static void print_state_change(struct drbd_resource *resource, const char *prefi - have_quorum[NEW] ? "yes" : "no"); - if (b != buffer) { - *(b-1) = 0; -- drbd_info(device, "%s%s\n", prefix, buffer); -+ drbd_info(device, "%s%s%s\n", prefix, buffer, tag_buffer); - } - - for_each_peer_device(peer_device, device) { -@@ -1253,7 +1259,7 @@ static void print_state_change(struct drbd_resource *resource, const char *prefi - - if (b != buffer) { - *(b-1) = 0; -- drbd_info(peer_device, "%s%s\n", prefix, buffer); -+ drbd_info(peer_device, "%s%s%s\n", prefix, buffer, tag_buffer); - } - } - } -@@ -2543,7 +2549,7 @@ static bool should_try_become_up_to_date(struct drbd_device *device, enum drbd_d - /** - * finish_state_change - carry out actions triggered by a state change - */ --static void finish_state_change(struct drbd_resource *resource) -+static void finish_state_change(struct drbd_resource *resource, const char *tag) - { - enum drbd_role *role = resource->role; - struct drbd_device *device; -@@ -2557,7 +2563,7 @@ static void finish_state_change(struct drbd_resource *resource) - bool unfreeze_io = false; - int vnr; - -- print_state_change(resource, ""); -+ print_state_change(resource, "", tag); - - resource_suspended[OLD] = resource_is_suspended(resource, OLD); - resource_suspended[NEW] = resource_is_suspended(resource, NEW); -@@ -3025,7 +3031,7 @@ static void abw_start_sync(struct drbd_device *device, - - if (rv) { - drbd_err(device, "Writing the bitmap failed not starting resync.\n"); -- stable_change_repl_state(peer_device, L_ESTABLISHED, CS_VERBOSE); -+ stable_change_repl_state(peer_device, L_ESTABLISHED, CS_VERBOSE, "start-sync"); - return; - } - -@@ -3039,12 +3045,13 @@ static void abw_start_sync(struct drbd_device *device, - rcu_read_unlock(); - - if (peer_device->connection->agreed_pro_version < 110) -- stable_change_repl_state(peer_device, L_WF_SYNC_UUID, CS_VERBOSE); -+ stable_change_repl_state(peer_device, L_WF_SYNC_UUID, CS_VERBOSE, -+ "start-sync"); - else -- drbd_start_resync(peer_device, L_SYNC_TARGET); -+ drbd_start_resync(peer_device, L_SYNC_TARGET, "start-sync"); - break; - case L_STARTING_SYNC_S: -- drbd_start_resync(peer_device, L_SYNC_SOURCE); -+ drbd_start_resync(peer_device, L_SYNC_SOURCE, "start-sync"); - break; - default: - break; -@@ -3531,7 +3538,7 @@ static void check_may_resume_io_after_fencing(struct drbd_state_change *state_ch - rcu_read_unlock(); - begin_state_change(resource, &irq_flags, CS_VERBOSE); - __change_io_susp_fencing(connection, false); -- end_state_change(resource, &irq_flags); -+ end_state_change(resource, &irq_flags, "after-fencing"); - } - /* case2: The connection was established again: */ - if (all_peer_disks_connected) { -@@ -3543,7 +3550,7 @@ static void check_may_resume_io_after_fencing(struct drbd_state_change *state_ch - rcu_read_unlock(); - begin_state_change(resource, &irq_flags, CS_VERBOSE); - __change_io_susp_fencing(connection, false); -- end_state_change(resource, &irq_flags); -+ end_state_change(resource, &irq_flags, "after-fencing"); - } - } - -@@ -4191,7 +4198,7 @@ static int w_after_state_change(struct drbd_work *w, int unused) - - begin_state_change(resource, &irq_flags, CS_VERBOSE); - resource->susp_uuid[NEW] = false; -- end_state_change(resource, &irq_flags); -+ end_state_change(resource, &irq_flags, "susp-uuid"); - } - - if (try_become_up_to_date) -@@ -4673,7 +4680,7 @@ static void twopc_phase2(struct drbd_resource *resource, - */ - static enum drbd_state_rv - change_cluster_wide_state(bool (*change)(struct change_context *, enum change_phase), -- struct change_context *context) -+ struct change_context *context, const char *tag) - { - struct drbd_resource *resource = context->resource; - unsigned long irq_flags; -@@ -4692,11 +4699,11 @@ change_cluster_wide_state(bool (*change)(struct change_context *, enum change_ph - if (local_state_change(context->flags)) { - /* Not a cluster-wide state change. */ - change(context, PH_LOCAL_COMMIT); -- return end_state_change(resource, &irq_flags); -+ return end_state_change(resource, &irq_flags, tag); - } else { - if (!change(context, PH_PREPARE)) { - /* Not a cluster-wide state change. */ -- return end_state_change(resource, &irq_flags); -+ return end_state_change(resource, &irq_flags, tag); - } - rv = try_state_change(resource); - if (rv != SS_SUCCESS) { -@@ -4704,7 +4711,7 @@ change_cluster_wide_state(bool (*change)(struct change_context *, enum change_ph - /* abort_state_change(resource, &irq_flags); */ - if (rv == SS_NOTHING_TO_DO) - resource->state_change_flags &= ~CS_VERBOSE; -- return __end_state_change(resource, &irq_flags, rv); -+ return __end_state_change(resource, &irq_flags, rv, tag); - } - /* Really a cluster-wide state change. */ - } -@@ -4720,12 +4727,12 @@ change_cluster_wide_state(bool (*change)(struct change_context *, enum change_ph - } - if (rv >= SS_SUCCESS) - change(context, PH_84_COMMIT); -- return __end_state_change(resource, &irq_flags, rv); -+ return __end_state_change(resource, &irq_flags, rv, tag); - } - - if (!expect(resource, context->flags & CS_SERIALIZE)) { - rv = SS_CW_FAILED_BY_PEER; -- return __end_state_change(resource, &irq_flags, rv); -+ return __end_state_change(resource, &irq_flags, rv, tag); - } - - rcu_read_lock(); -@@ -4740,7 +4747,7 @@ change_cluster_wide_state(bool (*change)(struct change_context *, enum change_ph - - retry: - if (current == resource->worker.task && resource->remote_state_change) -- return __end_state_change(resource, &irq_flags, SS_CONCURRENT_ST_CHG); -+ return __end_state_change(resource, &irq_flags, SS_CONCURRENT_ST_CHG, tag); - - complete_remote_state_change(resource, &irq_flags); - start_time = jiffies; -@@ -4756,7 +4763,7 @@ change_cluster_wide_state(bool (*change)(struct change_context *, enum change_ph - connection = drbd_get_connection_by_node_id(resource, context->target_node_id); - if (!connection) { - rv = SS_NEED_CONNECTION; -- return __end_state_change(resource, &irq_flags, rv); -+ return __end_state_change(resource, &irq_flags, rv, tag); - } - kref_debug_get(&connection->kref_debug, 8); - -@@ -4768,7 +4775,7 @@ change_cluster_wide_state(bool (*change)(struct change_context *, enum change_ph - - kref_debug_put(&connection->kref_debug, 8); - kref_put(&connection->kref, drbd_destroy_connection); -- return __end_state_change(resource, &irq_flags, rv); -+ return __end_state_change(resource, &irq_flags, rv, tag); - } - target_connection = connection; - -@@ -4959,7 +4966,7 @@ change_cluster_wide_state(bool (*change)(struct change_context *, enum change_ph - clear_bit(TWOPC_STATE_CHANGE_PENDING, &resource->flags); - if (rv >= SS_SUCCESS) { - change(context, PH_COMMIT); -- rv = end_state_change(resource, &irq_flags); -+ rv = end_state_change(resource, &irq_flags, tag); - if (rv < SS_SUCCESS) - drbd_err(resource, "FATAL: Local commit of already committed %u failed! \n", - request.tid); -@@ -5276,6 +5283,7 @@ static bool do_change_role(struct change_context *context, enum change_phase pha - enum drbd_state_rv change_role(struct drbd_resource *resource, - enum drbd_role role, - enum chg_state_flags flags, -+ const char *tag, - const char **err_str) - { - struct change_context role_context = { -@@ -5310,7 +5318,7 @@ enum drbd_state_rv change_role(struct drbd_resource *resource, - } - role_context.change_local_state_last = true; - } -- rv = change_cluster_wide_state(do_change_role, &role_context); -+ rv = change_cluster_wide_state(do_change_role, &role_context, tag); - out: - if (got_state_sem) - up(&resource->state_sem); -@@ -5330,7 +5338,7 @@ enum drbd_state_rv change_io_susp_user(struct drbd_resource *resource, - - begin_state_change(resource, &irq_flags, flags); - __change_io_susp_user(resource, value); -- return end_state_change(resource, &irq_flags); -+ return end_state_change(resource, &irq_flags, value ? "suspend-io" : "resume-io"); - } - - void __change_io_susp_no_data(struct drbd_resource *resource, bool value) -@@ -5465,7 +5473,7 @@ enum drbd_state_rv twopc_after_lost_peer(struct drbd_resource *resource, - /* The other nodes get the request for an empty state change. I.e. they - will agree to this change request. At commit time we know where to - go from the D_CONSISTENT, since we got the primary mask. */ -- return change_cluster_wide_state(do_twopc_after_lost_peer, &context); -+ return change_cluster_wide_state(do_twopc_after_lost_peer, &context, "lost-peer"); - } - - static bool do_change_disk_state(struct change_context *context, enum change_phase phase) -@@ -5496,6 +5504,7 @@ static bool do_change_disk_state(struct change_context *context, enum change_pha - enum drbd_state_rv change_disk_state(struct drbd_device *device, - enum drbd_disk_state disk_state, - enum chg_state_flags flags, -+ const char *tag, - const char **err_str) - { - struct change_disk_state_context disk_state_context = { -@@ -5513,7 +5522,7 @@ enum drbd_state_rv change_disk_state(struct drbd_device *device, - }; - - return change_cluster_wide_state(do_change_disk_state, -- &disk_state_context.context); -+ &disk_state_context.context, tag); - } - - void __change_cstate(struct drbd_connection *connection, enum drbd_conn_state cstate) -@@ -5683,11 +5692,11 @@ static bool do_change_cstate(struct change_context *context, enum change_phase p - * peer disks depending on the fencing policy. This cannot easily be split - * into two state changes. - */ --enum drbd_state_rv change_cstate_es(struct drbd_connection *connection, -+enum drbd_state_rv change_cstate_tag(struct drbd_connection *connection, - enum drbd_conn_state cstate, - enum chg_state_flags flags, -- const char **err_str -- ) -+ const char *tag, -+ const char **err_str) - { - struct change_cstate_context cstate_context = { - .context = { -@@ -5717,7 +5726,7 @@ enum drbd_state_rv change_cstate_es(struct drbd_connection *connection, - if (!(flags & CS_HARD)) - cstate_context.context.flags |= CS_SERIALIZE; - -- return change_cluster_wide_state(do_change_cstate, &cstate_context.context); -+ return change_cluster_wide_state(do_change_cstate, &cstate_context.context, tag); - } - - void __change_peer_role(struct drbd_connection *connection, enum drbd_role peer_role) -@@ -5759,7 +5768,8 @@ static bool do_change_repl_state(struct change_context *context, enum change_pha - - enum drbd_state_rv change_repl_state(struct drbd_peer_device *peer_device, - enum drbd_repl_state new_repl_state, -- enum chg_state_flags flags) -+ enum chg_state_flags flags, -+ const char *tag) - { - struct change_repl_context repl_context = { - .context = { -@@ -5776,15 +5786,16 @@ enum drbd_state_rv change_repl_state(struct drbd_peer_device *peer_device, - if (new_repl_state == L_WF_BITMAP_S || new_repl_state == L_VERIFY_S) - repl_context.context.change_local_state_last = true; - -- return change_cluster_wide_state(do_change_repl_state, &repl_context.context); -+ return change_cluster_wide_state(do_change_repl_state, &repl_context.context, tag); - } - - enum drbd_state_rv stable_change_repl_state(struct drbd_peer_device *peer_device, - enum drbd_repl_state repl_state, -- enum chg_state_flags flags) -+ enum chg_state_flags flags, -+ const char *tag) - { - return stable_state_change(peer_device->device->resource, -- change_repl_state(peer_device, repl_state, flags)); -+ change_repl_state(peer_device, repl_state, flags, tag)); - } - - void __change_peer_disk_state(struct drbd_peer_device *peer_device, enum drbd_disk_state disk_state) -@@ -5807,14 +5818,15 @@ void __downgrade_peer_disk_states(struct drbd_connection *connection, enum drbd_ - - enum drbd_state_rv change_peer_disk_state(struct drbd_peer_device *peer_device, - enum drbd_disk_state disk_state, -- enum chg_state_flags flags) -+ enum chg_state_flags flags, -+ const char *tag) - { - struct drbd_resource *resource = peer_device->device->resource; - unsigned long irq_flags; - - begin_state_change(resource, &irq_flags, flags); - __change_peer_disk_state(peer_device, disk_state); -- return end_state_change(resource, &irq_flags); -+ return end_state_change(resource, &irq_flags, tag); - } - - void __change_resync_susp_user(struct drbd_peer_device *peer_device, -@@ -5832,7 +5844,7 @@ enum drbd_state_rv change_resync_susp_user(struct drbd_peer_device *peer_device, - - begin_state_change(resource, &irq_flags, flags); - __change_resync_susp_user(peer_device, value); -- return end_state_change(resource, &irq_flags); -+ return end_state_change(resource, &irq_flags, value ? "pause-sync" : "resume-sync"); - } - - void __change_resync_susp_peer(struct drbd_peer_device *peer_device, -diff --git a/drbd/drbd_state.h b/drbd/drbd_state.h -index 6942f85123dd..952dea156697 100644 ---- a/drbd/drbd_state.h -+++ b/drbd/drbd_state.h -@@ -56,12 +56,13 @@ extern void state_change_lock(struct drbd_resource *, unsigned long *, enum chg_ - extern void state_change_unlock(struct drbd_resource *, unsigned long *); - - extern void begin_state_change(struct drbd_resource *, unsigned long *, enum chg_state_flags); --extern enum drbd_state_rv end_state_change(struct drbd_resource *, unsigned long *); -+extern enum drbd_state_rv end_state_change(struct drbd_resource *resource, unsigned long *irq_flags, -+ const char *tag); - extern void abort_state_change(struct drbd_resource *, unsigned long *); - extern void abort_state_change_locked(struct drbd_resource *resource); - - extern void begin_state_change_locked(struct drbd_resource *, enum chg_state_flags); --extern enum drbd_state_rv end_state_change_locked(struct drbd_resource *); -+extern enum drbd_state_rv end_state_change_locked(struct drbd_resource *resource, const char *tag); - - extern void clear_remote_state_change(struct drbd_resource *resource); - extern void __clear_remote_state_change(struct drbd_resource *resource); -@@ -89,7 +90,11 @@ extern enum drbd_state_rv nested_twopc_request(struct drbd_resource *res, struct - extern bool drbd_twopc_between_peer_and_me(struct drbd_connection *connection); - extern bool cluster_wide_reply_ready(struct drbd_resource *); - --extern enum drbd_state_rv change_role(struct drbd_resource *, enum drbd_role, enum chg_state_flags, const char **); -+extern enum drbd_state_rv change_role(struct drbd_resource *resource, -+ enum drbd_role role, -+ enum chg_state_flags flags, -+ const char *tag, -+ const char **err_str); - - extern void __change_io_susp_user(struct drbd_resource *, bool); - extern enum drbd_state_rv change_io_susp_user(struct drbd_resource *, bool, enum chg_state_flags); -@@ -99,27 +104,44 @@ extern void __change_io_susp_quorum(struct drbd_resource *, bool); - - extern void __change_disk_state(struct drbd_device *, enum drbd_disk_state); - extern void __downgrade_disk_states(struct drbd_resource *, enum drbd_disk_state); --extern enum drbd_state_rv change_disk_state(struct drbd_device *, enum drbd_disk_state, enum chg_state_flags, const char **); -+extern enum drbd_state_rv change_disk_state(struct drbd_device *device, -+ enum drbd_disk_state disk_state, -+ enum chg_state_flags flags, -+ const char *tag, -+ const char **err_str); - - extern void __change_cstate(struct drbd_connection *, enum drbd_conn_state); --extern enum drbd_state_rv change_cstate_es(struct drbd_connection *, enum drbd_conn_state, enum chg_state_flags, const char **); -+extern enum drbd_state_rv change_cstate_tag(struct drbd_connection *connection, -+ enum drbd_conn_state cstate, -+ enum chg_state_flags flags, -+ const char *tag, -+ const char **err_str); - static inline enum drbd_state_rv change_cstate(struct drbd_connection *connection, - enum drbd_conn_state cstate, - enum chg_state_flags flags) - { -- return change_cstate_es(connection, cstate, flags, NULL); -+ return change_cstate_tag(connection, cstate, flags, NULL, NULL); - } - - extern void __change_peer_role(struct drbd_connection *, enum drbd_role); - - extern void __change_repl_state(struct drbd_peer_device *, enum drbd_repl_state); --extern enum drbd_state_rv change_repl_state(struct drbd_peer_device *, enum drbd_repl_state, enum chg_state_flags); --extern enum drbd_state_rv stable_change_repl_state(struct drbd_peer_device *, enum drbd_repl_state, enum chg_state_flags); -+extern enum drbd_state_rv change_repl_state(struct drbd_peer_device *peer_device, -+ enum drbd_repl_state new_repl_state, -+ enum chg_state_flags flags, -+ const char *tag); -+extern enum drbd_state_rv stable_change_repl_state(struct drbd_peer_device *peer_device, -+ enum drbd_repl_state repl_state, -+ enum chg_state_flags flags, -+ const char *tag); - - extern void __change_peer_disk_state(struct drbd_peer_device *, enum drbd_disk_state); - extern void __downgrade_peer_disk_states(struct drbd_connection *, enum drbd_disk_state); - extern void __outdate_myself(struct drbd_resource *resource); --extern enum drbd_state_rv change_peer_disk_state(struct drbd_peer_device *, enum drbd_disk_state, enum chg_state_flags); -+extern enum drbd_state_rv change_peer_disk_state(struct drbd_peer_device *peer_device, -+ enum drbd_disk_state disk_state, -+ enum chg_state_flags flags, -+ const char *tag); - - enum drbd_state_rv twopc_after_lost_peer(struct drbd_resource *resource, enum chg_state_flags); - --- -2.35.3 - diff --git a/0014-drbd-split-out-a-drbd_discard_supported-helper.patch b/0014-drbd-split-out-a-drbd_discard_supported-helper.patch new file mode 100644 index 0000000..158b866 --- /dev/null +++ b/0014-drbd-split-out-a-drbd_discard_supported-helper.patch @@ -0,0 +1,73 @@ +From 78d5d462c2bdac350921c114caca588c606d7c0b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= + +Date: Mon, 1 Jul 2024 17:56:08 +0200 +Subject: [PATCH 14/32] drbd: split out a drbd_discard_supported helper + +Add a helper to check if discard is supported for a given connection / +backing device combination. + +Similar idea to upstream kernel commit 5eaee6e9c8f9 +("drbd: split out a drbd_discard_supported helper"), but also get rid of +the goto. +--- + drbd/drbd_nl.c | 29 ++++++++++++++++++----------- + 1 file changed, 18 insertions(+), 11 deletions(-) + +diff --git a/drbd/drbd_nl.c b/drbd/drbd_nl.c +index a0c3534d8996..e3f508cd0421 100644 +--- a/drbd/drbd_nl.c ++++ b/drbd/drbd_nl.c +@@ -2044,19 +2044,31 @@ static unsigned int drbd_max_discard_sectors(struct drbd_resource *resource) + return s; + } + +-static void decide_on_discard_support(struct drbd_device *device, ++static bool drbd_discard_supported(struct drbd_device *device, + struct drbd_backing_dev *bdev) + { +- struct request_queue *q = device->rq_queue; +- unsigned int max_discard_sectors; +- + if (bdev && !bdev_max_discard_sectors(bdev->backing_bdev)) +- goto not_supported; ++ return false; + + if (!(common_connection_features(device->resource) & DRBD_FF_TRIM)) { + drbd_info(device, + "peer DRBD too old, does not support TRIM: disabling discards\n"); +- goto not_supported; ++ return false; ++ } ++ ++ return true; ++} ++ ++static void decide_on_discard_support(struct drbd_device *device, ++ struct drbd_backing_dev *bdev) ++{ ++ struct request_queue *q = device->rq_queue; ++ unsigned int max_discard_sectors; ++ ++ if (!drbd_discard_supported(device, bdev)) { ++ blk_queue_discard_granularity(q, 0); ++ blk_queue_max_discard_sectors(q, 0); ++ return; + } + + /* +@@ -2070,11 +2082,6 @@ static void decide_on_discard_support(struct drbd_device *device, + blk_queue_discard_granularity(q, 512); + max_discard_sectors = drbd_max_discard_sectors(device->resource); + blk_queue_max_discard_sectors(q, max_discard_sectors); +- return; +- +-not_supported: +- blk_queue_discard_granularity(q, 0); +- blk_queue_max_discard_sectors(q, 0); + } + + static void fixup_write_zeroes(struct drbd_device *device, struct request_queue *q) +-- +2.35.3 + diff --git a/0015-compat-block-use-the-holder-as-indication-for-exclus.patch b/0015-compat-block-use-the-holder-as-indication-for-exclus.patch deleted file mode 100644 index 83881d6..0000000 --- a/0015-compat-block-use-the-holder-as-indication-for-exclus.patch +++ /dev/null @@ -1,202 +0,0 @@ -From 3b9fcc2cfaa32766724f371cc2054e057adbc425 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Moritz=20=22WanzenBug=22=20Wanzenb=C3=B6ck?= - -Date: Mon, 11 Sep 2023 13:36:07 +0200 -Subject: [PATCH 15/20] compat: block: use the holder as indication for - exclusive opens - -See also upstream Linux kernel commit -2736e8eeb0cc ("block: use the holder as indication for exclusive opens") -Original message: - -The current interface for exclusive opens is rather confusing as it -requires both the FMODE_EXCL flag and a holder. Remove the need to pass -FMODE_EXCL and just key off the exclusive open off a non-NULL holder. - -For blkdev_put this requires adding the holder argument, which provides -better debug checking that only the holder actually releases the hold, -but at the same time allows removing the now superfluous mode argument. ---- - .../cocci/blkdev_put__no_has_holder.cocci | 38 +++++++++++++++++++ - drbd/drbd-kernel-compat/gen_patch_names.c | 3 ++ - .../tests/blkdev_put_has_holder.c | 17 +++++++++ - drbd/drbd_nl.c | 28 ++++++++------ - 4 files changed, 75 insertions(+), 11 deletions(-) - create mode 100644 drbd/drbd-kernel-compat/cocci/blkdev_put__no_has_holder.cocci - create mode 100644 drbd/drbd-kernel-compat/tests/blkdev_put_has_holder.c - -diff --git a/drbd/drbd-kernel-compat/cocci/blkdev_put__no_has_holder.cocci b/drbd/drbd-kernel-compat/cocci/blkdev_put__no_has_holder.cocci -new file mode 100644 -index 000000000000..c903bc2d529c ---- /dev/null -+++ b/drbd/drbd-kernel-compat/cocci/blkdev_put__no_has_holder.cocci -@@ -0,0 +1,38 @@ -+@@ -+expression path, mode; -+@@ -+ blkdev_get_by_path( -+ path, -+- mode, -++ mode | FMODE_EXCL, -+ ... -+ ) -+ -+@@ -+expression bdev, holder; -+@@ -+ blkdev_put( -+ bdev, -+- holder -++ FMODE_READ | FMODE_WRITE | FMODE_EXCL -+ ) -+ -+@@ -+identifier device, bdev, holder, do_bd_unlink; -+@@ -+ void close_backing_dev( -+ struct drbd_device *device, -+ struct block_device *bdev, -+- void *holder, -+ bool do_bd_unlink -+ ) { ... } -+ -+@@ -+expression device, bdev, holder, do_bd_unlink; -+@@ -+ close_backing_dev( -+ device, -+ bdev, -+- holder, -+ do_bd_unlink -+ ) -diff --git a/drbd/drbd-kernel-compat/gen_patch_names.c b/drbd/drbd-kernel-compat/gen_patch_names.c -index 6e4f06d9a3a7..4761c1ef7d0c 100644 ---- a/drbd/drbd-kernel-compat/gen_patch_names.c -+++ b/drbd/drbd-kernel-compat/gen_patch_names.c -@@ -562,6 +562,9 @@ int main(int argc, char **argv) - patch(1, "block_device_operations_open", true, false, - COMPAT_BLOCK_DEVICE_OPERATIONS_OPEN_TAKES_GENDISK, "takes_gendisk"); - -+ patch(1, "blkdev_put", true, false, -+ COMPAT_BLKDEV_PUT_HAS_HOLDER, "has_holder"); -+ - /* #define BLKDEV_ISSUE_ZEROOUT_EXPORTED */ - /* #define BLKDEV_ZERO_NOUNMAP */ - -diff --git a/drbd/drbd-kernel-compat/tests/blkdev_put_has_holder.c b/drbd/drbd-kernel-compat/tests/blkdev_put_has_holder.c -new file mode 100644 -index 000000000000..d5f0c5dd0355 ---- /dev/null -+++ b/drbd/drbd-kernel-compat/tests/blkdev_put_has_holder.c -@@ -0,0 +1,17 @@ -+/* { "version": "v6.5-rc1", "commit": "ae220766d87cd6799dbf918fea10613ae14c0654", "comment": "block: remove the unused mode argument to ->release", "author": "Christoph Hellwig ", "date": "Thu Jun 8 13:02:37 2023 +0200" } */ -+#include -+ -+#ifndef __same_type -+# define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) -+#endif -+ -+void foo_blkdev_put(struct block_device *bdev, void *holder) -+{ -+} -+ -+ -+void foo(void) -+{ -+ BUILD_BUG_ON(!(__same_type(&blkdev_put, &foo_blkdev_put))); -+} -+ -diff --git a/drbd/drbd_nl.c b/drbd/drbd_nl.c -index b7e9e43312f9..8c968cf252ca 100644 ---- a/drbd/drbd_nl.c -+++ b/drbd/drbd_nl.c -@@ -2536,13 +2536,13 @@ bool want_bitmap(struct drbd_peer_device *peer_device) - } - - static void close_backing_dev(struct drbd_device *device, struct block_device *bdev, -- bool do_bd_unlink) -+ void *holder, bool do_bd_unlink) - { - if (!bdev) - return; - if (do_bd_unlink) - bd_unlink_disk_holder(bdev, device->vdisk); -- blkdev_put(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL); -+ blkdev_put(bdev, holder); - } - - void drbd_backing_dev_free(struct drbd_device *device, struct drbd_backing_dev *ldev) -@@ -2552,8 +2552,11 @@ void drbd_backing_dev_free(struct drbd_device *device, struct drbd_backing_dev * - - drbd_dax_close(ldev); - -- close_backing_dev(device, ldev->md_bdev, ldev->md_bdev != ldev->backing_bdev); -- close_backing_dev(device, ldev->backing_bdev, true); -+ close_backing_dev(device, -+ ldev->md_bdev, -+ ldev->md.meta_dev_idx < 0 ? (void *)device : (void *)drbd_m_holder, -+ ldev->md_bdev != ldev->backing_bdev); -+ close_backing_dev(device, ldev->backing_bdev, device, true); - - kfree(ldev->disk_conf); - kfree(ldev); -@@ -2563,7 +2566,7 @@ static struct block_device *open_backing_dev(struct drbd_device *device, - const char *bdev_path, void *claim_ptr) - { - struct block_device *bdev = blkdev_get_by_path(bdev_path, -- FMODE_READ | FMODE_WRITE | FMODE_EXCL, -+ FMODE_READ | FMODE_WRITE, - claim_ptr, NULL); - if (IS_ERR(bdev)) { - drbd_err(device, "open(\"%s\") failed with %ld\n", -@@ -2588,6 +2591,7 @@ static int open_backing_devices(struct drbd_device *device, - struct drbd_backing_dev *nbc) - { - struct block_device *bdev; -+ void *meta_claim_ptr; - int err; - - bdev = open_backing_dev(device, new_disk_conf->backing_dev, device); -@@ -2597,12 +2601,17 @@ static int open_backing_devices(struct drbd_device *device, - err = link_backing_dev(device, new_disk_conf->backing_dev, bdev); - if (err) { - /* close without unlinking; otherwise error path will try to unlink */ -- close_backing_dev(device, bdev, false); -+ close_backing_dev(device, bdev, device, false); - return ERR_OPEN_DISK; - } - - nbc->backing_bdev = bdev; - -+ /* meta_claim_ptr: device, if claimed exclusively; shared drbd_m_holder, -+ * if potentially shared with other drbd minors -+ */ -+ meta_claim_ptr = (new_disk_conf->meta_dev_idx < 0) ? -+ (void *)device : (void *)drbd_m_holder; - /* - * meta_dev_idx >= 0: external fixed size, possibly multiple - * drbd sharing one meta device. TODO in that case, paranoia -@@ -2611,10 +2620,7 @@ static int open_backing_devices(struct drbd_device *device, - * should check it for you already; but if you don't, or - * someone fooled it, we need to double check here) - */ -- bdev = open_backing_dev(device, new_disk_conf->meta_dev, -- /* claim ptr: device, if claimed exclusively; shared drbd_m_holder, -- * if potentially shared with other drbd minors */ -- (new_disk_conf->meta_dev_idx < 0) ? (void*)device : (void*)drbd_m_holder); -+ bdev = open_backing_dev(device, new_disk_conf->meta_dev, meta_claim_ptr); - if (IS_ERR(bdev)) - return ERR_OPEN_MD_DISK; - -@@ -2624,7 +2630,7 @@ static int open_backing_devices(struct drbd_device *device, - err = link_backing_dev(device, new_disk_conf->meta_dev, bdev); - if (err) { - /* close without unlinking; otherwise error path will try to unlink */ -- close_backing_dev(device, bdev, false); -+ close_backing_dev(device, bdev, meta_claim_ptr, false); - return ERR_OPEN_MD_DISK; - } - } --- -2.35.3 - diff --git a/0015-drbd-atomically-update-queue-limits-in-drbd_reconsid.patch b/0015-drbd-atomically-update-queue-limits-in-drbd_reconsid.patch new file mode 100644 index 0000000..d728d56 --- /dev/null +++ b/0015-drbd-atomically-update-queue-limits-in-drbd_reconsid.patch @@ -0,0 +1,194 @@ +From 5931286cb71114c0f34e51fc7f357dceec139ca1 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= + +Date: Tue, 13 Aug 2024 12:26:02 +0200 +Subject: [PATCH 15/32] drbd: atomically update queue limits in + drbd_reconsider_queue_parameters + +Switch drbd_reconsider_queue_parameters to set up the queue parameters +in an on-stack queue_limits structure and apply the limits atomically. +Remove various helpers that have become so trivial that they can be +folded into drbd_reconsider_queue_parameters. + +Same idea as upstream kernel commit e6dfe748f09e ("drbd: atomically +update queue limits in drbd_reconsider_queue_parameters"), but with some +adaptations to DRBD 9. +--- + drbd/drbd_nl.c | 136 ++++++++++++++++++++++--------------------------- + 1 file changed, 60 insertions(+), 76 deletions(-) + +diff --git a/drbd/drbd_nl.c b/drbd/drbd_nl.c +index e3f508cd0421..7193ba0c77e3 100644 +--- a/drbd/drbd_nl.c ++++ b/drbd/drbd_nl.c +@@ -2018,11 +2018,6 @@ static u32 common_connection_features(struct drbd_resource *resource) + return features; + } + +-static void blk_queue_discard_granularity(struct request_queue *q, unsigned int granularity) +-{ +- q->limits.discard_granularity = granularity; +-} +- + static unsigned int drbd_max_discard_sectors(struct drbd_resource *resource) + { + struct drbd_connection *connection; +@@ -2059,73 +2054,20 @@ static bool drbd_discard_supported(struct drbd_device *device, + return true; + } + +-static void decide_on_discard_support(struct drbd_device *device, +- struct drbd_backing_dev *bdev) +-{ +- struct request_queue *q = device->rq_queue; +- unsigned int max_discard_sectors; +- +- if (!drbd_discard_supported(device, bdev)) { +- blk_queue_discard_granularity(q, 0); +- blk_queue_max_discard_sectors(q, 0); +- return; +- } +- +- /* +- * We don't care for the granularity, really. +- * +- * Stacking limits below should fix it for the local device. Whether or +- * not it is a suitable granularity on the remote device is not our +- * problem, really. If you care, you need to use devices with similar +- * topology on all peers. +- */ +- blk_queue_discard_granularity(q, 512); +- max_discard_sectors = drbd_max_discard_sectors(device->resource); +- blk_queue_max_discard_sectors(q, max_discard_sectors); +-} +- +-static void fixup_write_zeroes(struct drbd_device *device, struct request_queue *q) +-{ +- /* Fixup max_write_zeroes_sectors after blk_stack_limits(): +- * if we can handle "zeroes" efficiently on the protocol, +- * we want to do that, even if our backend does not announce +- * max_write_zeroes_sectors itself. */ +- +- /* If all peers announce WZEROES support, use it. Otherwise, rather +- * send explicit zeroes than rely on some discard-zeroes-data magic. */ +- if (common_connection_features(device->resource) & DRBD_FF_WZEROES) +- q->limits.max_write_zeroes_sectors = DRBD_MAX_BBIO_SECTORS; +- else +- q->limits.max_write_zeroes_sectors = 0; +-} +- +-static void fixup_discard_support(struct drbd_device *device, struct request_queue *q) +-{ +- unsigned int max_discard = device->rq_queue->limits.max_discard_sectors; +- unsigned int discard_granularity = device->rq_queue->limits.discard_granularity >> SECTOR_SHIFT; +- +- if (discard_granularity > max_discard) { +- blk_queue_discard_granularity(q, 0); +- blk_queue_max_discard_sectors(q, 0); +- } +-} +- +-void drbd_reconsider_queue_parameters(struct drbd_device *device, struct drbd_backing_dev *bdev) ++static void get_common_queue_limits(struct queue_limits *common_limits, ++ struct drbd_device *device) + { +- struct request_queue * const q = device->rq_queue; +- struct queue_limits common_limits = { 0 }; /* sizeof(struct queue_limits) ~ 110 bytes */ +- struct queue_limits peer_limits = { 0 }; + struct drbd_peer_device *peer_device; +- struct request_queue *b = NULL; ++ struct queue_limits peer_limits = { 0 }; + +- blk_set_stacking_limits(&common_limits); ++ blk_set_stacking_limits(common_limits); + /* This is the workaround for "bio would need to, but cannot, be split" */ +- common_limits.seg_boundary_mask = PAGE_SIZE - 1; +- common_limits.max_hw_sectors = device->device_conf.max_bio_size >> SECTOR_SHIFT; +- common_limits.max_sectors = device->device_conf.max_bio_size >> SECTOR_SHIFT; +- common_limits.physical_block_size = device->device_conf.block_size; +- common_limits.logical_block_size = device->device_conf.block_size; +- common_limits.io_min = device->device_conf.block_size; ++ common_limits->seg_boundary_mask = PAGE_SIZE - 1; ++ common_limits->max_hw_sectors = device->device_conf.max_bio_size >> SECTOR_SHIFT; ++ common_limits->max_sectors = device->device_conf.max_bio_size >> SECTOR_SHIFT; ++ common_limits->physical_block_size = device->device_conf.block_size; ++ common_limits->logical_block_size = device->device_conf.block_size; ++ common_limits->io_min = device->device_conf.block_size; + + rcu_read_lock(); + for_each_peer_device_rcu(peer_device, device) { +@@ -2140,21 +2082,63 @@ void drbd_reconsider_queue_parameters(struct drbd_device *device, struct drbd_ba + peer_limits.io_opt = peer_device->q_limits.io_opt; + peer_limits.max_hw_sectors = peer_device->q_limits.max_bio_size >> SECTOR_SHIFT; + peer_limits.max_sectors = peer_device->q_limits.max_bio_size >> SECTOR_SHIFT; +- blk_stack_limits(&common_limits, &peer_limits, 0); ++ blk_stack_limits(common_limits, &peer_limits, 0); + } + rcu_read_unlock(); ++} ++ ++void drbd_reconsider_queue_parameters(struct drbd_device *device, struct drbd_backing_dev *bdev) ++{ ++ struct request_queue * const q = device->rq_queue; ++ struct queue_limits lim; ++ struct request_queue *b = NULL; ++ ++ lim = queue_limits_start_update(q); ++ get_common_queue_limits(&lim, device); ++ ++ /* ++ * We don't care for the granularity, really. ++ * Stacking limits below should fix it for the local device. Whether or ++ * not it is a suitable granularity on the remote device is not our ++ * problem, really. If you care, you need to use devices with similar ++ * topology on all peers. ++ */ ++ if (drbd_discard_supported(device, bdev)) { ++ lim.discard_granularity = 512; ++ lim.max_hw_discard_sectors = drbd_max_discard_sectors(device->resource); ++ } else { ++ lim.discard_granularity = 0; ++ lim.max_hw_discard_sectors = 0; ++ } + + if (bdev) { + b = bdev->backing_bdev->bd_disk->queue; +- blk_stack_limits(&common_limits, &b->limits, 0); +- disk_update_readahead(device->vdisk); ++ blk_stack_limits(&lim, &b->limits, 0); ++ } ++ ++ /* ++ * If we can handle "zeroes" efficiently on the protocol, ++ * we want to do that, even if our backend does not announce ++ * max_write_zeroes_sectors itself. ++ */ ++ if (common_connection_features(device->resource) & DRBD_FF_WZEROES) ++ lim.max_write_zeroes_sectors = DRBD_MAX_BBIO_SECTORS; ++ else ++ lim.max_write_zeroes_sectors = 0; ++ ++ if ((lim.discard_granularity >> SECTOR_SHIFT) > ++ lim.max_hw_discard_sectors) { ++ /* ++ * discard_granularity is the smallest supported unit of a ++ * discard. If that is larger than the maximum supported discard ++ * size, we need to disable discards altogether. ++ */ ++ lim.discard_granularity = 0; ++ lim.max_hw_discard_sectors = 0; + } +- q->limits = common_limits; +- blk_queue_max_hw_sectors(q, common_limits.max_hw_sectors); +- decide_on_discard_support(device, bdev); + +- fixup_write_zeroes(device, q); +- fixup_discard_support(device, q); ++ if (queue_limits_commit_update(q, &lim)) ++ drbd_err(device, "setting new queue limits failed\n"); + } + + /* Make sure IO is suspended before calling this function(). */ +-- +2.35.3 + diff --git a/0016-compat-test-and-patch-for-queue_limits_start_update.patch b/0016-compat-test-and-patch-for-queue_limits_start_update.patch new file mode 100644 index 0000000..dbf7e59 --- /dev/null +++ b/0016-compat-test-and-patch-for-queue_limits_start_update.patch @@ -0,0 +1,71 @@ +From fef08ee4fac426f5dfbec124bd2bd58fbd390cb2 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= + +Date: Thu, 22 Aug 2024 12:09:42 +0200 +Subject: [PATCH 16/32] compat: test and patch for queue_limits_start_update + +--- + ...ueue_limits_start_update__no_present.cocci | 20 +++++++++++++++++++ + drbd/drbd-kernel-compat/gen_patch_names.c | 3 +++ + .../tests/have_queue_limits_start_update.c | 8 ++++++++ + 3 files changed, 31 insertions(+) + create mode 100644 drbd/drbd-kernel-compat/cocci/queue_limits_start_update__no_present.cocci + create mode 100644 drbd/drbd-kernel-compat/tests/have_queue_limits_start_update.c + +diff --git a/drbd/drbd-kernel-compat/cocci/queue_limits_start_update__no_present.cocci b/drbd/drbd-kernel-compat/cocci/queue_limits_start_update__no_present.cocci +new file mode 100644 +index 000000000000..4e34f5887181 +--- /dev/null ++++ b/drbd/drbd-kernel-compat/cocci/queue_limits_start_update__no_present.cocci +@@ -0,0 +1,20 @@ ++@@ ++identifier lim; ++identifier q; ++identifier device; ++identifier bdev; ++@@ ++void drbd_reconsider_queue_parameters(struct drbd_device *device, struct drbd_backing_dev *bdev) ++{ ++... ++ lim = ++- queue_limits_start_update(q); +++ q->limits; ++... ++- if (queue_limits_commit_update(q, &lim)) { ... } +++ blk_queue_max_hw_sectors(q, lim.max_hw_sectors); +++ q->limits = lim; +++ if (bdev) +++ disk_update_readahead(device->vdisk); ++... ++} +diff --git a/drbd/drbd-kernel-compat/gen_patch_names.c b/drbd/drbd-kernel-compat/gen_patch_names.c +index c21a43b39488..13aec5c8bd5f 100644 +--- a/drbd/drbd-kernel-compat/gen_patch_names.c ++++ b/drbd/drbd-kernel-compat/gen_patch_names.c +@@ -393,6 +393,9 @@ int main(int argc, char **argv) + COMPAT_HAVE_WB_CONGESTED_ENUM, "present"); + #endif + ++ patch(1, "queue_limits_start_update", true, false, ++ COMPAT_HAVE_QUEUE_LIMITS_START_UPDATE, "present"); ++ + patch(1, "disk_update_readahead", true, false, + COMPAT_HAVE_DISK_UPDATE_READAHEAD, "present"); + +diff --git a/drbd/drbd-kernel-compat/tests/have_queue_limits_start_update.c b/drbd/drbd-kernel-compat/tests/have_queue_limits_start_update.c +new file mode 100644 +index 000000000000..a867d1675218 +--- /dev/null ++++ b/drbd/drbd-kernel-compat/tests/have_queue_limits_start_update.c +@@ -0,0 +1,8 @@ ++/* { "version": "v6.9-rc1", "commit": "d690cb8ae14bd377d422b7905b6959c7e7a45b95", "comment": "block: add an API to atomically update queue limits", "author": "Christoph Hellwig ", "date": "Tue Feb 13 08:34:14 2024 +0100" } */ ++ ++#include ++ ++static struct queue_limits foo(struct request_queue *q) ++{ ++ return queue_limits_start_update(q); ++} +-- +2.35.3 + diff --git a/0016-drbd-Fix-net-options-set-defaults-to-not-clear-the-t.patch b/0016-drbd-Fix-net-options-set-defaults-to-not-clear-the-t.patch deleted file mode 100644 index 8ba4ee9..0000000 --- a/0016-drbd-Fix-net-options-set-defaults-to-not-clear-the-t.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 69d9286628b730870665cd2c6f05dd9f1813c65e Mon Sep 17 00:00:00 2001 -From: Philipp Reisner -Date: Sun, 17 Sep 2023 22:21:11 +0800 -Subject: [PATCH 16/20] drbd: Fix `net-options --set-defaults` to not clear the - transport - -So far, `drbdsetup net-options --set-defaults` cleared the -transport_name. That is a stupid bug that caused `drbdadm adjust` to -do a disconnect/connect cycle. This affected `lb-tcp` and `rdma`. As -`tcp` is the default, it was not affected by this. ---- - drbd/drbd_nl.c | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/drbd/drbd_nl.c b/drbd/drbd_nl.c -index 8c968cf252ca..b0a1e6fa46f1 100644 ---- a/drbd/drbd_nl.c -+++ b/drbd/drbd_nl.c -@@ -3729,6 +3729,11 @@ int drbd_adm_net_opts(struct sk_buff *skb, struct genl_info *info) - if (should_set_defaults(info)) - set_net_conf_defaults(new_net_conf); - -+ /* The transport_name is immutable taking precedence over set_net_conf_defaults() */ -+ memcpy(new_net_conf->transport_name, old_net_conf->transport_name, -+ old_net_conf->transport_name_len); -+ new_net_conf->transport_name_len = old_net_conf->transport_name_len; -+ - err = net_conf_from_attrs_for_change(new_net_conf, info); - if (err && err != -ENOMSG) { - retcode = ERR_MANDATORY_TAG; --- -2.35.3 - diff --git a/0017-compat-specify-which-essential-change-was-not-made.patch b/0017-compat-specify-which-essential-change-was-not-made.patch new file mode 100644 index 0000000..6187426 --- /dev/null +++ b/0017-compat-specify-which-essential-change-was-not-made.patch @@ -0,0 +1,54 @@ +From 4352ece8e85da43090be171276a0d45d83c55a00 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= + +Date: Thu, 22 Aug 2024 12:25:39 +0200 +Subject: [PATCH 17/32] compat: specify which essential change was not made + +--- + drbd/drbd-kernel-compat/cocci/bdi_congested__yes_present.cocci | 2 +- + drbd/drbd-kernel-compat/cocci/bio_op_shift__yes_present.cocci | 2 +- + .../cocci/blk_queue_max_write_same_sectors__yes_present.cocci | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/drbd/drbd-kernel-compat/cocci/bdi_congested__yes_present.cocci b/drbd/drbd-kernel-compat/cocci/bdi_congested__yes_present.cocci +index 8a0260321ab5..fdf6afc8355f 100644 +--- a/drbd/drbd-kernel-compat/cocci/bdi_congested__yes_present.cocci ++++ b/drbd/drbd-kernel-compat/cocci/bdi_congested__yes_present.cocci +@@ -21,7 +21,7 @@ struct device_statistics *s; + @ script:python depends on !(add_bdi_read_congested_congested_remote && add_bdi_read_congested_device_to_statistics) @ + @@ + import sys +-print('ERROR: A rule making an essential change was not executed!', file=sys.stderr) ++print('ERROR: A rule making an essential change was not executed! (bdi_read_congested)', file=sys.stderr) + print('ERROR: This would not show up as a compiler error, but would still break DRBD.', file=sys.stderr) + print('ERROR: Check bdi_congested__yes_present.cocci', file=sys.stderr) + print('ERROR: As a precaution, the build will be aborted here.', file=sys.stderr) +diff --git a/drbd/drbd-kernel-compat/cocci/bio_op_shift__yes_present.cocci b/drbd/drbd-kernel-compat/cocci/bio_op_shift__yes_present.cocci +index cc02f5b91c2e..3225291f7dbd 100644 +--- a/drbd/drbd-kernel-compat/cocci/bio_op_shift__yes_present.cocci ++++ b/drbd/drbd-kernel-compat/cocci/bio_op_shift__yes_present.cocci +@@ -57,7 +57,7 @@ combine_opf(wire_flags_to_bio_op(dpf), + @ script:python depends on !combine_wire_flags @ + @@ + import sys +-print('ERROR: A rule making an essential change was not executed!', file=sys.stderr) ++print('ERROR: A rule making an essential change was not executed! (combine_opf)', 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/blk_queue_max_write_same_sectors__yes_present.cocci b/drbd/drbd-kernel-compat/cocci/blk_queue_max_write_same_sectors__yes_present.cocci +index 8eb4eef7dfd5..9202ee9c2dc4 100644 +--- a/drbd/drbd-kernel-compat/cocci/blk_queue_max_write_same_sectors__yes_present.cocci ++++ b/drbd/drbd-kernel-compat/cocci/blk_queue_max_write_same_sectors__yes_present.cocci +@@ -7,7 +7,7 @@ blk_queue_max_hw_sectors(q, ...); + @ script:python depends on !add_blk_queue_max_write_same_sectors @ + @@ + import sys +-print('ERROR: A rule making an essential change was not executed!', file=sys.stderr) ++print('ERROR: A rule making an essential change was not executed! (blk_queue_max_write_same_sectors)', file=sys.stderr) + print('ERROR: This would not show up as a compiler error, but would still break DRBD.', file=sys.stderr) + print('ERROR: Check blk_queue_max_write_same_sectors_yes_present.cocci', file=sys.stderr) + print('ERROR: As a precaution, the build will be aborted here.', file=sys.stderr) +-- +2.35.3 + diff --git a/0017-drbd-propagate-exposed-UUIDs-only-into-established-c.patch b/0017-drbd-propagate-exposed-UUIDs-only-into-established-c.patch deleted file mode 100644 index 33d6744..0000000 --- a/0017-drbd-propagate-exposed-UUIDs-only-into-established-c.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 0666bc5b014049b6aa184b5a8fdb60481b9c8717 Mon Sep 17 00:00:00 2001 -From: Philipp Reisner -Date: Fri, 22 Sep 2023 15:09:07 +0200 -Subject: [PATCH 17/20] drbd: propagate exposed UUIDs only into established - connections - -Sending into connections in C_CONNECTING state while we exchange the -feature and auth packets might interfere with exchanging those. I also -witnessed that it might block unexpectedly long (2 - 6 seconds), -holding the `connection->mutex[DATA_STREAM]` mutex and again causing -troubles with establishing connections. - -This is a fix for commit 772e5b21d from April 2023 -"drbd: Consider outdating a disk when more recent data is behind a diskless" -Released with of 9.1.15 and 9.2.4. ---- - drbd/drbd_receiver.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drbd/drbd_receiver.c b/drbd/drbd_receiver.c -index 0c3ab0fd486c..bfd265b86b43 100644 ---- a/drbd/drbd_receiver.c -+++ b/drbd/drbd_receiver.c -@@ -7206,7 +7206,7 @@ static void propagate_exposed_uuid(struct drbd_device *device) - u64 im; - - for_each_peer_device_ref(peer_device, im, device) { -- if (peer_device->connection->cstate[NOW] < C_CONNECTING) -+ if (!test_bit(INITIAL_STATE_SENT, &peer_device->flags)) - continue; - drbd_send_current_uuid(peer_device, device->exposed_data_uuid, 0); - } --- -2.35.3 - diff --git a/0018-drbd-rework-autopromote.patch b/0018-drbd-rework-autopromote.patch deleted file mode 100644 index dab770a..0000000 --- a/0018-drbd-rework-autopromote.patch +++ /dev/null @@ -1,185 +0,0 @@ -From e3ef0e229a6ae88346164d1507697ae1b397cdf9 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Moritz=20=22WanzenBug=22=20Wanzenb=C3=B6ck?= - -Date: Tue, 12 Sep 2023 10:17:08 +0200 -Subject: [PATCH 18/20] drbd: rework autopromote - -With upstream commit ae220766d87c we lost the ability to keep separate -counts for RW and RO openers. Instead, we keep track of openers using a -single count, and a flag indicating if the device was opened RW once. - -Once a device was opened RW, it will stay "writable" for DRBD, until all -openers are gone. This should offer a good compromise between keeping -the old auto-promote behaviour, and the changed device interface. ---- - drbd/drbd_int.h | 3 ++- - drbd/drbd_main.c | 38 +++++++++++++++++++++----------------- - drbd/drbd_nl.c | 9 +++++---- - drbd/drbd_state.c | 7 ++++--- - 4 files changed, 32 insertions(+), 25 deletions(-) - -diff --git a/drbd/drbd_int.h b/drbd/drbd_int.h -index b705f26e71a4..cf593c09cda1 100644 ---- a/drbd/drbd_int.h -+++ b/drbd/drbd_int.h -@@ -1399,7 +1399,8 @@ struct drbd_device { - - struct drbd_bitmap *bitmap; - -- int open_rw_cnt, open_ro_cnt; -+ int open_cnt; -+ bool writable; - /* FIXME clean comments, restructure so it is more obvious which - * members are protected by what */ - -diff --git a/drbd/drbd_main.c b/drbd/drbd_main.c -index 4b0b967c2c97..bb05b2215dfb 100644 ---- a/drbd/drbd_main.c -+++ b/drbd/drbd_main.c -@@ -2579,10 +2579,9 @@ static enum ioc_rv inc_open_count(struct drbd_device *device, fmode_t mode) - r = IOC_ABORT; - else if (!resource->remote_state_change) { - r = IOC_OK; -+ device->open_cnt++; - if (mode & FMODE_WRITE) -- device->open_rw_cnt++; -- else -- device->open_ro_cnt++; -+ device->writable = true; - } - read_unlock_irq(&resource->state_rwlock); - -@@ -2756,8 +2755,10 @@ void drbd_open_counts(struct drbd_resource *resource, int *rw_count_ptr, int *ro - - rcu_read_lock(); - idr_for_each_entry(&resource->devices, device, vnr) { -- rw_count += device->open_rw_cnt; -- ro_count += device->open_ro_cnt; -+ if (device->writable) -+ rw_count += device->open_cnt; -+ else -+ ro_count += device->open_cnt; - } - rcu_read_unlock(); - *rw_count_ptr = rw_count; -@@ -2825,33 +2826,35 @@ static void drbd_release(struct gendisk *gd, fmode_t mode) - { - struct drbd_device *device = gd->private_data; - struct drbd_resource *resource = device->resource; -+ bool was_writable = device->writable; - int open_rw_cnt, open_ro_cnt; - - mutex_lock(&resource->open_release); -- if (mode & FMODE_WRITE) -- device->open_rw_cnt--; -- else -- device->open_ro_cnt--; -+ device->open_cnt--; - - drbd_open_counts(resource, &open_rw_cnt, &open_ro_cnt); - -- /* last one to close will be responsible for write-out of all dirty pages */ -- if (mode & FMODE_WRITE && device->open_rw_cnt == 0) -+ /* last one to close will be responsible for write-out of all dirty pages. -+ * We also reset the writable flag for this device here: later code may -+ * check if the device is still opened for writes to determine things -+ * like auto-demote. -+ */ -+ if (was_writable && device->open_cnt == 0) { - drbd_fsync_device(device); -+ device->writable = false; -+ } - - if (open_ro_cnt == 0) - wake_up_all(&resource->state_wait); - -- if (test_bit(UNREGISTERED, &device->flags) && -- device->open_rw_cnt == 0 && device->open_ro_cnt == 0 && -+ if (test_bit(UNREGISTERED, &device->flags) && device->open_cnt == 0 && - !test_and_set_bit(DESTROYING_DEV, &device->flags)) - call_rcu(&device->rcu, drbd_reclaim_device); - - if (resource->res_opts.auto_promote) { - enum drbd_state_rv rv; - -- if (mode & FMODE_WRITE && -- open_rw_cnt == 0 && -+ if (was_writable && open_rw_cnt == 0 && - resource->role[NOW] == R_PRIMARY && - !test_bit(EXPLICIT_PRIMARY, &resource->flags)) { - rv = drbd_set_role(resource, R_SECONDARY, false, "auto-demote", NULL); -@@ -2869,9 +2872,10 @@ static void drbd_release(struct gendisk *gd, fmode_t mode) - end_state_change(resource, &irq_flags, "release"); - } - -- /* if the open counts are 0, we free the whole list, otherwise we remove the specific pid */ -+ /* if the open count is 0, we free the whole list, otherwise we remove the specific pid */ - prune_or_free_openers(device, -- (open_ro_cnt == 0 && open_rw_cnt == 0) ? 0 : task_pid_nr(current)); -+ (open_ro_cnt == 0 && open_rw_cnt == 0) ? -+ 0 : task_pid_nr(current)); - - mutex_unlock(&resource->open_release); - -diff --git a/drbd/drbd_nl.c b/drbd/drbd_nl.c -index b0a1e6fa46f1..71ed4272614e 100644 ---- a/drbd/drbd_nl.c -+++ b/drbd/drbd_nl.c -@@ -4541,8 +4541,10 @@ int drbd_open_ro_count(struct drbd_resource *resource) - int vnr, open_ro_cnt = 0; - - read_lock_irq(&resource->state_rwlock); -- idr_for_each_entry(&resource->devices, device, vnr) -- open_ro_cnt += device->open_ro_cnt; -+ idr_for_each_entry(&resource->devices, device, vnr) { -+ if (!device->writable) -+ open_ro_cnt += device->open_cnt; -+ } - read_unlock_irq(&resource->state_rwlock); - - return open_ro_cnt; -@@ -6394,8 +6396,7 @@ static enum drbd_ret_code adm_del_minor(struct drbd_device *device) - notify_device_state(NULL, 0, device, NULL, NOTIFY_DESTROY); - mutex_unlock(¬ification_mutex); - -- if (device->open_ro_cnt == 0 && device->open_rw_cnt == 0 && -- !test_and_set_bit(DESTROYING_DEV, &device->flags)) -+ if (device->open_cnt == 0 && !test_and_set_bit(DESTROYING_DEV, &device->flags)) - call_rcu(&device->rcu, drbd_reclaim_device); - - return ret; -diff --git a/drbd/drbd_state.c b/drbd/drbd_state.c -index 22cd134be962..fa70507df425 100644 ---- a/drbd/drbd_state.c -+++ b/drbd/drbd_state.c -@@ -1634,7 +1634,7 @@ handshake_found: - return SS_TWO_PRIMARIES; - if (!fail_io[NEW]) { - idr_for_each_entry(&resource->devices, device, vnr) { -- if (device->open_ro_cnt) -+ if (!device->writable && device->open_cnt) - return SS_PRIMARY_READER; - /* - * One might be tempted to add "|| open_rw_cont" here. -@@ -1661,7 +1661,7 @@ handshake_found: - (disk_state[OLD] > D_DETACHING && disk_state[NEW] == D_DETACHING))) - return SS_IN_TRANSIENT_STATE; - -- if (role[OLD] == R_PRIMARY && role[NEW] == R_SECONDARY && device->open_rw_cnt && -+ if (role[OLD] == R_PRIMARY && role[NEW] == R_SECONDARY && device->writable && - !(resource->state_change_flags & CS_FS_IGN_OPENERS)) - return SS_DEVICE_IN_USE; - -@@ -1693,7 +1693,8 @@ handshake_found: - return SS_NO_UP_TO_DATE_DISK; - - /* Prevent detach or disconnect while held open read only */ -- if (device->open_ro_cnt && any_disk_up_to_date[OLD] && !any_disk_up_to_date[NEW]) -+ if (!device->writable && device->open_cnt && -+ any_disk_up_to_date[OLD] && !any_disk_up_to_date[NEW]) - return SS_NO_UP_TO_DATE_DISK; - - if (disk_state[NEW] == D_NEGOTIATING) --- -2.35.3 - diff --git a/0018-gen_patch_names-reorder-blk_mode_t.patch b/0018-gen_patch_names-reorder-blk_mode_t.patch new file mode 100644 index 0000000..e735fe5 --- /dev/null +++ b/0018-gen_patch_names-reorder-blk_mode_t.patch @@ -0,0 +1,57 @@ +From b340c96d60065f08397d14360e7f045005c587e8 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= + +Date: Fri, 23 Aug 2024 12:30:45 +0200 +Subject: [PATCH 18/32] gen_patch_names: reorder blk_mode_t + +And match against bdev_file_open_by_path. +--- + drbd/drbd-kernel-compat/cocci/blk_mode_t__no_present.cocci | 7 +------ + drbd/drbd-kernel-compat/gen_patch_names.c | 6 +++--- + 2 files changed, 4 insertions(+), 9 deletions(-) + +diff --git a/drbd/drbd-kernel-compat/cocci/blk_mode_t__no_present.cocci b/drbd/drbd-kernel-compat/cocci/blk_mode_t__no_present.cocci +index d1312a093ffe..cde4430478e5 100644 +--- a/drbd/drbd-kernel-compat/cocci/blk_mode_t__no_present.cocci ++++ b/drbd/drbd-kernel-compat/cocci/blk_mode_t__no_present.cocci +@@ -22,12 +22,7 @@ identifier mode; + @@ + // special case: bdev_open_by_path takes a blk_mode_t, so convert that too. I can't seem to get + // coccinelle to match the "READ | WRITE" condition generically, so just hard code it. +-// NOTE: we use blkdev_get_by_path instead of bdev_open_by_path in some compat cases, so support that too. +-( +-bdev_open_by_path +-| +-blkdev_get_by_path +-) ++bdev_file_open_by_path + (..., + - BLK_OPEN_READ | BLK_OPEN_WRITE + + FMODE_READ | FMODE_WRITE +diff --git a/drbd/drbd-kernel-compat/gen_patch_names.c b/drbd/drbd-kernel-compat/gen_patch_names.c +index 13aec5c8bd5f..6f62ea5827b7 100644 +--- a/drbd/drbd-kernel-compat/gen_patch_names.c ++++ b/drbd/drbd-kernel-compat/gen_patch_names.c +@@ -568,6 +568,9 @@ int main(int argc, char **argv) + patch(1, "__bio_add_page", true, false, + COMPAT_HAVE___BIO_ADD_PAGE, "present"); + ++ patch(1, "blk_mode_t", true, false, ++ COMPAT_HAVE_BLK_MODE_T, "present"); ++ + /* blkdev_put is oldest, then bdev_open_by_path, then bdev_file_open_by_path */ + patch(1, "bdev_file_open_by_path", true, false, + COMPAT_HAVE_BDEV_FILE_OPEN_BY_PATH, "present"); +@@ -590,9 +593,6 @@ int main(int argc, char **argv) + patch(1, "block_device_operations_release", true, false, + COMPAT_BLOCK_DEVICE_OPERATIONS_RELEASE_TAKES_SINGLE_ARGUMENT, "takes_single_argument"); + +- patch(1, "blk_mode_t", true, false, +- COMPAT_HAVE_BLK_MODE_T, "present"); +- + patch(1, "genl_info_userhdr", true, false, + COMPAT_HAVE_GENL_INFO_USERHDR, "present"); + +-- +2.35.3 + diff --git a/0019-compat-block-remove-the-unused-mode-argument-to-rele.patch b/0019-compat-block-remove-the-unused-mode-argument-to-rele.patch deleted file mode 100644 index 9f40f7c..0000000 --- a/0019-compat-block-remove-the-unused-mode-argument-to-rele.patch +++ /dev/null @@ -1,107 +0,0 @@ -From bf287c15359c4495a706ca270e7dcab4c2d6ebcc Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Moritz=20=22WanzenBug=22=20Wanzenb=C3=B6ck?= - -Date: Tue, 12 Sep 2023 15:27:01 +0200 -Subject: [PATCH 19/20] compat: block: remove the unused mode argument to - ->release - -See also upstream Linux kernel commit -ae220766d87c ("block: remove the unused mode argument to ->release") - -Original message: - -The mode argument to the ->release block_device_operation is never used, -so remove it. ---- - ...ions_release__no_takes_single_argument.cocci | 17 +++++++++++++++++ - drbd/drbd-kernel-compat/gen_patch_names.c | 3 +++ - ...e_operations_release_takes_single_argument.c | 7 +++++++ - drbd/drbd_main.c | 6 +++--- - 4 files changed, 30 insertions(+), 3 deletions(-) - create mode 100644 drbd/drbd-kernel-compat/cocci/block_device_operations_release__no_takes_single_argument.cocci - create mode 100644 drbd/drbd-kernel-compat/tests/block_device_operations_release_takes_single_argument.c - -diff --git a/drbd/drbd-kernel-compat/cocci/block_device_operations_release__no_takes_single_argument.cocci b/drbd/drbd-kernel-compat/cocci/block_device_operations_release__no_takes_single_argument.cocci -new file mode 100644 -index 000000000000..b0a0ee9eef39 ---- /dev/null -+++ b/drbd/drbd-kernel-compat/cocci/block_device_operations_release__no_takes_single_argument.cocci -@@ -0,0 +1,17 @@ -+@@ -+identifier gd; -+fresh identifier mode = "" ## "mode"; -+@@ -+ drbd_release( -+ struct gendisk *gd -++ , fmode_t mode -+ ) { ... } -+ -+@@ -+symbol drbd_release; -+expression gd; -+@@ -+ drbd_release( -+ gd -++ , 0 -+ ) -diff --git a/drbd/drbd-kernel-compat/gen_patch_names.c b/drbd/drbd-kernel-compat/gen_patch_names.c -index 4761c1ef7d0c..608be8b4f099 100644 ---- a/drbd/drbd-kernel-compat/gen_patch_names.c -+++ b/drbd/drbd-kernel-compat/gen_patch_names.c -@@ -565,6 +565,9 @@ int main(int argc, char **argv) - patch(1, "blkdev_put", true, false, - COMPAT_BLKDEV_PUT_HAS_HOLDER, "has_holder"); - -+ patch(1, "block_device_operations_release", true, false, -+ COMPAT_BLOCK_DEVICE_OPERATIONS_RELEASE_TAKES_SINGLE_ARGUMENT, "takes_single_argument"); -+ - /* #define BLKDEV_ISSUE_ZEROOUT_EXPORTED */ - /* #define BLKDEV_ZERO_NOUNMAP */ - -diff --git a/drbd/drbd-kernel-compat/tests/block_device_operations_release_takes_single_argument.c b/drbd/drbd-kernel-compat/tests/block_device_operations_release_takes_single_argument.c -new file mode 100644 -index 000000000000..d51c863e359a ---- /dev/null -+++ b/drbd/drbd-kernel-compat/tests/block_device_operations_release_takes_single_argument.c -@@ -0,0 +1,7 @@ -+/* { "version": "v6.5-rc1", "commit": "ae220766d87cd6799dbf918fea10613ae14c0654", "comment": "block: remove the unused mode argument to ->release", "author": "Christoph Hellwig ", "date": "Thu Jun 8 13:02:37 2023 +0200" } */ -+#include -+ -+void foo(struct block_device_operations *ops, struct gendisk *gd) -+{ -+ ops->release(gd); -+} -diff --git a/drbd/drbd_main.c b/drbd/drbd_main.c -index bb05b2215dfb..1864861db21d 100644 ---- a/drbd/drbd_main.c -+++ b/drbd/drbd_main.c -@@ -53,7 +53,7 @@ - #include "drbd_dax_pmem.h" - - static int drbd_open(struct gendisk *gd, fmode_t mode); --static void drbd_release(struct gendisk *gd, fmode_t mode); -+static void drbd_release(struct gendisk *gd); - static void md_sync_timer_fn(struct timer_list *t); - static int w_bitmap_io(struct drbd_work *w, int unused); - static int flush_send_buffer(struct drbd_connection *connection, enum drbd_stream drbd_stream); -@@ -2740,7 +2740,7 @@ out: - - mutex_unlock(&resource->open_release); - if (err) { -- drbd_release(gd, mode); -+ drbd_release(gd); - if (err == -EAGAIN && !(mode & FMODE_NDELAY)) - err = -EMEDIUMTYPE; - } -@@ -2822,7 +2822,7 @@ void drbd_fsync_device(struct drbd_device *device) - drbd_flush_peer_acks(resource); - } - --static void drbd_release(struct gendisk *gd, fmode_t mode) -+static void drbd_release(struct gendisk *gd) - { - struct drbd_device *device = gd->private_data; - struct drbd_resource *resource = device->resource; --- -2.35.3 - diff --git a/0019-compat-fix-blk_queue_update_readahead-patch.patch b/0019-compat-fix-blk_queue_update_readahead-patch.patch new file mode 100644 index 0000000..4facc42 --- /dev/null +++ b/0019-compat-fix-blk_queue_update_readahead-patch.patch @@ -0,0 +1,38 @@ +From 37edd6c75cccba9b151e8b834c83832ae0382484 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= + +Date: Thu, 29 Aug 2024 13:27:31 +0200 +Subject: [PATCH 19/32] compat: fix blk_queue_update_readahead patch + +Did not match anymore +--- + .../cocci/blk_queue_update_readahead__no_present.cocci | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/drbd/drbd-kernel-compat/cocci/blk_queue_update_readahead__no_present.cocci b/drbd/drbd-kernel-compat/cocci/blk_queue_update_readahead__no_present.cocci +index ed62a3426ad6..2e78f626261d 100644 +--- a/drbd/drbd-kernel-compat/cocci/blk_queue_update_readahead__no_present.cocci ++++ b/drbd/drbd-kernel-compat/cocci/blk_queue_update_readahead__no_present.cocci +@@ -1,8 +1,10 @@ + @@ +-expression e; +-struct request_queue *q, b; ++identifier q, b; + @@ +-blk_stack_limits(e, &b->limits, 0); ++struct request_queue *q; ++... ++struct request_queue *b; ++<... + - blk_queue_update_readahead(q); + + if (q->backing_dev_info->ra_pages != + + b->backing_dev_info->ra_pages) { +@@ -12,3 +14,4 @@ blk_stack_limits(e, &b->limits, 0); + + q->backing_dev_info->ra_pages = + + b->backing_dev_info->ra_pages; + + } ++...> +\ No newline at end of file +-- +2.35.3 + diff --git a/0020-compat-test-and-patch-for-que_limits-max_hw_discard_.patch b/0020-compat-test-and-patch-for-que_limits-max_hw_discard_.patch new file mode 100644 index 0000000..e6237b4 --- /dev/null +++ b/0020-compat-test-and-patch-for-que_limits-max_hw_discard_.patch @@ -0,0 +1,57 @@ +From f2a779276e7b0918c8592da8254a044c291f1778 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= + +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 ", "date": "Tue Feb 13 08:34:16 2024 +0100" } */ ++ ++#include ++ ++int foo(struct queue_limits *lim) ++{ ++ return lim->max_hw_discard_sectors; ++} +-- +2.35.3 + diff --git a/0020-drbd-do-not-allow-auto-demote-to-be-interrupted-by-s.patch b/0020-drbd-do-not-allow-auto-demote-to-be-interrupted-by-s.patch deleted file mode 100644 index f95b989..0000000 --- a/0020-drbd-do-not-allow-auto-demote-to-be-interrupted-by-s.patch +++ /dev/null @@ -1,66 +0,0 @@ -From c8e2a3c4355b4794267cd6e58a074802b4607cb9 Mon Sep 17 00:00:00 2001 -From: Joel Colledge -Date: Fri, 22 Sep 2023 16:57:24 +0200 -Subject: [PATCH 20/20] drbd: do not allow auto-demote to be interrupted by - signal - -Pending signals can mess up auto-demote: - -drbd res: Preparing cluster-wide state change 671410162 (0->-1 3/2) -drbd res: Aborting cluster-wide state change 671410162 (6ms) rv = -21 -drbd res: Auto-demote failed: Interrupted state change - -After this state change failure no process has the DRBD device open, but -DRBD remains Primary. ---- - drbd/drbd_main.c | 33 +++++++++++++++++++++++---------- - 1 file changed, 23 insertions(+), 10 deletions(-) - -diff --git a/drbd/drbd_main.c b/drbd/drbd_main.c -index 1864861db21d..0719229f210e 100644 ---- a/drbd/drbd_main.c -+++ b/drbd/drbd_main.c -@@ -2851,17 +2851,30 @@ static void drbd_release(struct gendisk *gd) - !test_and_set_bit(DESTROYING_DEV, &device->flags)) - call_rcu(&device->rcu, drbd_reclaim_device); - -- if (resource->res_opts.auto_promote) { -- enum drbd_state_rv rv; -+ if (resource->res_opts.auto_promote && -+ open_rw_cnt == 0 && -+ resource->role[NOW] == R_PRIMARY && -+ !test_bit(EXPLICIT_PRIMARY, &resource->flags)) { -+ sigset_t mask, oldmask; -+ int rv; -+ -+ /* -+ * Auto-demote is triggered by the last opener releasing the -+ * DRBD device. However, it is an implicit action, so it should -+ * not be affected by the state of the process. In particular, -+ * it should ignore any pending signals. It may be the case -+ * that the process is releasing DRBD because it is being -+ * terminated using a signal. -+ */ -+ sigfillset(&mask); -+ sigprocmask(SIG_BLOCK, &mask, &oldmask); - -- if (was_writable && open_rw_cnt == 0 && -- resource->role[NOW] == R_PRIMARY && -- !test_bit(EXPLICIT_PRIMARY, &resource->flags)) { -- rv = drbd_set_role(resource, R_SECONDARY, false, "auto-demote", NULL); -- if (rv < SS_SUCCESS) -- drbd_warn(resource, "Auto-demote failed: %s (%d)\n", -- drbd_set_st_err_str(rv), rv); -- } -+ rv = drbd_set_role(resource, R_SECONDARY, false, "auto-demote", NULL); -+ if (rv < SS_SUCCESS) -+ drbd_warn(resource, "Auto-demote failed: %s (%d)\n", -+ drbd_set_st_err_str(rv), rv); -+ -+ sigprocmask(SIG_SETMASK, &oldmask, NULL); - } - - if (open_ro_cnt == 0 && open_rw_cnt == 0 && resource->fail_io[NOW]) { --- -2.35.3 - diff --git a/0021-compat-fixup-write_zeroes__no_capable.patch b/0021-compat-fixup-write_zeroes__no_capable.patch new file mode 100644 index 0000000..0d0a4f9 --- /dev/null +++ b/0021-compat-fixup-write_zeroes__no_capable.patch @@ -0,0 +1,26 @@ +From 4578726d3b0e5b7c699659c1ecd26194060e7be7 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= + +Date: Thu, 29 Aug 2024 16:15:47 +0200 +Subject: [PATCH 21/32] compat: fixup write_zeroes__no_capable + +We now access the field directly instead of using this helper +--- + drbd/drbd-kernel-compat/cocci/write_zeroes__no_capable.cocci | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drbd/drbd-kernel-compat/cocci/write_zeroes__no_capable.cocci b/drbd/drbd-kernel-compat/cocci/write_zeroes__no_capable.cocci +index 4fa6d9e249d7..2b060e2abd16 100644 +--- a/drbd/drbd-kernel-compat/cocci/write_zeroes__no_capable.cocci ++++ b/drbd/drbd-kernel-compat/cocci/write_zeroes__no_capable.cocci +@@ -30,5 +30,6 @@ expression e; + +WARN_ON_ONCE(e); /* WRITE_ZEROES not supported on this kernel */ + + @@ ++struct queue_limits lim; + @@ +-- blk_queue_max_write_zeroes_sectors(...); ++- lim.max_write_zeroes_sectors = ...; +-- +2.35.3 + diff --git a/0021-compat-sock-Remove-sendpage-in-favour-of-sendmsg-MSG.patch b/0021-compat-sock-Remove-sendpage-in-favour-of-sendmsg-MSG.patch deleted file mode 100644 index 33b16e8..0000000 --- a/0021-compat-sock-Remove-sendpage-in-favour-of-sendmsg-MSG.patch +++ /dev/null @@ -1,107 +0,0 @@ -From a000a5577210929ca808fe19719186cb7e917f44 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Moritz=20WanzenBug=20Wanzenb=C3=B6ck?= - -Date: Wed, 13 Sep 2023 13:30:57 +0200 -Subject: [PATCH] compat: sock: Remove ->sendpage*() in favour of - sendmsg(MSG_SPLICE_PAGES) - -See also upstream Linux kernel commits -dc97391e6610 ("sock: Remove ->sendpage*() in favour of sendmsg(MSG_SPLICE_PAGES)") -eeac7405c735 ("drbd: Use sendmsg(MSG_SPLICE_PAGES) rather than sendpage()") -4b9c2edaf728 ("drbd: swap bvec_set_page len and offset") - -Original message: - -Remove ->sendpage() and ->sendpage_locked(). sendmsg() with -MSG_SPLICE_PAGES should be used instead. This allows multiple pages and -multipage folios to be passed through. ---- - .../cocci/msg_splice_pages__no_present.cocci | 16 ++++++++++++++++ - drbd/drbd-kernel-compat/gen_patch_names.c | 3 +++ - .../tests/have_msg_splice_pages.c | 7 +++++++ - drbd/drbd_transport_tcp.c | 8 ++++++-- - 4 files changed, 32 insertions(+), 2 deletions(-) - create mode 100644 drbd/drbd-kernel-compat/cocci/msg_splice_pages__no_present.cocci - create mode 100644 drbd/drbd-kernel-compat/tests/have_msg_splice_pages.c - -diff --git a/drbd/drbd-kernel-compat/cocci/msg_splice_pages__no_present.cocci b/drbd/drbd-kernel-compat/cocci/msg_splice_pages__no_present.cocci -new file mode 100644 -index 000000000000..0fdf77e43737 ---- /dev/null -+++ b/drbd/drbd-kernel-compat/cocci/msg_splice_pages__no_present.cocci -@@ -0,0 +1,16 @@ -+@@ -+expression flags; -+@@ -+ flags -+- | MSG_SPLICE_PAGES -+ -+@@ -+identifier bvec, page, len, offset, msg, socket; -+@@ -+- struct bio_vec bvec; -+ ... -+ int sent; -+- bvec_set_page(&bvec, page, len, offset); -+- iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, len); -+- sent = sock_sendmsg(socket, &msg); -++ sent = socket->ops->sendpage(socket, page, offset, len, msg.msg_flags); -diff --git a/drbd/drbd-kernel-compat/gen_patch_names.c b/drbd/drbd-kernel-compat/gen_patch_names.c -index 608be8b4f099..6a96c5b89f11 100644 ---- a/drbd/drbd-kernel-compat/gen_patch_names.c -+++ b/drbd/drbd-kernel-compat/gen_patch_names.c -@@ -127,6 +127,9 @@ int main(int argc, char **argv) - patch(1, "bvec_kmap_local", true, false, - COMPAT_HAVE_BVEC_KMAP_LOCAL, "present"); - -+ patch(1, "msg_splice_pages", true, false, -+ COMPAT_HAVE_MSG_SPLICE_PAGES, "present"); -+ - patch(1, "struct_bvec_iter", true, false, - COMPAT_HAVE_STRUCT_BVEC_ITER, "present"); - -diff --git a/drbd/drbd-kernel-compat/tests/have_msg_splice_pages.c b/drbd/drbd-kernel-compat/tests/have_msg_splice_pages.c -new file mode 100644 -index 000000000000..0bb23ef6d39a ---- /dev/null -+++ b/drbd/drbd-kernel-compat/tests/have_msg_splice_pages.c -@@ -0,0 +1,7 @@ -+/* { "version": "v6.5-rc1", "commit": "dc97391e661009eab46783030d2404c9b6e6f2e7", "comment": "sock: Remove ->sendpage*() in favour of sendmsg(MSG_SPLICE_PAGES)", "author": "David Howells ", "date": "Fri Jun 23 23:55:12 2023 +0100" } */ -+#include -+ -+int foo(void) -+{ -+ return MSG_SPLICE_PAGES; -+} -diff --git a/drbd/drbd_transport_tcp.c b/drbd/drbd_transport_tcp.c -index ca60833f73d7..5dcba50dd0eb 100644 ---- a/drbd/drbd_transport_tcp.c -+++ b/drbd/drbd_transport_tcp.c -@@ -1193,18 +1193,22 @@ static int dtt_send_page(struct drbd_transport *transport, enum drbd_stream stre - struct drbd_tcp_transport *tcp_transport = - container_of(transport, struct drbd_tcp_transport, transport); - struct socket *socket = tcp_transport->stream[stream]; -+ struct msghdr msg = { .msg_flags = msg_flags | MSG_NOSIGNAL | MSG_SPLICE_PAGES }; -+ struct bio_vec bvec; - int len = size; - int err = -EIO; - - if (!socket) - return -ENOTCONN; - -- msg_flags |= MSG_NOSIGNAL; - dtt_update_congested(tcp_transport); - do { - int sent; - -- sent = socket->ops->sendpage(socket, page, offset, len, msg_flags); -+ bvec_set_page(&bvec, page, len, offset); -+ iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, len); -+ -+ sent = sock_sendmsg(socket, &msg); - if (sent <= 0) { - if (sent == -EAGAIN) { - if (drbd_stream_send_timed_out(transport, stream)) --- -2.42.1 - diff --git a/0022-compat-block-replace-fmode_t-with-a-block-specific-t.patch b/0022-compat-block-replace-fmode_t-with-a-block-specific-t.patch deleted file mode 100644 index 82ef213..0000000 --- a/0022-compat-block-replace-fmode_t-with-a-block-specific-t.patch +++ /dev/null @@ -1,183 +0,0 @@ -From 2d3c3fd6546174a0452c9bbd64d4f4193c0c39e2 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Moritz=20WanzenBug=20Wanzenb=C3=B6ck?= - -Date: Wed, 13 Sep 2023 11:26:35 +0200 -Subject: [PATCH] compat: block: replace fmode_t with a block-specific type for - block open flags - -See also upstream Linux kernel commit -05bdb9965305 ("block: replace fmode_t with a block-specific type for block open flags" - -Original message: - -The only overlap between the block open flags mapped into the fmode_t and -other uses of fmode_t are FMODE_READ and FMODE_WRITE. Define a new -blk_mode_t instead for use in blkdev_get_by_{dev,path}, ->open and -->ioctl and stop abusing fmode_t. ---- - .../cocci/blk_mode_t__no_present.cocci | 19 ++++++++++++++ - drbd/drbd-kernel-compat/gen_patch_names.c | 3 +++ - .../tests/have_blk_mode_t.c | 4 +++ - drbd/drbd_main.c | 26 +++++++++---------- - 4 files changed, 39 insertions(+), 13 deletions(-) - create mode 100644 drbd/drbd-kernel-compat/cocci/blk_mode_t__no_present.cocci - create mode 100644 drbd/drbd-kernel-compat/tests/have_blk_mode_t.c - -diff --git a/drbd/drbd-kernel-compat/cocci/blk_mode_t__no_present.cocci b/drbd/drbd-kernel-compat/cocci/blk_mode_t__no_present.cocci -new file mode 100644 -index 000000000000..030723c817de ---- /dev/null -+++ b/drbd/drbd-kernel-compat/cocci/blk_mode_t__no_present.cocci -@@ -0,0 +1,19 @@ -+@@ -+identifier fn; -+identifier mode; -+@@ -+ fn ( -+ ..., -+- blk_mode_t mode -++ fmode_t mode -+ ) { -+ <... -+( -+- BLK_OPEN_WRITE -++ FMODE_WRITE -+| -+- BLK_OPEN_NDELAY -++ FMODE_NDELAY -+) -+ ...> -+ } -diff --git a/drbd/drbd-kernel-compat/gen_patch_names.c b/drbd/drbd-kernel-compat/gen_patch_names.c -index 6a96c5b89f11..e4a65a3c451e 100644 ---- a/drbd/drbd-kernel-compat/gen_patch_names.c -+++ b/drbd/drbd-kernel-compat/gen_patch_names.c -@@ -571,6 +571,9 @@ int main(int argc, char **argv) - patch(1, "block_device_operations_release", true, false, - COMPAT_BLOCK_DEVICE_OPERATIONS_RELEASE_TAKES_SINGLE_ARGUMENT, "takes_single_argument"); - -+ patch(1, "blk_mode_t", true, false, -+ COMPAT_HAVE_BLK_MODE_T, "present"); -+ - /* #define BLKDEV_ISSUE_ZEROOUT_EXPORTED */ - /* #define BLKDEV_ZERO_NOUNMAP */ - -diff --git a/drbd/drbd-kernel-compat/tests/have_blk_mode_t.c b/drbd/drbd-kernel-compat/tests/have_blk_mode_t.c -new file mode 100644 -index 000000000000..e063bdc30f43 ---- /dev/null -+++ b/drbd/drbd-kernel-compat/tests/have_blk_mode_t.c -@@ -0,0 +1,4 @@ -+/* { "version": "v6.5-rc1", "commit": "05bdb9965305bbfdae79b31d22df03d1e2cfcb22", "comment": "block: replace fmode_t with a block-specific type for block open flags", "author": "Christoph Hellwig ", "date": "Thu Jun 8 13:02:55 2023 +0200" } */ -+#include -+ -+void foo(blk_mode_t mode) {} -diff --git a/drbd/drbd_main.c b/drbd/drbd_main.c -index 0719229f210e..f9560bdff63f 100644 ---- a/drbd/drbd_main.c -+++ b/drbd/drbd_main.c -@@ -52,7 +52,7 @@ - #include "drbd_meta_data.h" - #include "drbd_dax_pmem.h" - --static int drbd_open(struct gendisk *gd, fmode_t mode); -+static int drbd_open(struct gendisk *gd, blk_mode_t mode); - static void drbd_release(struct gendisk *gd); - static void md_sync_timer_fn(struct timer_list *t); - static int w_bitmap_io(struct drbd_work *w, int unused); -@@ -2566,10 +2566,10 @@ enum ioc_rv { - IOC_ABORT = 2, - }; - --static enum ioc_rv inc_open_count(struct drbd_device *device, fmode_t mode) -+static enum ioc_rv inc_open_count(struct drbd_device *device, blk_mode_t mode) - { - struct drbd_resource *resource = device->resource; -- enum ioc_rv r = mode & FMODE_NDELAY ? IOC_ABORT : IOC_SLEEP; -+ enum ioc_rv r = mode & BLK_OPEN_NDELAY ? IOC_ABORT : IOC_SLEEP; - - if (test_bit(DOWN_IN_PROGRESS, &resource->flags)) - return IOC_ABORT; -@@ -2580,7 +2580,7 @@ static enum ioc_rv inc_open_count(struct drbd_device *device, fmode_t mode) - else if (!resource->remote_state_change) { - r = IOC_OK; - device->open_cnt++; -- if (mode & FMODE_WRITE) -+ if (mode & BLK_OPEN_WRITE) - device->writable = true; - } - read_unlock_irq(&resource->state_rwlock); -@@ -2646,7 +2646,7 @@ out: - spin_unlock(&device->openers_lock); - } - --static int drbd_open(struct gendisk *gd, fmode_t mode) -+static int drbd_open(struct gendisk *gd, blk_mode_t mode) - { - struct drbd_device *device = gd->private_data; - struct drbd_resource *resource = device->resource; -@@ -2655,7 +2655,7 @@ static int drbd_open(struct gendisk *gd, fmode_t mode) - int err = 0; - - /* Fail read-only open from systemd-udev (version <= 238) */ -- if (!(mode & FMODE_WRITE) && !drbd_allow_oos) { -+ if (!(mode & BLK_OPEN_WRITE) && !drbd_allow_oos) { - char comm[TASK_COMM_LEN]; - get_task_comm(comm, current); - if (!strcmp("systemd-udevd", comm)) -@@ -2664,7 +2664,7 @@ static int drbd_open(struct gendisk *gd, fmode_t mode) - - /* Fail read-write open early, - * in case someone explicitly set us read-only (blockdev --setro) */ -- if (bdev_read_only(gd->part0) && (mode & FMODE_WRITE)) -+ if (bdev_read_only(gd->part0) && (mode & BLK_OPEN_WRITE)) - return -EACCES; - - if (resource->fail_io[NOW]) -@@ -2693,14 +2693,14 @@ static int drbd_open(struct gendisk *gd, fmode_t mode) - This avoids split brain when the drbd volume gets opened - temporarily by udev while it scans for PV signatures. */ - -- if (mode & FMODE_WRITE) { -+ if (mode & BLK_OPEN_WRITE) { - if (resource->role[NOW] == R_SECONDARY) { -- rv = try_to_promote(device, timeout, (mode & FMODE_NDELAY)); -+ rv = try_to_promote(device, timeout, (mode & BLK_OPEN_NDELAY)); - if (rv < SS_SUCCESS) - drbd_info(resource, "Auto-promote failed: %s (%d)\n", - drbd_set_st_err_str(rv), rv); - } -- } else if ((mode & FMODE_NDELAY) == 0) { -+ } else if ((mode & BLK_OPEN_NDELAY) == 0) { - /* Double check peers - * - * Some services may try to first open ro, and only if that -@@ -2720,14 +2720,14 @@ static int drbd_open(struct gendisk *gd, fmode_t mode) - } - } - } else if (resource->role[NOW] != R_PRIMARY && -- !(mode & FMODE_WRITE) && !drbd_allow_oos) { -+ !(mode & BLK_OPEN_WRITE) && !drbd_allow_oos) { - err = -EMEDIUMTYPE; - goto out; - } - - if (test_bit(UNREGISTERED, &device->flags)) { - err = -ENODEV; -- } else if (mode & FMODE_WRITE) { -+ } else if (mode & BLK_OPEN_WRITE) { - if (resource->role[NOW] != R_PRIMARY) - err = -EROFS; - } else /* READ access only */ { -@@ -2741,7 +2741,7 @@ out: - mutex_unlock(&resource->open_release); - if (err) { - drbd_release(gd); -- if (err == -EAGAIN && !(mode & FMODE_NDELAY)) -+ if (err == -EAGAIN && !(mode & BLK_OPEN_NDELAY)) - err = -EMEDIUMTYPE; - } - --- -2.42.1 - diff --git a/0022-compat-fixup-queue_flag_discard__yes_present.patch b/0022-compat-fixup-queue_flag_discard__yes_present.patch new file mode 100644 index 0000000..4ff3367 --- /dev/null +++ b/0022-compat-fixup-queue_flag_discard__yes_present.patch @@ -0,0 +1,77 @@ +From ce06250eb289e98bf97940104c92751282704783 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= + +Date: Wed, 4 Sep 2024 19:05:06 +0200 +Subject: [PATCH 22/32] compat: fixup queue_flag_discard__yes_present + +blk_queue_discard_granularity does not exist anymore, just use the field +in queue_limits. +Match directly do drbd_reconsider_queue_parameters instead of trying to +guess the right function. +--- + .../queue_flag_discard__yes_present.cocci | 30 ++++++------------- + 1 file changed, 9 insertions(+), 21 deletions(-) + +diff --git a/drbd/drbd-kernel-compat/cocci/queue_flag_discard__yes_present.cocci b/drbd/drbd-kernel-compat/cocci/queue_flag_discard__yes_present.cocci +index cc28c3d02d82..e0ecc697b10a 100644 +--- a/drbd/drbd-kernel-compat/cocci/queue_flag_discard__yes_present.cocci ++++ b/drbd/drbd-kernel-compat/cocci/queue_flag_discard__yes_present.cocci +@@ -1,27 +1,19 @@ + @@ +-struct request_queue *q; +-@@ +-( +-q->limits.max_discard_sectors = 0; +-+ blk_queue_flag_clear(QUEUE_FLAG_DISCARD, q); +-| +-q->limits.max_discard_sectors = ...; +-+ blk_queue_flag_set(QUEUE_FLAG_DISCARD, q); +-) +- +-@@ +-struct request_queue *q; ++struct queue_limits lim; ++identifier q; + @@ ++struct request_queue *q = device->rq_queue; ++... + ( +-blk_queue_discard_granularity(q, 0); ++lim.max_hw_discard_sectors = 0; + + blk_queue_flag_clear(QUEUE_FLAG_DISCARD, q); + | +-blk_queue_discard_granularity(q, 512); ++lim.max_hw_discard_sectors = ...; + + blk_queue_flag_set(QUEUE_FLAG_DISCARD, q); + ) + + @@ +-identifier q, device, fn; ++identifier q, device; + @@ + +static void fixup_discard_if_not_supported(struct request_queue *q) + +{ +@@ -31,18 +23,14 @@ identifier q, device, fn; + + * */ + + if (!blk_queue_discard(q)) { + + blk_queue_max_discard_sectors(q, 0); +-+ blk_queue_discard_granularity(q, 0); +++ q->limits.discard_granularity = 0; + + } + +} + +-fn (struct drbd_device *device, ...) ++void drbd_reconsider_queue_parameters(struct drbd_device *device, ...) + { + ... + struct request_queue *q = device->rq_queue; + ... +-decide_on_discard_support(...); +-<+... +-blk_stack_limits(...); +-...+> + + fixup_discard_if_not_supported(q); + } +-- +2.35.3 + diff --git a/0023-compat-genetlink-remove-userhdr-from-struct-genl_inf.patch b/0023-compat-genetlink-remove-userhdr-from-struct-genl_inf.patch deleted file mode 100644 index 490b1e3..0000000 --- a/0023-compat-genetlink-remove-userhdr-from-struct-genl_inf.patch +++ /dev/null @@ -1,96 +0,0 @@ -From 1412792a443ddc696fd1c8981a6cc544272f54bf Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Moritz=20WanzenBug=20Wanzenb=C3=B6ck?= - -Date: Wed, 13 Sep 2023 15:46:12 +0200 -Subject: [PATCH] compat: genetlink: remove userhdr from struct genl_info - -See also upstream Linux kernel commit -bffcc6882a1b ("genetlink: remove userhdr from struct genl_info") - -Original message: - -Only three families use info->userhdr today and going forward -we discourage using fixed headers in new families. -So having the pointer to user header in struct genl_info -is an overkill. Compute the header pointer at runtime. ---- - .../cocci/genl_info_userhdr__no_present.cocci | 5 +++++ - drbd/drbd-kernel-compat/gen_patch_names.c | 3 +++ - drbd/drbd-kernel-compat/tests/have_genl_info_userhdr.c | 7 +++++++ - drbd/drbd_nl.c | 6 +++--- - 4 files changed, 18 insertions(+), 3 deletions(-) - create mode 100644 drbd/drbd-kernel-compat/cocci/genl_info_userhdr__no_present.cocci - create mode 100644 drbd/drbd-kernel-compat/tests/have_genl_info_userhdr.c - -diff --git a/drbd/drbd-kernel-compat/cocci/genl_info_userhdr__no_present.cocci b/drbd/drbd-kernel-compat/cocci/genl_info_userhdr__no_present.cocci -new file mode 100644 -index 000000000000..75e787797068 ---- /dev/null -+++ b/drbd/drbd-kernel-compat/cocci/genl_info_userhdr__no_present.cocci -@@ -0,0 +1,5 @@ -+@@ -+expression info; -+@@ -+- genl_info_userhdr(info) -++ info->userhdr -diff --git a/drbd/drbd-kernel-compat/gen_patch_names.c b/drbd/drbd-kernel-compat/gen_patch_names.c -index e4a65a3c451e..b136acf3148a 100644 ---- a/drbd/drbd-kernel-compat/gen_patch_names.c -+++ b/drbd/drbd-kernel-compat/gen_patch_names.c -@@ -574,6 +574,9 @@ int main(int argc, char **argv) - patch(1, "blk_mode_t", true, false, - COMPAT_HAVE_BLK_MODE_T, "present"); - -+ patch(1, "genl_info_userhdr", true, false, -+ COMPAT_HAVE_GENL_INFO_USERHDR, "present"); -+ - /* #define BLKDEV_ISSUE_ZEROOUT_EXPORTED */ - /* #define BLKDEV_ZERO_NOUNMAP */ - -diff --git a/drbd/drbd-kernel-compat/tests/have_genl_info_userhdr.c b/drbd/drbd-kernel-compat/tests/have_genl_info_userhdr.c -new file mode 100644 -index 000000000000..3c69dacce244 ---- /dev/null -+++ b/drbd/drbd-kernel-compat/tests/have_genl_info_userhdr.c -@@ -0,0 +1,7 @@ -+/* { "version": "v6.6-rc1", "commit": "bffcc6882a1bb2be8c9420184966f4c2c822078e", "comment": "genetlink: remove userhdr from struct genl_info", "author": "Jakub Kicinski ", "date": "Mon Aug 14 14:47:16 2023 -0700" } */ -+#include -+ -+void *foo(struct genl_info *info) -+{ -+ return genl_info_userhdr(info); -+} -diff --git a/drbd/drbd_nl.c b/drbd/drbd_nl.c -index 71ed4272614e..538c31202e4b 100644 ---- a/drbd/drbd_nl.c -+++ b/drbd/drbd_nl.c -@@ -203,7 +203,7 @@ static struct drbd_path *first_path(struct drbd_connection *connection) - static int drbd_adm_prepare(struct drbd_config_context *adm_ctx, - struct sk_buff *skb, struct genl_info *info, unsigned flags) - { -- struct drbd_genlmsghdr *d_in = info->userhdr; -+ struct drbd_genlmsghdr *d_in = genl_info_userhdr(info); - const u8 cmd = info->genlhdr->cmd; - int err; - -@@ -2106,7 +2106,7 @@ static void drbd_try_suspend_al(struct drbd_device *device) - - static bool should_set_defaults(struct genl_info *info) - { -- unsigned flags = ((struct drbd_genlmsghdr*)info->userhdr)->flags; -+ unsigned int flags = ((struct drbd_genlmsghdr *)genl_info_userhdr(info))->flags; - return 0 != (flags & DRBD_GENL_F_SET_DEFAULTS); - } - -@@ -6279,7 +6279,7 @@ out_no_unlock: - int drbd_adm_new_minor(struct sk_buff *skb, struct genl_info *info) - { - struct drbd_config_context adm_ctx; -- struct drbd_genlmsghdr *dh = info->userhdr; -+ struct drbd_genlmsghdr *dh = genl_info_userhdr(info); - struct device_conf device_conf; - struct drbd_resource *resource; - struct drbd_device *device; --- -2.42.1 - diff --git a/0023-drbd-move-flags-to-queue_limits.patch b/0023-drbd-move-flags-to-queue_limits.patch new file mode 100644 index 0000000..6226093 --- /dev/null +++ b/0023-drbd-move-flags-to-queue_limits.patch @@ -0,0 +1,53 @@ +From ac4e2f85066d2da306ec0e3fed8db4e945be6f6d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= + +Date: Thu, 5 Sep 2024 13:03:07 +0200 +Subject: [PATCH 23/32] drbd: move flags to queue_limits + +Roughly equivalent to the following commits from upstream Linux: + +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 +--- + drbd/drbd_main.c | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +diff --git a/drbd/drbd_main.c b/drbd/drbd_main.c +index 2792b9896271..407b0a1d1773 100644 +--- a/drbd/drbd_main.c ++++ b/drbd/drbd_main.c +@@ -3886,6 +3886,11 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig + int vnr = adm_ctx->volume; + enum drbd_ret_code err = ERR_NOMEM; + bool locked = false; ++ struct queue_limits lim = { ++ .features = BLK_FEAT_WRITE_CACHE | BLK_FEAT_FUA | ++ BLK_FEAT_ROTATIONAL | ++ BLK_FEAT_STABLE_WRITES, ++ }; + + lockdep_assert_held(&resource->conf_update); + +@@ -3948,7 +3953,7 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig + + init_rwsem(&device->uuid_sem); + +- disk = blk_alloc_disk(NULL, NUMA_NO_NODE); ++ disk = blk_alloc_disk(&lim, NUMA_NO_NODE); + if (IS_ERR(disk)) { + err = PTR_ERR(disk); + goto out_no_disk; +@@ -3967,9 +3972,6 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig + sprintf(disk->disk_name, "drbd%d", minor); + disk->private_data = device; + +- blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, disk->queue); +- blk_queue_write_cache(disk->queue, true, true); +- + device->md_io.page = alloc_page(GFP_KERNEL); + if (!device->md_io.page) + goto out_no_io_page; +-- +2.35.3 + diff --git a/0024-compat-fixup-FMODE_READ-FMODE_WRITE-usage.patch b/0024-compat-fixup-FMODE_READ-FMODE_WRITE-usage.patch deleted file mode 100644 index 154ab5f..0000000 --- a/0024-compat-fixup-FMODE_READ-FMODE_WRITE-usage.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 5a09ad97f57eb276dc1e9a84e1c82f11ce1fe1b7 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= - -Date: Thu, 4 Apr 2024 15:53:31 +0200 -Subject: [PATCH 1/3] compat: fixup FMODE_READ/FMODE_WRITE usage - -Fixes: 4a84d1d0 ("compat: block: replace fmode_t with a block-specific type for block open flags") ---- - .../cocci/blk_mode_t__no_present.cocci | 15 +++++++++++++++ - drbd/drbd-kernel-compat/gen_patch_names.c | 6 +++--- - drbd/drbd_nl.c | 2 +- - 3 files changed, 19 insertions(+), 4 deletions(-) - -diff --git a/drbd/drbd-kernel-compat/cocci/blk_mode_t__no_present.cocci b/drbd/drbd-kernel-compat/cocci/blk_mode_t__no_present.cocci -index 030723c817de..d1312a093ffe 100644 ---- a/drbd/drbd-kernel-compat/cocci/blk_mode_t__no_present.cocci -+++ b/drbd/drbd-kernel-compat/cocci/blk_mode_t__no_present.cocci -@@ -17,3 +17,18 @@ identifier mode; - ) - ...> - } -+ -+@@ -+@@ -+// special case: bdev_open_by_path takes a blk_mode_t, so convert that too. I can't seem to get -+// coccinelle to match the "READ | WRITE" condition generically, so just hard code it. -+// NOTE: we use blkdev_get_by_path instead of bdev_open_by_path in some compat cases, so support that too. -+( -+bdev_open_by_path -+| -+blkdev_get_by_path -+) -+ (..., -+- BLK_OPEN_READ | BLK_OPEN_WRITE -++ FMODE_READ | FMODE_WRITE -+ , ...) -diff --git a/drbd/drbd-kernel-compat/gen_patch_names.c b/drbd/drbd-kernel-compat/gen_patch_names.c -index b136acf3148a..86a7ce7a93ed 100644 ---- a/drbd/drbd-kernel-compat/gen_patch_names.c -+++ b/drbd/drbd-kernel-compat/gen_patch_names.c -@@ -565,15 +565,15 @@ int main(int argc, char **argv) - patch(1, "block_device_operations_open", true, false, - COMPAT_BLOCK_DEVICE_OPERATIONS_OPEN_TAKES_GENDISK, "takes_gendisk"); - -- patch(1, "blkdev_put", true, false, -- COMPAT_BLKDEV_PUT_HAS_HOLDER, "has_holder"); -- - patch(1, "block_device_operations_release", true, false, - COMPAT_BLOCK_DEVICE_OPERATIONS_RELEASE_TAKES_SINGLE_ARGUMENT, "takes_single_argument"); - - patch(1, "blk_mode_t", true, false, - COMPAT_HAVE_BLK_MODE_T, "present"); - -+ patch(1, "blkdev_put", true, false, -+ COMPAT_BLKDEV_PUT_HAS_HOLDER, "has_holder"); -+ - patch(1, "genl_info_userhdr", true, false, - COMPAT_HAVE_GENL_INFO_USERHDR, "present"); - -diff --git a/drbd/drbd_nl.c b/drbd/drbd_nl.c -index d41ccfcd4bb2..a355f5d5feb1 100644 ---- a/drbd/drbd_nl.c -+++ b/drbd/drbd_nl.c -@@ -2566,7 +2566,7 @@ static struct block_device *open_backing_dev(struct drbd_device *device, - const char *bdev_path, void *claim_ptr) - { - struct block_device *bdev = blkdev_get_by_path(bdev_path, -- FMODE_READ | FMODE_WRITE, -+ BLK_OPEN_READ | BLK_OPEN_WRITE, - claim_ptr, NULL); - if (IS_ERR(bdev)) { - drbd_err(device, "open(\"%s\") failed with %ld\n", --- -2.44.0 - diff --git a/0024-compat-test-and-patch-for-queue_limits.features.patch b/0024-compat-test-and-patch-for-queue_limits.features.patch new file mode 100644 index 0000000..f21096a --- /dev/null +++ b/0024-compat-test-and-patch-for-queue_limits.features.patch @@ -0,0 +1,191 @@ +From 3c18af1a3e8d67833e3ea8a2d38408501c9ee6be Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= + +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 ", "date": "Mon Jun 17 08:04:40 2024 +0200" } */ ++ ++#include ++ ++unsigned int foo(struct queue_limits lim) ++{ ++ return lim.features; ++} +-- +2.35.3 + diff --git a/0025-compat-drdb-Convert-to-use-bdev_open_by_path.patch b/0025-compat-drdb-Convert-to-use-bdev_open_by_path.patch deleted file mode 100644 index 538cf41..0000000 --- a/0025-compat-drdb-Convert-to-use-bdev_open_by_path.patch +++ /dev/null @@ -1,379 +0,0 @@ -From 604f31ab14eeca9eddb42028de93bb89f3ae6515 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= - -Date: Thu, 4 Apr 2024 16:27:51 +0200 -Subject: [PATCH 2/3] compat: drdb: Convert to use bdev_open_by_path() - -Equivalent to upstream Linux commit 75e27d373425 -("drdb [sic]: Convert to use bdev_open_by_path()"), plus a compat patch. ---- - .../cocci/bdev_open_by_path__no_present.cocci | 173 ++++++++++++++++++ - drbd/drbd-kernel-compat/gen_patch_names.c | 3 + - .../tests/have_bdev_open_by_path.c | 8 + - drbd/drbd_int.h | 2 + - drbd/drbd_nl.c | 59 +++--- - 5 files changed, 216 insertions(+), 29 deletions(-) - create mode 100644 drbd/drbd-kernel-compat/cocci/bdev_open_by_path__no_present.cocci - create mode 100644 drbd/drbd-kernel-compat/tests/have_bdev_open_by_path.c - -diff --git a/drbd/drbd-kernel-compat/cocci/bdev_open_by_path__no_present.cocci b/drbd/drbd-kernel-compat/cocci/bdev_open_by_path__no_present.cocci -new file mode 100644 -index 000000000000..983f05080f79 ---- /dev/null -+++ b/drbd/drbd-kernel-compat/cocci/bdev_open_by_path__no_present.cocci -@@ -0,0 +1,173 @@ -+@@ -+@@ -+struct drbd_backing_dev { -+... -+- struct bdev_handle *backing_bdev_handle; -+... -+- struct bdev_handle *md_bdev_handle; -+... -+} -+ -+@@ -+identifier handle; -+@@ -+static void close_backing_dev(..., -+- struct bdev_handle *handle -++ struct block_device *bdev, void *holder -+ , ... -+ ) -+{ -+<... -+( -+- handle->bdev -++ bdev -+| -+- bdev_release(handle) -++ blkdev_put(bdev, holder) -+| -+- handle -++ bdev -+) -+...> -+} -+ -+@@ -+identifier device; -+struct bdev_handle *handle; -+identifier err; -+identifier new_disk_conf; -+@@ -+// special case: when linking the meta_dev, we want to pass meta_claim_ptr to close instead of device -+err = link_backing_dev(..., new_disk_conf->meta_dev, ...); -+if (err) { -+ ... -+ close_backing_dev(device, -+- handle -++ bdev, meta_claim_ptr -+ , ...); -+ ... -+} -+ -+@@ -+identifier ldev; -+struct bdev_handle *handle; -+identifier device; -+@@ -+// generic close_backing_dev usage -+close_backing_dev(device, -+( -+- ldev->backing_bdev_handle -++ ldev->backing_bdev, device -+| -+- ldev->md_bdev_handle -++ ldev->md_bdev, -++ ldev->md.meta_dev_idx < 0 ? (void *)device : (void *)drbd_m_holder -+| -+- handle -++ bdev, device -+) -+, ...); -+ -+@@ -+identifier handle; -+@@ -+- struct bdev_handle * -++ struct block_device * -+open_backing_dev(...) -+{ -+... -+- struct bdev_handle *handle = bdev_open_by_path( -++ struct block_device *bdev = blkdev_get_by_path( -+...); -+<... -+( -+IS_ERR -+| -+PTR_ERR -+) -+ ( -+- handle -++ bdev -+ ) -+...> -+return -+- handle -++ bdev -+; -+} -+ -+@@ -+identifier handle; -+identifier err; -+@@ -+static int link_backing_dev(..., -+- struct bdev_handle *handle -++ struct block_device *bdev -+ ) -+{ -+... -+int err = bd_link_disk_holder( -+- handle->bdev -++ bdev -+ , ...); -+if (err) { -+- bdev_release(handle); -+ ... -+} -+... -+} -+ -+@@ -+identifier device; -+expression bd; -+identifier handle; -+@@ -+// generic link_backing_dev usage -+link_backing_dev(device, bd, -+- handle -++ bdev -+ ) -+ -+@@ -+identifier handle; -+@@ -+// generic open_backing_dev usage -+{ -+... -+- struct bdev_handle *handle; -++ struct block_device *bdev; -+<... -+( -+- handle -++ bdev -+= open_backing_dev(...); -+| -+IS_ERR( -+- handle -++ bdev -+ ) -+) -+...> -+} -+ -+@@ -+struct drbd_backing_dev *nbc; -+identifier handle; -+@@ -+( -+- nbc->backing_bdev = handle->bdev; -+- nbc->backing_bdev_handle = handle; -++ nbc->backing_bdev = bdev; -+| -+- nbc->md_bdev = handle->bdev; -+- nbc->md_bdev_handle = handle; -++ nbc->md_bdev = bdev; -+) -+ -+@@ -+identifier handle; -+identifier nbc; -+@@ -+// only this one comparison exists in the code, just special-case it instead of implementing the generic case -+- handle != nbc->backing_bdev_handle -++ bdev != nbc->backing_bdev -diff --git a/drbd/drbd-kernel-compat/gen_patch_names.c b/drbd/drbd-kernel-compat/gen_patch_names.c -index 86a7ce7a93ed..d6fe75a80cf6 100644 ---- a/drbd/drbd-kernel-compat/gen_patch_names.c -+++ b/drbd/drbd-kernel-compat/gen_patch_names.c -@@ -559,6 +559,9 @@ int main(int argc, char **argv) - patch(1, "__bio_add_page", true, false, - COMPAT_HAVE___BIO_ADD_PAGE, "present"); - -+ patch(1, "bdev_open_by_path", true, false, -+ COMPAT_HAVE_BDEV_OPEN_BY_PATH, "present"); -+ - patch(1, "blkdev_get_by_path", true, false, - COMPAT_BLKDEV_GET_BY_PATH_HAS_HOLDER_OPS, "has_holder_ops"); - -diff --git a/drbd/drbd-kernel-compat/tests/have_bdev_open_by_path.c b/drbd/drbd-kernel-compat/tests/have_bdev_open_by_path.c -new file mode 100644 -index 000000000000..92266de0b15b ---- /dev/null -+++ b/drbd/drbd-kernel-compat/tests/have_bdev_open_by_path.c -@@ -0,0 +1,8 @@ -+/* { "version": "v6.7", "commit": "e719b4d156749f02eafed31a3c515f2aa9dcc72a", "comment": "introduce bdev_open_by_* functions", "author": "Jan Kara ", "date": "Wed Sep 27 11:34:07 2023 +0200" } */ -+ -+#include -+ -+struct bdev_handle *foo(const char *path, blk_mode_t mode, void *holder, -+ const struct blk_holder_ops *hops) { -+ return bdev_open_by_path(path, mode, holder, hops); -+} -diff --git a/drbd/drbd_int.h b/drbd/drbd_int.h -index cf593c09cda1..a41b228cb13b 100644 ---- a/drbd/drbd_int.h -+++ b/drbd/drbd_int.h -@@ -700,7 +700,9 @@ struct drbd_md { - - struct drbd_backing_dev { - struct block_device *backing_bdev; -+ struct bdev_handle *backing_bdev_handle; - struct block_device *md_bdev; -+ struct bdev_handle *md_bdev_handle; - struct drbd_md md; - struct disk_conf __rcu *disk_conf; /* RCU, for updates: resource->conf_update */ - sector_t known_size; /* last known size of that backing device */ -diff --git a/drbd/drbd_nl.c b/drbd/drbd_nl.c -index a355f5d5feb1..6a48287e251e 100644 ---- a/drbd/drbd_nl.c -+++ b/drbd/drbd_nl.c -@@ -94,7 +94,7 @@ atomic_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */ - - DEFINE_MUTEX(notification_mutex); - --/* used blkdev_get_by_path, to claim our meta data device(s) */ -+/* used bdev_open_by_path, to claim our meta data device(s) */ - static char *drbd_m_holder = "Hands off! this is DRBD's meta data device."; - - static void drbd_adm_send_reply(struct sk_buff *skb, struct genl_info *info) -@@ -2535,14 +2535,14 @@ bool want_bitmap(struct drbd_peer_device *peer_device) - return want_bitmap; - } - --static void close_backing_dev(struct drbd_device *device, struct block_device *bdev, -- void *holder, bool do_bd_unlink) -+static void close_backing_dev(struct drbd_device *device, -+ struct bdev_handle *handle, bool do_bd_unlink) - { -- if (!bdev) -+ if (!handle) - return; - if (do_bd_unlink) -- bd_unlink_disk_holder(bdev, device->vdisk); -- blkdev_put(bdev, holder); -+ bd_unlink_disk_holder(handle->bdev, device->vdisk); -+ bdev_release(handle); - } - - void drbd_backing_dev_free(struct drbd_device *device, struct drbd_backing_dev *ldev) -@@ -2553,33 +2553,33 @@ void drbd_backing_dev_free(struct drbd_device *device, struct drbd_backing_dev * - drbd_dax_close(ldev); - - close_backing_dev(device, -- ldev->md_bdev, -- ldev->md.meta_dev_idx < 0 ? (void *)device : (void *)drbd_m_holder, -+ ldev->md_bdev_handle, - ldev->md_bdev != ldev->backing_bdev); -- close_backing_dev(device, ldev->backing_bdev, device, true); -+ close_backing_dev(device, ldev->backing_bdev_handle, true); - - kfree(ldev->disk_conf); - kfree(ldev); - } - --static struct block_device *open_backing_dev(struct drbd_device *device, -+static struct bdev_handle *open_backing_dev(struct drbd_device *device, - const char *bdev_path, void *claim_ptr) - { -- struct block_device *bdev = blkdev_get_by_path(bdev_path, -+ struct bdev_handle *handle = bdev_open_by_path(bdev_path, - BLK_OPEN_READ | BLK_OPEN_WRITE, - claim_ptr, NULL); -- if (IS_ERR(bdev)) { -+ if (IS_ERR(handle)) { - drbd_err(device, "open(\"%s\") failed with %ld\n", -- bdev_path, PTR_ERR(bdev)); -+ bdev_path, PTR_ERR(handle)); - } -- return bdev; -+ return handle; - } - - static int link_backing_dev(struct drbd_device *device, -- const char *bdev_path, struct block_device *bdev) -+ const char *bdev_path, struct bdev_handle *handle) - { -- int err = bd_link_disk_holder(bdev, device->vdisk); -+ int err = bd_link_disk_holder(handle->bdev, device->vdisk); - if (err) { -+ bdev_release(handle); - drbd_err(device, "bd_link_disk_holder(\"%s\", ...) failed with %d\n", - bdev_path, err); - } -@@ -2590,22 +2590,22 @@ static int open_backing_devices(struct drbd_device *device, - struct disk_conf *new_disk_conf, - struct drbd_backing_dev *nbc) - { -- struct block_device *bdev; -+ struct bdev_handle *handle; - void *meta_claim_ptr; - int err; - -- bdev = open_backing_dev(device, new_disk_conf->backing_dev, device); -- if (IS_ERR(bdev)) -+ handle = open_backing_dev(device, new_disk_conf->backing_dev, device); -+ if (IS_ERR(handle)) - return ERR_OPEN_DISK; - -- err = link_backing_dev(device, new_disk_conf->backing_dev, bdev); -+ err = link_backing_dev(device, new_disk_conf->backing_dev, handle); - if (err) { - /* close without unlinking; otherwise error path will try to unlink */ -- close_backing_dev(device, bdev, device, false); -+ close_backing_dev(device, handle, false); - return ERR_OPEN_DISK; - } -- -- nbc->backing_bdev = bdev; -+ nbc->backing_bdev = handle->bdev; -+ nbc->backing_bdev_handle = handle; - - /* meta_claim_ptr: device, if claimed exclusively; shared drbd_m_holder, - * if potentially shared with other drbd minors -@@ -2620,22 +2620,23 @@ static int open_backing_devices(struct drbd_device *device, - * should check it for you already; but if you don't, or - * someone fooled it, we need to double check here) - */ -- bdev = open_backing_dev(device, new_disk_conf->meta_dev, meta_claim_ptr); -- if (IS_ERR(bdev)) -+ handle = open_backing_dev(device, new_disk_conf->meta_dev, meta_claim_ptr); -+ if (IS_ERR(handle)) - return ERR_OPEN_MD_DISK; - - /* avoid double bd_claim_by_disk() for the same (source,target) tuple, - * as would happen with internal metadata. */ -- if (bdev != nbc->backing_bdev) { -- err = link_backing_dev(device, new_disk_conf->meta_dev, bdev); -+ if (handle != nbc->backing_bdev_handle) { -+ err = link_backing_dev(device, new_disk_conf->meta_dev, handle); - if (err) { - /* close without unlinking; otherwise error path will try to unlink */ -- close_backing_dev(device, bdev, meta_claim_ptr, false); -+ close_backing_dev(device, handle, false); - return ERR_OPEN_MD_DISK; - } - } - -- nbc->md_bdev = bdev; -+ nbc->md_bdev = handle->bdev; -+ nbc->md_bdev_handle = handle; - return NO_ERROR; - } - --- -2.44.0 - diff --git a/0025-drbd-Annotate-struct-fifo_buffer-with-__counted_by.patch b/0025-drbd-Annotate-struct-fifo_buffer-with-__counted_by.patch new file mode 100644 index 0000000..be79746 --- /dev/null +++ b/0025-drbd-Annotate-struct-fifo_buffer-with-__counted_by.patch @@ -0,0 +1,47 @@ +From 85afbf893a6c7cd55e04407731e52d495b6f228f Mon Sep 17 00:00:00 2001 +From: Kees Cook +Date: Fri, 15 Sep 2023 13:03:16 -0700 +Subject: [PATCH 25/32] drbd: Annotate struct fifo_buffer with __counted_by +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Prepare for the coming implementation by GCC and Clang of the __counted_by +attribute. Flexible array members annotated with __counted_by can have +their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS +(for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family +functions). + +As found with Coccinelle[1], add __counted_by for struct fifo_buffer. + +[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci + +Cc: Philipp Reisner +Cc: Lars Ellenberg +Cc: Christoph Böhmwalder +Cc: Jens Axboe +Cc: drbd-dev@lists.linbit.com +Cc: linux-block@vger.kernel.org +Reviewed-by: "Gustavo A. R. Silva" +Link: https://lore.kernel.org/r/20230915200316.never.707-kees@kernel.org +Signed-off-by: Kees Cook +--- + drbd/drbd_int.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drbd/drbd_int.h b/drbd/drbd_int.h +index c18407899f59..182593257c6a 100644 +--- a/drbd/drbd_int.h ++++ b/drbd/drbd_int.h +@@ -746,7 +746,7 @@ struct fifo_buffer { + unsigned int head_index; + unsigned int size; + int total; /* sum of all values */ +- int values[]; ++ int values[] __counted_by(size); + }; + extern struct fifo_buffer *fifo_alloc(unsigned int fifo_size); + +-- +2.35.3 + diff --git a/0026-compat-gate-blkdev_-patches-behind-bdev_open_by_path.patch b/0026-compat-gate-blkdev_-patches-behind-bdev_open_by_path.patch deleted file mode 100644 index 007e365..0000000 --- a/0026-compat-gate-blkdev_-patches-behind-bdev_open_by_path.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 6088f29b44fed60d1e631383a9b6f280ff42aaa6 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= - -Date: Thu, 11 Apr 2024 11:59:38 +0200 -Subject: [PATCH 3/3] compat: gate blkdev_* patches behind bdev_open_by_path - -If we have bdev_open_by_path, there is no need to consider these patches -since they only apply to the (older) blkdev_{get_put}_* functions. ---- - drbd/drbd-kernel-compat/gen_patch_names.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/drbd/drbd-kernel-compat/gen_patch_names.c b/drbd/drbd-kernel-compat/gen_patch_names.c -index d6fe75a80cf6..8355e723f82c 100644 ---- a/drbd/drbd-kernel-compat/gen_patch_names.c -+++ b/drbd/drbd-kernel-compat/gen_patch_names.c -@@ -562,8 +562,10 @@ int main(int argc, char **argv) - patch(1, "bdev_open_by_path", true, false, - COMPAT_HAVE_BDEV_OPEN_BY_PATH, "present"); - -+#if !defined(COMPAT_HAVE_BDEV_OPEN_BY_PATH) - patch(1, "blkdev_get_by_path", true, false, - COMPAT_BLKDEV_GET_BY_PATH_HAS_HOLDER_OPS, "has_holder_ops"); -+#endif - - patch(1, "block_device_operations_open", true, false, - COMPAT_BLOCK_DEVICE_OPERATIONS_OPEN_TAKES_GENDISK, "takes_gendisk"); -@@ -574,8 +576,10 @@ int main(int argc, char **argv) - patch(1, "blk_mode_t", true, false, - COMPAT_HAVE_BLK_MODE_T, "present"); - -+#if !defined(COMPAT_HAVE_BDEV_OPEN_BY_PATH) - patch(1, "blkdev_put", true, false, - COMPAT_BLKDEV_PUT_HAS_HOLDER, "has_holder"); -+#endif - - patch(1, "genl_info_userhdr", true, false, - COMPAT_HAVE_GENL_INFO_USERHDR, "present"); --- -2.44.0 - diff --git a/0026-compat-test-and-patch-for-__counted_by.patch b/0026-compat-test-and-patch-for-__counted_by.patch new file mode 100644 index 0000000..797e68c --- /dev/null +++ b/0026-compat-test-and-patch-for-__counted_by.patch @@ -0,0 +1,94 @@ +From 3a1d6d3e2bd0e1506995e316b183cef8abc0034b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= + +Date: Fri, 6 Sep 2024 11:14:43 +0200 +Subject: [PATCH 26/32] compat: test and patch for __counted_by + +Unfortunately, the "attribute name" variable type only works with very +recent coccinelle versions (>=1.1.1). So add a hint about that in the +README. +--- + README.md | 9 ++++----- + .../cocci/counted_by__no_present.cocci | 12 ++++++++++++ + drbd/drbd-kernel-compat/gen_patch_names.c | 3 +++ + drbd/drbd-kernel-compat/tests/have_counted_by.c | 8 ++++++++ + 4 files changed, 27 insertions(+), 5 deletions(-) + create mode 100644 drbd/drbd-kernel-compat/cocci/counted_by__no_present.cocci + create mode 100644 drbd/drbd-kernel-compat/tests/have_counted_by.c + +diff --git a/README.md b/README.md +index ec513d19438e..b63286db0113 100644 +--- a/README.md ++++ b/README.md +@@ -38,7 +38,7 @@ Since version 9.0.20, DRBD has been using a kernel backwards compatibility syste + based on [Coccinelle](https://github.com/coccinelle/coccinelle) semantic patches. + While this has many advantages, it also makes it a little harder for "casual" + developers to build DRBD from the git sources. The problem is that we require a +-very recent version of `spatch` (at least 1.0.8 at time of writing), and most ++very recent version of `spatch` (at least 1.1.1 at time of writing), and most + distributions only have relatively old versions in their repositories. + + ## From git +@@ -48,10 +48,9 @@ For users wishing to build DRBD from its git sources, here are a few options: + chances are you won't even have to use any of the compat features, which + means you won't require compatibility patches and in turn don't need spatch + installed. +-2. On Ubuntu 18.04 and newer, use a recent spatch version from the +- [Coccinelle PPA](https://launchpad.net/~npalix/+archive/ubuntu/coccinelle). +- This provides (at time of writing) version 1.0.8, which is recent enough to +- build DRBD. ++2. Fedora >=39 packages Coccinelle 1.1.1, which is recent enough to build DRBD. **Warning**: while ++ Ubuntu also ships Coccinelle with supposedly the same version number (1.1.1), this version ++ is *not* able to build DRBD. + 3. Build and install spatch from source. This will also give you a version that + is recent enough to build DRBD. + +diff --git a/drbd/drbd-kernel-compat/cocci/counted_by__no_present.cocci b/drbd/drbd-kernel-compat/cocci/counted_by__no_present.cocci +new file mode 100644 +index 000000000000..40db31bece0c +--- /dev/null ++++ b/drbd/drbd-kernel-compat/cocci/counted_by__no_present.cocci +@@ -0,0 +1,12 @@ ++@@ ++type T; ++identifier s, x; ++attribute name __counted_by; ++@@ ++struct s { ++... ++ T x ++- __counted_by(...) ++ ; ++... ++}; +diff --git a/drbd/drbd-kernel-compat/gen_patch_names.c b/drbd/drbd-kernel-compat/gen_patch_names.c +index cc3bad2d84e4..72c1e25512ea 100644 +--- a/drbd/drbd-kernel-compat/gen_patch_names.c ++++ b/drbd/drbd-kernel-compat/gen_patch_names.c +@@ -605,6 +605,9 @@ int main(int argc, char **argv) + patch(1, "need_recalc_sigpending", false, true, + COMPAT_NEED_RECALC_SIGPENDING, "need"); + ++ patch(1, "counted_by", true, false, ++ COMPAT_HAVE_COUNTED_BY, "present"); ++ + /* #define BLKDEV_ISSUE_ZEROOUT_EXPORTED */ + /* #define BLKDEV_ZERO_NOUNMAP */ + +diff --git a/drbd/drbd-kernel-compat/tests/have_counted_by.c b/drbd/drbd-kernel-compat/tests/have_counted_by.c +new file mode 100644 +index 000000000000..07fac32aad16 +--- /dev/null ++++ b/drbd/drbd-kernel-compat/tests/have_counted_by.c +@@ -0,0 +1,8 @@ ++/* { "version": "v6.4", "commit": "dd06e72e68bcb4070ef211be100d2896e236c8fb", "comment": "add __counted_by macro", "author": "Kees Cook ", "date": "Wed May 17 12:08:44 2023 -0700" } */ ++ ++#include ++ ++struct foo { ++ int a; ++ int b[] __counted_by(a); ++}; +-- +2.35.3 + diff --git a/0027-drbd-fix-function-cast-warnings-in-state-machine.patch b/0027-drbd-fix-function-cast-warnings-in-state-machine.patch new file mode 100644 index 0000000..36a9c2f --- /dev/null +++ b/0027-drbd-fix-function-cast-warnings-in-state-machine.patch @@ -0,0 +1,100 @@ +From fa5329fb2c7e089cbe712acecb2c75ba8887754e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= + +Date: Fri, 6 Sep 2024 15:16:49 +0200 +Subject: [PATCH 27/32] drbd: fix function cast warnings in state machine + +Equivalent to upstream commit fe0b1e9a ("drbd: fix function cast +warnings in state machine"). +--- + drbd/drbd_state.c | 16 ++++++++++------ + drbd/drbd_state_change.h | 8 ++++---- + 2 files changed, 14 insertions(+), 10 deletions(-) + +diff --git a/drbd/drbd_state.c b/drbd/drbd_state.c +index 44f55ee5c939..100e32ba037f 100644 +--- a/drbd/drbd_state.c ++++ b/drbd/drbd_state.c +@@ -3212,10 +3212,11 @@ static union drbd_state state_change_word(struct drbd_state_change *state_change + + int notify_resource_state_change(struct sk_buff *skb, + unsigned int seq, +- struct drbd_state_change *state_change, ++ void *state_change, + enum drbd_notification_type type) + { +- struct drbd_resource_state_change *resource_state_change = state_change->resource; ++ struct drbd_resource_state_change *resource_state_change = ++ ((struct drbd_state_change *)state_change)->resource; + struct drbd_resource *resource = resource_state_change->resource; + struct resource_info resource_info = { + .res_role = resource_state_change->role[NEW], +@@ -3232,9 +3233,10 @@ int notify_resource_state_change(struct sk_buff *skb, + + int notify_connection_state_change(struct sk_buff *skb, + unsigned int seq, +- struct drbd_connection_state_change *connection_state_change, ++ void *state_change, + enum drbd_notification_type type) + { ++ struct drbd_connection_state_change *connection_state_change = state_change; + struct drbd_connection *connection = connection_state_change->connection; + struct connection_info connection_info = { + .conn_connection_state = connection_state_change->cstate[NEW], +@@ -3246,9 +3248,10 @@ int notify_connection_state_change(struct sk_buff *skb, + + int notify_device_state_change(struct sk_buff *skb, + unsigned int seq, +- struct drbd_device_state_change *device_state_change, ++ void *state_change, + enum drbd_notification_type type) + { ++ struct drbd_device_state_change *device_state_change = state_change; + struct drbd_device *device = device_state_change->device; + struct device_info device_info; + device_state_change_to_info(&device_info, device_state_change); +@@ -3258,10 +3261,11 @@ int notify_device_state_change(struct sk_buff *skb, + + int notify_peer_device_state_change(struct sk_buff *skb, + unsigned int seq, +- struct drbd_peer_device_state_change *state_change, ++ void *state_change, + enum drbd_notification_type type) + { +- struct drbd_peer_device *peer_device = state_change->peer_device; ++ struct drbd_peer_device_state_change *peer_device_state_change = state_change; ++ struct drbd_peer_device *peer_device = peer_device_state_change->peer_device; + struct peer_device_info peer_device_info; + peer_device_state_change_to_info(&peer_device_info, state_change); + +diff --git a/drbd/drbd_state_change.h b/drbd/drbd_state_change.h +index 3dc8616dedd4..40687d40b222 100644 +--- a/drbd/drbd_state_change.h ++++ b/drbd/drbd_state_change.h +@@ -69,19 +69,19 @@ extern void forget_state_change(struct drbd_state_change *); + + extern int notify_resource_state_change(struct sk_buff *, + unsigned int, +- struct drbd_state_change *, ++ void *, + enum drbd_notification_type type); + extern int notify_connection_state_change(struct sk_buff *, + unsigned int, +- struct drbd_connection_state_change *, ++ void *, + enum drbd_notification_type type); + extern int notify_device_state_change(struct sk_buff *, + unsigned int, +- struct drbd_device_state_change *, ++ void *, + enum drbd_notification_type type); + extern int notify_peer_device_state_change(struct sk_buff *, + unsigned int, +- struct drbd_peer_device_state_change *, ++ void *, + enum drbd_notification_type type); + + #endif /* DRBD_STATE_CHANGE_H */ +-- +2.35.3 + diff --git a/0028-Add-missing-documentation-of-peer_device-parameter-t.patch b/0028-Add-missing-documentation-of-peer_device-parameter-t.patch new file mode 100644 index 0000000..33b5c5f --- /dev/null +++ b/0028-Add-missing-documentation-of-peer_device-parameter-t.patch @@ -0,0 +1,61 @@ +From 11e96ecc0575eb0d6d4e29caaffb70d1e299908d Mon Sep 17 00:00:00 2001 +From: Simon Horman +Date: Tue, 23 Jul 2024 10:41:52 +0100 +Subject: [PATCH 28/32] Add missing documentation of peer_device parameter to + Kernel doc. +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +These parameters were added in commit 8164dd6c8ae1 ("drbd: Add peer +device parameter to whole-bitmap I/O handlers") + +Flagged by W=1 builds. + +Signed-off-by: Simon Horman +Link: https://lore.kernel.org/r/20240723-drbd-doc-v1-1-a04d9b7a9688@kernel.org +Signed-off-by: Jens Axboe +Signed-off-by: Christoph Böhmwalder +--- + drbd/drbd_main.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/drbd/drbd_main.c b/drbd/drbd_main.c +index 407b0a1d1773..a216b725e66c 100644 +--- a/drbd/drbd_main.c ++++ b/drbd/drbd_main.c +@@ -5356,6 +5356,7 @@ int drbd_bmio_set_all_n_write(struct drbd_device *device, + /** + * drbd_bmio_set_n_write() - io_fn for drbd_queue_bitmap_io() or drbd_bitmap_io() + * @device: DRBD device. ++ * @peer_device: Peer DRBD device. + * + * Sets all bits in the bitmap towards one peer and writes the whole bitmap to stable storage. + */ +@@ -5408,6 +5409,7 @@ int drbd_bmio_set_allocated_n_write(struct drbd_device *device, + /** + * drbd_bmio_clear_all_n_write() - io_fn for drbd_queue_bitmap_io() or drbd_bitmap_io() + * @device: DRBD device. ++ * @peer_device: Peer DRBD device. + * + * Clears all bits in the bitmap and writes the whole bitmap to stable storage. + */ +@@ -5474,6 +5476,7 @@ void drbd_queue_pending_bitmap_work(struct drbd_device *device) + * @io_fn: IO callback to be called when bitmap IO is possible + * @done: callback to be called after the bitmap IO was performed + * @why: Descriptive text of the reason for doing the IO ++ * @peer_device: Peer DRBD device. + * + * While IO on the bitmap happens we freeze application IO thus we ensure + * that drbd_set_out_of_sync() can not be called. This function MAY ONLY be +@@ -5549,6 +5552,7 @@ void drbd_queue_bitmap_io(struct drbd_device *device, + * @device: DRBD device. + * @io_fn: IO callback to be called when bitmap IO is possible + * @why: Descriptive text of the reason for doing the IO ++ * @peer_device: Peer DRBD device. + * + * freezes application IO while that the actual IO operations runs. This + * functions MAY NOT be called from sender context. +-- +2.35.3 + diff --git a/0030-drbd-kref_put-path-when-kernel_accept-fails.patch b/0030-drbd-kref_put-path-when-kernel_accept-fails.patch new file mode 100644 index 0000000..58c2be7 --- /dev/null +++ b/0030-drbd-kref_put-path-when-kernel_accept-fails.patch @@ -0,0 +1,42 @@ +From 9fe2be655a793d2f9425b96e53a7e1e7feec067e Mon Sep 17 00:00:00 2001 +From: Joel Colledge +Date: Wed, 18 Sep 2024 15:08:55 +0200 +Subject: [PATCH 30/32] drbd: kref_put() path when kernel_accept() fails + +We need to put the reference that dtt_wait_connect_cond() gets. + +This is an unusual situation. The function dtt_wait_connect_cond() only +returns a path when pending_accepts is positive or there is a socket in +the path->sockets list. So if the code reaches the kernel_accept() call, +we expect it to succeed. However, it has been observed to fail, so we +need to handle that case cleanly. + +Without the kref_put(), it is impossible to rmmod drbd. + +For any error other than -EAGAIN, the error is be passed up and is +logged by conn_connect(). However, when -EAGAIN is returned, +dtt_connect() continues trying to connect and the error from +kernel_accept() leaves no traces in the logs. +--- + drbd/drbd_transport_tcp.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/drbd/drbd_transport_tcp.c b/drbd/drbd_transport_tcp.c +index df144fcb4522..d59f68d83c58 100644 +--- a/drbd/drbd_transport_tcp.c ++++ b/drbd/drbd_transport_tcp.c +@@ -625,8 +625,10 @@ retry: + + s_estab = NULL; + err = kernel_accept(listener->s_listen, &s_estab, O_NONBLOCK); +- if (err < 0) ++ if (err < 0) { ++ kref_put(&path->path.kref, drbd_destroy_path); + return err; ++ } + + /* The established socket inherits the sk_state_change callback + from the listening socket. */ +-- +2.35.3 + diff --git a/0031-build-fix-typo-in-Makefile.spatch.patch b/0031-build-fix-typo-in-Makefile.spatch.patch new file mode 100644 index 0000000..52436dd --- /dev/null +++ b/0031-build-fix-typo-in-Makefile.spatch.patch @@ -0,0 +1,29 @@ +From 903779df9a65ac04814afb1530423914bdfe305c Mon Sep 17 00:00:00 2001 +From: Lars Ellenberg +Date: Sun, 6 Oct 2024 01:14:19 +0200 +Subject: [PATCH 31/32] build: fix typo in Makefile.spatch + +The variable name should be cached_compat_h, compat_h does not exist. +Noticed when built with `make -j`: +Because of the empty prerequisites, sometimes make would try to build +kernelrelease.txt before the directory was created. +--- + drbd/Makefile.spatch | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drbd/Makefile.spatch b/drbd/Makefile.spatch +index bbcf10dc0603..a5cc774c18b5 100644 +--- a/drbd/Makefile.spatch ++++ b/drbd/Makefile.spatch +@@ -42,7 +42,7 @@ cached_compat_patch := $(cache_dir)/compat.patch + + # Remember which kernel releases this supposedly works for. + # If KERNELRELEASE is not known, will add an empty line (at most once). +-$(cache_dir)/kernelrelease.txt: $(compat_h) FORCE ++$(cache_dir)/kernelrelease.txt: $(cached_compat_h) FORCE + $(Q)set -e; \ + grep -sqxFe "$(KERNELRELEASE)" $@ < /dev/null || \ + echo $(KERNELRELEASE) >> $@; +-- +2.35.3 + diff --git a/0032-drbd-open-do-not-delay-open-if-already-Primary.patch b/0032-drbd-open-do-not-delay-open-if-already-Primary.patch new file mode 100644 index 0000000..90900e9 --- /dev/null +++ b/0032-drbd-open-do-not-delay-open-if-already-Primary.patch @@ -0,0 +1,90 @@ +From 13ada1be201eb14ff8295a17194de8db5cdccd7f Mon Sep 17 00:00:00 2001 +From: Lars Ellenberg +Date: Wed, 2 Oct 2024 14:34:02 +0200 +Subject: [PATCH 32/32] drbd: open: do not delay open() if already Primary + +Since 48376549f (drbd: When a remote state change is active to not touch the open_counts, 2017-10-30) +if a remote state change is pending when someone tries to open() a DRBD volume, +we wait, interruptible, for "auto-promote-timeout", +until that state change is finalized (committed or aborted), +or give up with EAGAIN if the auto-promote timeout is reached. + +auto-promote-timeout by default is much smaller than twopc-timeout, +so we may get spurious open() failures. + +This could be mitigated with auto-promote-timeout > twopc-timeout. + +But we can just ignore the pending state change, +if changing the open_cnt won't make a difference: +if we are already Primary, or we already have openers anyways. + +If +- we have some remote state change pending, +- and we are not Primary already, +- and we do not have any openers, or this is an open with write intent, +we reject NDELAY openers immediately. +Normal openers wait for the state change to be finalized +(or give up after auto-promote-timeout). + +We do not need to wait if: +- there is no remote state change pending, +- or we are already Primary anyways, +- or we are Secondary, this is a read-only open, and we have openers already. + +Note: we may still want to immediately reject NDELAY open if +there is a remote state change pending, even if we have an +open count != 0. These are typically short lived openers +triggered via udev. If they overlap (new open comes in +before previous close), these may still accumulate enough +time to mess with state changes. +For now, I decide to allow them. +--- + drbd/drbd_main.c | 22 ++++++++++++++++++++-- + 1 file changed, 20 insertions(+), 2 deletions(-) + +diff --git a/drbd/drbd_main.c b/drbd/drbd_main.c +index a216b725e66c..258be3b9c10d 100644 +--- a/drbd/drbd_main.c ++++ b/drbd/drbd_main.c +@@ -2583,10 +2583,21 @@ enum ioc_rv { + IOC_ABORT = 2, + }; + ++/* If we are in the middle of a cluster wide state change, we don't want ++ * to change (open_cnt == 0), as that then could cause a failure to commit ++ * some already promised peer auto-promote locally. ++ * So we wait until the pending remote_state_change is finalized, ++ * or give up when the timeout is reached. ++ * ++ * But we don't want to fail an open on a Primary just because it happens ++ * during some unrelated remote state change. ++ * If we are already Primary, or already have an open count != 0, ++ * we don't need to wait, it won't change anything. ++ */ + static enum ioc_rv inc_open_count(struct drbd_device *device, blk_mode_t mode) + { + struct drbd_resource *resource = device->resource; +- enum ioc_rv r = mode & BLK_OPEN_NDELAY ? IOC_ABORT : IOC_SLEEP; ++ enum ioc_rv r; + + if (test_bit(DOWN_IN_PROGRESS, &resource->flags)) + return IOC_ABORT; +@@ -2594,7 +2605,14 @@ static enum ioc_rv inc_open_count(struct drbd_device *device, blk_mode_t mode) + read_lock_irq(&resource->state_rwlock); + if (test_bit(UNREGISTERED, &device->flags)) + r = IOC_ABORT; +- else if (!resource->remote_state_change) { ++ else if (resource->remote_state_change && ++ resource->role[NOW] != R_PRIMARY && ++ (device->open_cnt == 0 || mode & BLK_OPEN_WRITE)) { ++ if (mode & BLK_OPEN_NDELAY) ++ r = IOC_ABORT; ++ else ++ r = IOC_SLEEP; ++ } else { + r = IOC_OK; + device->open_cnt++; + if (mode & BLK_OPEN_WRITE) +-- +2.35.3 + diff --git a/boo1229062-re-enable-blk_queue_max_hw_sectors.patch b/boo1229062-re-enable-blk_queue_max_hw_sectors.patch deleted file mode 100644 index 37cbd36..0000000 --- a/boo1229062-re-enable-blk_queue_max_hw_sectors.patch +++ /dev/null @@ -1,59 +0,0 @@ -diff -Nupr a/drbd/drbd_nl.c b/drbd/drbd_nl.c ---- a/drbd/drbd_nl.c 2024-08-12 15:03:18.458476462 +0800 -+++ b/drbd/drbd_nl.c 2024-08-12 15:05:08.415670056 +0800 -@@ -2017,6 +2017,55 @@ static void fixup_discard_support(struct - } - } - -+/** -+ * blk_queue_max_hw_sectors - set max sectors for a request for this queue -+ * @q: the request queue for the device -+ * @max_hw_sectors: max hardware sectors in the usual 512b unit -+ * -+ * Description: -+ * Enables a low level driver to set a hard upper limit, -+ * max_hw_sectors, on the size of requests. max_hw_sectors is set by -+ * the device driver based upon the capabilities of the I/O -+ * controller. -+ * -+ * max_dev_sectors is a hard limit imposed by the storage device for -+ * READ/WRITE requests. It is set by the disk driver. -+ * -+ * max_sectors is a soft limit imposed by the block layer for -+ * filesystem type requests. This value can be overridden on a -+ * per-device basis in /sys/block//queue/max_sectors_kb. -+ * The soft limit can not exceed max_hw_sectors. -+ **/ -+static void blk_queue_max_hw_sectors(struct request_queue *q, unsigned int max_hw_sectors) -+{ -+ struct queue_limits *limits = &q->limits; -+ unsigned int max_sectors; -+ -+ if ((max_hw_sectors << 9) < PAGE_SIZE) { -+ max_hw_sectors = 1 << (PAGE_SHIFT - 9); -+ pr_info("%s: set to minimum %u\n", __func__, max_hw_sectors); -+ } -+ -+ max_hw_sectors = round_down(max_hw_sectors, -+ limits->logical_block_size >> SECTOR_SHIFT); -+ limits->max_hw_sectors = max_hw_sectors; -+ -+ max_sectors = min_not_zero(max_hw_sectors, limits->max_dev_sectors); -+ -+ if (limits->max_user_sectors) -+ max_sectors = min(max_sectors, limits->max_user_sectors); -+ else -+ max_sectors = min(max_sectors, BLK_DEF_MAX_SECTORS_CAP); -+ -+ max_sectors = round_down(max_sectors, -+ limits->logical_block_size >> SECTOR_SHIFT); -+ limits->max_sectors = max_sectors; -+ -+ if (!q->disk) -+ return; -+ q->disk->bdi->io_pages = max_sectors >> (PAGE_SHIFT - 9); -+} -+ - void drbd_reconsider_queue_parameters(struct drbd_device *device, struct drbd_backing_dev *bdev) - { - struct request_queue * const q = device->rq_queue; diff --git a/boo1230635_02-drbd-port-block-device-access-to-file.patch b/boo1230635_02-drbd-port-block-device-access-to-file.patch deleted file mode 100644 index d801f85..0000000 --- a/boo1230635_02-drbd-port-block-device-access-to-file.patch +++ /dev/null @@ -1,180 +0,0 @@ -From cfa95bfaefdc2c4e91806fdeb810901015a42a36 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= - -Date: Thu, 27 Jun 2024 11:19:33 +0200 -Subject: [PATCH] drbd: port block device access to file - -Equivalent to upstream kernel commit 20e6a8d0dcdc -("drbd: port block device access to file"). - - ---- -by heming.zhao@suse.com - -change this patch (ignore commit cdd3b8aa03f1a) -from: -``` - /* avoid double bd_claim_by_disk() for the same (source,target) tuple, - * as would happen with internal metadata. */ -- if (handle->bdev != nbc->backing_bdev) { -- err = link_backing_dev(device, new_disk_conf->meta_dev, handle); -``` -to: -``` - /* avoid double bd_claim_by_disk() for the same (source,target) tuple, - * as would happen with internal metadata. */ -- if (handle != nbc->backing_bdev_handle) { -- err = link_backing_dev(device, new_disk_conf->meta_dev, handle); -``` - ---- - drbd/drbd_int.h | 4 ++-- - drbd/drbd_nl.c | 56 ++++++++++++++++++++++++------------------------- - 2 files changed, 30 insertions(+), 30 deletions(-) - -diff --git a/drbd/drbd_int.h b/drbd/drbd_int.h -index ae7b45b2f8df..0ebd79091af6 100644 ---- a/drbd/drbd_int.h -+++ b/drbd/drbd_int.h -@@ -704,9 +704,9 @@ struct drbd_md { - - struct drbd_backing_dev { - struct block_device *backing_bdev; -- struct bdev_handle *backing_bdev_handle; -+ struct file *backing_bdev_file; - struct block_device *md_bdev; -- struct bdev_handle *md_bdev_handle; -+ struct file *f_md_bdev; - struct drbd_md md; - struct disk_conf __rcu *disk_conf; /* RCU, for updates: resource->conf_update */ - sector_t known_size; /* last known size of that backing device */ -diff --git a/drbd/drbd_nl.c b/drbd/drbd_nl.c -index 298db40b22ea..b732fa6f9d60 100644 ---- a/drbd/drbd_nl.c -+++ b/drbd/drbd_nl.c -@@ -2710,13 +2710,13 @@ bool want_bitmap(struct drbd_peer_device *peer_device) - } - - static void close_backing_dev(struct drbd_device *device, -- struct bdev_handle *handle, bool do_bd_unlink) -+ struct file *bdev_file, bool do_bd_unlink) - { -- if (!handle) -+ if (!bdev_file) - return; - if (do_bd_unlink) -- bd_unlink_disk_holder(handle->bdev, device->vdisk); -- bdev_release(handle); -+ bd_unlink_disk_holder(file_bdev(bdev_file), device->vdisk); -+ fput(bdev_file); - } - - void drbd_backing_dev_free(struct drbd_device *device, struct drbd_backing_dev *ldev) -@@ -2727,33 +2727,33 @@ void drbd_backing_dev_free(struct drbd_device *device, struct drbd_backing_dev * - drbd_dax_close(ldev); - - close_backing_dev(device, -- ldev->md_bdev_handle, -+ ldev->f_md_bdev, - ldev->md_bdev != ldev->backing_bdev); -- close_backing_dev(device, ldev->backing_bdev_handle, true); -+ close_backing_dev(device, ldev->backing_bdev_file, true); - - kfree(ldev->disk_conf); - kfree(ldev); - } - --static struct bdev_handle *open_backing_dev(struct drbd_device *device, -+static struct file *open_backing_dev(struct drbd_device *device, - const char *bdev_path, void *claim_ptr) - { -- struct bdev_handle *handle = bdev_open_by_path(bdev_path, -+ struct file *file = bdev_file_open_by_path(bdev_path, - BLK_OPEN_READ | BLK_OPEN_WRITE, - claim_ptr, NULL); -- if (IS_ERR(handle)) { -+ if (IS_ERR(file)) { - drbd_err(device, "open(\"%s\") failed with %ld\n", -- bdev_path, PTR_ERR(handle)); -+ bdev_path, PTR_ERR(file)); - } -- return handle; -+ return file; - } - - static int link_backing_dev(struct drbd_device *device, -- const char *bdev_path, struct bdev_handle *handle) -+ const char *bdev_path, struct file *file) - { -- int err = bd_link_disk_holder(handle->bdev, device->vdisk); -+ int err = bd_link_disk_holder(file_bdev(file), device->vdisk); - if (err) { -- bdev_release(handle); -+ fput(file); - drbd_err(device, "bd_link_disk_holder(\"%s\", ...) failed with %d\n", - bdev_path, err); - } -@@ -2764,22 +2764,22 @@ static int open_backing_devices(struct drbd_device *device, - struct disk_conf *new_disk_conf, - struct drbd_backing_dev *nbc) - { -- struct bdev_handle *handle; -+ struct file *file; - void *meta_claim_ptr; - int err; - -- handle = open_backing_dev(device, new_disk_conf->backing_dev, device); -- if (IS_ERR(handle)) -+ file = open_backing_dev(device, new_disk_conf->backing_dev, device); -+ if (IS_ERR(file)) - return ERR_OPEN_DISK; - -- err = link_backing_dev(device, new_disk_conf->backing_dev, handle); -+ err = link_backing_dev(device, new_disk_conf->backing_dev, file); - if (err) { - /* close without unlinking; otherwise error path will try to unlink */ -- close_backing_dev(device, handle, false); -+ close_backing_dev(device, file, false); - return ERR_OPEN_DISK; - } -- nbc->backing_bdev = handle->bdev; -- nbc->backing_bdev_handle = handle; -+ nbc->backing_bdev = file_bdev(file); -+ nbc->backing_bdev_file = file; - - /* meta_claim_ptr: device, if claimed exclusively; shared drbd_m_holder, - * if potentially shared with other drbd minors -@@ -2794,23 +2794,23 @@ static int open_backing_devices(struct drbd_device *device, - * should check it for you already; but if you don't, or - * someone fooled it, we need to double check here) - */ -- handle = open_backing_dev(device, new_disk_conf->meta_dev, meta_claim_ptr); -- if (IS_ERR(handle)) -+ file = open_backing_dev(device, new_disk_conf->meta_dev, meta_claim_ptr); -+ if (IS_ERR(file)) - return ERR_OPEN_MD_DISK; - - /* avoid double bd_claim_by_disk() for the same (source,target) tuple, - * as would happen with internal metadata. */ -- if (handle != nbc->backing_bdev_handle) { -- err = link_backing_dev(device, new_disk_conf->meta_dev, handle); -+ if (file_bdev(file) != nbc->backing_bdev) { -+ err = link_backing_dev(device, new_disk_conf->meta_dev, file); - if (err) { - /* close without unlinking; otherwise error path will try to unlink */ -- close_backing_dev(device, handle, false); -+ close_backing_dev(device, file, false); - return ERR_OPEN_MD_DISK; - } - } - -- nbc->md_bdev = handle->bdev; -- nbc->md_bdev_handle = handle; -+ nbc->md_bdev = file_bdev(file); -+ nbc->f_md_bdev = file; - return NO_ERROR; - } - --- -2.35.3 - diff --git a/boo1231290_fix_drbd_build_error_against_kernel_v6.11.0.patch b/boo1231290_fix_drbd_build_error_against_kernel_v6.11.0.patch new file mode 100644 index 0000000..b81763b --- /dev/null +++ b/boo1231290_fix_drbd_build_error_against_kernel_v6.11.0.patch @@ -0,0 +1,92 @@ +Oct 11, 2024. by heming.zhao@suse.com + +This patch includes the following 4 changes for passing the build on v6.11.0. + +------------- +for 'queue_flag_stable_writes__no_present', modifying +drbd-kernel-compat/cocci/queue_flag_stable_writes__no_present.cocci + +upstream kernel: +commit 1a02f3a73f8c670eddeb44bf52a75ae7f67cfc11 +Author: Christoph Hellwig +Date: Mon Jun 17 08:04:44 2024 +0200 + + block: move the stable_writes flag to queue_limits + +------------- +for 'disk_update_readahead__no_present', modifying +drbd-kernel-compat/cocci/disk_update_readahead__no_present.cocci + +upstream kernel: +commit 73781b3b81e76583708a652c853d54d03dce031d +Author: Christoph Hellwig +Date: Wed Jun 26 16:26:27 2024 +0200 + + block: remove disk_update_readahead + +-------------- +for 'blk_queue_update_readahead__no_present', modifying +'drbd-kernel-compat/gen_patch_names.c', which bypasses the +testing of COMPAT_HAVE_BLK_QUEUE_UPDATE_READAHEAD. + +--------------- +for 'blk_queue_write_cache__no_present__yes_flush', modifying +drbd-kernel-compat/tests/have_blk_queue_write_cache.c + +upstream kernel: +commit 62e35f942231e372f8e465d8484de66a60221226 +Author: Christoph Hellwig +Date: Thu Jun 27 13:14:03 2024 +0200 + + block: pass a gendisk to the queue_sysfs_entry methods + +--------------- + +diff -Nupr a/drbd/drbd-kernel-compat/cocci/disk_update_readahead__no_present.cocci b/drbd/drbd-kernel-compat/cocci/disk_update_readahead__no_present.cocci +--- a/drbd/drbd-kernel-compat/cocci/disk_update_readahead__no_present.cocci 2024-10-11 09:23:43.340688884 +0800 ++++ b/drbd/drbd-kernel-compat/cocci/disk_update_readahead__no_present.cocci 2024-10-11 09:27:53.755206413 +0800 +@@ -6,5 +6,5 @@ type T; + T q = dev->rq_queue; + <... + - disk_update_readahead(dev->vdisk); +-+ blk_queue_update_readahead(q); +++ blk_apply_bdi_limits(dev->vdisk->bdi, &dev->vdisk->queue->limits); + ...> +diff -Nupr a/drbd/drbd-kernel-compat/cocci/queue_flag_stable_writes__no_present.cocci b/drbd/drbd-kernel-compat/cocci/queue_flag_stable_writes__no_present.cocci +--- a/drbd/drbd-kernel-compat/cocci/queue_flag_stable_writes__no_present.cocci 2024-10-11 09:23:25.420604140 +0800 ++++ b/drbd/drbd-kernel-compat/cocci/queue_flag_stable_writes__no_present.cocci 2024-10-11 09:28:33.265393250 +0800 +@@ -2,4 +2,4 @@ + expression q; + @@ + - blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, q); +-+ q->backing_dev_info->capabilities |= BDI_CAP_STABLE_WRITES; +++ q->limits.features |= BLK_FEAT_STABLE_WRITES; +diff -Nupr a/drbd/drbd-kernel-compat/gen_patch_names.c b/drbd/drbd-kernel-compat/gen_patch_names.c +--- a/drbd/drbd-kernel-compat/gen_patch_names.c 2024-10-11 09:24:54.021023132 +0800 ++++ b/drbd/drbd-kernel-compat/gen_patch_names.c 2024-10-11 09:26:48.508231197 +0800 +@@ -405,6 +405,7 @@ int main(int argc, char **argv) + patch(1, "disk_update_readahead", true, false, + COMPAT_HAVE_DISK_UPDATE_READAHEAD, "present"); + ++#if 0 + #if !defined(COMPAT_HAVE_DISK_UPDATE_READAHEAD) + /* disk_update_readahead is the "new version" of + * blk_queue_update_readahead. we only need to consider compat +@@ -412,6 +413,7 @@ int main(int argc, char **argv) + patch(1, "blk_queue_update_readahead", true, false, + COMPAT_HAVE_BLK_QUEUE_UPDATE_READAHEAD, "present"); + #endif ++#endif + + patch(1, "struct_gendisk", true, false, + COMPAT_STRUCT_GENDISK_HAS_BACKING_DEV_INFO, "has_backing_dev_info"); +diff -Nupr a/drbd/drbd-kernel-compat/tests/have_blk_queue_write_cache.c b/drbd/drbd-kernel-compat/tests/have_blk_queue_write_cache.c +--- a/drbd/drbd-kernel-compat/tests/have_blk_queue_write_cache.c 2024-10-11 09:25:57.557990258 +0800 ++++ b/drbd/drbd-kernel-compat/tests/have_blk_queue_write_cache.c 2024-10-11 09:27:17.571701979 +0800 +@@ -2,5 +2,5 @@ + + void dummy(struct request_queue *q, bool enabled, bool fua) + { +- blk_queue_write_cache(q, enabled, fua); ++ blk_queue_write_cache(q); + } diff --git a/bsc1226510-fix-build-err-against-6.9.3.patch b/bsc1226510-fix-build-err-against-6.9.3.patch deleted file mode 100644 index a967532..0000000 --- a/bsc1226510-fix-build-err-against-6.9.3.patch +++ /dev/null @@ -1,78 +0,0 @@ -By heming.zhao@suse.com - -This patch was updated/changed after boo#1230635 - ----- - -diff -Nupr a/drbd/drbd-kernel-compat/tests/have_bdev_open_by_path.c b/drbd/drbd-kernel-compat/tests/have_bdev_open_by_path.c ---- a/drbd/drbd-kernel-compat/tests/have_bdev_open_by_path.c 2024-06-19 15:02:47.050694378 +0800 -+++ b/drbd/drbd-kernel-compat/tests/have_bdev_open_by_path.c 2024-06-19 15:11:39.313298178 +0800 -@@ -2,7 +2,7 @@ - - #include - --struct bdev_handle *foo(const char *path, blk_mode_t mode, void *holder, -- const struct blk_holder_ops *hops) { -- return bdev_open_by_path(path, mode, holder, hops); -+void foo(void) -+{ -+ return; - } -diff -Nupr a/drbd/drbd-kernel-compat/tests/have_blk_alloc_disk.c b/drbd/drbd-kernel-compat/tests/have_blk_alloc_disk.c ---- a/drbd/drbd-kernel-compat/tests/have_blk_alloc_disk.c 2024-06-19 11:35:39.957400039 +0800 -+++ b/drbd/drbd-kernel-compat/tests/have_blk_alloc_disk.c 2024-06-19 11:36:43.594396686 +0800 -@@ -2,7 +2,17 @@ - - #include - -+#define DRBD_MAX_BIO_SIZE_SAFE (1U << 12) /* Works always = 4k */ -+ - struct gendisk *foo(int node) - { -- return blk_alloc_disk(node); -+ struct queue_limits lim = { -+ /* -+ * Setting the max_hw_sectors to an odd value of 8kibyte here. -+ * This triggers a max_bio_size message upon first attach or -+ * connect. -+ */ -+ .max_hw_sectors = DRBD_MAX_BIO_SIZE_SAFE >> 8, -+ }; -+ return blk_alloc_disk(&lim, node); - } -diff -Nupr a/drbd/drbd_main.c b/drbd/drbd_main.c ---- a/drbd/drbd_main.c 2024-06-19 11:41:59.409367593 +0800 -+++ b/drbd/drbd_main.c 2024-06-19 11:41:40.052600574 +0800 -@@ -3752,6 +3752,7 @@ static int init_submitter(struct drbd_de - return 0; - } - -+#define DRBD_MAX_BIO_SIZE_SAFE (1U << 12) /* Works always = 4k */ - enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsigned int minor, - struct device_conf *device_conf, struct drbd_device **p_device) - { -@@ -3767,6 +3768,15 @@ enum drbd_ret_code drbd_create_device(st - enum drbd_ret_code err = ERR_NOMEM; - bool locked = false; - -+ struct queue_limits lim = { -+ /* -+ * Setting the max_hw_sectors to an odd value of 8kibyte here. -+ * This triggers a max_bio_size message upon first attach or -+ * connect. -+ */ -+ .max_hw_sectors = DRBD_MAX_BIO_SIZE_SAFE >> 8, -+ }; -+ - lockdep_assert_held(&resource->conf_update); - - device = minor_to_device(minor); -@@ -3824,7 +3834,7 @@ enum drbd_ret_code drbd_create_device(st - - init_rwsem(&device->uuid_sem); - -- disk = blk_alloc_disk(NUMA_NO_NODE); -+ disk = blk_alloc_disk(&lim, NUMA_NO_NODE); - if (!disk) - goto out_no_disk; - diff --git a/drbd-9.1.16.tar.gz b/drbd-9.1.16.tar.gz deleted file mode 100644 index e01fee3..0000000 --- a/drbd-9.1.16.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1ad99353dbae62acc1bf4ef32fa8ca317e6657138e02c009e3d4cf42bfb465fb -size 1332576 diff --git a/drbd-9.1.22.tar.gz b/drbd-9.1.22.tar.gz new file mode 100644 index 0000000..a0607da --- /dev/null +++ b/drbd-9.1.22.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4a0af3560d6d133f8062d4284dd6a2be8614388bbacd140a0978232fd163c533 +size 1427992 diff --git a/drbd.changes b/drbd.changes index 526b2a3..1e4ce94 100644 --- a/drbd.changes +++ b/drbd.changes @@ -1,3 +1,186 @@ +------------------------------------------------------------------- +Fri Oct 11 03:30:00 UTC 2024 - heming zhao + +- Update DRBD version from 9.1.16 to 9.1.22 + + * Changelog from Linbit: + + 9.1.22 (api:genl2/proto:86-121/transport:18) + -------- + * Upgrade from partial resync to a full resync if necessary when the + user manually resolves a split-brain situation + * Fix a potential NULL deref when a disk fails while doing a + forget-peer operation. + * Fix a rcu_read_lock()/rcu_read_unlock() imbalance + * Restart the open() syscall when a process auto promoting a drbd device gets + interrupted by a signal + * Remove a deadlock that caused DRBD to connect sometimes + exceptionally slow + * Make detach operations interruptible + * Added dev_is_open to events2 status information + * Improve log readability for 2PC state changes and drbd-threads + * Updated compability code for Linux 6.9 + + 9.1.21 (api:genl2/proto:86-121/transport:18) + -------- + * fix a deadlock that can trigger when deleting a connection and + another connection going down in parallel. This is a regression of + 9.1.20 + * Fix an out-of-bounds access when scanning the bitmap. It leads to a + crash when the bitmap ends on a page boundary, and this is also a + regression in 9.1.20. + + 9.1.20 (api:genl2/proto:86-121/transport:18) + -------- + * Fix a kernel crash that is sometimes triggered when downing drbd + resources in a specific, unusual order (was triggered by the + Kubernetes CSI driver) + * Fix a rarely triggering kernel crash upon adding paths to a + connection by rehauling the path lists' locking + * Fix the continuation of an interrupted initial resync + * Fix the state engine so that an incapable primary does not outdate + indirectly reachable secondary nodes + * Fix a logic bug that caused drbd to pretend that a peer's disk is + outdated when doing a manual disconnect on a down connection; with + that cured impact on fencing and quorum. + * Fix forceful demotion of suspended devices + * Rehaul of the build system to apply compatibility patches out of + place that allows one to build for different target kernels from a + single drbd source tree + * Updated compability code for Linux 6.8 + + 9.1.19 (api:genl2/proto:86-121/transport:18) + -------- + * Fix a resync decision case where drbd wrongly decided to do a full + resync, where a partial resync was sufficient; that happened in a + specific connect order when all nodes were on the same data + generation (UUID) + * Fix the online resize code to obey cached size information about + temporal unreachable nodes + * Fix a rare corner case in which DRBD on a diskless primary node + failed to re-issue a read request to another node with a backing + disk upon connection loss on the connection where it shipped the + read request initially + * Make timeout during promotion attempts interruptible + * No longer write activity-log updates on the secondary node in a + cluster with precisely two nodes with backing disk; this is a + performance optimization + * Reduce CPU usage of acknowledgment processing + + 9.1.18 (api:genl2/proto:86-121/transport:18) + -------- + * Fixed connecting nodes with differently sized backing disks, + specifically when the smaller node is primary, before establishing + the connections + * Fixed thawing a device that has I/O frozen after loss of quorum + when a configuration change eases its quorum requirements + * Properly fail TLS if requested (only available in drbd-9.2) + * Fixed a race condition that can cause auto-demote to trigger right + after an explicit promote + * Fixed a rare race condition that could mess up the handshake result + before it is committed to the replication state. + * Preserve "tiebreaker quorum" over a reboot of the last node (3-node + clusters only) + * Update compatibility code for Linux 6.6 + + 9.1.17 (api:genl2/proto:86-121/transport:18) + -------- + * fix a potential crash when configuring drbd to bind to a + non-existent local IP address (this is a regression of drbd-9.1.8) + * Cure a very seldom triggering race condition bug during + establishing connections; when you triggered it, you got an OOPS + hinting to list corruption + * fix a race condition regarding operations on the bitmap while + forgetting a bitmap slot and a pointless warning + * Fix handling of unexpected (on a resource in secondary role) write + requests + * Fix a corner case that can cause a process to hang when closing the + DRBD device, while a connection gets re-established + * Correctly block signal delivery during auto-demote + * Improve the reliability of establishing connections + * Do not clear the transport with `net-options --set-defaults`. This + fix avoids unexpected disconnect/connect cycles upon an `adjust` + when using the 'lb-tcp' or 'rdma' transports in drbd-9.2. + * New netlink packet to report path status to drbdsetup + * Improvements to the content and rate-limiting of many log messages + * Update compatibility code and follow Linux upstream development + until Linux 6.5 + + * remove patches which already included in the new version: + 0001-drbd-allow-transports-to-take-additional-krefs-on-a-.patch + 0002-drbd-improve-decision-about-marking-a-failed-disk-Ou.patch + 0003-drbd-fix-error-path-in-drbd_get_listener.patch + 0004-drbd-build-fix-spurious-re-build-attempt-of-compat.p.patch + 0005-drbd-log-error-code-when-thread-fails-to-start.patch + 0006-drbd-log-numeric-value-of-drbd_state_rv-as-well-as-s.patch + 0007-drbd-stop-defining-__KERNEL_SYSCALLS__.patch + 0008-compat-block-introduce-holder-ops.patch + 0009-drbd-reduce-net_ee-not-empty-info-to-a-dynamic-debug.patch + 0010-drbd-do-not-send-P_CURRENT_UUID-to-DRBD-8-peer-when-.patch + 0011-compat-block-pass-a-gendisk-to-open.patch + 0012-drbd-Restore-DATA_CORKED-and-CONTROL_CORKED-bits.patch + 0013-drbd-remove-unused-extern-for-conn_try_outdate_peer.patch + 0014-drbd-include-source-of-state-change-in-log.patch + 0015-compat-block-use-the-holder-as-indication-for-exclus.patch + 0016-drbd-Fix-net-options-set-defaults-to-not-clear-the-t.patch + 0017-drbd-propagate-exposed-UUIDs-only-into-established-c.patch + 0018-drbd-rework-autopromote.patch + 0019-compat-block-remove-the-unused-mode-argument-to-rele.patch + 0020-drbd-do-not-allow-auto-demote-to-be-interrupted-by-s.patch + 0021-compat-sock-Remove-sendpage-in-favour-of-sendmsg-MSG.patch + 0022-compat-block-replace-fmode_t-with-a-block-specific-t.patch + 0023-compat-genetlink-remove-userhdr-from-struct-genl_inf.patch + 0024-compat-fixup-FMODE_READ-FMODE_WRITE-usage.patch + 0025-compat-drdb-Convert-to-use-bdev_open_by_path.patch + 0026-compat-gate-blkdev_-patches-behind-bdev_open_by_path.patch + boo1230635_01-compat-fix-nla_nest_start_noflag-test.patch + boo1230635_02-drbd-port-block-device-access-to-file.patch + + * removed patches which are not needed anymore: + boo1229062-re-enable-blk_queue_max_hw_sectors.patch + bsc1226510-fix-build-err-against-6.9.3.patch + + * update: + drbd_git_revision + suse-coccinelle.patch + drbd.spec + + * add upstream patches to align commit 13ada1be201e: + 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 + + * add patch to fix kernel imcompatibility issue (boo#1231290): + boo1231290_fix_drbd_build_error_against_kernel_v6.11.0.patch + ------------------------------------------------------------------- Tue Sep 17 11:38:00 UTC 2024 - heming zhao diff --git a/drbd.spec b/drbd.spec index c70d7d4..d0f744e 100644 --- a/drbd.spec +++ b/drbd.spec @@ -24,11 +24,11 @@ %endif %endif Name: drbd -Version: 9.1.16 +Version: 9.1.22 Release: 0 Summary: Linux driver for the "Distributed Replicated Block Device" License: GPL-2.0-or-later -URL: https://drbd.linbit.com/ +URL: https://pkg.linbit.com/ Source: %{name}-%{version}.tar.gz Source1: preamble Source2: Module.supported @@ -36,40 +36,43 @@ Source3: drbd_git_revision ######################## # upstream patch -Patch0001: 0001-drbd-allow-transports-to-take-additional-krefs-on-a-.patch -Patch0002: 0002-drbd-improve-decision-about-marking-a-failed-disk-Ou.patch -Patch0003: 0003-drbd-fix-error-path-in-drbd_get_listener.patch -Patch0004: 0004-drbd-build-fix-spurious-re-build-attempt-of-compat.p.patch -Patch0005: 0005-drbd-log-error-code-when-thread-fails-to-start.patch -Patch0006: 0006-drbd-log-numeric-value-of-drbd_state_rv-as-well-as-s.patch -Patch0007: 0007-drbd-stop-defining-__KERNEL_SYSCALLS__.patch -Patch0008: 0008-compat-block-introduce-holder-ops.patch -Patch0009: 0009-drbd-reduce-net_ee-not-empty-info-to-a-dynamic-debug.patch -Patch0010: 0010-drbd-do-not-send-P_CURRENT_UUID-to-DRBD-8-peer-when-.patch -Patch0011: 0011-compat-block-pass-a-gendisk-to-open.patch -Patch0012: 0012-drbd-Restore-DATA_CORKED-and-CONTROL_CORKED-bits.patch -Patch0013: 0013-drbd-remove-unused-extern-for-conn_try_outdate_peer.patch -Patch0014: 0014-drbd-include-source-of-state-change-in-log.patch -Patch0015: 0015-compat-block-use-the-holder-as-indication-for-exclus.patch -Patch0016: 0016-drbd-Fix-net-options-set-defaults-to-not-clear-the-t.patch -Patch0017: 0017-drbd-propagate-exposed-UUIDs-only-into-established-c.patch -Patch0018: 0018-drbd-rework-autopromote.patch -Patch0019: 0019-compat-block-remove-the-unused-mode-argument-to-rele.patch -Patch0020: 0020-drbd-do-not-allow-auto-demote-to-be-interrupted-by-s.patch -Patch0021: 0021-compat-sock-Remove-sendpage-in-favour-of-sendmsg-MSG.patch -Patch0022: 0022-compat-block-replace-fmode_t-with-a-block-specific-t.patch -Patch0023: 0023-compat-genetlink-remove-userhdr-from-struct-genl_inf.patch -Patch0024: 0024-compat-fixup-FMODE_READ-FMODE_WRITE-usage.patch -Patch0025: 0025-compat-drdb-Convert-to-use-bdev_open_by_path.patch -Patch0026: 0026-compat-gate-blkdev_-patches-behind-bdev_open_by_path.patch -Patch0027: boo1230635_01-compat-fix-nla_nest_start_noflag-test.patch -Patch0028: boo1230635_02-drbd-port-block-device-access-to-file.patch +Patch0001: 0001-drbd-properly-rate-limit-resync-progress-reports.patch +Patch0002: 0002-drbd-inherit-history-UUIDs-from-sync-source-when-res.patch +Patch0003: 0003-build-compat-fix-line-offset-in-annotation-pragmas-p.patch +Patch0004: 0004-drbd-fix-exposed_uuid-going-backward.patch +Patch0005: 0005-drbd-Proper-locking-around-new_current_uuid-on-a-dis.patch +Patch0006: 0006-build-CycloneDX-fix-bom-ref-add-purl.patch +Patch0007: 0007-build-Another-update-to-the-spdx-files.patch +Patch0008: 0008-build-generate-spdx.json-not-tag-value-format.patch +Patch0009: 0009-compat-fix-gen_patch_names-for-bdev_file_open_by_pat.patch +Patch0010: 0010-compat-fix-nla_nest_start_noflag-test.patch +Patch0011: 0011-compat-fix-blk_alloc_disk-rule.patch +Patch0012: 0012-drbd-remove-const-from-function-return-type.patch +Patch0013: 0013-drbd-don-t-set-max_write_zeroes_sectors-in-decide_on.patch +Patch0014: 0014-drbd-split-out-a-drbd_discard_supported-helper.patch +Patch0015: 0015-drbd-atomically-update-queue-limits-in-drbd_reconsid.patch +Patch0016: 0016-compat-test-and-patch-for-queue_limits_start_update.patch +Patch0017: 0017-compat-specify-which-essential-change-was-not-made.patch +Patch0018: 0018-gen_patch_names-reorder-blk_mode_t.patch +Patch0019: 0019-compat-fix-blk_queue_update_readahead-patch.patch +Patch0020: 0020-compat-test-and-patch-for-que_limits-max_hw_discard_.patch +Patch0021: 0021-compat-fixup-write_zeroes__no_capable.patch +Patch0022: 0022-compat-fixup-queue_flag_discard__yes_present.patch +Patch0023: 0023-drbd-move-flags-to-queue_limits.patch +Patch0024: 0024-compat-test-and-patch-for-queue_limits.features.patch +Patch0025: 0025-drbd-Annotate-struct-fifo_buffer-with-__counted_by.patch +Patch0026: 0026-compat-test-and-patch-for-__counted_by.patch +Patch0027: 0027-drbd-fix-function-cast-warnings-in-state-machine.patch +Patch0028: 0028-Add-missing-documentation-of-peer_device-parameter-t.patch +# 0029-ci-update-build-helpers.patch is fedora special, we ignore it. +Patch0029: 0030-drbd-kref_put-path-when-kernel_accept-fails.patch +Patch0030: 0031-build-fix-typo-in-Makefile.spatch.patch +Patch0031: 0032-drbd-open-do-not-delay-open-if-already-Primary.patch # suse special patch -Patch1001: bsc-1025089_fix-resync-finished-with-syncs-have-bits-set.patch -Patch1002: suse-coccinelle.patch -Patch1003: bsc1226510-fix-build-err-against-6.9.3.patch -Patch1004: boo1229062-re-enable-blk_queue_max_hw_sectors.patch +Patch1001: bsc-1025089_fix-resync-finished-with-syncs-have-bits-set.patch +Patch1002: suse-coccinelle.patch +Patch1003: boo1231290_fix_drbd_build_error_against_kernel_v6.11.0.patch ######################## #https://github.com/openSUSE/rpmlint-checks/blob/master/KMPPolicyCheck.py @@ -78,6 +81,7 @@ BuildRequires: kernel-source BuildRequires: kernel-syms BuildRequires: libelf-devel BuildRequires: modutils +BuildRequires: perl BuildRequires: %kernel_module_package_buildreqs Requires: drbd-utils >= 9.3.0 Supplements: drbd-utils >= 9.3.0 @@ -106,10 +110,6 @@ installed kernel. %prep %autosetup -p1 -n drbd-%{version} -mkdir source -cp -a drbd/. source/. || : -cp $RPM_SOURCE_DIR/drbd_git_revision source/.drbd_git_revision - %build rm -rf obj mkdir obj @@ -124,22 +124,29 @@ export SPAAS='false' for flavor in %{flavors_to_build}; do rm -rf $flavor - cp -a -r source $flavor - cp -a %{_sourcedir}/Module.supported $flavor + cp -a -r drbd $flavor + cp $RPM_SOURCE_DIR/drbd_git_revision ${flavor}/.drbd_git_revision + export DRBDSRC="$PWD/obj/$flavor" # bsc#1160194, check the coccicheck work. #make coccicheck - make %{?_smp_mflags} -C %{kernel_source $flavor} modules M=$PWD/$flavor SPAAS=${SPAAS} + + # call make prep to generate drbd build dir + make %{?_smp_mflags} -C $flavor KDIR=%{kernel_source $flavor} prep SPAAS=${SPAAS} + + cp -a %{_sourcedir}/Module.supported ${flavor}/build-current + + make %{?_smp_mflags} -C %{kernel_source $flavor} modules M=$PWD/$flavor/build-current SPAAS=${SPAAS} # Check the compat result - cat $PWD/$flavor/compat.h + cat $PWD/${flavor}/build-current/compat.h done %install export INSTALL_MOD_PATH=%{buildroot} export INSTALL_MOD_DIR=updates for flavor in %{flavors_to_build}; do - make -C %{kernel_source $flavor} modules_install M=$PWD/$flavor + make -C %{kernel_source $flavor} modules_install M=$PWD/$flavor/build-current done mkdir -p %{buildroot}/%{_sbindir} diff --git a/drbd_git_revision b/drbd_git_revision index 634f6fa..508cfc7 100644 --- a/drbd_git_revision +++ b/drbd_git_revision @@ -1 +1 @@ -GIT-hash: 288abda1fb8c93e385960af01ab28729fefdaa38 +GIT-hash: 13ada1be201eb14ff8295a17194de8db5cdccd7f diff --git a/suse-coccinelle.patch b/suse-coccinelle.patch index 8ffdb7b..f44470b 100644 --- a/suse-coccinelle.patch +++ b/suse-coccinelle.patch @@ -1,76 +1,71 @@ -diff -Naur drbd-9.0.29~0+git.9a7bc817.orig/drbd/drbd-kernel-compat/gen_compat_patch.sh drbd-9.0.29~0+git.9a7bc817/drbd/drbd-kernel-compat/gen_compat_patch.sh ---- drbd-9.0.29~0+git.9a7bc817.orig/drbd/drbd-kernel-compat/gen_compat_patch.sh 2021-05-07 11:24:44.877547149 +0800 -+++ drbd-9.0.29~0+git.9a7bc817/drbd/drbd-kernel-compat/gen_compat_patch.sh 2021-05-07 12:30:58.385703306 +0800 -@@ -44,9 +44,19 @@ +diff -Nupr a/drbd/drbd-kernel-compat/gen_compat_patch.sh b/drbd/drbd-kernel-compat/gen_compat_patch.sh +--- a/drbd/drbd-kernel-compat/gen_compat_patch.sh 2024-09-16 10:24:47.044861735 +0800 ++++ b/drbd/drbd-kernel-compat/gen_compat_patch.sh 2024-09-16 10:32:03.256040980 +0800 +@@ -43,9 +43,19 @@ fi if hash spatch && spatch_is_recent; then - K=$(cat $incdir/kernelrelease.txt) + K=$(cat $incdir/kernelrelease.txt || echo unknown kernel release) + -+ echo " compat.h content "; -+ cat $incdir/compat.h; -+ echo " ------------------- "; ++ echo " compat.h content "; ++ cat $incdir/compat.h; ++ echo " ------------------- "; + - echo " GENPATCHNAMES "$K - gcc -I $incdir -o $incdir/gen_patch_names -std=c99 drbd-kernel-compat/gen_patch_names.c - $incdir/gen_patch_names > $incdir/applied_cocci_files.txt + echo " GENPATCHNAMES "$K + gcc -I $incdir -o $incdir/gen_patch_names -std=c99 drbd-kernel-compat/gen_patch_names.c + $incdir/gen_patch_names > $incdir/applied_cocci_files.txt + -+ echo " APPLIED_COCCI_FILES "; -+ cat $incdir/applied_cocci_files.txt; -+ echo " ------------------- "; ++ echo " APPLIED_COCCI_FILES "; ++ cat $incdir/applied_cocci_files.txt; ++ echo " ------------------- "; + - rm $incdir/gen_patch_names - rm -f $incdir/.compat.cocci - rm -f $incdir/.compat.patch -@@ -67,7 +77,15 @@ - < drbd-kernel-compat/cocci/debugfs_compat_template.cocci.in \ - >> $incdir/.compat.cocci - done -+ -+ coccilibpath=$(rpm -ql coccinelle|grep standard.h|xargs dirname); -+ echo " SPATCH_SOURCES: "$*; -+ echo " COCCI_LIBPATH: "$coccilibpath; -+ - if [ -e $incdir/.compat.cocci ]; then -+ echo " GENCOCCIRULES .compat.cocci"; -+ cat $incdir/.compat.cocci; -+ - echo " SPATCH $chksum "$K - # Note: $* (or $@) is NOT make magic variable now, this is a shell script - # make $@, the target file, was passed as $1, and is now $compat_patch -@@ -77,8 +95,14 @@ - # we know we don't have white-space in the argument list + rm $incdir/gen_patch_names + # truncat them all + : > $incdir/.compat.cocci +@@ -72,15 +82,28 @@ if hash spatch && spatch_is_recent; then + >> $incdir/.compat.cocci.tmp + done - set +e ++ coccilibpath=$(rpm -ql coccinelle|grep standard.h|xargs dirname); ++ echo " SPATCH_SOURCES: "$*; ++ echo " COCCI_LIBPATH: "$coccilibpath; + -+ command="spatch --sp-file $incdir/.compat.cocci $@ --macro-file drbd-kernel-compat/cocci_macros.h --macro-file-builtins $coccilibpath/standard.h --iso-file $coccilibpath/standard.iso --very-quiet --all-includes > $compat_patch.tmp 2> $incdir/.spatch.stderr" -+ echo " SPATCH COMMAND $command "; + mv $incdir/.compat.cocci.tmp $incdir/.compat.cocci + mv $incdir/.compat.patch.tmp $incdir/.compat.patch + + if [ -s $incdir/.compat.cocci ]; then ++ echo " GENCOCCIRULES .compat.cocci"; ++ cat $incdir/.compat.cocci; + - spatch --sp-file "$incdir/.compat.cocci" "$@" \ - --macro-file drbd-kernel-compat/cocci_macros.h \ -+ --macro-file-builtins $coccilibpath/standard.h \ -+ --iso-file $coccilibpath/standard.iso \ - --very-quiet \ - --all-includes \ - > "$compat_patch.tmp" \ -@@ -94,9 +118,21 @@ - echo " SPATCH $chksum "$K" - nothing to do" - touch $compat_patch.tmp - fi + # sources=( ... ) passed in via environment + echo " SPATCH $chksum "$K + set +e + -+ echo " GENSPATCHFILE $compat_patch.tmp "; -+ cat $compat_patch.tmp; ++ command="spatch --sp-file $incdir/.compat.cocci $@ --macro-file drbd-kernel-compat/cocci_macros.h --macro-file-builtins $coccilibpath/standard.h --iso-file $coccilibpath/standard.iso --very-quiet --all-includes > $compat_patch.tmp 2> $incdir/.spatch.stderr" ++ echo " SPATCH COMMAND $command "; + - if [ -e $incdir/.compat.patch ]; then -+ echo " EXIST $incdir/.compat.patch "; - cat $incdir/.compat.patch >> $compat_patch.tmp + spatch --sp-file "$incdir/.compat.cocci" "${sources[@]}" \ + --macro-file drbd-kernel-compat/cocci_macros.h \ ++ --macro-file-builtins $coccilibpath/standard.h \ ++ --iso-file $coccilibpath/standard.iso \ + --very-quiet \ + --all-includes \ + ${SPATCH_DEBUG:+ --debug} \ +@@ -101,8 +124,18 @@ if hash spatch && spatch_is_recent; then + echo " SPATCH $chksum "$K" - nothing to do" + fi + ++ echo " GENSPATCHFILE $compat_patch.tmp "; + cat $compat_patch.tmp; - fi + -+ if [ -e $incdir/.spatch.stderr ]; then -+ echo " GENSPATCHERR .spatch.stderr"; -+ cat $incdir/.spatch.stderr; -+ fi + if [ -s $incdir/.compat.patch ]; then ++ echo " EXIST $incdir/.compat.patch "; + cat $incdir/.compat.patch >> $compat_patch.tmp ++ cat $compat_patch.tmp; ++ fi + - mv $compat_patch.tmp $compat_patch - # keep it around - # to better be able to match the "stderr" warnings to their source files ++ if [ -e $incdir/.spatch.stderr ]; then ++ echo " GENSPATCHERR .spatch.stderr"; ++ cat $incdir/.spatch.stderr; + fi + + if [ -s $compat_patch.tmp ]; then