[Ocfs2-tools-devel] [PATCH 21/25] libocfs2: Add c_flags to struct o2cb_cluster_desc
Sunil Mushran
sunil.mushran at Oracle.COM
Wed Jun 23 11:44:31 PDT 2010
ocfs2_fill_cluster_desc() and ocfs2_set_cluster_desc() are now aware of
cluster flags.
Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
---
include/o2cb/o2cb.h | 1 +
libo2cb/o2cb_abi.c | 19 +++++++++++++------
libo2cb/o2cb_abi.h | 5 +++++
libocfs2/dlm.c | 32 ++++++++++++++++++++++++++++++++
4 files changed, 51 insertions(+), 6 deletions(-)
diff --git a/include/o2cb/o2cb.h b/include/o2cb/o2cb.h
index 4ac35cb..e051a2d 100644
--- a/include/o2cb/o2cb.h
+++ b/include/o2cb/o2cb.h
@@ -81,6 +81,7 @@ struct o2cb_cluster_desc {
char *c_cluster; /* The name of the cluster, NULL for the
default cluster, which is only valid in
the classic stack. */
+ uint8_t c_flags;
};
struct o2cb_region_desc {
diff --git a/libo2cb/o2cb_abi.c b/libo2cb/o2cb_abi.c
index 18888fc..e88bbfe 100644
--- a/libo2cb/o2cb_abi.c
+++ b/libo2cb/o2cb_abi.c
@@ -1702,21 +1702,18 @@ errcode_t o2cb_running_cluster_desc(struct o2cb_cluster_desc *cluster)
errcode_t err;
const char *stack;
char **clusters = NULL;
+ int globalhb;
+ /* c_stack */
err = o2cb_get_stack_name(&stack);
if (err)
return err;
- if (!strcmp(stack, classic_stack.s_name)) {
- cluster->c_stack = NULL;
- cluster->c_cluster = NULL;
- return 0;
- }
-
cluster->c_stack = strdup(stack);
if (!cluster->c_stack)
return O2CB_ET_NO_MEMORY;
+ /* c_cluster */
err = o2cb_list_clusters(&clusters);
if (err) {
free(cluster->c_stack);
@@ -1733,6 +1730,16 @@ errcode_t o2cb_running_cluster_desc(struct o2cb_cluster_desc *cluster)
}
o2cb_free_cluster_list(clusters);
+ /* c_flags */
+ err = o2cb_global_heartbeat_mode(cluster->c_cluster, &globalhb);
+ if (err)
+ return err;
+
+ cluster->c_flags = 0;
+
+ if (globalhb)
+ cluster->c_flags |= OCFS2_CLUSTER_O2CB_GLOBAL_HEARTBEAT;
+
return 0;
}
diff --git a/libo2cb/o2cb_abi.h b/libo2cb/o2cb_abi.h
index 1edbf74..727b7a8 100644
--- a/libo2cb/o2cb_abi.h
+++ b/libo2cb/o2cb_abi.h
@@ -43,4 +43,9 @@
#define O2CB_GLOBAL_HEARTBEAT_TAG "global"
+/*
+ * Cluster info flags (ocfs2_cluster_info.ci_stackflags)
+ */
+#define OCFS2_CLUSTER_O2CB_GLOBAL_HEARTBEAT (0x01)
+
#endif /* _O2CB_ABI_H */
diff --git a/libocfs2/dlm.c b/libocfs2/dlm.c
index 2f23e9b..e9ea3f8 100644
--- a/libocfs2/dlm.c
+++ b/libocfs2/dlm.c
@@ -110,6 +110,7 @@ errcode_t ocfs2_fill_cluster_desc(ocfs2_filesys *fs,
if (!ocfs2_clusterinfo_valid(sb)) {
desc->c_stack = NULL;
desc->c_cluster = NULL;
+ desc->c_flags = 0;
return 0;
}
@@ -128,9 +129,36 @@ errcode_t ocfs2_fill_cluster_desc(ocfs2_filesys *fs,
memcpy(desc->c_cluster, sb->s_cluster_info.ci_cluster,
OCFS2_CLUSTER_NAME_LEN);
+ if (ocfs2_clusterinfo_v2(sb))
+ desc->c_flags = sb->s_cluster_info.ci_stackflags;
+
return 0;
}
+errcode_t ocfs2_set_cluster_flags(ocfs2_filesys *fs,
+ struct o2cb_cluster_desc *desc)
+{
+ errcode_t ret = 0;
+ struct ocfs2_super_block *sb = OCFS2_RAW_SB(fs->fs_super);
+ int globalhb;
+
+ if (!ocfs2_clusterinfo_v2(sb))
+ goto out;
+
+ if (ocfs2_o2cb_stack(sb)) {
+ ret = o2cb_global_heartbeat_mode(desc->c_cluster, &globalhb);
+ if (ret)
+ goto out;
+ if (globalhb)
+ sb->s_cluster_info.ci_stackflags |=
+ OCFS2_CLUSTER_O2CB_GLOBAL_HEARTBEAT;
+ }
+
+out:
+ return ret;
+}
+
+
errcode_t ocfs2_set_cluster_desc(ocfs2_filesys *fs,
struct o2cb_cluster_desc *desc)
{
@@ -161,6 +189,10 @@ errcode_t ocfs2_set_cluster_desc(ocfs2_filesys *fs,
OCFS2_STACK_LABEL_LEN);
memcpy(sb->s_cluster_info.ci_cluster, desc->c_cluster,
OCFS2_CLUSTER_NAME_LEN);
+
+ ret = ocfs2_set_cluster_flags(fs, desc);
+ if (ret)
+ goto out;
} else {
sb->s_feature_incompat &=
~(OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK |
--
1.7.0.4
More information about the Ocfs2-tools-devel
mailing list