Skip to contentSkip to conversation

master - lvmlockd: prevent vgremove of dlm VG while lockspace is used

PATCH David Teigland 1 participant 1 message Sep 11, 2015

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6bc3d72a655395a7f1ca299d85000ff65280d24d
Commit:        6bc3d72a655395a7f1ca299d85000ff65280d24d
Parent:        854a559a494e81228905f6739de9150853ce2ea7
Author:        David Teigland <[email protected]>
AuthorDate:    Fri Sep 11 14:06:46 2015 -0500
Committer:     David Teigland <[email protected]>
CommitterDate: Fri Sep 11 14:12:13 2015 -0500

lvmlockd: prevent vgremove of dlm VG while lockspace is used

This applies the same rule/logic to dlm VGs that has always existed for sanlock VGs. Allowing a dlm VG to be removed while its lockspace was still running on other hosts largely worked, but there were difficult problems if another VG with the same name was recreated. Forcing the VG lockspace to be stopped, gives both sanlock and dlm VGs the same behavior.

---
 daemons/lvmlockd/lvmlockd-core.c     |   22 ++++++++++++-
 daemons/lvmlockd/lvmlockd-dlm.c      |   56 +++++++++++++++++++++++++++++++++
 daemons/lvmlockd/lvmlockd-internal.h |    7 ++++
 lib/locking/lvmlockd.c               |   57 ++++++++++++++++++++++++++++------
 4 files changed, 131 insertions(+), 11 deletions(-)
daemons/lvmlockd/lvmlockd-core.c +21 -1
index ffeef5c..7d5b158 100644
@@ -735,6 +735,8 @@ static const char *op_str(int x)
 		return "dump_log";
 	case LD_OP_DUMP_INFO:
 		return "dump_info";
+	case LD_OP_BUSY:
+		return "busy";
 	default:
 		return "op_unknown";
 	};
@@ -926,7 +928,7 @@ static int lm_unlock(struct lockspace *ls, struct resource *r, struct action *ac
 static int lm_hosts(struct lockspace *ls, int notify)
 {
 	if (ls->lm_type == LD_LM_DLM)
-		return 0;
+		return lm_hosts_dlm(ls, notify);
 	else if (ls->lm_type == LD_LM_SANLOCK)
 		return lm_hosts_sanlock(ls, notify);
 	return -1;
@@ -2364,6 +2366,18 @@ static void *lockspace_thread_main(void *arg_in)
 				break;
 			}
 
+			if (act->op == LD_OP_BUSY && act->rt == LD_RT_VG) {
+				log_debug("S %s checking if lockspace is busy", ls->name);
+				rv = lm_hosts(ls, 0);
+				if (rv)
+					act->result = -EBUSY;
+				else
+					act->result = 0;
+				list_del(&act->list);
+				add_client_result(act);
+				continue;
+			}
+
 			if (act->op == LD_OP_RENAME_BEFORE && act->rt == LD_RT_VG) {
 				/* vgrename */
 				log_debug("S %s checking for lockspace hosts", ls->name);
@@ -3825,6 +3839,11 @@ static int str_to_op_rt(const char *req_name, int *op, int *rt)
 		*rt = LD_RT_VG;
 		return 0;
 	}
+	if (!strcmp(req_name, "busy_vg")) {
+		*op = LD_OP_BUSY;
+		*rt = LD_RT_VG;
+		return 0;
+	}
 	if (!strcmp(req_name, "free_lv")) {
 		*op = LD_OP_FREE;
 		*rt = LD_RT_LV;
@@ -4477,6 +4496,7 @@ static void client_recv_action(struct client *cl)
 	case LD_OP_FIND_FREE_LOCK:
 	case LD_OP_KILL_VG:
 	case LD_OP_DROP_VG:
+	case LD_OP_BUSY:
 		rv = add_lock_action(act);
 		break;
 	default:
daemons/lvmlockd/lvmlockd-dlm.c +56 -0

62 lines not on this page · raw message

daemons/lvmlockd/lvmlockd-internal.h +7 -0
index 55ac460..a90dd99 100644
@@ -52,6 +52,7 @@ enum {
 	LD_OP_FIND_FREE_LOCK,
 	LD_OP_KILL_VG,
 	LD_OP_DROP_VG,
+	LD_OP_BUSY,
 };
 
 /* resource types */
@@ -364,6 +365,7 @@ int lm_rem_resource_dlm(struct lockspace *ls, struct resource *r);
 int lm_get_lockspaces_dlm(struct list_head *ls_rejoin);
 int lm_data_size_dlm(void);
 int lm_is_running_dlm(void);
+int lm_hosts_dlm(struct lockspace *ls, int notify);
 
 static inline int lm_support_dlm(void)
 {
@@ -435,6 +437,11 @@ static inline int lm_support_dlm(void)
 	return 0;
 }
 
+static inline int lm_hosts_dlm(struct lockspace *ls, int notify)
+{
+	return 0;
+}
+
 #endif /* dlm support */
 
 #ifdef LOCKDSANLOCK_SUPPORT
lib/locking/lvmlockd.c +47 -10

76 lines not on this page · raw message