]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ocfs2: add clustername to cluster connection
authorGoldwyn Rodrigues <rgoldwyn@suse.de>
Tue, 5 Nov 2013 05:55:08 +0000 (16:55 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 5 Nov 2013 05:55:08 +0000 (16:55 +1100)
This is an effort of removing ocfs2_controld.pcmk and getting ocfs2 DLM
handling up to the times with respect to DLM (>=4.0.1) and corosync
(2.3.x).  AFAIK, cman also is being phased out for a unified corosync
cluster stack.

fs/dlm performs all the functions with respect to fencing and node
management and provides the API's to do so for ocfs2.  For all future
references, DLM stands for fs/dlm code.

The advantages are:
 + No need to run an additional userspace daemon (ocfs2_controld)
 + No contrrold devince handling and controld protocol
 + Shifting responsibilities of node management to DLM layer

For backward compatibility, we are keeping the controld handling code.
Once enough time has passed we can remove a significant portion of the
code.

This feature requires modification in the userspace ocfs2-tools.  The
changes can be found at: https://github.com/goldwynr/ocfs2-tools branch:
nocontrold Currently, not many checks are present in the userspace code,
but that would change soon.

These changes were developed on linux-stable 3.11.y.  However, the changes
are applicable to the current upstream as well.  If you wish to give the
entire kernel a spin, the link is:

https://github.com/goldwynr/linux-stable branch: nocontrold

This patch (of 6):

Add clustername to cluster connection.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Mark Fasheh <mfasheh@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/ocfs2/dlmglue.c
fs/ocfs2/ocfs2.h
fs/ocfs2/stackglue.c
fs/ocfs2/stackglue.h
fs/ocfs2/super.c

index 3a44a648dae7709b1cd5431c426cf3b9e057e54a..7c57de3882a47601d48412ec3c218abf3a2668a3 100644 (file)
@@ -2996,6 +2996,8 @@ int ocfs2_dlm_init(struct ocfs2_super *osb)
 
        /* for now, uuid == domain */
        status = ocfs2_cluster_connect(osb->osb_cluster_stack,
+                                      osb->osb_cluster_name,
+                                      strlen(osb->osb_cluster_name),
                                       osb->uuid_str,
                                       strlen(osb->uuid_str),
                                       &lproto, ocfs2_do_node_down, osb,
index 3a903470c794ec61dace1c03f9446cfe5f388e9c..553f53cc73ae532f7bad618b17f566ecba6bb690 100644 (file)
@@ -387,6 +387,7 @@ struct ocfs2_super
        u8 osb_stackflags;
 
        char osb_cluster_stack[OCFS2_STACK_LABEL_LEN + 1];
+       char osb_cluster_name[OCFS2_CLUSTER_NAME_LEN + 1];
        struct ocfs2_cluster_connection *cconn;
        struct ocfs2_lock_res osb_super_lockres;
        struct ocfs2_lock_res osb_rename_lockres;
index 39abf89697edfc296173dce40a3e5aab1575202b..58b53f9a4d833a64eae3ac7dacc408c136c6e010 100644 (file)
@@ -309,6 +309,8 @@ int ocfs2_plock(struct ocfs2_cluster_connection *conn, u64 ino,
 EXPORT_SYMBOL_GPL(ocfs2_plock);
 
 int ocfs2_cluster_connect(const char *stack_name,
+                         const char *cluster_name,
+                         int cluster_name_len,
                          const char *group,
                          int grouplen,
                          struct ocfs2_locking_protocol *lproto,
@@ -342,8 +344,10 @@ int ocfs2_cluster_connect(const char *stack_name,
                goto out;
        }
 
-       memcpy(new_conn->cc_name, group, grouplen);
+       strlcpy(new_conn->cc_name, group, grouplen + 1);
        new_conn->cc_namelen = grouplen;
+       strlcpy(new_conn->cc_cluster_name, cluster_name, cluster_name_len + 1);
+       new_conn->cc_cluster_name_len = cluster_name_len;
        new_conn->cc_recovery_handler = recovery_handler;
        new_conn->cc_recovery_data = recovery_data;
 
@@ -386,8 +390,9 @@ int ocfs2_cluster_connect_agnostic(const char *group,
 
        if (cluster_stack_name[0])
                stack_name = cluster_stack_name;
-       return ocfs2_cluster_connect(stack_name, group, grouplen, lproto,
-                                    recovery_handler, recovery_data, conn);
+       return ocfs2_cluster_connect(stack_name, NULL, 0, group, grouplen,
+                                    lproto, recovery_handler, recovery_data,
+                                    conn);
 }
 EXPORT_SYMBOL_GPL(ocfs2_cluster_connect_agnostic);
 
index 1ec56fdb8d0d91752682bc532132dc6ae9cc029b..b46fd51f2e423413e9a0f84d88902fffeaced752 100644 (file)
@@ -45,6 +45,9 @@ struct file_lock;
  */
 #define GROUP_NAME_MAX         64
 
+/* This shadows  OCFS2_CLUSTER_NAME_LEN */
+#define CLUSTER_NAME_MAX       16
+
 
 /*
  * ocfs2_protocol_version changes when ocfs2 does something different in
@@ -99,6 +102,8 @@ struct ocfs2_locking_protocol {
 struct ocfs2_cluster_connection {
        char cc_name[GROUP_NAME_MAX];
        int cc_namelen;
+       char cc_cluster_name[CLUSTER_NAME_MAX];
+       int cc_cluster_name_len;
        struct ocfs2_protocol_version cc_version;
        struct ocfs2_locking_protocol *cc_proto;
        void (*cc_recovery_handler)(int node_num, void *recovery_data);
@@ -239,6 +244,8 @@ struct ocfs2_stack_plugin {
 
 /* Used by the filesystem */
 int ocfs2_cluster_connect(const char *stack_name,
+                         const char *cluster_name,
+                         int cluster_name_len,
                          const char *group,
                          int grouplen,
                          struct ocfs2_locking_protocol *lproto,
index c41492957aa5f4ab4f7aa7a056ac2715a352c2b7..817080b3925347e40fa4512370de2774c2151ce5 100644 (file)
@@ -2225,9 +2225,9 @@ static int ocfs2_initialize_super(struct super_block *sb,
        if (ocfs2_clusterinfo_valid(osb)) {
                osb->osb_stackflags =
                        OCFS2_RAW_SB(di)->s_cluster_info.ci_stackflags;
-               memcpy(osb->osb_cluster_stack,
+               strlcpy(osb->osb_cluster_stack,
                       OCFS2_RAW_SB(di)->s_cluster_info.ci_stack,
-                      OCFS2_STACK_LABEL_LEN);
+                      OCFS2_STACK_LABEL_LEN + 1);
                osb->osb_cluster_stack[OCFS2_STACK_LABEL_LEN] = '\0';
                if (strlen(osb->osb_cluster_stack) != OCFS2_STACK_LABEL_LEN) {
                        mlog(ML_ERROR,
@@ -2237,6 +2237,9 @@ static int ocfs2_initialize_super(struct super_block *sb,
                        status = -EINVAL;
                        goto bail;
                }
+               strlcpy(osb->osb_cluster_name,
+                       OCFS2_RAW_SB(di)->s_cluster_info.ci_cluster,
+                       OCFS2_CLUSTER_NAME_LEN + 1);
        } else {
                /* The empty string is identical with classic tools that
                 * don't know about s_cluster_info. */