main - lvmlockd: purge the lock resources left in previous lockspace
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=39e6c4f749e97c0efae116e1fa0dbc25451de80e Commit: 39e6c4f749e97c0efae116e1fa0dbc25451de80e Parent: a23588d77cb1585e642946fe84c3eaafe7e2d270 Author: Lidong Zhong <[email protected]> AuthorDate: Fri Sep 30 16:34:51 2022 +0800 Committer: David Teigland <[email protected]> CommitterDate: Fri Oct 7 09:45:57 2022 -0500
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 | 13 +++++- daemons/lvmlockd/lvmlockd-dlm.c | 79 ++++++++++++++++++++++++++++++++++++ daemons/lvmlockd/lvmlockd-internal.h | 6 +++ 3 files changed, 97 insertions(+), 1 deletion(-)
daemons/lvmlockd/lvmlockd-core.c +12 -1
@@ -5954,7 +5954,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;
daemons/lvmlockd/lvmlockd-dlm.c +79 -0
85 lines not on this page · raw message
daemons/lvmlockd/lvmlockd-internal.h +6 -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 ;