Accepting request 1113587 from network:ha-clustering:Factory
OBS-URL: https://build.opensuse.org/request/show/1113587 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/drbd?expand=0&rev=105
This commit is contained in:
commit
d09a2c7cea
@ -0,0 +1,37 @@
|
||||
From 0dda200877d1b801fba948a5948f321bee1a75a9 Mon Sep 17 00:00:00 2001
|
||||
From: Philipp Reisner <philipp.reisner@linbit.com>
|
||||
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
|
||||
|
@ -0,0 +1,65 @@
|
||||
From f2cd05b8d60d27f43b07175b92ef4c2a69b8e3a2 Mon Sep 17 00:00:00 2001
|
||||
From: Joel Colledge <joel.colledge@linbit.com>
|
||||
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
|
||||
|
32
0003-drbd-fix-error-path-in-drbd_get_listener.patch
Normal file
32
0003-drbd-fix-error-path-in-drbd_get_listener.patch
Normal file
@ -0,0 +1,32 @@
|
||||
From fbfb92d11e64daec167b24521c715ceab505b55d Mon Sep 17 00:00:00 2001
|
||||
From: Philipp Reisner <philipp.reisner@linbit.com>
|
||||
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
|
||||
|
@ -0,0 +1,47 @@
|
||||
From 67ac093d6dc176fd6a3bf0c7f5a3ad046d48f558 Mon Sep 17 00:00:00 2001
|
||||
From: Lars Ellenberg <lars.ellenberg@linbit.com>
|
||||
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
|
||||
|
28
0005-drbd-log-error-code-when-thread-fails-to-start.patch
Normal file
28
0005-drbd-log-error-code-when-thread-fails-to-start.patch
Normal file
@ -0,0 +1,28 @@
|
||||
From a98c818bd33920fd5189cdd8f5d81850ad4a945b Mon Sep 17 00:00:00 2001
|
||||
From: Joel Colledge <joel.colledge@linbit.com>
|
||||
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
|
||||
|
@ -0,0 +1,82 @@
|
||||
From 8c2c783a09d81f0a725e7a3ae48be4ceb2d79a63 Mon Sep 17 00:00:00 2001
|
||||
From: Joel Colledge <joel.colledge@linbit.com>
|
||||
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
|
||||
|
45
0007-drbd-stop-defining-__KERNEL_SYSCALLS__.patch
Normal file
45
0007-drbd-stop-defining-__KERNEL_SYSCALLS__.patch
Normal file
@ -0,0 +1,45 @@
|
||||
From 15cf257c277020e1ba76eff7aa99ed08d44f7d3c Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Moritz=20=22WanzenBug=22=20Wanzenb=C3=B6ck?=
|
||||
<moritz.wanzenboeck@linbit.com>
|
||||
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 <linux/notifier.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/kthread.h>
|
||||
-#define __KERNEL_SYSCALLS__
|
||||
#include <linux/unistd.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include <linux/device.h>
|
||||
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 <linux/slab.h>
|
||||
#include <linux/pkt_sched.h>
|
||||
#include <uapi/linux/sched/types.h>
|
||||
-#define __KERNEL_SYSCALLS__
|
||||
#include <linux/unistd.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include <linux/random.h>
|
||||
--
|
||||
2.35.3
|
||||
|
80
0008-compat-block-introduce-holder-ops.patch
Normal file
80
0008-compat-block-introduce-holder-ops.patch
Normal file
@ -0,0 +1,80 @@
|
||||
From c34a13c3df85352124e94456f81e3d4ba4f52440 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Moritz=20=22WanzenBug=22=20Wanzenb=C3=B6ck?=
|
||||
<moritz.wanzenboeck@linbit.com>
|
||||
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 <hch@lst.de>", "date": "Thu Jun 1 11:44:52 2023 +0200" } */
|
||||
+#include <linux/blkdev.h>
|
||||
+
|
||||
+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
|
||||
|
@ -0,0 +1,45 @@
|
||||
From fc7b1ad2c422e4148d6419f1eec56189a7a578ac Mon Sep 17 00:00:00 2001
|
||||
From: Joel Colledge <joel.colledge@linbit.com>
|
||||
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
|
||||
|
@ -0,0 +1,37 @@
|
||||
From 1b94c10250c7d37423ba894457c40d9799025a93 Mon Sep 17 00:00:00 2001
|
||||
From: Joel Colledge <joel.colledge@linbit.com>
|
||||
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
|
||||
|
129
0011-compat-block-pass-a-gendisk-to-open.patch
Normal file
129
0011-compat-block-pass-a-gendisk-to-open.patch
Normal file
@ -0,0 +1,129 @@
|
||||
From b993152e80676f5b9ce583c9471b630cbd0675d7 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Moritz=20=22WanzenBug=22=20Wanzenb=C3=B6ck?=
|
||||
<moritz.wanzenboeck@linbit.com>
|
||||
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 <hch@lst.de>", "date": "Thu Jun 8 13:02:36 2023 +0200" } */
|
||||
+#include <linux/blkdev.h>
|
||||
+
|
||||
+#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
|
||||
|
67
0012-drbd-Restore-DATA_CORKED-and-CONTROL_CORKED-bits.patch
Normal file
67
0012-drbd-Restore-DATA_CORKED-and-CONTROL_CORKED-bits.patch
Normal file
@ -0,0 +1,67 @@
|
||||
From 88bf7f95dc359f4901f08ac8fb8ffc7dfceca9c1 Mon Sep 17 00:00:00 2001
|
||||
From: Philipp Reisner <philipp.reisner@linbit.com>
|
||||
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
|
||||
|
@ -0,0 +1,38 @@
|
||||
From 9e087399533445e3df60a34f26a1e6a285b0504a Mon Sep 17 00:00:00 2001
|
||||
From: Joel Colledge <joel.colledge@linbit.com>
|
||||
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
|
||||
|
1480
0014-drbd-include-source-of-state-change-in-log.patch
Normal file
1480
0014-drbd-include-source-of-state-change-in-log.patch
Normal file
File diff suppressed because it is too large
Load Diff
202
0015-compat-block-use-the-holder-as-indication-for-exclus.patch
Normal file
202
0015-compat-block-use-the-holder-as-indication-for-exclus.patch
Normal file
@ -0,0 +1,202 @@
|
||||
From 3b9fcc2cfaa32766724f371cc2054e057adbc425 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Moritz=20=22WanzenBug=22=20Wanzenb=C3=B6ck?=
|
||||
<moritz.wanzenboeck@linbit.com>
|
||||
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 <hch@lst.de>", "date": "Thu Jun 8 13:02:37 2023 +0200" } */
|
||||
+#include <linux/blkdev.h>
|
||||
+
|
||||
+#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
|
||||
|
@ -0,0 +1,33 @@
|
||||
From 69d9286628b730870665cd2c6f05dd9f1813c65e Mon Sep 17 00:00:00 2001
|
||||
From: Philipp Reisner <philipp.reisner@linbit.com>
|
||||
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
|
||||
|
@ -0,0 +1,35 @@
|
||||
From 0666bc5b014049b6aa184b5a8fdb60481b9c8717 Mon Sep 17 00:00:00 2001
|
||||
From: Philipp Reisner <philipp.reisner@linbit.com>
|
||||
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
|
||||
|
185
0018-drbd-rework-autopromote.patch
Normal file
185
0018-drbd-rework-autopromote.patch
Normal file
@ -0,0 +1,185 @@
|
||||
From e3ef0e229a6ae88346164d1507697ae1b397cdf9 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Moritz=20=22WanzenBug=22=20Wanzenb=C3=B6ck?=
|
||||
<moritz.wanzenboeck@linbit.com>
|
||||
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
|
||||
|
107
0019-compat-block-remove-the-unused-mode-argument-to-rele.patch
Normal file
107
0019-compat-block-remove-the-unused-mode-argument-to-rele.patch
Normal file
@ -0,0 +1,107 @@
|
||||
From bf287c15359c4495a706ca270e7dcab4c2d6ebcc Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Moritz=20=22WanzenBug=22=20Wanzenb=C3=B6ck?=
|
||||
<moritz.wanzenboeck@linbit.com>
|
||||
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 <hch@lst.de>", "date": "Thu Jun 8 13:02:37 2023 +0200" } */
|
||||
+#include <linux/blkdev.h>
|
||||
+
|
||||
+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
|
||||
|
@ -0,0 +1,66 @@
|
||||
From c8e2a3c4355b4794267cd6e58a074802b4607cb9 Mon Sep 17 00:00:00 2001
|
||||
From: Joel Colledge <joel.colledge@linbit.com>
|
||||
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
|
||||
|
86
bsc-1215699_fix-build-error-against-kernel-v6.5.4.patch
Normal file
86
bsc-1215699_fix-build-error-against-kernel-v6.5.4.patch
Normal file
@ -0,0 +1,86 @@
|
||||
Author: Heming Zhao <heming.zhao@suse.com>
|
||||
Date: Thu Sep 28 11:12:00 2023 +0800
|
||||
Subject: drbd: fix build error against kernel v6.5.4
|
||||
|
||||
Below two upstream commits broken drbd v9.1 building
|
||||
|
||||
(belonging to v6.5-rc1)
|
||||
```
|
||||
commit dc97391e661009eab46783030d2404c9b6e6f2e7
|
||||
Author: David Howells <dhowells@redhat.com>
|
||||
Date: Fri Jun 23 23:55:12 2023 +0100
|
||||
|
||||
sock: Remove ->sendpage*() in favour of sendmsg(MSG_SPLICE_PAGES)
|
||||
|
||||
|
||||
commit 0733ad8002916b9dbbbcfe6e92ad44d2657de1c1
|
||||
Author: Christoph Hellwig <hch@lst.de>
|
||||
Date: Thu Jun 8 13:02:58 2023 +0200
|
||||
|
||||
fs: remove the now unused FMODE_* flags
|
||||
```
|
||||
|
||||
This patch fix the build error.
|
||||
|
||||
---
|
||||
|
||||
diff -Nupr a/drbd/drbd_main.c b/drbd/drbd_main.c
|
||||
--- a/drbd/drbd_main.c 2023-09-26 11:08:57.142974614 +0800
|
||||
+++ b/drbd/drbd_main.c 2023-09-26 11:07:53.646071680 +0800
|
||||
@@ -2569,7 +2569,7 @@ enum ioc_rv {
|
||||
static enum ioc_rv inc_open_count(struct drbd_device *device, fmode_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;
|
||||
@@ -2695,12 +2695,12 @@ static int drbd_open(struct gendisk *gd,
|
||||
|
||||
if (mode & FMODE_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
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
diff -Nupr a/drbd/drbd_transport_tcp.c b/drbd/drbd_transport_tcp.c
|
||||
--- a/drbd/drbd_transport_tcp.c 2023-09-26 11:09:04.016333505 +0800
|
||||
+++ b/drbd/drbd_transport_tcp.c 2023-09-26 11:07:59.132758771 +0800
|
||||
@@ -1193,6 +1193,8 @@ static int dtt_send_page(struct drbd_tra
|
||||
struct drbd_tcp_transport *tcp_transport =
|
||||
container_of(transport, struct drbd_tcp_transport, transport);
|
||||
struct socket *socket = tcp_transport->stream[stream];
|
||||
+ struct msghdr msghdr = { .msg_flags = MSG_SPLICE_PAGES|msg_flags, };
|
||||
+ struct bio_vec bvec;
|
||||
int len = size;
|
||||
int err = -EIO;
|
||||
|
||||
@@ -1204,7 +1206,10 @@ static int dtt_send_page(struct drbd_tra
|
||||
do {
|
||||
int sent;
|
||||
|
||||
- sent = socket->ops->sendpage(socket, page, offset, len, msg_flags);
|
||||
+ //sent = socket->ops->sendpage(socket, page, offset, len, msg_flags);
|
||||
+ bvec_set_page(&bvec, page, offset, len);
|
||||
+ iov_iter_bvec(&msghdr.msg_iter, ITER_SOURCE, &bvec, 1, len);
|
||||
+ sent = sock_sendmsg(socket, &msghdr);
|
||||
if (sent <= 0) {
|
||||
if (sent == -EAGAIN) {
|
||||
if (drbd_stream_send_timed_out(transport, stream))
|
28
drbd.changes
28
drbd.changes
@ -1,3 +1,31 @@
|
||||
------------------------------------------------------------------
|
||||
Tue Sep 26 03:35:00 UTC 2023 - Heming Zhao <heming.zhao@suse.com>
|
||||
|
||||
- drbd: fix build error against kernel v6.5.4 (boo#1215699)
|
||||
* add upstream patch
|
||||
+ 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
|
||||
* add suse special patch
|
||||
+ bsc-1215699_fix-build-error-against-kernel-v6.5.4.patch
|
||||
|
||||
------------------------------------------------------------------
|
||||
Mon Sep 04 11:35:00 UTC 2023 - Heming Zhao <heming.zhao@suse.com>
|
||||
|
||||
|
54
drbd.spec
54
drbd.spec
@ -34,8 +34,33 @@ Source1: preamble
|
||||
Source2: Module.supported
|
||||
Source3: drbd_git_revision
|
||||
|
||||
Patch1: bsc-1025089_fix-resync-finished-with-syncs-have-bits-set.patch
|
||||
Patch99: suse-coccinelle.patch
|
||||
########################
|
||||
# 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
|
||||
# suse special patch
|
||||
Patch1001: bsc-1025089_fix-resync-finished-with-syncs-have-bits-set.patch
|
||||
Patch1002: suse-coccinelle.patch
|
||||
Patch1003: bsc-1215699_fix-build-error-against-kernel-v6.5.4.patch
|
||||
########################
|
||||
|
||||
#https://github.com/openSUSE/rpmlint-checks/blob/master/KMPPolicyCheck.py
|
||||
BuildRequires: coccinelle >= 1.0.8
|
||||
@ -70,8 +95,29 @@ installed kernel.
|
||||
|
||||
%prep
|
||||
%setup -q -n drbd-%{version}
|
||||
%patch1 -p1
|
||||
%patch99 -p1
|
||||
%patch0001 -p1
|
||||
%patch0002 -p1
|
||||
%patch0003 -p1
|
||||
%patch0004 -p1
|
||||
%patch0005 -p1
|
||||
%patch0006 -p1
|
||||
%patch0007 -p1
|
||||
%patch0008 -p1
|
||||
%patch0009 -p1
|
||||
%patch0010 -p1
|
||||
%patch0011 -p1
|
||||
%patch0012 -p1
|
||||
%patch0013 -p1
|
||||
%patch0014 -p1
|
||||
%patch0015 -p1
|
||||
%patch0016 -p1
|
||||
%patch0017 -p1
|
||||
%patch0018 -p1
|
||||
%patch0019 -p1
|
||||
%patch0020 -p1
|
||||
%patch1001 -p1
|
||||
%patch1002 -p1
|
||||
%patch1003 -p1
|
||||
|
||||
mkdir source
|
||||
cp -a drbd/. source/. || :
|
||||
|
Loading…
Reference in New Issue
Block a user