Skip to contentSkip to conversation

master - lvmlockd: replace lock adopt info source

PATCH David Teigland 1 participant 1 message May 4, 2020

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5263551a2d14e52a3f62152616bb8fb9ac8c384c
Commit:        5263551a2d14e52a3f62152616bb8fb9ac8c384c
Parent:        d945b53ff7076bf7713f5e3b9ad7b79ed1db14c0
Author:        David Teigland <[email protected]>
AuthorDate:    Mon May 4 13:35:03 2020 -0500
Committer:     David Teigland <[email protected]>
CommitterDate: Mon May 4 13:35:03 2020 -0500

lvmlockd: replace lock adopt info source

The lock adopt feature was disabled since it had used lvmetad as a source of info. This replaces the lvmetad info with a local file and enables the adopt feature again (enabled with lvmlockd --adopt 1).

---
 daemons/lvmlockd/lvmlockd-client.h   |   1 +
 daemons/lvmlockd/lvmlockd-core.c     | 370 +++++++++++++++++------------------
 daemons/lvmlockd/lvmlockd-dlm.c      |   8 +-
 daemons/lvmlockd/lvmlockd-internal.h |   1 +
 man/lvmlockd.8_main                  |  14 +-
 5 files changed, 207 insertions(+), 187 deletions(-)
daemons/lvmlockd/lvmlockd-client.h +1 -0
index 16d16132a..62ffb732a 100644
@@ -14,6 +14,7 @@
 #include "libdaemon/client/daemon-client.h"
 
 #define LVMLOCKD_SOCKET DEFAULT_RUN_DIR "/lvmlockd.socket"
+#define LVMLOCKD_ADOPT_FILE DEFAULT_RUN_DIR "/lvmlockd.adopt"
 
 /* Wrappers to open/close connection */
 
daemons/lvmlockd/lvmlockd-core.c +185 -185

486 lines not on this page · raw message

daemons/lvmlockd/lvmlockd-dlm.c +7 -1
index 75e6deec4..7915cc008 100644
@@ -398,12 +398,18 @@ static int lm_adopt_dlm(struct lockspace *ls, struct resource *r, int ld_mode,
 			  (void *)1, (void *)1, (void *)1,
 			  NULL, NULL);
 
-	if (rv == -1 && errno == -EAGAIN) {
+	if (rv == -1 && (errno == EAGAIN)) {
 		log_debug("S %s R %s adopt_dlm adopt mode %d try other mode",
 			  ls->name, r->name, ld_mode);
 		rv = -EUCLEAN;
 		goto fail;
 	}
+	if (rv == -1 && (errno == ENOENT)) {
+		log_debug("S %s R %s adopt_dlm adopt mode %d no lock",
+			  ls->name, r->name, ld_mode);
+		rv = -ENOENT;
+		goto fail;
+	}
 	if (rv < 0) {
 		log_debug("S %s R %s adopt_dlm mode %d flags %x error %d errno %d",
 			  ls->name, r->name, mode, flags, rv, errno);
daemons/lvmlockd/lvmlockd-internal.h +1 -0
index 85e8caf9a..04100c0c1 100644
@@ -145,6 +145,7 @@ struct resource {
 	char name[MAX_NAME+1];		/* vg name or lv name */
 	int8_t type;			/* resource type LD_RT_ */
 	int8_t mode;
+	int8_t adopt_mode;
 	unsigned int sh_count;		/* number of sh locks on locks list */
 	uint32_t version;
 	uint32_t last_client_id;	/* last client_id to lock or unlock resource */
man/lvmlockd.8_main +13 -1
index 8ed5400e4..c21f7a916 100644
@@ -58,6 +58,10 @@ For default settings, see lvmlockd -h.
 .I path
         Set path to the socket to listen on.
 
+.B  --adopt-file
+.I path
+        Set path to the adopt file.
+
 .B  --syslog-priority | -S err|warning|debug
         Write log messages from this level up to syslog.
 
@@ -76,6 +80,8 @@ For default settings, see lvmlockd -h.
 .I seconds
         Override the default sanlock I/O timeout.
 
+.B --adopt | -A 0|1
+        Enable (1) or disable (0) lock adoption.
 
 .SH USAGE
 
@@ -548,7 +554,13 @@ necessary locks.
 .B lvmlockd failure
 
 If lvmlockd fails or is killed while holding locks, the locks are orphaned
-in the lock manager.
+in the lock manager.  Orphaned locks must be cleared or adopted before the
+associated resources can be accessed normally.  If lock adoption is
+enabled, lvmlockd keeps a record of locks in the adopt-file.  A subsequent
+instance of lvmlockd will then adopt locks orphaned by the previous
+instance.  Adoption must be enabled in both instances (--adopt|-A 1).
+Without adoption, the lock manager or host would require a reset to clear
+orphaned lock state.
 
 .B dlm/corosync failure