[Ocfs2-tools-devel] [PATCH 20/32] libocfs2: Add an incompat feature flag OCFS2_FEATURE_INCOMPAT_CLUSTERINFO
Sunil Mushran
sunil.mushran at oracle.com
Tue Sep 14 15:54:50 PDT 2010
OCFS2_FEATURE_INCOMPAT_CLUSTERINFO allows us to use sb->s_cluster_info for
both userspace and o2cb cluster stacks. It also allows us to extend cluster
info to include stack flags.
This incompat flag can be set/cleared using tunefs.ocfs2 --fs-features.
Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
---
debugfs.ocfs2/dump.c | 2 +-
include/ocfs2-kernel/ocfs2_fs.h | 18 +++++++++++++-----
include/ocfs2/ocfs2.h | 25 ++++++++++++++++++++++++-
libocfs2/checkhb.c | 2 +-
libocfs2/dlm.c | 2 +-
libocfs2/feature_string.c | 9 +++++++++
mkfs.ocfs2/check.c | 2 +-
7 files changed, 50 insertions(+), 10 deletions(-)
diff --git a/debugfs.ocfs2/dump.c b/debugfs.ocfs2/dump.c
index 90e8fe1..fcdee0c 100644
--- a/debugfs.ocfs2/dump.c
+++ b/debugfs.ocfs2/dump.c
@@ -93,7 +93,7 @@ void dump_super_block(FILE *out, struct ocfs2_super_block *sb)
for (i = 0; i < 3; i++)
fprintf(out, "\tDX Seed[%d]: 0x%08x\n", i, sb->s_dx_seed[i]);
- if (ocfs2_userspace_stack(sb))
+ if (ocfs2_clusterinfo_valid(sb))
fprintf(out,
"\tCluster stack: %s\n"
"\tCluster name: %s\n",
diff --git a/include/ocfs2-kernel/ocfs2_fs.h b/include/ocfs2-kernel/ocfs2_fs.h
index ffda634..5d335ad 100644
--- a/include/ocfs2-kernel/ocfs2_fs.h
+++ b/include/ocfs2-kernel/ocfs2_fs.h
@@ -101,7 +101,8 @@
| OCFS2_FEATURE_INCOMPAT_XATTR \
| OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE \
| OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS \
- | OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG)
+ | OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG \
+ | OCFS2_FEATURE_INCOMPAT_CLUSTERINFO)
#define OCFS2_FEATURE_RO_COMPAT_SUPP (OCFS2_FEATURE_RO_COMPAT_UNWRITTEN \
| OCFS2_FEATURE_RO_COMPAT_USRQUOTA \
| OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)
@@ -170,6 +171,13 @@
#define OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG 0x2000
/*
+ * Incompat bit to indicate useable clusterinfo with stackflags for all
+ * cluster stacks (userspace adnd o2cb). If this bit is set,
+ * INCOMPAT_USERSPACE_STACK becomes superfluous and thus should not be set.
+ */
+#define OCFS2_FEATURE_INCOMPAT_CLUSTERINFO 0x4000
+
+/*
* backup superblock flag is used to indicate that this volume
* has backup superblocks.
*/
@@ -282,7 +290,7 @@
#define OCFS2_VOL_UUID_LEN 16
#define OCFS2_MAX_VOL_LABEL_LEN 64
-/* The alternate, userspace stack fields */
+/* The cluster stack fields */
#define OCFS2_STACK_LABEL_LEN 4
#define OCFS2_CLUSTER_NAME_LEN 16
@@ -602,9 +610,9 @@ struct ocfs2_super_block {
* group header */
/*50*/ __u8 s_label[OCFS2_MAX_VOL_LABEL_LEN]; /* Label for mounting, etc. */
/*90*/ __u8 s_uuid[OCFS2_VOL_UUID_LEN]; /* 128-bit uuid */
-/*A0*/ struct ocfs2_cluster_info s_cluster_info; /* Selected userspace
- stack. Only valid
- with INCOMPAT flag. */
+/*A0*/ struct ocfs2_cluster_info s_cluster_info; /* Only valid if either
+ userspace or clusterinfo
+ INCOMPAT flag set. */
/*B8*/ __le16 s_xattr_inline_size; /* extended attribute inline size
for this fs*/
__le16 s_reserved0;
diff --git a/include/ocfs2/ocfs2.h b/include/ocfs2/ocfs2.h
index 8fcc9e1..e9b43f2 100644
--- a/include/ocfs2/ocfs2.h
+++ b/include/ocfs2/ocfs2.h
@@ -136,6 +136,9 @@
#define OCFS2_QF_INFO_DIRTY 1
#define OCFS2_QF_INFO_LOADED 2
+/* Classic (historically speaking) cluster stack */
+#define OCFS2_CLASSIC_CLUSTER_STACK "o2cb"
+
typedef void (*ocfs2_chb_notify)(int state, char *progress, void *data);
typedef struct _ocfs2_filesys ocfs2_filesys;
@@ -1234,9 +1237,29 @@ static inline int ocfs2_sparse_alloc(struct ocfs2_super_block *osb)
return 0;
}
+static inline int ocfs2_clusterinfo_valid(struct ocfs2_super_block *osb)
+{
+ if (osb->s_feature_incompat &
+ (OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK |
+ OCFS2_FEATURE_INCOMPAT_CLUSTERINFO))
+ return 1;
+ return 0;
+}
+
static inline int ocfs2_userspace_stack(struct ocfs2_super_block *osb)
{
- if (osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK)
+ if (ocfs2_clusterinfo_valid(osb) &&
+ memcmp(osb->s_cluster_info.ci_stack, OCFS2_CLASSIC_CLUSTER_STACK,
+ OCFS2_STACK_LABEL_LEN))
+ return 1;
+ return 0;
+}
+
+static inline int ocfs2_o2cb_stack(struct ocfs2_super_block *osb)
+{
+ if (ocfs2_clusterinfo_valid(osb) &&
+ !memcmp(osb->s_cluster_info.ci_stack, OCFS2_CLASSIC_CLUSTER_STACK,
+ OCFS2_STACK_LABEL_LEN))
return 1;
return 0;
}
diff --git a/libocfs2/checkhb.c b/libocfs2/checkhb.c
index 0c28f80..9b57697 100644
--- a/libocfs2/checkhb.c
+++ b/libocfs2/checkhb.c
@@ -99,7 +99,7 @@ errcode_t ocfs2_check_heartbeats(struct list_head *dev_list, int ignore_local)
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_userspace_stack(OCFS2_RAW_SB(fs->fs_super)))
+ else if (ocfs2_clusterinfo_valid(OCFS2_RAW_SB(fs->fs_super)))
snprintf(dev->stack, sizeof(dev->stack), "%.*s",
OCFS2_STACK_LABEL_LEN,
OCFS2_RAW_SB(fs->fs_super)->s_cluster_info.ci_stack);
diff --git a/libocfs2/dlm.c b/libocfs2/dlm.c
index 4c8cda8..8751c07 100644
--- a/libocfs2/dlm.c
+++ b/libocfs2/dlm.c
@@ -107,7 +107,7 @@ errcode_t ocfs2_fill_cluster_desc(ocfs2_filesys *fs,
errcode_t ret = 0;
struct ocfs2_super_block *sb = OCFS2_RAW_SB(fs->fs_super);
- if (!ocfs2_userspace_stack(sb)) {
+ if (!ocfs2_clusterinfo_valid(sb)) {
desc->c_stack = NULL;
desc->c_cluster = NULL;
return 0;
diff --git a/libocfs2/feature_string.c b/libocfs2/feature_string.c
index 0f3dcf8..2a052e9 100644
--- a/libocfs2/feature_string.c
+++ b/libocfs2/feature_string.c
@@ -181,6 +181,11 @@ static struct fs_feature_flags ocfs2_supported_features[] = {
{0, OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG, 0},
},
{
+ "clusterinfo",
+ {0, OCFS2_FEATURE_INCOMPAT_CLUSTERINFO, 0},
+ {0, OCFS2_FEATURE_INCOMPAT_CLUSTERINFO, 0},
+ },
+ {
NULL,
{0, 0, 0},
{0, 0, 0}
@@ -268,6 +273,10 @@ static struct feature_name ocfs2_feature_names[] = {
.fn_flag = {0, OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG, 0},
},
{
+ .fn_name = "clusterinfo",
+ .fn_flag = {0, OCFS2_FEATURE_INCOMPAT_CLUSTERINFO, 0},
+ },
+ {
.fn_name = NULL,
},
};
diff --git a/mkfs.ocfs2/check.c b/mkfs.ocfs2/check.c
index e48707e..597b87b 100644
--- a/mkfs.ocfs2/check.c
+++ b/mkfs.ocfs2/check.c
@@ -64,7 +64,7 @@ static void disk_fill(const char *device, char **stack_name,
if (err)
return;
- if (!ocfs2_userspace_stack(OCFS2_RAW_SB(fs->fs_super))) {
+ if (!ocfs2_clusterinfo_valid(OCFS2_RAW_SB(fs->fs_super))) {
*stack_name = strdup("o2cb");
goto close;
}
--
1.7.0.4
More information about the Ocfs2-tools-devel
mailing list