[Ocfs2-tools-devel] [PATCH 30/32] mounted.ocfs2: Show cluster and global heartbeat
Sunil Mushran
sunil.mushran at oracle.com
Tue Sep 14 15:55:00 PDT 2010
Tweak output to show the cluster name and global heartbeat (for o2cb only).
Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
---
include/ocfs2/ocfs2.h | 4 +++-
libocfs2/checkhb.c | 33 +++++++++++++++++++--------------
mounted.ocfs2/mounted.c | 23 ++++++++++++++++-------
3 files changed, 38 insertions(+), 22 deletions(-)
diff --git a/include/ocfs2/ocfs2.h b/include/ocfs2/ocfs2.h
index fe4ebb1..285970b 100644
--- a/include/ocfs2/ocfs2.h
+++ b/include/ocfs2/ocfs2.h
@@ -232,7 +232,9 @@ struct _ocfs2_devices {
int mount_flags;
int fs_type; /* 0=unknown, 1=ocfs, 2=ocfs2 */
int hb_dev;
- char stack[8]; /* Local, O2CB, CMAN, PCMK */
+ char stack[OCFS2_STACK_LABEL_LEN + 1]; /* Local, O2CB, CMAN, PCMK */
+ char cluster[OCFS2_CLUSTER_NAME_LEN + 1];
+ unsigned char stackflags;
uint32_t maj_num; /* major number of the device */
uint32_t min_num; /* minor number of the device */
errcode_t errcode; /* error encountered reading device */
diff --git a/libocfs2/checkhb.c b/libocfs2/checkhb.c
index 9b57697..d223891 100644
--- a/libocfs2/checkhb.c
+++ b/libocfs2/checkhb.c
@@ -58,6 +58,7 @@
errcode_t ocfs2_check_heartbeats(struct list_head *dev_list, int ignore_local)
{
ocfs2_filesys *fs = NULL;
+ struct ocfs2_super_block *osb;
errcode_t ret = 0;
struct list_head *pos;
ocfs2_devices *dev = NULL;
@@ -78,8 +79,10 @@ errcode_t ocfs2_check_heartbeats(struct list_head *dev_list, int ignore_local)
} else
dev->fs_type = 2;
- if (OCFS2_HAS_INCOMPAT_FEATURE(OCFS2_RAW_SB(fs->fs_super),
- OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV))
+ osb = OCFS2_RAW_SB(fs->fs_super);
+
+ if (OCFS2_HAS_INCOMPAT_FEATURE(osb,
+ OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV))
dev->hb_dev = 1;
/* is it locally mounted */
@@ -91,20 +94,22 @@ errcode_t ocfs2_check_heartbeats(struct list_head *dev_list, int ignore_local)
}
/* get label/uuid for ocfs2 */
- memcpy(dev->label, OCFS2_RAW_SB(fs->fs_super)->s_label,
- sizeof(dev->label));
- memcpy(dev->uuid, OCFS2_RAW_SB(fs->fs_super)->s_uuid,
- sizeof(dev->uuid));
-
- if (OCFS2_HAS_INCOMPAT_FEATURE(OCFS2_RAW_SB(fs->fs_super),
- OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT))
- snprintf(dev->stack, sizeof(dev->stack), "%s", "local");
- else if (ocfs2_clusterinfo_valid(OCFS2_RAW_SB(fs->fs_super)))
+ memcpy(dev->label, osb->s_label, sizeof(dev->label));
+ memcpy(dev->uuid, osb->s_uuid, sizeof(dev->uuid));
+
+ if (ocfs2_mount_local(fs))
+ snprintf(dev->stack, sizeof(dev->stack), "%s", "None");
+ else if (ocfs2_clusterinfo_valid(osb)) {
snprintf(dev->stack, sizeof(dev->stack), "%.*s",
OCFS2_STACK_LABEL_LEN,
- OCFS2_RAW_SB(fs->fs_super)->s_cluster_info.ci_stack);
- else
- snprintf(dev->stack, sizeof(dev->stack), "%s", "o2cb");
+ osb->s_cluster_info.ci_stack);
+ snprintf(dev->cluster, sizeof(dev->cluster), "%.*s",
+ OCFS2_CLUSTER_NAME_LEN,
+ osb->s_cluster_info.ci_cluster);
+ dev->stackflags = osb->s_cluster_info.ci_stackflags;
+ } else
+ snprintf(dev->stack, sizeof(dev->stack), "%s",
+ OCFS2_CLASSIC_CLUSTER_STACK);
if (dev->hb_dev)
goto close;
diff --git a/mounted.ocfs2/mounted.c b/mounted.ocfs2/mounted.c
index 10d421e..d501a62 100644
--- a/mounted.ocfs2/mounted.c
+++ b/mounted.ocfs2/mounted.c
@@ -110,7 +110,7 @@ static void ocfs2_print_full_detect(struct list_head *dev_list)
printf("%-20s %-5s %s\n", "Device", "FS", "Nodes");
list_for_each(pos, dev_list) {
dev = list_entry(pos, ocfs2_devices, list);
- if (dev->fs_type == 0)
+ if (dev->fs_type != 2)
continue;
printf("%-20s %-5s ", dev->dev_name, "ocfs2");
@@ -144,12 +144,13 @@ static void ocfs2_print_quick_detect(struct list_head *dev_list)
char uuid[OCFS2_VOL_UUID_LEN * 2 + 1];
int i;
char *p;
+ char cluster[OCFS2_CLUSTER_NAME_LEN + 4];
- printf("%-20s %-5s %-5s %-32s %-s\n", "Device", "FS", "Stack",
- "UUID", "Label");
+ printf("%-20s %-5s %-20s %-32s %-s\n", "Device", "Stack",
+ "Cluster", "UUID", "Label");
list_for_each(pos, dev_list) {
dev = list_entry(pos, ocfs2_devices, list);
- if (dev->fs_type == 0)
+ if (dev->fs_type != 2)
continue;
for (i = 0, p = uuid; i < OCFS2_VOL_UUID_LEN; i++) {
@@ -157,9 +158,17 @@ static void ocfs2_print_quick_detect(struct list_head *dev_list)
p += 2;
}
- printf("%-20s %-5s %-5s %-32s %-s\n", dev->dev_name,
- (dev->fs_type == 2 ? "ocfs2" : "ocfs"), dev->stack,
- uuid, dev->label);
+ snprintf(cluster, sizeof(cluster), dev->cluster);
+
+ if (!strcmp(dev->stack, OCFS2_CLASSIC_CLUSTER_STACK)) {
+ if (dev->stackflags &
+ OCFS2_CLUSTER_O2CB_GLOBAL_HEARTBEAT)
+ strncat(cluster, " (G)",
+ sizeof(cluster) - strlen(cluster));
+ }
+
+ printf("%-20s %-5s %-20s %-32s %-s\n",
+ dev->dev_name, dev->stack, cluster, uuid, dev->label);
}
}
--
1.7.0.4
More information about the Ocfs2-tools-devel
mailing list