Skip to contentSkip to conversation

Add dlm operations placeholders

PATCH New Goldwyn Rodrigues 2 participants 3 messages Sep 27, 2013 – Sep 28, 2013 OCFS2

lore
Share & tools
lore
#0 lore raw

PATCH 1/7 Add dlm operations placeholders

Try locking with the new DLM semantics with the dlm operations. If operation fails with EOPNOTSUPP, try the old semantics. This would ensure that filesystems are mounted for those who are upgrading the kernel but not the tools.
Users using old tools will be presented with a notice message to upgrade the tools.

recover_prep() is called when DLM understands a node is down. recover_slot() is called once all nodes have acknowledged recover_prep and recovery can begin.
recover_done() is called once the recovery is complete. It returns the new membership.

---
 fs/ocfs2/stack_user.c | 70 +++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 51 insertions(+), 19 deletions(-)
fs/ocfs2/stack_user.c +51 -19
index 286edf1..b44490b 100644
@@ -799,14 +799,63 @@ static int fs_protocol_compare(struct ocfs2_protocol_version *existing,
 	return 0;
 }
 
+static void user_recover_prep(void *arg)
+{
+}
+
+static void user_recover_slot(void *arg, struct dlm_slot *slot)
+{
+}
+
+static void user_recover_done(void *arg, struct dlm_slot *slots,
+			      int num_slots, int our_slot,
+			      uint32_t generation)
+{
+}
+
+const struct dlm_lockspace_ops ocfs2_ls_ops = {
+	.recover_prep = user_recover_prep,
+	.recover_slot = user_recover_slot,
+	.recover_done = user_recover_done,
+};
+
+static int user_cluster_disconnect(struct ocfs2_cluster_connection *conn)
+{
+	dlm_release_lockspace(conn->cc_lockspace, 2);
+	conn->cc_lockspace = NULL;
+	ocfs2_live_connection_drop(conn->cc_private);
+	conn->cc_private = NULL;
+	return 0;
+}
+
 static int user_cluster_connect(struct ocfs2_cluster_connection *conn)
 {
 	dlm_lockspace_t *fsdlm;
 	struct ocfs2_live_connection *uninitialized_var(control);
-	int rc = 0;
+	int rc = 0, ops_rv;
 
 	BUG_ON(conn == NULL);
 
+	rc = dlm_new_lockspace(conn->cc_name, NULL, DLM_LSFL_FS, DLM_LVB_LEN,
+				&ocfs2_ls_ops, conn, &ops_rv, &fsdlm);
+
+	if (rc)
+		goto out;
+
+	if (!ops_rv) {
+		/* DLM lockspace creation with newer new_lockspace successful */
+		goto out;
+	} else if (ops_rv != -EOPNOTSUPP) {
+		rc = ops_rv;
+		goto out;
+	}
+
+	conn->cc_lockspace = fsdlm;
+
+	printk(KERN_NOTICE "ocfs2: You seem to be using an older version "
+			"of dlm_controld and/or ocfs2-tools. Please consider "
+			"upgrading.\n");
+
 	rc = ocfs2_live_connection_new(conn, &control);
 	if (rc)
 		goto out;
@@ -823,32 +872,15 @@ static int user_cluster_connect(struct ocfs2_cluster_connection *conn)
 		       conn->cc_version.pv_major, conn->cc_version.pv_minor,
 		       running_proto.pv_major, running_proto.pv_minor);
 		rc = -EPROTO;
-		ocfs2_live_connection_drop(control);
-		goto out;
-	}
-
-	rc = dlm_new_lockspace(conn->cc_name, NULL, DLM_LSFL_FS, DLM_LVB_LEN,
-			       NULL, NULL, NULL, &fsdlm);
-	if (rc) {
-		ocfs2_live_connection_drop(control);
+		user_cluster_disconnect(conn);
 		goto out;
 	}
 
 	conn->cc_private = control;
-	conn->cc_lockspace = fsdlm;
 out:
 	return rc;
 }
 
-static int user_cluster_disconnect(struct ocfs2_cluster_connection *conn)
-{
-	dlm_release_lockspace(conn->cc_lockspace, 2);
-	conn->cc_lockspace = NULL;
-	ocfs2_live_connection_drop(conn->cc_private);
-	conn->cc_private = NULL;
-	return 0;
-}
-
 static int user_cluster_this_node(unsigned int *this_node)
 {
 	int rc;
Signature · 5 lines
1.8.1.4


-- 
Goldwyn
maintainer
#1 lore raw

PATCH 1/7 Add dlm operations placeholders

Quoted 7 lines · Goldwyn Rodrigues

Try locking with the new DLM semantics with the dlm operations. If operation fails with EOPNOTSUPP, try the old semantics. This would ensure that filesystems are mounted for those who are upgrading the kernel but not the tools.
Users using old tools will be presented with a notice message to upgrade the tools.

Quoted 5 lines

recover_prep() is called when DLM understands a node is down. recover_slot() is called once all nodes have acknowledged recover_prep and recovery can begin.
recover_done() is called once the recovery is complete. It returns the new membership.

Can recover_prep() pause? What does the cluster do when not all
nodes acknowledge the prep? When they die during recover_slot()? Which node recovers the slot?

Quoted 55 lines
---
 fs/ocfs2/stack_user.c | 70 +++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 51 insertions(+), 19 deletions(-)
fs/ocfs2/stack_user.c +35 -1
index 286edf1..b44490b 100644
@@ -799,14 +799,63 @@ static int fs_protocol_compare(struct ocfs2_protocol_version *existing,
 	return 0;
 }
 
+static void user_recover_prep(void *arg)
+{
+}
+
+static void user_recover_slot(void *arg, struct dlm_slot *slot)
+{
+}
+
+static void user_recover_done(void *arg, struct dlm_slot *slots,
+			      int num_slots, int our_slot,
+			      uint32_t generation)
+{
+}
+
+const struct dlm_lockspace_ops ocfs2_ls_ops = {
+	.recover_prep = user_recover_prep,
+	.recover_slot = user_recover_slot,
+	.recover_done = user_recover_done,
+};
+
+static int user_cluster_disconnect(struct ocfs2_cluster_connection *conn)
+{
+	dlm_release_lockspace(conn->cc_lockspace, 2);
+	conn->cc_lockspace = NULL;
+	ocfs2_live_connection_drop(conn->cc_private);
+	conn->cc_private = NULL;
+	return 0;
+}
+
 static int user_cluster_connect(struct ocfs2_cluster_connection *conn)
 {
 	dlm_lockspace_t *fsdlm;
 	struct ocfs2_live_connection *uninitialized_var(control);
-	int rc = 0;
+	int rc = 0, ops_rv;
 
 	BUG_ON(conn == NULL);
 
+	rc = dlm_new_lockspace(conn->cc_name, NULL, DLM_LSFL_FS, DLM_LVB_LEN,
+				&ocfs2_ls_ops, conn, &ops_rv, &fsdlm);
+
+	if (rc)
+		goto out;

fs/ocfs2/stack_user.c static int fs_protocol_compare(struct ocfs2_protocol_version *existing, · line 853

Quoted 10 lines
fs/ocfs2/stack_user.c +10 -0
+
+	if (!ops_rv) {
+		/* DLM lockspace creation with newer new_lockspace successful */
+		goto out;
+	} else if (ops_rv != -EOPNOTSUPP) {
+		rc = ops_rv;
+		goto out;
+	}
+
+	conn->cc_lockspace = fsdlm;

This code returns from !ops_rv before setting cc_lockspace, yet tries to reference it out in user_cluster_disconnect(). That looks like a crashing bug.

Also, it looks like you call the new form of dlm_new_lockspace() before the callbacks are even implemented. If I just apply this patch, the code does not work. Please reorder the patch so that ocfs2 works at each patch.

Joel

Quoted 53 lines
fs/ocfs2/stack_user.c +6 -18
+
+	printk(KERN_NOTICE "ocfs2: You seem to be using an older version "
+			"of dlm_controld and/or ocfs2-tools. Please consider "
+			"upgrading.\n");
+
 	rc = ocfs2_live_connection_new(conn, &control);
 	if (rc)
 		goto out;
@@ -823,32 +872,15 @@ static int user_cluster_connect(struct ocfs2_cluster_connection *conn)
 		       conn->cc_version.pv_major, conn->cc_version.pv_minor,
 		       running_proto.pv_major, running_proto.pv_minor);
 		rc = -EPROTO;
-		ocfs2_live_connection_drop(control);
-		goto out;
-	}
-
-	rc = dlm_new_lockspace(conn->cc_name, NULL, DLM_LSFL_FS, DLM_LVB_LEN,
-			       NULL, NULL, NULL, &fsdlm);
-	if (rc) {
-		ocfs2_live_connection_drop(control);
+		user_cluster_disconnect(conn);
 		goto out;
 	}
 
 	conn->cc_private = control;
-	conn->cc_lockspace = fsdlm;
 out:
 	return rc;
 }
 
-static int user_cluster_disconnect(struct ocfs2_cluster_connection *conn)
-{
-	dlm_release_lockspace(conn->cc_lockspace, 2);
-	conn->cc_lockspace = NULL;
-	ocfs2_live_connection_drop(conn->cc_private);
-	conn->cc_private = NULL;
-	return 0;
-}
-
 static int user_cluster_this_node(unsigned int *this_node)
 {
 	int rc;
Signature · 10 lines
1.8.1.4


-- 
Goldwyn

_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel
Signature · 7 lines
"But all my words come back to me
 In shades of mediocrity.
 Like emptiness in harmony
 I need someone to comfort me."

			http://www.jlbec.org/
			jlbec at evilplan.org
#2 lore raw

PATCH 1/7 Add dlm operations placeholders

Quoted 8 lines · Joel Becker
Quoted 7 lines · Goldwyn Rodrigues

Try locking with the new DLM semantics with the dlm operations. If operation fails with EOPNOTSUPP, try the old semantics. This would ensure that filesystems are mounted for those who are upgrading the kernel but not the tools.
Users using old tools will be presented with a notice message to upgrade the tools.

Quoted 7 lines
Quoted 5 lines

recover_prep() is called when DLM understands a node is down. recover_slot() is called once all nodes have acknowledged recover_prep and recovery can begin.
recover_done() is called once the recovery is complete. It returns the new membership.

Can recover_prep() pause?

From a locking/lockdep POV yes. However, you want to recover from a
node failure soon, so not recommended.

Quoted 1 line

What does the cluster do when not all nodes acknowledge the prep?

New membership.

Quoted 1 line

When they die during recover_slot()?

New membership.

Quoted 1 line

Which node recovers the slot?

recover_slot() and recover_done() is called on all nodes because it also has to relay the failing node and the new membership. So, any node can perform the recovery.

With this patch series, it is working just as it would before: All nodes call recovery. the one who locks the journal first performs the recovery.

Quoted 70 lines
Quoted 55 lines
---
  fs/ocfs2/stack_user.c | 70 +++++++++++++++++++++++++++++++++++++--------------
  1 file changed, 51 insertions(+), 19 deletions(-)
fs/ocfs2/stack_user.c +35 -1
index 286edf1..b44490b 100644
@@ -799,14 +799,63 @@ static int fs_protocol_compare(struct ocfs2_protocol_version *existing,
  	return 0;
  }
 
+static void user_recover_prep(void *arg)
+{
+}
+
+static void user_recover_slot(void *arg, struct dlm_slot *slot)
+{
+}
+
+static void user_recover_done(void *arg, struct dlm_slot *slots,
+			      int num_slots, int our_slot,
+			      uint32_t generation)
+{
+}
+
+const struct dlm_lockspace_ops ocfs2_ls_ops = {
+	.recover_prep = user_recover_prep,
+	.recover_slot = user_recover_slot,
+	.recover_done = user_recover_done,
+};
+
+static int user_cluster_disconnect(struct ocfs2_cluster_connection *conn)
+{
+	dlm_release_lockspace(conn->cc_lockspace, 2);
+	conn->cc_lockspace = NULL;
+	ocfs2_live_connection_drop(conn->cc_private);
+	conn->cc_private = NULL;
+	return 0;
+}
+
  static int user_cluster_connect(struct ocfs2_cluster_connection *conn)
  {
  	dlm_lockspace_t *fsdlm;
  	struct ocfs2_live_connection *uninitialized_var(control);
-	int rc = 0;
+	int rc = 0, ops_rv;
 
  	BUG_ON(conn == NULL);
 
+	rc = dlm_new_lockspace(conn->cc_name, NULL, DLM_LSFL_FS, DLM_LVB_LEN,
+				&ocfs2_ls_ops, conn, &ops_rv, &fsdlm);
+
+	if (rc)
+		goto out;

fs/ocfs2/stack_user.c static int fs_protocol_compare(struct ocfs2_protocol_version *existing, · line 853

Quoted 10 lines
fs/ocfs2/stack_user.c +10 -0
+
+	if (!ops_rv) {
+		/* DLM lockspace creation with newer new_lockspace successful */
+		goto out;
+	} else if (ops_rv != -EOPNOTSUPP) {
+		rc = ops_rv;
+		goto out;
+	}
+
+	conn->cc_lockspace = fsdlm;

This code returns from !ops_rv before setting cc_lockspace, yet tries to reference it out in user_cluster_disconnect(). That looks like a crashing bug.

Quoted 5 lines

Also, it looks like you call the new form of dlm_new_lockspace() before the callbacks are even implemented. If I just apply this patch, the code does not work. Please reorder the patch so that ocfs2 works at each patch.

Ok.

Quoted 57 lines

Joel

Quoted 53 lines
fs/ocfs2/stack_user.c +6 -19
+
+	printk(KERN_NOTICE "ocfs2: You seem to be using an older version "
+			"of dlm_controld and/or ocfs2-tools. Please consider "
+			"upgrading.\n");
+
  	rc = ocfs2_live_connection_new(conn, &control);
  	if (rc)
  		goto out;
@@ -823,32 +872,15 @@ static int user_cluster_connect(struct ocfs2_cluster_connection *conn)
  		       conn->cc_version.pv_major, conn->cc_version.pv_minor,
  		       running_proto.pv_major, running_proto.pv_minor);
  		rc = -EPROTO;
-		ocfs2_live_connection_drop(control);
-		goto out;
-	}
-
-	rc = dlm_new_lockspace(conn->cc_name, NULL, DLM_LSFL_FS, DLM_LVB_LEN,
-			       NULL, NULL, NULL, &fsdlm);
-	if (rc) {
-		ocfs2_live_connection_drop(control);
+		user_cluster_disconnect(conn);
  		goto out;
  	}
 
  	conn->cc_private = control;
-	conn->cc_lockspace = fsdlm;
  out:
  	return rc;
  }
 
-static int user_cluster_disconnect(struct ocfs2_cluster_connection *conn)
-{
-	dlm_release_lockspace(conn->cc_lockspace, 2);
-	conn->cc_lockspace = NULL;
-	ocfs2_live_connection_drop(conn->cc_private);
-	conn->cc_private = NULL;
-	return 0;
-}
-
  static int user_cluster_this_node(unsigned int *this_node)
  {
  	int rc;
--

1.8.1.4

--
Goldwyn

_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel

Signature · 1 line
Goldwyn