Accepting request 732597 from network:ha-clustering:Factory

OBS-URL: https://build.opensuse.org/request/show/732597
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/drbd?expand=0&rev=80
This commit is contained in:
Dominique Leuenberger 2019-09-23 10:46:32 +00:00 committed by Git OBS Bridge
commit 841aa96012
4 changed files with 87 additions and 80 deletions

View File

@ -1,3 +1,15 @@
-------------------------------------------------------------------
Wed Sep 20 08:22:12 UTC 2019 - nick wang <nwang@suse.com>
- bsc#1151579, fix collinelle default path and always trigger in obs
Add patch suse-coccinelle.patch
-------------------------------------------------------------------
Tue Sep 17 04:31:08 UTC 2019 - nwang@suse.com
- bsc#1146117, disallow dual primaries when not configured.
Modify patch rely-on-sb-handles.patch
-------------------------------------------------------------------
Tue Sep 10 07:45:05 UTC 2019 - Jan Engelhardt <jengelh@inai.de>

View File

@ -22,7 +22,6 @@
%define buildrt 1
%endif
%endif
Name: drbd
Version: 9.0.19~1+git.8e93a5d9
Release: 0
@ -37,11 +36,12 @@ Source2: Module.supported
Source3: drbd_git_revision
Patch1: fix-resync-finished-with-syncs-have-bits-set.patch
Patch2: rely-on-sb-handlers.patch
Patch3: suse-coccinelle.patch
#https://github.com/openSUSE/rpmlint-checks/blob/master/KMPPolicyCheck.py
BuildRequires: coccinelle
BuildRequires: kernel-source
BuildRequires: kernel-syms
BuildRequires: libelf-devel
#https://github.com/openSUSE/rpmlint-checks/blob/master/KMPPolicyCheck.py
BuildRequires: coccinelle
BuildRequires: modutils
Requires: drbd-utils >= 9.2.0
Supplements: drbd-utils >= 9.2.0
@ -61,7 +61,7 @@ raid 1. It is a building block for setting up clusters.
%package KMP
Summary: Kernel driver
Group: Productivity/Clustering/HA
Url: http://drbd.linbit.com/
URL: http://drbd.linbit.com/
%description KMP
This module is the kernel-dependent driver for DRBD. This is split out so
@ -72,6 +72,7 @@ installed kernel.
%setup -q -n drbd-%{version}
%patch1 -p1
%patch2 -p1
%patch3 -p1
mkdir source
cp -a drbd/. source/. || :
@ -85,13 +86,14 @@ ln -s ../scripts obj/
export WANT_DRBD_REPRODUCIBLE_BUILD=1
export CONFIG_BLK_DEV_DRBD=m
export EXTRA_CFLAGS='-DVERSION=\"%{version}\"'
export ALWAYS_WANT_SPATCH='yes'
for flavor in %{flavors_to_build}; do
rm -rf $flavor
cp -r source $flavor
cp %{_sourcedir}/Module.supported $flavor
export DRBDSRC="$PWD/obj/$flavor"
make -C %{kernel_source $flavor} modules M=$PWD/$flavor
make %{?_smp_mflags} -C %{kernel_source $flavor} modules M=$PWD/$flavor
#Check the compat result
cat $PWD/$flavor/compat.h
@ -109,7 +111,7 @@ ln -s -f %{_sbindir}/service %{buildroot}/%{_sbindir}/rc%{name}
rm -f drbd.conf
%files
%doc COPYING
%license COPYING
%doc ChangeLog
%{_sbindir}/rc%{name}

View File

@ -1,96 +1,45 @@
diff -Naur drbd-9.0.15+git.c46d2790.orig/drbd/drbd_state.c drbd-9.0.15+git.c46d2790/drbd/drbd_state.c
--- drbd-9.0.15+git.c46d2790.orig/drbd/drbd_state.c 2019-01-10 13:10:28.152414247 +0800
+++ drbd-9.0.15+git.c46d2790/drbd/drbd_state.c 2019-01-10 13:10:38.140407675 +0800
@@ -251,6 +251,27 @@
return rv;
}
+static bool is_sb_handlers_configured(struct drbd_connection *connection)
+{
+ bool configured = false;
+
+ enum drbd_after_sb_p after_sb_0p = -1;
+ enum drbd_after_sb_p after_sb_1p = -1;
+ enum drbd_after_sb_p after_sb_2p = -1;
+
+ after_sb_0p = rcu_dereference(connection->transport.net_conf)->after_sb_0p;
+ after_sb_1p = rcu_dereference(connection->transport.net_conf)->after_sb_1p;
+ after_sb_2p = rcu_dereference(connection->transport.net_conf)->after_sb_2p;
+
+ if (after_sb_2p != 0 || after_sb_0p != 0 || after_sb_1p != 0) {
+ drbd_info(connection, "Split-brain handler configured, rely on it.\n");
+ configured = true;
+ }
+
+ return configured;
+}
+
+
bool resource_is_suspended(struct drbd_resource *resource, enum which_state which)
{
bool rv = resource->susp_user[which] || resource->susp_nod[which];
@@ -1465,7 +1486,8 @@
if (!nc || nc->two_primaries)
continue;
if (connection->peer_role[NEW] == R_PRIMARY)
- return SS_TWO_PRIMARIES;
+ if (!is_sb_handlers_configured(connection))
+ return SS_TWO_PRIMARIES;
}
}
@@ -1500,10 +1522,10 @@
diff -Naur drbd-9.0.11+git.1e2bccdc.orig/drbd/drbd_state.c drbd-9.0.11+git.1e2bccdc/drbd/drbd_state.c
--- drbd-9.0.11+git.1e2bccdc.orig/drbd/drbd_state.c 2019-08-27 13:34:08.462567903 +0800
+++ drbd-9.0.11+git.1e2bccdc/drbd/drbd_state.c 2019-08-30 12:56:37.664186710 +0800
@@ -1398,8 +1398,13 @@
nc = rcu_dereference(connection->transport.net_conf);
two_primaries = nc ? nc->two_primaries : false;
if (peer_role[NEW] == R_PRIMARY && peer_role[OLD] != R_PRIMARY && !two_primaries) {
- if (role[NOW] == R_PRIMARY)
+ if (role[NOW] == R_PRIMARY && !is_sb_handlers_configured(connection))
return SS_TWO_PRIMARIES;
- return SS_TWO_PRIMARIES;
+ if (role[NOW] == R_PRIMARY) {
+ if (role[OLD] == R_PRIMARY && connection->cstate[OLD] < C_CONNECTED) {
+ drbd_info(connection, "Two primaries but not allowed. Rely on split brain handler or to disconnect.\n");
+ } else {
+ return SS_TWO_PRIMARIES;
+ }
+ }
idr_for_each_entry(&resource->devices, device, vnr) {
- if (device->open_ro_cnt)
+ if (device->open_ro_cnt && !is_sb_handlers_configured(connection))
if (device->open_ro_cnt)
return SS_PRIMARY_READER;
}
}
@@ -3785,8 +3807,10 @@
@@ -3665,7 +3670,11 @@
mask = NODE_MASK(connection->peer_node_id);
if ((resource->twopc_reply.primary_nodes & mask) &&
!(connection->transport.net_conf->two_primaries)) {
- rv = SS_TWO_PRIMARIES;
- break;
+ if (!is_sb_handlers_configured(connection)){
+ if (connection->cstate[OLD] < C_CONNECTED && connection->cstate[NEW] == C_CONNECTED) {
+ drbd_info(connection, "Two primaries but not allowed after reconnected. Rely on split brain handler or to disconnect.\n");
+ } else {
+ rv = SS_TWO_PRIMARIES;
+ break;
+ }
break;
}
}
rcu_read_unlock();
@@ -3829,10 +3853,13 @@
rcu_read_lock();
nc = rcu_dereference(connection->transport.net_conf);
two_primaries = nc ? nc->two_primaries : false;
- rcu_read_unlock();
- if (!two_primaries)
+ if (!two_primaries && !is_sb_handlers_configured(connection)) {
+ rcu_read_unlock();
return SS_TWO_PRIMARIES;
+ }
+
+ rcu_read_unlock();
}
return SS_SUCCESS;
@@ -3859,8 +3886,10 @@
@@ -3739,7 +3748,11 @@
nc = rcu_dereference(connection->transport.net_conf);
if (!nc->two_primaries &&
NODE_MASK(connection->peer_node_id) & reply->primary_nodes) {
- rv = SS_PRIMARY_READER;
- break;
+ if (!is_sb_handlers_configured(connection)){
+ if (connection->cstate[OLD] < C_CONNECTED && connection->cstate[NEW] == C_CONNECTED) {
+ drbd_info(connection, "Two primaries and device is opened as read only. Rely on split brain handler or to disconnect.\n");
+ } else {
+ rv = SS_PRIMARY_READER;
+ break;
+ }
break;
}
}
rcu_read_unlock();

44
suse-coccinelle.patch Normal file
View File

@ -0,0 +1,44 @@
diff -Naur drbd-9.0.19~1+git.8e93a5d9.orig/drbd/Makefile drbd-9.0.19~1+git.8e93a5d9/drbd/Makefile
--- drbd-9.0.19~1+git.8e93a5d9.orig/drbd/Makefile 2019-09-23 13:27:35.397783666 +0800
+++ drbd-9.0.19~1+git.8e93a5d9/drbd/Makefile 2019-09-23 13:30:43.378710223 +0800
@@ -170,6 +170,9 @@
ifeq ($(DRBD_BUILD_FROM_GIT),yes)
sources := $(filter-out drbd_strings.c drbd_buildtag.c,$(wildcard *.c))
sources += $(wildcard drbd-headers/linux/*.h)
+else ifeq ($(ALWAYS_WANT_SPATCH),yes)
+ sources := $(filter-out drbd_strings.c drbd_buildtag.c,$(wildcard *.c))
+ sources += $(wildcard drbd-headers/linux/*.h)
else
sources :=
endif
@@ -196,9 +199,27 @@
fi \
done
@echo " SPATCH $(chksum)"
- @spatch --sp-file $(incdir)/.compat.cocci \
- $(sources) \
- --macro-file drbd-kernel-compat/cocci_macros.h > $@.tmp 2> $(incdir)/.spatch.stderr
+ $(eval libpath := $(shell rpm -ql coccinelle|grep standard.h|xargs dirname))
+ @echo " sources: $(sources)"
+ @echo " libpath: $(libpath)"
+ @touch $@.tmp
+ @if [ -e $(incdir)/.compat.cocci ]; then \
+ echo " GENCOCCIRULES .compat.cocci"; \
+ cat $(incdir)/.compat.cocci; \
+ spatch --sp-file $(incdir)/.compat.cocci \
+ $(sources) \
+ --macro-file drbd-kernel-compat/cocci_macros.h \
+ --macro-file-builtins $(libpath)/standard.h \
+ --iso-file $(libpath)/standard.iso >> $@.tmp 2> $(incdir)/.spatch.stderr; \
+ fi
+ @if [ -e $@.tmp ]; then \
+ echo " GENSPATCHFILE $@.tmp"; \
+ cat $@.tmp; \
+ fi
+ @if [ -e $(incdir)/.spatch.stderr ]; then \
+ echo " GENSPATCHERR .spatch.stderr"; \
+ cat $(incdir)/.spatch.stderr; \
+ fi
@if [ -e $(incdir)/.compat.patch ]; then \
cat $(incdir)/.compat.patch >> $@.tmp; \
fi