[Ocfs2-tools-devel] [PATCH 19/25] libocfs2: Add an incompat feature flag OCFS2_FEATURE_INCOMPAT_O2CB_STACK
Sunil Mushran
sunil.mushran at oracle.com
Wed Jun 23 11:44:29 PDT 2010
OCFS2_FEATURE_INCOMPAT_O2CB_STACK is set if o2cb cluster stack is active.
This flag allows us to use the cluster_info fields in the super block store
o2cb related info.
Like the userspace-stack incompat flag, this flag is set and cleared by using
tunefs.ocfs2 --update-cluster-stack.
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 | 17 +++++++++++++++++
libocfs2/checkhb.c | 2 +-
libocfs2/dlm.c | 13 +++++++++----
libocfs2/feature_string.c | 8 ++++++++
mkfs.ocfs2/check.c | 2 +-
mkfs.ocfs2/mkfs.c | 11 +++++++++--
tunefs.ocfs2/feature_local.c | 3 ++-
9 files changed, 61 insertions(+), 15 deletions(-)
diff --git a/debugfs.ocfs2/dump.c b/debugfs.ocfs2/dump.c
index d0b1d4f..dc59071 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 6fc63e8..7b7de72 100644
--- a/include/ocfs2-kernel/ocfs2_fs.h
+++ b/include/ocfs2-kernel/ocfs2_fs.h
@@ -100,7 +100,8 @@
| OCFS2_FEATURE_INCOMPAT_META_ECC \
| OCFS2_FEATURE_INCOMPAT_XATTR \
| OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE \
- | OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS)
+ | OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS \
+ | OCFS2_FEATURE_INCOMPAT_O2CB_STACK)
#define OCFS2_FEATURE_RO_COMPAT_SUPP (OCFS2_FEATURE_RO_COMPAT_UNWRITTEN \
| OCFS2_FEATURE_RO_COMPAT_USRQUOTA \
| OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)
@@ -166,6 +167,13 @@
#define OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE 0x1000
/*
+ * Optional incompat bit to indicate o2cb stack. With this bit set, users
+ * can read the s_cluster_info to read/write the cluster_name. Both this bit
+ * and the userspace stack bit cannot be set at the same time.
+ */
+#define OCFS2_FEATURE_INCOMPAT_O2CB_STACK 0x2000
+
+/*
* backup superblock flag is used to indicate that this volume
* has backup superblocks.
*/
@@ -278,7 +286,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
@@ -595,9 +603,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 o2cb stack
+ 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 e452960..34e83f4 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,6 +1237,20 @@ static inline int ocfs2_userspace_stack(struct ocfs2_super_block *osb)
return 0;
}
+static inline int ocfs2_o2cb_stack(struct ocfs2_super_block *osb)
+{
+ if (osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_O2CB_STACK)
+ return 1;
+ return 0;
+}
+
+static inline int ocfs2_clusterinfo_valid(struct ocfs2_super_block *osb)
+{
+ if (ocfs2_userspace_stack(osb) || ocfs2_o2cb_stack(osb))
+ return 1;
+ return 0;
+}
+
static inline int ocfs2_writes_unwritten_extents(struct ocfs2_super_block *osb)
{
/*
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..2f23e9b 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;
@@ -151,15 +151,20 @@ errcode_t ocfs2_set_cluster_desc(ocfs2_filesys *fs,
if (ret)
goto out;
}
- sb->s_feature_incompat |=
- OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK;
+ if (!strcmp(desc->c_stack, OCFS2_CLASSIC_CLUSTER_STACK))
+ sb->s_feature_incompat |=
+ OCFS2_FEATURE_INCOMPAT_O2CB_STACK;
+ else
+ sb->s_feature_incompat |=
+ OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK;
memcpy(sb->s_cluster_info.ci_stack, desc->c_stack,
OCFS2_STACK_LABEL_LEN);
memcpy(sb->s_cluster_info.ci_cluster, desc->c_cluster,
OCFS2_CLUSTER_NAME_LEN);
} else {
sb->s_feature_incompat &=
- ~OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK;
+ ~(OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK |
+ OCFS2_FEATURE_INCOMPAT_O2CB_STACK);
}
ret = ocfs2_write_super(fs);
diff --git a/libocfs2/feature_string.c b/libocfs2/feature_string.c
index a6eeb2c..ad44807 100644
--- a/libocfs2/feature_string.c
+++ b/libocfs2/feature_string.c
@@ -218,6 +218,10 @@ static struct feature_name ocfs2_feature_names[] = {
.fn_flag = {0, OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK, 0},
},
{
+ .fn_name = "o2cb-stack",
+ .fn_flag = {0, OCFS2_FEATURE_INCOMPAT_O2CB_STACK, 0},
+ },
+ {
.fn_name = "backup-super",
.fn_flag = {OCFS2_FEATURE_COMPAT_BACKUP_SB, 0, 0},
},
@@ -258,6 +262,10 @@ static struct feature_name ocfs2_feature_names[] = {
.fn_flag = {0, OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE, 0},
},
{
+ .fn_name = "o2cb-stack",
+ .fn_flag = {0, OCFS2_FEATURE_INCOMPAT_O2CB_STACK, 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;
}
diff --git a/mkfs.ocfs2/mkfs.c b/mkfs.ocfs2/mkfs.c
index 5507872..10da1db 100644
--- a/mkfs.ocfs2/mkfs.c
+++ b/mkfs.ocfs2/mkfs.c
@@ -2243,8 +2243,15 @@ format_superblock(State *s, SystemFileDiskRecord *rec,
if (s->cluster_stack) {
s->feature_flags.opt_incompat |=
- (OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP|
- OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK);
+ OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP;
+
+ if (!strcmp(s->cluster_stack, OCFS2_CLASSIC_CLUSTER_STACK))
+ s->feature_flags.opt_incompat |=
+ OCFS2_FEATURE_INCOMPAT_O2CB_STACK;
+ else
+ s->feature_flags.opt_incompat |=
+ OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK;
+
memcpy(di->id2.i_super.s_cluster_info.ci_stack,
s->cluster_stack, OCFS2_STACK_LABEL_LEN);
memcpy(di->id2.i_super.s_cluster_info.ci_cluster,
diff --git a/tunefs.ocfs2/feature_local.c b/tunefs.ocfs2/feature_local.c
index dd71d3c..b56931d 100644
--- a/tunefs.ocfs2/feature_local.c
+++ b/tunefs.ocfs2/feature_local.c
@@ -126,7 +126,8 @@ static int enable_local(ocfs2_filesys *fs, int flags)
sb->s_feature_incompat |=
OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT;
sb->s_feature_incompat &=
- ~OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK;
+ ~(OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK |
+ OCFS2_FEATURE_INCOMPAT_O2CB_STACK);
tunefs_block_signals();
ret = ocfs2_write_super(fs);
--
1.7.0.4
More information about the Ocfs2-tools-devel
mailing list