Skip to contentSkip to conversation

lvmlockd: purge the lock resources left in previous lockspace

RFC PATCH New Lidong Zhong 2 participants 3 messages Sep 30, 2022 – Oct 5, 2022

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 lvmlockd: purge the lock resources left in previous lockspace

If lvmlockd in cluster is killed accidently or any other reason, the lock resources will become orphaned in the VG lockspace. When the cluster manager tries to restart this daemon, the LVs will probably become inactive because of resource schedule policy and thus the lock resouce will be omited during the adoption process. This patch will try to purge the lock resources left in previous lockspace, so the following actions can work again.

---
 ?daemons/lvmlockd/lvmlockd-core.c???? | 12 +++++
 ?daemons/lvmlockd/lvmlockd-dlm.c????? | 77 ++++++++++++++++++++++++++++

?daemons/lvmlockd/lvmlockd-internal.h |? 6 +++
?3 files changed, 95 insertions(+)

(quoted diff) +0 -0

b/daemons/lvmlockd/lvmlockd-core.c
index 6d0d4d98c..054bd9a10 100644

daemons/lvmlockd/lvmlockd-core.c +12 -0
@@ -5955,6 +5955,18 @@ static void adopt_locks(void)
 
 
 ???? /* FIXME: purge any remaining orphan locks in each rejoined ls? */
+??? /* Try to purge the orphan locks when lock manager is dlm */
+??? if (lm_support_dlm() && lm_is_running_dlm()) {
+??? ??? list_for_each_entry(ls, &ls_found, list) {
+??? ??? ??? pthread_mutex_lock(&lockspaces_mutex);
+??? ??? ??? ls1 = find_lockspace_name(ls->name);
+??? ??? ??? if (ls1) {
+??? ??? ??? ??? log_debug("ls: %s purge locks", ls->name);
+??? ??? ??? ??? lm_purge_locks_dlm(ls1);
+??? ??? ??? }
+??? ??? ??? pthread_mutex_unlock(&lockspaces_mutex);
+??? ??? }
+??? }
 
 ???? if (count_start_fail || count_adopt_fail)
 ???? ??? goto fail;
(quoted diff) +0 -0

b/daemons/lvmlockd/lvmlockd-dlm.c
index 1305c3dc2..f63f5ec82 100644

daemons/lvmlockd/lvmlockd-dlm.c +77 -0

83 lines not on this page · raw message

(quoted diff) +0 -0

b/daemons/lvmlockd/lvmlockd-internal.h
index ad32eb3a4..dd59b6a5d 100644

daemons/lvmlockd/lvmlockd-internal.h +0 -0
@@ -392,6 +392,7 @@ static inline const char *mode_str(int x)
 ?int lm_init_vg_dlm(char *ls_name, char *vg_name, uint32_t flags, char 

*vg_args);
?int lm_prepare_lockspace_dlm(struct lockspace *ls);
?int lm_add_lockspace_dlm(struct lockspace *ls, int adopt);
+int lm_purge_locks_dlm(struct lockspace *ls);
?int lm_rem_lockspace_dlm(struct lockspace *ls, int free_vg); ?int lm_lock_dlm(struct lockspace *ls, struct resource *r, int ld_mode, ???? ??? struct val_blk *vb_out, int adopt);
@@ -429,6 +430,11 @@ static inline int lm_add_lockspace_dlm(struct lockspace *ls, int adopt)
???? return -1;
?}

+static inline int lm_purge_locks_dlm(struct lockspace *ls)
+{
+??? return -1;
+}
+
?static inline int lm_rem_lockspace_dlm(struct lockspace *ls, int free_vg) ?{
???? return -1;

Signature · 1 line
2.35.3
#1 lore raw

RFC PATCH 1/1 lvmlockd: purge the lock resources left in previous lockspace

Quoted 1 line · Lidong Zhong

???? /* FIXME: purge any remaining orphan locks in each rejoined ls? */

You're fixing it, so we can drop the comment.

Quoted 7 lines

+??? ??? ??? ??? file = fopen(ls_comms_path, "r"); +??? ??? ??? ??? if (!file)
+??? ??? ??? ??? ??? continue;
+??? ??? ??? ??? if (fgets(line, LOCK_LINE_MAX, file)) { +??? ??? ??? ??? ??? rv = sscanf(line, "%d", &val); +??? ??? ??? ??? ??? if (rv == 1)
+??? ??? ??? ??? ??? ??? return val;

Is this missing an fclose?

Please confirm that this works for your test case and I'll include it.

Thanks,
Dave

#2 lore raw

RFC PATCH 1/1 lvmlockd: purge the lock resources left in previous lockspace

Quoted 11 lines · David Teigland
Quoted 1 line · Lidong Zhong

???? /* FIXME: purge any remaining orphan locks in each rejoined ls? */

You're fixing it, so we can drop the comment.

Quoted 7 lines

+??? ??? ??? ??? file = fopen(ls_comms_path, "r"); +??? ??? ??? ??? if (!file)
+??? ??? ??? ??? ??? continue;
+??? ??? ??? ??? if (fgets(line, LOCK_LINE_MAX, file)) { +??? ??? ??? ??? ??? rv = sscanf(line, "%d", &val); +??? ??? ??? ??? ??? if (rv == 1)
+??? ??? ??? ??? ??? ??? return val;

Quoted 3 lines

Is this missing an fclose?

Please confirm that this works for your test case and I'll include it.

Hi David,

I have made the modifications based on your review. Thanks.

The patch works in my test. I am sending the new version patch as an attachment. Sorry if it causes any

inconvenience.

Regards,

Lidong

Quoted 4 lines

Thanks,
Dave

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-lvmlockd-purge-the-lock-resources-left-in-previous-l.patch
Type: text/x-patch
Size: 4927 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20221005/15fa3d1b/attachment.bin>