Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package libdlm for openSUSE:Factory checked 
in at 2023-09-21 22:13:30
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/libdlm (Old)
 and      /work/SRC/openSUSE:Factory/.libdlm.new.1770 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "libdlm"

Thu Sep 21 22:13:30 2023 rev:57 rq:1112458 version:4.2.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/libdlm/libdlm.changes    2023-09-15 
22:04:18.638637077 +0200
+++ /work/SRC/openSUSE:Factory/.libdlm.new.1770/libdlm.changes  2023-09-21 
22:14:03.857302399 +0200
@@ -1,0 +2,50 @@
+Wed Sep 20 02:59:00 UTC 2023 - heming.z...@suse.com
+
+- update libdlm to latest code (e5ca08c20e6f) (jsc#PED-6362)
+  * remove patches which replaced by upstream patch
+    - 0007-Revert-treewide-add-fcf-protection-full-to-CFLAGS.patch
+
+  * change patch name
+    - 0006-dlm_controld-remove-unnecessary-header-include.patch
+    + bug-1212767-dlm_controld-remove-unnecessary-header-include.patch
+
+  * add upstream patch
+    + 0001-Revert-treewide-add-fcf-protection-full-to-CFLAGS.patch
+    + 0002-dlm_controld-increase-uevent-recv-buffer.patch
+    + 0003-dlm_controld-constify-lsnames.patch
+    + 0004-dlm_controld-better-uevent-filtering.patch
+    + 0005-libdlm_lt-fix-pc-file.patch
+    + 0006-dlm_tool-add-fail-functionality-if-dump-failed.patch
+    + 0007-dlm_controld-always-create-logdir.patch
+    + 0008-dlm_controld-move-processing-of-saved-messages-to-pl.patch
+    + 0009-dlm_controld-remove-ls-parameter.patch
+    + 0010-dlm_controld-constify-timeval-of-dt_usec.patch
+    + 0011-dlm_controld-add-gcc-format-printf-attribute-to-log_.patch
+    + 0012-dlm_controld-use-write_result.patch
+    + 0013-dlm_controld-be-sure-we-stop-lockspaces-before-shutd.patch
+    + 0014-dlm_controld-constify-name_in-in-log_level.patch
+    + 0015-dlm_controld-initialize-waiter-flags.patch
+    + 0016-dlm_controld-get-rid-of-unnecessary-memset.patch
+    + 0017-dlm_controld-remove-unnecessary-list_empty-check.patch
+    + 0018-dlm_controld-set-posix_lock-flags-to-zero.patch
+    + 0019-dlm_controld-init-plocks_data-to-zero.patch
+    + 0020-dlm_tool-fix-missing-fclose-calls.patch
+
+  * WHAT'S NEW for this update
+    + dlm_tool: fix missing fclose calls
+    + dlm_controld: init plocks_data to zero
+    + dlm_controld: set posix_lock flags to zero
+    + dlm_controld: remove unnecessary list_empty check
+    + dlm_controld: get rid of unnecessary memset
+    + dlm_controld: initialize waiter->flags
+    + dlm_controld: be sure we stop lockspaces before shutdown
+    + dlm_controld: use write_result()
+    + dlm_controld: remove ls parameter
+    + dlm_controld: move processing of saved messages to plock level
+    + dlm_controld: always create logdir
+    + dlm_tool: add fail functionality if dump failed
+    + libdlm_lt: fix pc file
+    + dlm_controld: better uevent filtering
+    + dlm_controld: increase uevent recv buffer
+
+-------------------------------------------------------------------

Old:
----
  0006-dlm_controld-remove-unnecessary-header-include.patch
  0007-Revert-treewide-add-fcf-protection-full-to-CFLAGS.patch

New:
----
  0001-Revert-treewide-add-fcf-protection-full-to-CFLAGS.patch
  0002-dlm_controld-increase-uevent-recv-buffer.patch
  0003-dlm_controld-constify-lsnames.patch
  0004-dlm_controld-better-uevent-filtering.patch
  0005-libdlm_lt-fix-pc-file.patch
  0006-dlm_tool-add-fail-functionality-if-dump-failed.patch
  0007-dlm_controld-always-create-logdir.patch
  0008-dlm_controld-move-processing-of-saved-messages-to-pl.patch
  0009-dlm_controld-remove-ls-parameter.patch
  0010-dlm_controld-constify-timeval-of-dt_usec.patch
  0011-dlm_controld-add-gcc-format-printf-attribute-to-log_.patch
  0012-dlm_controld-use-write_result.patch
  0013-dlm_controld-be-sure-we-stop-lockspaces-before-shutd.patch
  0014-dlm_controld-constify-name_in-in-log_level.patch
  0015-dlm_controld-initialize-waiter-flags.patch
  0016-dlm_controld-get-rid-of-unnecessary-memset.patch
  0017-dlm_controld-remove-unnecessary-list_empty-check.patch
  0018-dlm_controld-set-posix_lock-flags-to-zero.patch
  0019-dlm_controld-init-plocks_data-to-zero.patch
  0020-dlm_tool-fix-missing-fclose-calls.patch
  bug-1212767-dlm_controld-remove-unnecessary-header-include.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ libdlm.spec ++++++
--- /var/tmp/diff_new_pack.1NXhuE/_old  2023-09-21 22:14:05.529363084 +0200
+++ /var/tmp/diff_new_pack.1NXhuE/_new  2023-09-21 22:14:05.529363084 +0200
@@ -38,17 +38,41 @@
 Release:        0
 URL:            https://pagure.io/dlm/
 Source:         https://releases.pagure.org/dlm/dlm-%{version}.tar.gz
+
+##################
+#upstream patch
+Patch0001:      0001-Revert-treewide-add-fcf-protection-full-to-CFLAGS.patch
+Patch0002:      0002-dlm_controld-increase-uevent-recv-buffer.patch
+Patch0003:      0003-dlm_controld-constify-lsnames.patch
+Patch0004:      0004-dlm_controld-better-uevent-filtering.patch
+Patch0005:      0005-libdlm_lt-fix-pc-file.patch
+Patch0006:      0006-dlm_tool-add-fail-functionality-if-dump-failed.patch
+Patch0007:      0007-dlm_controld-always-create-logdir.patch
+Patch0008:      0008-dlm_controld-move-processing-of-saved-messages-to-pl.patch
+Patch0009:      0009-dlm_controld-remove-ls-parameter.patch
+Patch0010:      0010-dlm_controld-constify-timeval-of-dt_usec.patch
+Patch0011:      0011-dlm_controld-add-gcc-format-printf-attribute-to-log_.patch
+Patch0012:      0012-dlm_controld-use-write_result.patch
+Patch0013:      0013-dlm_controld-be-sure-we-stop-lockspaces-before-shutd.patch
+Patch0014:      0014-dlm_controld-constify-name_in-in-log_level.patch
+Patch0015:      0015-dlm_controld-initialize-waiter-flags.patch
+Patch0016:      0016-dlm_controld-get-rid-of-unnecessary-memset.patch
+Patch0017:      0017-dlm_controld-remove-unnecessary-list_empty-check.patch
+Patch0018:      0018-dlm_controld-set-posix_lock-flags-to-zero.patch
+Patch0019:      0019-dlm_controld-init-plocks_data-to-zero.patch
+Patch0020:      0020-dlm_tool-fix-missing-fclose-calls.patch
+
 # suse special patch
-Patch101:       0001-makefile-for-diff-arch.patch
-Patch102:       0002-remove-sd-notify.patch
-Patch103:       0003-bnc#874705-nodes-without-quorum.patch
-Patch104:       0004-man-dlm.conf-add-note-that-the-file-is-not-creat.patch
-Patch105:       
bug-1191734_0015-Revert-dlm_controld-add-version-check-for-libquorum.patch
-Patch106:       
bug-1191734_0016-Revert-dlm_controld-use-new-quorum-api-to-detect-mis.patch
-Patch107:       0005-build-dlm_controld-disable-annobin-plugin.patch
-Patch108:       0006-dlm_controld-remove-unnecessary-header-include.patch
-Patch109:       0007-Revert-treewide-add-fcf-protection-full-to-CFLAGS.patch
-###################
+Patch1001:      0001-makefile-for-diff-arch.patch
+Patch1002:      0002-remove-sd-notify.patch
+Patch1003:      0003-bnc#874705-nodes-without-quorum.patch
+Patch1004:      0004-man-dlm.conf-add-note-that-the-file-is-not-creat.patch
+Patch1005:      
bug-1191734_0015-Revert-dlm_controld-add-version-check-for-libquorum.patch
+Patch1006:      
bug-1191734_0016-Revert-dlm_controld-use-new-quorum-api-to-detect-mis.patch
+Patch1007:      0005-build-dlm_controld-disable-annobin-plugin.patch
+Patch1008:      
bug-1212767-dlm_controld-remove-unnecessary-header-include.patch
+##################
+
 BuildRequires:  fdupes
 BuildRequires:  glib2-devel
 BuildRequires:  libcorosync-devel
@@ -68,8 +92,8 @@
 # libdlm2 (openSUSE 11.2) also contained libdlm*.so.3
 License:        GPL-2.0-only AND GPL-2.0-or-later AND LGPL-2.1-or-later
 Group:          System/Libraries
-Obsoletes:      libdlm2
-Conflicts:      libdlm2
+Obsoletes:      libdlm2 < 2.99
+Conflicts:      libdlm2 < 2.99
 
 %description -n libdlm3
 Libraries and tools that allow applications, particularly filesystems

++++++ 0007-Revert-treewide-add-fcf-protection-full-to-CFLAGS.patch -> 
0001-Revert-treewide-add-fcf-protection-full-to-CFLAGS.patch ++++++
--- 
/work/SRC/openSUSE:Factory/libdlm/0007-Revert-treewide-add-fcf-protection-full-to-CFLAGS.patch
      2023-06-30 19:57:58.473323111 +0200
+++ 
/work/SRC/openSUSE:Factory/.libdlm.new.1770/0001-Revert-treewide-add-fcf-protection-full-to-CFLAGS.patch
    2023-09-21 22:14:03.569291947 +0200
@@ -1,7 +1,7 @@
 From 4cfb7b21a88f0ae32d97ea4cbb0c7419b88f397d Mon Sep 17 00:00:00 2001
 From: Alexander Aring <aahri...@redhat.com>
 Date: Wed, 12 Oct 2022 12:44:03 -0400
-Subject: [PATCH] Revert "treewide: add -fcf-protection=full to CFLAGS"
+Subject: [PATCH 01/24] Revert "treewide: add -fcf-protection=full to CFLAGS"
 
 This reverts commit 215aedf1fdff58c62fe596284948590965acc85c.
 ---
@@ -12,7 +12,7 @@
  4 files changed, 5 insertions(+), 5 deletions(-)
 
 diff --git a/dlm_controld/Makefile b/dlm_controld/Makefile
-index ec8c360c..9cf7152f 100644
+index ec8c360cc853..9cf7152f60ab 100644
 --- a/dlm_controld/Makefile
 +++ b/dlm_controld/Makefile
 @@ -43,7 +43,7 @@ CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
@@ -25,7 +25,7 @@
  BIN_CFLAGS += $(CFLAGS) -fPIE -DPIE
  BIN_CFLAGS += -I../include -I../libdlm
 diff --git a/dlm_tool/Makefile b/dlm_tool/Makefile
-index 57629c73..1c3d61d5 100644
+index 57629c731771..1c3d61d5c860 100644
 --- a/dlm_tool/Makefile
 +++ b/dlm_tool/Makefile
 @@ -15,7 +15,7 @@ CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
@@ -38,7 +38,7 @@
  CFLAGS += -fPIE -DPIE
  CFLAGS += -I../include -I../libdlm -I../dlm_controld
 diff --git a/fence/Makefile b/fence/Makefile
-index 446f4eaa..ee4dfb88 100644
+index 446f4eaac9f9..ee4dfb886d4c 100644
 --- a/fence/Makefile
 +++ b/fence/Makefile
 @@ -15,7 +15,7 @@ CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
@@ -51,7 +51,7 @@
  CFLAGS += -fPIE -DPIE
  CFLAGS += -I../include
 diff --git a/libdlm/Makefile b/libdlm/Makefile
-index 823fdaa9..5069ccf1 100644
+index 823fdaa94073..5069ccf1f7f9 100644
 --- a/libdlm/Makefile
 +++ b/libdlm/Makefile
 @@ -80,8 +80,8 @@ CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
@@ -66,5 +66,5 @@
  LIB_LDFLAGS += $(LDFLAGS) -lpthread -Wl,-z,now
  LLT_LDFLAGS += $(LDFLAGS) -Wl,-z,now
 -- 
-2.41.0
+2.35.3
 

++++++ 0002-dlm_controld-increase-uevent-recv-buffer.patch ++++++
>From 07954ba55352bb07fb9d80f0d886ef4448038847 Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahri...@redhat.com>
Date: Mon, 16 Jan 2023 14:30:36 -0500
Subject: [PATCH 02/24] dlm_controld: increase uevent recv buffer

This patch increases the uevent recv buffer from 256 bytes to 4096
bytes. To ensure everything fits into one recv() call.
---
 dlm_controld/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dlm_controld/main.c b/dlm_controld/main.c
index 7cf6348e1a96..2c534a1e0ad1 100644
--- a/dlm_controld/main.c
+++ b/dlm_controld/main.c
@@ -682,7 +682,7 @@ const char *dlm_mode_str(int mode)
 
 /* recv "online" (join) and "offline" (leave) messages from dlm via uevents */
 
-#define MAX_LINE_UEVENT 256
+#define MAX_LINE_UEVENT 4096
 
 static void process_uevent(int ci)
 {
-- 
2.35.3


++++++ 0003-dlm_controld-constify-lsnames.patch ++++++
>From 9466d5a56c27bbf5af479412dd8f55990fad889a Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahri...@redhat.com>
Date: Mon, 16 Jan 2023 14:31:42 -0500
Subject: [PATCH 03/24] dlm_controld: constify lsnames

This patch constify some ls name parameter which are used read only in
ls_create() and ls_find().
---
 dlm_controld/dlm_daemon.h | 2 +-
 dlm_controld/main.c       | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/dlm_controld/dlm_daemon.h b/dlm_controld/dlm_daemon.h
index b829e0de421a..f0bad90fd699 100644
--- a/dlm_controld/dlm_daemon.h
+++ b/dlm_controld/dlm_daemon.h
@@ -479,7 +479,7 @@ int client_add(int fd, void (*workfn)(int ci), void 
(*deadfn)(int ci));
 int client_fd(int ci);
 void client_ignore(int ci, int fd);
 void client_back(int ci, int fd);
-struct lockspace *find_ls(char *name);
+struct lockspace *find_ls(const char *name);
 struct lockspace *find_ls_id(uint32_t id);
 const char *dlm_mode_str(int mode);
 void cluster_dead(int ci);
diff --git a/dlm_controld/main.c b/dlm_controld/main.c
index 2c534a1e0ad1..31489d544d93 100644
--- a/dlm_controld/main.c
+++ b/dlm_controld/main.c
@@ -537,7 +537,7 @@ static int check_run_operation(char *uuid_str, uint32_t 
flags, struct dlmc_run_c
        return 0;
 }
 
-static struct lockspace *create_ls(char *name)
+static struct lockspace *create_ls(const char *name)
 {
        struct lockspace *ls;
 
@@ -562,7 +562,7 @@ static struct lockspace *create_ls(char *name)
        return ls;
 }
 
-struct lockspace *find_ls(char *name)
+struct lockspace *find_ls(const char *name)
 {
        struct lockspace *ls;
 
-- 
2.35.3


++++++ 0004-dlm_controld-better-uevent-filtering.patch ++++++
>From 7ca6eca5b22ff8eead036516ae3285243671eba4 Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahri...@redhat.com>
Date: Fri, 13 Jan 2023 17:33:31 -0500
Subject: [PATCH 04/24] dlm_controld: better uevent filtering

When I did test with dlm_locktorture module I got several log messages
about:

uevent message has 3 args: add@/module/dlm_locktorture
uevent message has 3 args: remove@/module/dlm_locktorture

which are not expected and not able to parse by dlm_controld
process_uevent() function, because mismatch of argument counts.
Debugging it more, I figured out that those uevents are for
loading/unloading the dlm_locktorture module and there are uevents for
loading and unloading modules which have nothing todo with dlm lockspace
uevent handling.

The current filter works as:

if (!strstr(buf, "dlm"))

for matching the dlm joining/leaving uevent string which looks like:

offline@/kernel/dlm/locktorture

to avoid matching with other uevent which has somehow the string "dlm"
in it, we switch to the match the uevent env variables for action,
devpath (just to check if it's set) and subsystem. Additional the dlm
subsystem sets the LOCKSPACE variable which can be used to get the
lockspace name instead of extracting it previously from the devpath.

The code to decode the uevent envs were taken from the gfs2_controld
utility [0].

[0] 
https://github.com/andyprice/gfs2-utils/blob/91c3e9a69ed70d3d522f5b47015da5e5868722ec/group/gfs_controld/main.c
---
 dlm_controld/main.c | 126 +++++++++++++++++++++++++-------------------
 1 file changed, 71 insertions(+), 55 deletions(-)

diff --git a/dlm_controld/main.c b/dlm_controld/main.c
index 31489d544d93..c9d1c5f148db 100644
--- a/dlm_controld/main.c
+++ b/dlm_controld/main.c
@@ -46,6 +46,50 @@ struct client {
        struct lockspace *ls;
 };
 
+enum {
+       Env_ACTION = 0,
+       Env_DEVPATH,
+       Env_SUBSYSTEM,
+       Env_LOCKSPACE,
+       Env_Last, /* Flag for end of vars */
+};
+
+static const char *uevent_vars[] = {
+       [Env_ACTION]            = "ACTION=",
+       [Env_DEVPATH]           = "DEVPATH=",
+       [Env_SUBSYSTEM]         = "SUBSYSTEM=",
+       [Env_LOCKSPACE]         = "LOCKSPACE=",
+};
+
+static void decode_uevent(const char *buf, unsigned len, const char *vars[],
+                         unsigned nvars, const char *vals[])
+{
+       const char *ptr;
+       unsigned int i;
+       int slen, vlen;
+
+       memset(vals, 0, sizeof(const char *) * nvars);
+
+       while (len > 0) {
+               ptr = buf;
+               slen = strlen(ptr);
+               buf += slen;
+               len -= slen;
+               buf++;
+               len--;
+
+               for (i = 0; i < nvars; i++) {
+                       vlen = strlen(vars[i]);
+                       if (vlen > slen)
+                               continue;
+                       if (memcmp(vars[i], ptr, vlen) != 0)
+                               continue;
+                       vals[i] = ptr + vlen;
+                       break;
+               }
+       }
+}
+
 int do_read(int fd, void *buf, size_t count)
 {
        int rv, off = 0;
@@ -627,38 +671,6 @@ static void fs_register_del(char *name)
        }
 }
 
-#define MAXARGS 8
-
-static char *get_args(char *buf, int *argc, char **argv, char sep, int want)
-{
-       char *p = buf, *rp = NULL;
-       int i;
-
-       argv[0] = p;
-
-       for (i = 1; i < MAXARGS; i++) {
-               p = strchr(buf, sep);
-               if (!p)
-                       break;
-               *p = '\0';
-
-               if (want == i) {
-                       rp = p + 1;
-                       break;
-               }
-
-               argv[i] = p + 1;
-               buf = p + 1;
-       }
-       *argc = i;
-
-       /* we ended by hitting \0, return the point following that */
-       if (!rp)
-               rp = strchr(buf, '\0') + 1;
-
-       return rp;
-}
-
 const char *dlm_mode_str(int mode)
 {
        switch (mode) {
@@ -686,13 +698,12 @@ const char *dlm_mode_str(int mode)
 
 static void process_uevent(int ci)
 {
+       const char *uevent_vals[Env_Last];
        struct lockspace *ls;
        char buf[MAX_LINE_UEVENT];
-       char *argv[MAXARGS], *act, *sys;
-       int rv, argc = 0;
+       int rv;
 
        memset(buf, 0, sizeof(buf));
-       memset(argv, 0, sizeof(char *) * MAXARGS);
 
  retry_recv:
        rv = recv(client[ci].fd, &buf, sizeof(buf), 0);
@@ -704,35 +715,38 @@ static void process_uevent(int ci)
                return;
        }
 
-       if (!strstr(buf, "dlm"))
-               return;
+       decode_uevent(buf, rv, uevent_vars, Env_Last, uevent_vals);
 
-       log_debug("uevent: %s", buf);
-
-       get_args(buf, &argc, argv, '/', 4);
-       if (argc != 4)
-               log_error("uevent message has %d args", argc);
-       act = argv[0];
-       sys = argv[2];
-
-       if (!act || !sys || !argv[3])
+       if (!uevent_vals[Env_ACTION] ||
+           !uevent_vals[Env_DEVPATH] ||
+           !uevent_vals[Env_SUBSYSTEM] ||
+           !uevent_vals[Env_LOCKSPACE]) {
+               log_debug("failed to validate uevent, action: %p, devpath: %p, 
subsystem: %p, lockspace: %p",
+                         uevent_vals[Env_ACTION], uevent_vals[Env_DEVPATH],
+                         uevent_vals[Env_SUBSYSTEM],
+                         uevent_vals[Env_LOCKSPACE]);
                return;
+       }
 
-       if (strncmp(sys, "dlm", 3))
+       if (strcmp(uevent_vals[Env_SUBSYSTEM], "dlm")) {
+               log_debug("uevent looks like dlm but came not from dlm 
subsystem");
                return;
+       }
 
-       log_debug("kernel: %s %s", act, argv[3]);
+       log_debug("uevent action: %s, devpath: %s, devpath: %s, lockspace: %s",
+                 uevent_vals[Env_ACTION], uevent_vals[Env_SUBSYSTEM],
+                 uevent_vals[Env_DEVPATH], uevent_vals[Env_LOCKSPACE]);
 
        rv = 0;
 
-       if (!strcmp(act, "online@")) {
-               ls = find_ls(argv[3]);
+       if (!strcmp(uevent_vals[Env_ACTION], "online")) {
+               ls = find_ls(uevent_vals[Env_LOCKSPACE]);
                if (ls) {
                        rv = -EEXIST;
                        goto out;
                }
 
-               ls = create_ls(argv[3]);
+               ls = create_ls(uevent_vals[Env_LOCKSPACE]);
                if (!ls) {
                        rv = -ENOMEM;
                        goto out;
@@ -747,8 +761,8 @@ static void process_uevent(int ci)
                        goto out;
                }
 
-       } else if (!strcmp(act, "offline@")) {
-               ls = find_ls(argv[3]);
+       } else if (!strcmp(uevent_vals[Env_ACTION], "offline")) {
+               ls = find_ls(uevent_vals[Env_LOCKSPACE]);
                if (!ls) {
                        rv = -ENOENT;
                        goto out;
@@ -758,8 +772,10 @@ static void process_uevent(int ci)
        }
  out:
        if (rv < 0)
-               log_error("process_uevent %s error %d errno %d",
-                         act, rv, errno);
+               log_error("%s action: %s, devpath: %s, devpath: %s, lockspace: 
%s - error %d errno %d",
+                         __func__, uevent_vals[Env_ACTION],
+                         uevent_vals[Env_SUBSYSTEM], uevent_vals[Env_DEVPATH],
+                         uevent_vals[Env_LOCKSPACE], rv, errno);
 }
 
 static int setup_uevent(void)
-- 
2.35.3


++++++ 0005-libdlm_lt-fix-pc-file.patch ++++++
>From f1b2adb5b76c2ba80ddfb84a9929ef7bbb9768ef Mon Sep 17 00:00:00 2001
From: David Teigland <teigl...@redhat.com>
Date: Fri, 17 Feb 2023 10:07:12 -0600
Subject: [PATCH 05/24] libdlm_lt: fix pc file

---
 libdlm/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libdlm/Makefile b/libdlm/Makefile
index 5069ccf1f7f9..918fb46eeb0c 100644
--- a/libdlm/Makefile
+++ b/libdlm/Makefile
@@ -108,7 +108,7 @@ $(LIB_PC): $(LIB_PCIN)
        cat $(LIB_PCIN) | sed -e 
's#@PREFIX@#$(PREFIX)#g;s#@LIBDIR@#$(LIBDIR)#g' > $@
 
 $(LLT_PC): $(LLT_PCIN)
-       cat $(LIB_PCIN) | sed -e 
's#@PREFIX@#$(PREFIX)#g;s#@LIBDIR@#$(LIBDIR)#g' > $@
+       cat $(LLT_PCIN) | sed -e 
's#@PREFIX@#$(PREFIX)#g;s#@LIBDIR@#$(LIBDIR)#g' > $@
 
 clean:
        rm -f *.o *.so *.so.* *.a *.pc
-- 
2.35.3


++++++ 0006-dlm_tool-add-fail-functionality-if-dump-failed.patch ++++++
>From 5549d522c33c8ef8a5a480e6e5a63af4a7c452d3 Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahri...@redhat.com>
Date: Fri, 27 Jan 2023 10:27:04 -0500
Subject: [PATCH 06/24] dlm_tool: add fail functionality if dump failed

Currently dlm_controld sets a embedded data int value of dlm_controld
dump functionality failed for e.g. if lockspace cannot be found. The
dlm_tool does not parse this possible error functionality and will exit
successfully. This patch will add dlm_tool fail functionality if
dlm_controld sets an embedded data error value.
---
 dlm_controld/lib.c           | 25 +++++++++-------
 dlm_controld/libdlmcontrol.h | 10 +++----
 dlm_tool/main.c              | 57 +++++++++++++++++++++++++++---------
 3 files changed, 62 insertions(+), 30 deletions(-)

diff --git a/dlm_controld/lib.c b/dlm_controld/lib.c
index 2888ad058707..a21150f222c1 100644
--- a/dlm_controld/lib.c
+++ b/dlm_controld/lib.c
@@ -109,7 +109,7 @@ static void init_header(struct dlmc_header *h, int cmd, 
char *name,
 
 static char copy_buf[DLMC_DUMP_SIZE];
 
-static int do_dump(int cmd, char *name, char *buf)
+static int do_dump(int cmd, char *name, char *buf, int *data)
 {
        struct dlmc_header h;
        int fd, rv, len;
@@ -118,6 +118,8 @@ static int do_dump(int cmd, char *name, char *buf)
 
        init_header(&h, cmd, name, 0);
 
+       *data = 0;
+
        fd = do_connect(DLMC_QUERY_SOCK_PATH);
        if (fd < 0) {
                rv = fd;
@@ -134,6 +136,7 @@ static int do_dump(int cmd, char *name, char *buf)
        if (rv < 0)
                goto out_close;
 
+       *data = h.data;
        len = h.len - sizeof(h);
 
        if (len <= 0 || len > DLMC_DUMP_SIZE)
@@ -150,29 +153,29 @@ static int do_dump(int cmd, char *name, char *buf)
        return rv;
 }
 
-int dlmc_dump_debug(char *buf)
+int dlmc_dump_debug(char *buf, int *data)
 {
-       return do_dump(DLMC_CMD_DUMP_DEBUG, NULL, buf);
+       return do_dump(DLMC_CMD_DUMP_DEBUG, NULL, buf, data);
 }
 
-int dlmc_dump_config(char *buf)
+int dlmc_dump_config(char *buf, int *data)
 {
-       return do_dump(DLMC_CMD_DUMP_CONFIG, NULL, buf);
+       return do_dump(DLMC_CMD_DUMP_CONFIG, NULL, buf, data);
 }
 
-int dlmc_dump_log_plock(char *buf)
+int dlmc_dump_log_plock(char *buf, int *data)
 {
-       return do_dump(DLMC_CMD_DUMP_LOG_PLOCK, NULL, buf);
+       return do_dump(DLMC_CMD_DUMP_LOG_PLOCK, NULL, buf, data);
 }
 
-int dlmc_dump_plocks(char *name, char *buf)
+int dlmc_dump_plocks(char *name, char *buf, int *data)
 {
-       return do_dump(DLMC_CMD_DUMP_PLOCKS, name, buf);
+       return do_dump(DLMC_CMD_DUMP_PLOCKS, name, buf, data);
 }
 
-int dlmc_dump_run(char *buf)
+int dlmc_dump_run(char *buf, int *data)
 {
-       return do_dump(DLMC_CMD_DUMP_RUN, NULL, buf);
+       return do_dump(DLMC_CMD_DUMP_RUN, NULL, buf, data);
 }
 
 int dlmc_reload_config(void)
diff --git a/dlm_controld/libdlmcontrol.h b/dlm_controld/libdlmcontrol.h
index a8654f3ec90f..08f04c39f287 100644
--- a/dlm_controld/libdlmcontrol.h
+++ b/dlm_controld/libdlmcontrol.h
@@ -80,11 +80,11 @@ struct dlmc_lockspace {
 
 #define DLMC_STATUS_VERBOSE    0x00000001
 
-int dlmc_dump_debug(char *buf);
-int dlmc_dump_config(char *buf);
-int dlmc_dump_run(char *buf);
-int dlmc_dump_log_plock(char *buf);
-int dlmc_dump_plocks(char *name, char *buf);
+int dlmc_dump_debug(char *buf, int *data);
+int dlmc_dump_config(char *buf, int *data);
+int dlmc_dump_run(char *buf, int *data);
+int dlmc_dump_log_plock(char *buf, int *data);
+int dlmc_dump_plocks(char *name, char *buf, int *data);
 int dlmc_lockspace_info(char *lsname, struct dlmc_lockspace *ls);
 int dlmc_node_info(char *lsname, int nodeid, struct dlmc_node *node);
 /* caller need to free *lss */
diff --git a/dlm_tool/main.c b/dlm_tool/main.c
index 50f0cae91560..52fd5b8974b8 100644
--- a/dlm_tool/main.c
+++ b/dlm_tool/main.c
@@ -1466,36 +1466,51 @@ static void do_fence_ack(char *name)
        dlmc_fence_ack(name);
 }
 
-static void do_plocks(char *name)
+static int do_plocks(char *name)
 {
        char buf[DLMC_DUMP_SIZE];
+       int rv, data;
 
        memset(buf, 0, sizeof(buf));
 
-       dlmc_dump_plocks(name, buf);
+       rv = dlmc_dump_plocks(name, buf, &data);
+       if (rv)
+               return rv;
+       else if (data)
+               return data;
 
        buf[DLMC_DUMP_SIZE-1] = '\0';
 
        do_write(STDOUT_FILENO, buf, strlen(buf));
+
+       return 0;
 }
 
-static void do_dump(int op)
+static int do_dump(int op)
 {
+       int rv = -EOPNOTSUPP, data;
        char buf[DLMC_DUMP_SIZE];
 
        memset(buf, 0, sizeof(buf));
 
        if (op == OP_DUMP)
-               dlmc_dump_debug(buf);
+               rv = dlmc_dump_debug(buf, &data);
        else if (op == OP_DUMP_CONFIG)
-               dlmc_dump_config(buf);
+               rv = dlmc_dump_config(buf, &data);
        else if (op == OP_DUMP_RUN)
-               dlmc_dump_run(buf);
+               rv = dlmc_dump_run(buf, &data);
+
+       if (rv)
+               return rv;
+       else if (data)
+               return data;
 
        buf[DLMC_DUMP_SIZE-1] = '\0';
 
        do_write(STDOUT_FILENO, buf, strlen(buf));
        printf("\n");
+
+       return 0;
 }
 
 static void do_reload_config(void)
@@ -1514,18 +1529,25 @@ static void do_set_config(void)
                printf("set_config done\n");
 }
 
-static void do_log_plock(void)
+static int do_log_plock(void)
 {
        char buf[DLMC_DUMP_SIZE];
+       int rv, data;
 
        memset(buf, 0, sizeof(buf));
 
-       dlmc_dump_log_plock(buf);
+       rv = dlmc_dump_log_plock(buf, &data);
+       if (rv)
+               return rv;
+       else if (data)
+               return data;
 
        buf[DLMC_DUMP_SIZE-1] = '\0';
 
        do_write(STDOUT_FILENO, buf, strlen(buf));
        printf("\n");
+
+       return 0;
 }
 
 static int do_run(int op)
@@ -1576,6 +1598,7 @@ int main(int argc, char **argv)
 {
        prog_name = argv[0];
        decode_arguments(argc, argv);
+       int rv = 0;
 
        switch (operation) {
 
@@ -1605,11 +1628,11 @@ int main(int argc, char **argv)
                break;
 
        case OP_DUMP:
-               do_dump(operation);
+               rv = do_dump(operation);
                break;
 
        case OP_DUMP_CONFIG:
-               do_dump(operation);
+               rv = do_dump(operation);
                break;
 
        case OP_RELOAD_CONFIG:
@@ -1621,11 +1644,11 @@ int main(int argc, char **argv)
                break;
 
        case OP_LOG_PLOCK:
-               do_log_plock();
+               rv = do_log_plock();
                break;
 
        case OP_PLOCKS:
-               do_plocks(lsname);
+               rv = do_plocks(lsname);
                break;
 
        case OP_DEADLOCK_CHECK:
@@ -1654,9 +1677,15 @@ int main(int argc, char **argv)
                break;
 
        case OP_DUMP_RUN:
-               do_dump(operation);
+               rv = do_dump(operation);
                break;
        }
-       return 0;
+
+       if (rv < 0) {
+               fprintf(stderr, "failed: %s\n", strerror(-rv));
+               return EXIT_FAILURE;
+       }
+
+       return EXIT_SUCCESS;
 }
 
-- 
2.35.3


++++++ 0007-dlm_controld-always-create-logdir.patch ++++++
>From a57ed6c2235e1cbde77b087cfef65f950b612c8b Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahri...@redhat.com>
Date: Fri, 27 Jan 2023 21:09:16 -0500
Subject: [PATCH 07/24] dlm_controld: always create logdir

Currently the logdir will be created only if logfile does contain a
string. To add another logfiles we simple create the logdir always on
startup.
---
 dlm_controld/logging.c | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/dlm_controld/logging.c b/dlm_controld/logging.c
index 2c57138ce766..3298ef999e8a 100644
--- a/dlm_controld/logging.c
+++ b/dlm_controld/logging.c
@@ -38,27 +38,27 @@ void init_logging(void)
 
        set_logfile_priority();
 
-       if (logfile[0]) {
-               old_umask = umask(0077);
-               rv = mkdir(SYS_VARDIR, 0700);
-               if (rv < 0 && errno != EEXIST) {
-                       umask(old_umask);
-                       goto skip_logfile;
-               }
+       old_umask = umask(0077);
+       rv = mkdir(SYS_VARDIR, 0700);
+       if (rv < 0 && errno != EEXIST) {
+               umask(old_umask);
+               goto skip_logfile;
+       }
 
-               rv = mkdir(SYS_LOGDIR, 0700);
-               if (rv < 0 && errno != EEXIST) {
-                       umask(old_umask);
-                       goto skip_logfile;
-               }
+       rv = mkdir(SYS_LOGDIR, 0700);
+       if (rv < 0 && errno != EEXIST) {
+               umask(old_umask);
+               goto skip_logfile;
+       }
 
-               rv = mkdir(LOGDIR, 0700);
-               if (rv < 0 && errno != EEXIST) {
-                       umask(old_umask);
-                       goto skip_logfile;
-               }
+       rv = mkdir(LOGDIR, 0700);
+       if (rv < 0 && errno != EEXIST) {
                umask(old_umask);
+               goto skip_logfile;
+       }
+       umask(old_umask);
 
+       if (logfile[0]) {
                logfile_fp = fopen(logfile, "a+");
                if (logfile_fp != NULL) {
                        int fd = fileno(logfile_fp);
-- 
2.35.3


++++++ 0008-dlm_controld-move-processing-of-saved-messages-to-pl.patch ++++++
>From d377cfd400ca268010e52d485523386df98fee25 Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahri...@redhat.com>
Date: Mon, 30 Jan 2023 09:23:20 -0500
Subject: [PATCH 08/24] dlm_controld: move processing of saved messages to
 plock level

Ad the loglevel is for save plock messages during corosync resource
membership upate. This patch will put the processing of saved messages
on the same loglevel.
---
 dlm_controld/plock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dlm_controld/plock.c b/dlm_controld/plock.c
index 692787e2b758..c2c803607db8 100644
--- a/dlm_controld/plock.c
+++ b/dlm_controld/plock.c
@@ -1612,7 +1612,7 @@ void process_saved_plocks(struct lockspace *ls)
        struct dlm_header *hd;
        int count = 0;
 
-       log_dlock(ls, "process_saved_plocks begin");
+       log_plock(ls, "process_saved_plocks begin");
 
        if (list_empty(&ls->saved_messages))
                goto out;
@@ -1643,7 +1643,7 @@ void process_saved_plocks(struct lockspace *ls)
                count++;
        }
  out:
-       log_dlock(ls, "process_saved_plocks %d done", count);
+       log_plock(ls, "process_saved_plocks %d done", count);
 }
 
 /* locks still marked SYNCING should not go into the ckpt; the new node
-- 
2.35.3


++++++ 0009-dlm_controld-remove-ls-parameter.patch ++++++
>From accd768091ff54352e6ba76ec107c00692f86611 Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahri...@redhat.com>
Date: Mon, 30 Jan 2023 11:10:41 -0500
Subject: [PATCH 09/24] dlm_controld: remove ls parameter

The ls parameter in write_result() is not used, so we can remove it.
---
 dlm_controld/plock.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/dlm_controld/plock.c b/dlm_controld/plock.c
index c2c803607db8..462c921220a4 100644
--- a/dlm_controld/plock.c
+++ b/dlm_controld/plock.c
@@ -684,8 +684,7 @@ static int add_waiter(struct lockspace *ls, struct resource 
*r,
        return 0;
 }
 
-static void write_result(struct lockspace *ls, struct dlm_plock_info *in,
-                        int rv)
+static void write_result(struct dlm_plock_info *in, int rv)
 {
        int write_rv;
 
@@ -719,7 +718,7 @@ static void do_waiters(struct lockspace *ls, struct 
resource *r)
                rv = lock_internal(ls, r, in);
 
                if (in->nodeid == our_nodeid)
-                       write_result(ls, in, rv);
+                       write_result(in, rv);
 
                free(w);
        }
@@ -744,7 +743,7 @@ static void do_lock(struct lockspace *ls, struct 
dlm_plock_info *in,
 
  out:
        if (in->nodeid == our_nodeid && rv != -EINPROGRESS)
-               write_result(ls, in, rv);
+               write_result(in, rv);
 
        do_waiters(ls, r);
        put_resource(ls, r);
@@ -768,7 +767,7 @@ static void do_unlock(struct lockspace *ls, struct 
dlm_plock_info *in,
        }
 
        if (in->nodeid == our_nodeid)
-               write_result(ls, in, rv);
+               write_result(in, rv);
 
  skip_result:
        do_waiters(ls, r);
@@ -787,7 +786,7 @@ static void do_get(struct lockspace *ls, struct 
dlm_plock_info *in,
        else
                rv = 0;
 
-       write_result(ls, in, rv);
+       write_result(in, rv);
        put_resource(ls, r);
 }
 
@@ -830,7 +829,7 @@ static void __receive_plock(struct lockspace *ls, struct 
dlm_plock_info *in,
                log_elock(ls, "receive_plock error from %d optype %d",
                          from, in->optype);
                if (from == our_nodeid)
-                       write_result(ls, in, -EINVAL);
+                       write_result(in, -EINVAL);
        }
 }
 
-- 
2.35.3


++++++ 0010-dlm_controld-constify-timeval-of-dt_usec.patch ++++++
>From f34212f436166cbf6170a698c765a6f76fcc7d7c Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahri...@redhat.com>
Date: Mon, 30 Jan 2023 13:39:02 -0500
Subject: [PATCH 10/24] dlm_controld: constify timeval of dt_usec()

Those parameters are only used read only. We don't change any data where
those pointers point to.
---
 dlm_controld/plock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dlm_controld/plock.c b/dlm_controld/plock.c
index 462c921220a4..8b052a946f8b 100644
--- a/dlm_controld/plock.c
+++ b/dlm_controld/plock.c
@@ -198,7 +198,7 @@ static unsigned long time_diff_ms(struct timeval *begin, 
struct timeval *end)
        return (result.tv_sec * 1000) + (result.tv_usec / 1000);
 }
 
-static uint64_t dt_usec(struct timeval *start, struct timeval *stop)
+static uint64_t dt_usec(const struct timeval *start, const struct timeval 
*stop)
 {
        uint64_t dt;
 
-- 
2.35.3


++++++ 0011-dlm_controld-add-gcc-format-printf-attribute-to-log_.patch ++++++
>From 1490dfb9a6966cf984f88090b985f662ea04859d Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahri...@redhat.com>
Date: Tue, 31 Jan 2023 08:52:24 -0500
Subject: [PATCH 11/24] dlm_controld: add gcc format printf attribute to
 log_level

This patch will add __attribute__ (( format( printf, 3, 4 ) ) to
log_level() functionality which has a format string as parameter. With
this change we enable compiler warnings if format string and applied
parameters do not match. We had some couple of warnings which this patch
fixes as well.
---
 dlm_controld/daemon_cpg.c | 2 +-
 dlm_controld/dlm_daemon.h | 1 +
 dlm_controld/plock.c      | 3 ++-
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/dlm_controld/daemon_cpg.c b/dlm_controld/daemon_cpg.c
index e6a03a288ae4..2e0634d4624c 100644
--- a/dlm_controld/daemon_cpg.c
+++ b/dlm_controld/daemon_cpg.c
@@ -2080,7 +2080,7 @@ int receive_run_reply(struct dlm_header *hd, int len)
                return 0;
 
        if (len != sizeof(struct run_reply)) {
-               log_debug("receive_run_reply %s bad len %s expect %d",
+               log_debug("receive_run_reply %s bad len %d expect %zu",
                          rep->uuid, len, sizeof(struct run_reply));
                run->info.reply_count++;
                run->info.need_replies--;
diff --git a/dlm_controld/dlm_daemon.h b/dlm_controld/dlm_daemon.h
index f0bad90fd699..94a9238f9cd5 100644
--- a/dlm_controld/dlm_daemon.h
+++ b/dlm_controld/dlm_daemon.h
@@ -216,6 +216,7 @@ EXTERN struct list_head run_ops;
 #define LOG_PLOCK 0x00010000
 #define LOG_NONE  0x00001111
 
+__attribute__ (( format( printf, 3, 4 ) ))
 void log_level(char *name_in, uint32_t level_in, const char *fmt, ...);
 
 #define log_error(fmt, args...) log_level(NULL, LOG_ERR, fmt, ##args)
diff --git a/dlm_controld/plock.c b/dlm_controld/plock.c
index 8b052a946f8b..2f0392c3368c 100644
--- a/dlm_controld/plock.c
+++ b/dlm_controld/plock.c
@@ -1925,7 +1925,8 @@ void receive_plocks_data(struct lockspace *ls, struct 
dlm_header *hd, int len)
                /* no locks should be included for owned resources */
 
                if (owner && count) {
-                       log_elock(ls, "recv_plocks_data %d:%u n %llu o %d bad 
count %u",
+                       log_elock(ls, "recv_plocks_data %d:%u n %llu o %d bad 
count %" PRIu32,
+                                 hd->nodeid, hd->msgdata,
                                  (unsigned long long)num, owner, count);
                        goto fail_free;
                }
-- 
2.35.3


++++++ 0012-dlm_controld-use-write_result.patch ++++++
>From 8db5382fc8391ba74eb2b6d6efca2f26e7884b55 Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahri...@redhat.com>
Date: Sun, 12 Feb 2023 18:39:01 -0500
Subject: [PATCH 12/24] dlm_controld: use write_result()

This patch will use write_result() instead of code the same code again
what write_result() is doing.

Reported-by: Andreas Gruenbacher <agrue...@redhat.com>
---
 dlm_controld/plock.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/dlm_controld/plock.c b/dlm_controld/plock.c
index 2f0392c3368c..24ad777a69b6 100644
--- a/dlm_controld/plock.c
+++ b/dlm_controld/plock.c
@@ -1600,8 +1600,7 @@ void process_plocks(int ci)
 #else
        if (!(info.flags & DLM_PLOCK_FL_CLOSE)) {
 #endif
-               info.rv = rv;
-               rv = write(plock_device_fd, &info, sizeof(info));
+               write_result(&info, rv);
        }
 }
 
-- 
2.35.3


++++++ 0013-dlm_controld-be-sure-we-stop-lockspaces-before-shutd.patch ++++++
>From e74cc7ee33481dd31d4149b8d8af1b5e364f6294 Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahri...@redhat.com>
Date: Thu, 23 Feb 2023 10:36:12 -0500
Subject: [PATCH 13/24] dlm_controld: be sure we stop lockspaces before
 shutdown

The dlm_controld shutdown process will drop all dlm configfs entries of
dlm communication settings regarding corosync address configuration.
This will end in an socket close in the dlm subsystem of the connection
which belongs to it. Newly introduced kernel warnings will check if the
lockspace is stopped before we close the socket connection. This is
necessary because no new dlm messages should be triggered afterwards. To
be sure dlm_controld does stop the lockspaces we will make sure that it
does it always in close_cpg_daemon. Currently there is a missing handle
to stop all lockspaces when there is no cpg_handle_daemon anymore.
---
 dlm_controld/daemon_cpg.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/dlm_controld/daemon_cpg.c b/dlm_controld/daemon_cpg.c
index 2e0634d4624c..10c80ddc5eff 100644
--- a/dlm_controld/daemon_cpg.c
+++ b/dlm_controld/daemon_cpg.c
@@ -2527,6 +2527,15 @@ int setup_cpg_daemon(void)
        return -1;
 }
 
+static void stop_lockspaces(void)
+{
+       struct lockspace *ls;
+
+       list_for_each_entry(ls, &lockspaces, list) {
+               cpg_stop_kernel(ls);
+       }
+}
+
 void close_cpg_daemon(void)
 {
        struct lockspace *ls;
@@ -2534,8 +2543,11 @@ void close_cpg_daemon(void)
        struct cpg_name name;
        int i = 0;
 
-       if (!cpg_handle_daemon)
+       if (!cpg_handle_daemon) {
+               stop_lockspaces();
                return;
+       }
+
        if (cluster_down)
                goto fin;
 
-- 
2.35.3


++++++ 0014-dlm_controld-constify-name_in-in-log_level.patch ++++++
>From e730e60495db6248d7189237d4adb8c3f735f54b Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahri...@redhat.com>
Date: Tue, 28 Feb 2023 15:29:53 -0500
Subject: [PATCH 14/24] dlm_controld: constify name_in in log_level()

This patch will constify the name_in parameter of log_level() which is
only used as readonly pointer.
---
 dlm_controld/dlm_daemon.h | 2 +-
 dlm_controld/logging.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/dlm_controld/dlm_daemon.h b/dlm_controld/dlm_daemon.h
index 94a9238f9cd5..86b37603a38d 100644
--- a/dlm_controld/dlm_daemon.h
+++ b/dlm_controld/dlm_daemon.h
@@ -217,7 +217,7 @@ EXTERN struct list_head run_ops;
 #define LOG_NONE  0x00001111
 
 __attribute__ (( format( printf, 3, 4 ) ))
-void log_level(char *name_in, uint32_t level_in, const char *fmt, ...);
+void log_level(const char *name_in, uint32_t level_in, const char *fmt, ...);
 
 #define log_error(fmt, args...) log_level(NULL, LOG_ERR, fmt, ##args)
 #define log_debug(fmt, args...) log_level(NULL, LOG_DEBUG, fmt, ##args)
diff --git a/dlm_controld/logging.c b/dlm_controld/logging.c
index 3298ef999e8a..f1f23f3fea28 100644
--- a/dlm_controld/logging.c
+++ b/dlm_controld/logging.c
@@ -151,7 +151,7 @@ static void log_save_str(int len, char *log_buf, unsigned 
int *point,
        *wrap = w;
 }
 
-void log_level(char *name_in, uint32_t level_in, const char *fmt, ...)
+void log_level(const char *name_in, uint32_t level_in, const char *fmt, ...)
 {
        va_list ap;
        char name[NAME_ID_SIZE + 2];
-- 
2.35.3


++++++ 0015-dlm_controld-initialize-waiter-flags.patch ++++++
>From 0834ed4b596d0d77dd4f7e52e4f9b045778b2ced Mon Sep 17 00:00:00 2001
From: Andreas Gruenbacher <agrue...@redhat.com>
Date: Mon, 13 Mar 2023 22:22:55 +0100
Subject: [PATCH 15/24] dlm_controld: initialize waiter->flags

In function add_waiter(), waiter->flags is left uninitialized.  Fix that.

In function add_lock(), the allocated lock is zeroed out and then all
fields except po->flags are initialized.  That's not wrong, but it seems
easier to initialize po->flags instead, like add_waiter() does now.
---
 dlm_controld/plock.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/dlm_controld/plock.c b/dlm_controld/plock.c
index 24ad777a69b6..f03f3abea983 100644
--- a/dlm_controld/plock.c
+++ b/dlm_controld/plock.c
@@ -455,7 +455,6 @@ static int add_lock(struct resource *r, uint32_t nodeid, 
uint64_t owner,
        po = malloc(sizeof(struct posix_lock));
        if (!po)
                return -ENOMEM;
-       memset(po, 0, sizeof(struct posix_lock));
 
        po->start = start;
        po->end = end;
@@ -463,6 +462,7 @@ static int add_lock(struct resource *r, uint32_t nodeid, 
uint64_t owner,
        po->owner = owner;
        po->pid = pid;
        po->ex = ex;
+       po->flags = 0;
        list_add_tail(&po->list, &r->locks);
 
        return 0;
@@ -680,6 +680,7 @@ static int add_waiter(struct lockspace *ls, struct resource 
*r,
        if (!w)
                return -ENOMEM;
        memcpy(&w->info, in, sizeof(struct dlm_plock_info));
+       w->flags = 0;
        list_add_tail(&w->list, &r->waiters);
        return 0;
 }
@@ -1095,6 +1096,7 @@ static void save_pending_plock(struct lockspace *ls, 
struct resource *r,
                return;
        }
        memcpy(&w->info, in, sizeof(struct dlm_plock_info));
+       w->flags = 0;
        list_add_tail(&w->list, &r->pending);
 }
 
@@ -1967,6 +1969,7 @@ void receive_plocks_data(struct lockspace *ls, struct 
dlm_header *hd, int len)
                        w->info.pid     = le32_to_cpu(pp->pid);
                        w->info.nodeid  = le32_to_cpu(pp->nodeid);
                        w->info.ex      = pp->ex;
+                       w->flags        = 0;
                        list_add_tail(&w->list, &r->waiters);
                }
                pp++;
-- 
2.35.3


++++++ 0016-dlm_controld-get-rid-of-unnecessary-memset.patch ++++++
>From 6a41300deb2611ed69c49507746bc96a634f800c Mon Sep 17 00:00:00 2001
From: Andreas Gruenbacher <agrue...@redhat.com>
Date: Thu, 9 Mar 2023 14:30:05 +0100
Subject: [PATCH 16/24] dlm_controld: get rid of unnecessary memset

In process_plocks(), we're reading in the entire info object, so there
is no need to zero out the buffer first.
---
 dlm_controld/plock.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/dlm_controld/plock.c b/dlm_controld/plock.c
index f03f3abea983..85d6fdf2819b 100644
--- a/dlm_controld/plock.c
+++ b/dlm_controld/plock.c
@@ -1523,8 +1523,6 @@ void process_plocks(int ci)
 
        gettimeofday(&now, NULL);
 
-       memset(&info, 0, sizeof(info));
-
        rv = do_read(plock_device_fd, &info, sizeof(info));
        if (rv < 0) {
                log_debug("process_plocks: read error %d fd %d\n",
-- 
2.35.3


++++++ 0017-dlm_controld-remove-unnecessary-list_empty-check.patch ++++++
>From 1c967ee1ecae6bd944d4d901bc7032a02f5547ee Mon Sep 17 00:00:00 2001
From: Andreas Gruenbacher <agrue...@redhat.com>
Date: Wed, 8 Mar 2023 22:18:47 +0100
Subject: [PATCH 17/24] dlm_controld: remove unnecessary list_empty check

All that do_waiters() does is iterate the the waiters list of a
resource, so there is no need to check if the waiters list is empty
before calling do_waiters().
---
 dlm_controld/plock.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/dlm_controld/plock.c b/dlm_controld/plock.c
index 85d6fdf2819b..ad9b0f2788aa 100644
--- a/dlm_controld/plock.c
+++ b/dlm_controld/plock.c
@@ -2055,8 +2055,7 @@ void purge_plocks(struct lockspace *ls, int nodeid, int 
unmount)
                        send_pending_plocks(ls, r);
                }
                
-               if (!list_empty(&r->waiters))
-                       do_waiters(ls, r);
+               do_waiters(ls, r);
 
                if (!opt(plock_ownership_ind) &&
                    list_empty(&r->locks) && list_empty(&r->waiters)) {
-- 
2.35.3


++++++ 0018-dlm_controld-set-posix_lock-flags-to-zero.patch ++++++
>From f616364f44ea3bc797c826ed9bd71ff306443bc6 Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahri...@redhat.com>
Date: Tue, 21 Mar 2023 09:12:21 -0400
Subject: [PATCH 18/24] dlm_controld: set posix_lock flags to zero

This patch sets another flags variable to zero which is a leftover of
commit 0834ed4b ("dlm_controld: initialize waiter->flags").
---
 dlm_controld/plock.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/dlm_controld/plock.c b/dlm_controld/plock.c
index ad9b0f2788aa..7f632888793f 100644
--- a/dlm_controld/plock.c
+++ b/dlm_controld/plock.c
@@ -1956,6 +1956,7 @@ void receive_plocks_data(struct lockspace *ls, struct 
dlm_header *hd, int len)
                        po->pid         = le32_to_cpu(pp->pid);
                        po->nodeid      = le32_to_cpu(pp->nodeid);
                        po->ex          = pp->ex;
+                       po->flags       = 0;
                        list_add_tail(&po->list, &r->locks);
                } else {
                        w = malloc(sizeof(struct lock_waiter));
-- 
2.35.3


++++++ 0019-dlm_controld-init-plocks_data-to-zero.patch ++++++
>From ec2182530da8f787270d4d7dad5213c503215cad Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahri...@redhat.com>
Date: Tue, 21 Mar 2023 09:30:15 -0400
Subject: [PATCH 19/24] dlm_controld: init plocks_data to zero

Inits plocks_data to zero in case of send_all_plocks_data() does not set
plocks_data to any value or nodes_added() returns false. This patch fixes
cppcheck warning:

cpg.c:1299:27: error: Uninitialized variable: plocks_data [uninitvar]
 send_plocks_done(ls, cg, plocks_data);
---
 dlm_controld/cpg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dlm_controld/cpg.c b/dlm_controld/cpg.c
index b85fef5f1b45..32aad9246a56 100644
--- a/dlm_controld/cpg.c
+++ b/dlm_controld/cpg.c
@@ -1244,8 +1244,8 @@ static int nodes_added(struct lockspace *ls)
 static void prepare_plocks(struct lockspace *ls)
 {
        struct change *cg = list_first_entry(&ls->changes, struct change, list);
+       uint32_t plocks_data = 0;
        struct member *memb;
-       uint32_t plocks_data;
 
        if (!opt(enable_plock_ind) || ls->disable_plock)
                return;
-- 
2.35.3


++++++ 0020-dlm_tool-fix-missing-fclose-calls.patch ++++++
>From e5ca08c20e6f530bfb95db67cbd62e6958f9af26 Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahri...@redhat.com>
Date: Thu, 30 Mar 2023 15:21:58 -0400
Subject: [PATCH 20/24] dlm_tool: fix missing fclose calls

This patch will fix missing fclose() calls when fgets() of do_lockdump()
fails.
---
 dlm_tool/main.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/dlm_tool/main.c b/dlm_tool/main.c
index 52fd5b8974b8..2e6810d6da08 100644
--- a/dlm_tool/main.c
+++ b/dlm_tool/main.c
@@ -1177,8 +1177,9 @@ static void do_lockdump(char *name)
        }
 
        /* skip the header on the first line */
-       if (!fgets(line, LOCK_LINE_MAX, file))
-               return;
+       if (!fgets(line, LOCK_LINE_MAX, file)) {
+               goto out;
+       }
 
        while (fgets(line, LOCK_LINE_MAX, file)) {
                rv = sscanf(line, "%x %d %x %u %llu %x %x %hhd %hhd %hhd %u %d 
%d",
@@ -1199,7 +1200,7 @@ static void do_lockdump(char *name)
                if (rv != 13) {
                        fprintf(stderr, "invalid debugfs line %d: %s\n",
                                rv, line);
-                       return;
+                       goto out;
                }
 
                memset(r_name, 0, sizeof(r_name));
@@ -1229,6 +1230,7 @@ static void do_lockdump(char *name)
                        ownpid, nodeid, r_name);
        }
 
+ out:
        fclose(file);
 }
 
-- 
2.35.3


++++++ bug-1212767-dlm_controld-remove-unnecessary-header-include.patch ++++++
>From ddbba6608896f81bfce8f8edf3d0f507714cfc43 Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahri...@redhat.com>
Date: Wed, 24 May 2023 08:56:41 -0400
Subject: [PATCH] dlm_controld: remove unnecessary header include

The timewarn netlink functionality got dropped and will be removed by
kernel v6.4. The user space part was already dropped by commit 34ea31e7
("controld: remove timewarn handling"). This is just a left over of this
commit. Recent builds fails now because the UAPI header in the Linux
kernel was removed. This means older dlm sources cannot be build with
newer kernel-headers, however it is not recommended to use older dlm
sources and all existing users should upgrade anyway.

Reported-by: Fabio M. Di Nitto <fdini...@redhat.com>
---
 dlm_controld/main.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/dlm_controld/main.c b/dlm_controld/main.c
index c9d1c5f1..14be5edd 100644
--- a/dlm_controld/main.c
+++ b/dlm_controld/main.c
@@ -12,7 +12,6 @@
 #include <pthread.h>
 #include <linux/netlink.h>
 #include <linux/genetlink.h>
-#include <linux/dlm_netlink.h>
 #include <uuid/uuid.h>
 
 #ifdef USE_SD_NOTIFY
-- 
2.41.0

Reply via email to