[Ocfs2-tools-devel] [PATCH 27/39] o2cb: Introduce the cluster info
struct.
Joel Becker
joel.becker at oracle.com
Fri Mar 14 16:52:50 PDT 2008
The filesystem now has a field on disk called ocfs2_cluster_info. It
contains the name of the cluster stack and the name of the cluster. It
is only valid if the USERSPACE_STACK incompat bit is set. If the bit is
not set, the filesystem expects the classic stack.
libocfs2 gains a routine to read this field. It fills in a struct
o2cb_cluster_desc. If the classic stack is in use, the structure is
filled in with NULLs.
Likewise, o2cb_*_group_*() take the o2cb_cluster_desc structure rather
than a cluster name. This allows them to check the stack expected by
the filesystem with the stack actually in use. If a userspace stack,
the name will be passed over the wire to the control daemon.
Signed-off-by: Joel Becker <joel.becker at oracle.com>
---
include/o2cb/o2cb.h | 19 +++--
include/ocfs2-kernel/ocfs2_fs.h | 40 +++++++++-
include/ocfs2/ocfs2.h | 9 ++
libo2cb/o2cb_abi.c | 168 ++++++++++++++++++++++++---------------
libo2cb/o2cb_err.et | 3 +
libocfs2/dlm.c | 49 +++++++++++-
mount.ocfs2/mount.ocfs2.c | 18 +++-
mount.ocfs2/umount.ocfs2.c | 12 +++-
ocfs2_hb_ctl/ocfs2_hb_ctl.c | 12 ++-
9 files changed, 245 insertions(+), 85 deletions(-)
diff --git a/include/o2cb/o2cb.h b/include/o2cb/o2cb.h
index 2d94813..35e2d1d 100644
--- a/include/o2cb/o2cb.h
+++ b/include/o2cb/o2cb.h
@@ -68,6 +68,13 @@ void o2cb_free_cluster_list(char **clusters);
errcode_t o2cb_list_nodes(char *cluster_name, char ***nodes);
void o2cb_free_nodes_list(char **nodes);
+struct o2cb_cluster_desc {
+ char *c_stack; /* The cluster stack, NULL for classic */
+ char *c_cluster; /* The name of the cluster, NULL for the
+ default cluster, which is only valid in
+ the classic stack. */
+};
+
struct o2cb_region_desc {
char *r_name; /* The uuid of the region */
char *r_device_name; /* The device the region is on */
@@ -83,13 +90,13 @@ struct o2cb_region_desc {
* begin_group_join(). Regular programs (not mount.ocfs2) should provide
* a mountpoint that does not begin with a '/'. Eg, fsck could use "fsck"
*/
-errcode_t o2cb_begin_group_join(const char *cluster_name,
- struct o2cb_region_desc *desc);
-errcode_t o2cb_complete_group_join(const char *cluster_name,
- struct o2cb_region_desc *desc,
+errcode_t o2cb_begin_group_join(struct o2cb_cluster_desc *cluster,
+ struct o2cb_region_desc *region);
+errcode_t o2cb_complete_group_join(struct o2cb_cluster_desc *cluster,
+ struct o2cb_region_desc *region,
int result);
-errcode_t o2cb_group_leave(const char *cluster_name,
- struct o2cb_region_desc *desc);
+errcode_t o2cb_group_leave(struct o2cb_cluster_desc *cluster,
+ struct o2cb_region_desc *region);
errcode_t o2cb_get_hb_thread_pid (const char *cluster_name,
const char *region_name,
diff --git a/include/ocfs2-kernel/ocfs2_fs.h b/include/ocfs2-kernel/ocfs2_fs.h
index 56cbb48..e4903ef 100644
--- a/include/ocfs2-kernel/ocfs2_fs.h
+++ b/include/ocfs2-kernel/ocfs2_fs.h
@@ -89,7 +89,8 @@
#define OCFS2_FEATURE_INCOMPAT_SUPP (OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT \
| OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC \
| OCFS2_FEATURE_INCOMPAT_INLINE_DATA \
- | OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP)
+ | OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP \
+ | OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK)
#define OCFS2_FEATURE_RO_COMPAT_SUPP OCFS2_FEATURE_RO_COMPAT_UNWRITTEN
/*
@@ -131,6 +132,17 @@
/*
+ * Support for alternate, userspace cluster stacks. If set, the superblock
+ * field s_cluster_info contains a tag for the alternate stack in use as
+ * well as the name of the cluster being joined.
+ * mount.ocfs2 must pass in a matching stack name.
+ *
+ * If not set, the classic stack will be used. This is compatbile with
+ * all older versions.
+ */
+#define OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK 0x0080
+
+/*
* backup superblock flag is used to indicate that this volume
* has backup superblocks.
*/
@@ -272,6 +284,10 @@ struct ocfs2_new_group_input {
#define OCFS2_VOL_UUID_LEN 16
#define OCFS2_MAX_VOL_LABEL_LEN 64
+/* The alternate, userspace stack fields */
+#define OCFS2_STACK_LABEL_LEN 4
+#define OCFS2_CLUSTER_NAME_LEN 16
+
/* Journal limits (in bytes) */
#define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024)
@@ -471,6 +487,13 @@ struct ocfs2_extent_block
/* Actual on-disk size is one block */
};
+struct ocfs2_cluster_info {
+/*00*/ __u8 ci_stack[OCFS2_STACK_LABEL_LEN];
+ __le32 ci_reserved;
+/*08*/ __u8 ci_cluster[OCFS2_CLUSTER_NAME_LEN];
+/*18*/
+};
+
/*
* On disk slot map for OCFS2. This defines the contents of the "slot_map"
* system file. A slot is valid if it contains a node number >= 0. The
@@ -537,7 +560,20 @@ 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*/
+/*A0*/ struct ocfs2_cluster_info s_cluster_info; /* Selected userspace
+ stack. Only valid
+ with INCOMPAT flag. */
+/*B8*/ __le64 s_reserved2[17]; /* Fill out superblock */
+/*140*/
+
+ /*
+ * NOTE: As stated above, all offsets are relative to
+ * ocfs2_dinode.id2, which is at 0xC0 in the inode.
+ * 0xC0 + 0x140 = 0x200 or 512 bytes. A superblock must fit within
+ * our smallest blocksize, which is 512 bytes. To ensure this,
+ * we reserve the space in s_reserved2. Anything past s_reserved2
+ * will not be available on the smallest blocksize.
+ */
};
/*
diff --git a/include/ocfs2/ocfs2.h b/include/ocfs2/ocfs2.h
index 075e4d2..1cb1b9a 100644
--- a/include/ocfs2/ocfs2.h
+++ b/include/ocfs2/ocfs2.h
@@ -515,6 +515,8 @@ errcode_t ocfs2_file_read(ocfs2_cached_inode *ci, void *buf, uint32_t count,
errcode_t ocfs2_file_write(ocfs2_cached_inode *ci, void *buf, uint32_t count,
uint64_t offset, uint32_t *wrote);
+errcode_t ocfs2_fill_cluster_desc(ocfs2_filesys *fs,
+ struct o2cb_cluster_desc *desc);
errcode_t ocfs2_fill_heartbeat_desc(ocfs2_filesys *fs,
struct o2cb_region_desc *desc);
@@ -739,6 +741,13 @@ static inline int ocfs2_sparse_alloc(struct ocfs2_super_block *osb)
return 0;
}
+static inline int ocfs2_userspace_stack(struct ocfs2_super_block *osb)
+{
+ if (osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK)
+ return 1;
+ return 0;
+}
+
static inline int ocfs2_writes_unwritten_extents(struct ocfs2_super_block *osb)
{
/*
diff --git a/libo2cb/o2cb_abi.c b/libo2cb/o2cb_abi.c
index 0a9bc3e..7d26da3 100644
--- a/libo2cb/o2cb_abi.c
+++ b/libo2cb/o2cb_abi.c
@@ -48,13 +48,13 @@
struct o2cb_stack_ops {
errcode_t (*list_clusters)(char ***clusters);
- errcode_t (*begin_group_join)(const char *cluster_name,
- struct o2cb_region_desc *desc);
- errcode_t (*complete_group_join)(const char *cluster_name,
- struct o2cb_region_desc *desc,
+ errcode_t (*begin_group_join)(struct o2cb_cluster_desc *cluster,
+ struct o2cb_region_desc *region);
+ errcode_t (*complete_group_join)(struct o2cb_cluster_desc *cluster,
+ struct o2cb_region_desc *region,
int result);
- errcode_t (*group_leave)(const char *cluster_name,
- struct o2cb_region_desc *desc);
+ errcode_t (*group_leave)(struct o2cb_cluster_desc *cluster,
+ struct o2cb_region_desc *region);
};
struct o2cb_stack {
@@ -63,13 +63,13 @@ struct o2cb_stack {
};
static errcode_t classic_list_clusters(char ***clusters);
-static errcode_t classic_begin_group_join(const char *cluster_name,
- struct o2cb_region_desc *desc);
-static errcode_t classic_complete_group_join(const char *cluster_name,
- struct o2cb_region_desc *desc,
+static errcode_t classic_begin_group_join(struct o2cb_cluster_desc *cluster,
+ struct o2cb_region_desc *region);
+static errcode_t classic_complete_group_join(struct o2cb_cluster_desc *cluster,
+ struct o2cb_region_desc *region,
int result);
-static errcode_t classic_group_leave(const char *cluster_name,
- struct o2cb_region_desc *desc);
+static errcode_t classic_group_leave(struct o2cb_cluster_desc *cluster,
+ struct o2cb_region_desc *region);
static struct o2cb_stack_ops classic_ops = {
.list_clusters = classic_list_clusters,
.begin_group_join = classic_begin_group_join,
@@ -82,13 +82,13 @@ static struct o2cb_stack classic_stack = {
};
static errcode_t user_list_clusters(char ***clusters);
-static errcode_t user_begin_group_join(const char *cluster_name,
- struct o2cb_region_desc *desc);
-static errcode_t user_complete_group_join(const char *cluster_name,
- struct o2cb_region_desc *desc,
+static errcode_t user_begin_group_join(struct o2cb_cluster_desc *cluster,
+ struct o2cb_region_desc *region);
+static errcode_t user_complete_group_join(struct o2cb_cluster_desc *cluster,
+ struct o2cb_region_desc *region,
int result);
-static errcode_t user_group_leave(const char *cluster_name,
- struct o2cb_region_desc *desc);
+static errcode_t user_group_leave(struct o2cb_cluster_desc *cluster,
+ struct o2cb_region_desc *region);
static struct o2cb_stack_ops user_ops = {
.list_clusters = user_list_clusters,
.begin_group_join = user_begin_group_join,
@@ -1117,14 +1117,14 @@ out:
* to drop the reference taken during startup, otherwise that
* reference was dropped automatically at process shutdown so there's
* no need to drop one here. */
-static errcode_t classic_group_leave(const char *cluster_name,
- struct o2cb_region_desc *desc)
+static errcode_t classic_group_leave(struct o2cb_cluster_desc *cluster,
+ struct o2cb_region_desc *region)
{
errcode_t ret, up_ret;
int hb_refs;
int semid;
- ret = o2cb_mutex_down_lookup(desc->r_name, &semid);
+ ret = o2cb_mutex_down_lookup(region->r_name, &semid);
if (ret)
return ret;
@@ -1136,7 +1136,7 @@ static errcode_t classic_group_leave(const char *cluster_name,
* references on the region. We avoid a negative error count
* here and clean up the region as normal. */
if (hb_refs) {
- ret = __o2cb_drop_ref(semid, !desc->r_persist);
+ ret = __o2cb_drop_ref(semid, !region->r_persist);
if (ret)
goto up;
@@ -1148,8 +1148,8 @@ static errcode_t classic_group_leave(const char *cluster_name,
if (!hb_refs) {
/* XXX: If this fails, shouldn't we still destroy the
* semaphore set? */
- ret = o2cb_remove_heartbeat_region(cluster_name,
- desc->r_name);
+ ret = o2cb_remove_heartbeat_region(cluster->c_cluster,
+ region->r_name);
if (ret)
goto up;
@@ -1168,26 +1168,26 @@ done:
return ret;
}
-static errcode_t classic_begin_group_join(const char *cluster_name,
- struct o2cb_region_desc *desc)
+static errcode_t classic_begin_group_join(struct o2cb_cluster_desc *cluster,
+ struct o2cb_region_desc *region)
{
errcode_t ret, up_ret;
int semid;
- ret = o2cb_mutex_down_lookup(desc->r_name, &semid);
+ ret = o2cb_mutex_down_lookup(region->r_name, &semid);
if (ret)
return ret;
- ret = o2cb_create_heartbeat_region(cluster_name,
- desc->r_name,
- desc->r_device_name,
- desc->r_block_bytes,
- desc->r_start_block,
- desc->r_blocks);
+ ret = o2cb_create_heartbeat_region(cluster->c_cluster,
+ region->r_name,
+ region->r_device_name,
+ region->r_block_bytes,
+ region->r_start_block,
+ region->r_blocks);
if (ret && ret != O2CB_ET_REGION_EXISTS)
goto up;
- ret = __o2cb_get_ref(semid, !desc->r_persist);
+ ret = __o2cb_get_ref(semid, !region->r_persist);
/* XXX: Maybe stop heartbeat on error here? */
up:
up_ret = o2cb_mutex_up(semid);
@@ -1197,14 +1197,14 @@ up:
return ret;
}
-static errcode_t classic_complete_group_join(const char *cluster_name,
- struct o2cb_region_desc *desc,
+static errcode_t classic_complete_group_join(struct o2cb_cluster_desc *cluster,
+ struct o2cb_region_desc *region,
int result)
{
errcode_t ret = 0;
if (result)
- ret = classic_group_leave(cluster_name, desc);
+ ret = classic_group_leave(cluster, region);
return ret;
}
@@ -1230,8 +1230,8 @@ static errcode_t user_parse_status(char **args, int *error, char **error_msg)
return err;
}
-static errcode_t user_begin_group_join(const char *cluster_name,
- struct o2cb_region_desc *desc)
+static errcode_t user_begin_group_join(struct o2cb_cluster_desc *cluster,
+ struct o2cb_region_desc *region)
{
errcode_t err;
int rc;
@@ -1266,8 +1266,8 @@ static errcode_t user_begin_group_join(const char *cluster_name,
controld_fd = rc;
rc = send_message(controld_fd, CM_MOUNT, OCFS2_FS_NAME,
- desc->r_name, cluster_name, desc->r_device_name,
- desc->r_service);
+ region->r_name, cluster->c_cluster,
+ region->r_device_name, region->r_service);
if (rc) {
/* fprintf(stderr, "Unable to send MOUNT message: %s\n",
strerror(-rc)); */
@@ -1320,8 +1320,8 @@ out:
return err;
}
-static errcode_t user_complete_group_join(const char *cluster_name,
- struct o2cb_region_desc *desc,
+static errcode_t user_complete_group_join(struct o2cb_cluster_desc *cluster,
+ struct o2cb_region_desc *region,
int result)
{
errcode_t err = O2CB_ET_SERVICE_UNAVAILABLE;
@@ -1339,7 +1339,7 @@ static errcode_t user_complete_group_join(const char *cluster_name,
}
rc = send_message(controld_fd, CM_MRESULT, OCFS2_FS_NAME,
- desc->r_name, result, desc->r_service);
+ region->r_name, result, region->r_service);
if (rc) {
/* fprintf(stderr, "Unable to send MRESULT message: %s\n",
strerror(-rc)); */
@@ -1391,8 +1391,8 @@ out:
return err;
}
-static errcode_t user_group_leave(const char *cluster_name,
- struct o2cb_region_desc *desc)
+static errcode_t user_group_leave(struct o2cb_cluster_desc *cluster,
+ struct o2cb_region_desc *region)
{
errcode_t err = O2CB_ET_SERVICE_UNAVAILABLE;
int rc;
@@ -1427,7 +1427,7 @@ static errcode_t user_group_leave(const char *cluster_name,
controld_fd = rc;
rc = send_message(controld_fd, CM_UNMOUNT, OCFS2_FS_NAME,
- desc->r_name, desc->r_service);
+ region->r_name, region->r_service);
if (rc) {
/* fprintf(stderr, "Unable to send UNMOUNT message: %s\n",
strerror(-rc)); */
@@ -1480,63 +1480,105 @@ out:
return err;
}
-errcode_t o2cb_begin_group_join(const char *cluster_name,
- struct o2cb_region_desc *desc)
+static errcode_t o2cb_validate_cluster_desc(struct o2cb_cluster_desc *desc)
{
errcode_t err;
+ const char *name;
+
+ if (!desc)
+ return O2CB_ET_INVALID_STACK_NAME;
+
+ if (desc->c_stack && !desc->c_cluster)
+ return O2CB_ET_INVALID_STACK_NAME;
+
+ err = o2cb_get_stack_name(&name);
+ if (err)
+ return err;
+
+ if (desc->c_stack) {
+ if (strcmp(desc->c_stack, name))
+ return O2CB_ET_INVALID_STACK_NAME;
+ } else if (strcmp(name, classic_stack.s_name))
+ return O2CB_ET_INVALID_STACK_NAME;
+
+ return 0;
+}
+
+errcode_t o2cb_begin_group_join(struct o2cb_cluster_desc *cluster,
+ struct o2cb_region_desc *region)
+{
+ errcode_t err;
+ struct o2cb_cluster_desc desc;
char _fake_cluster_name[NAME_MAX];
if (!current_stack)
return O2CB_ET_SERVICE_UNAVAILABLE;
- if (!cluster_name) {
+ err = o2cb_validate_cluster_desc(cluster);
+ if (err)
+ return err;
+
+ desc = *cluster;
+ if (!desc.c_cluster) {
err = _fake_default_cluster(_fake_cluster_name);
if (err)
return err;
- cluster_name = _fake_cluster_name;
+ desc.c_cluster = _fake_cluster_name;
}
- return current_stack->s_ops->begin_group_join(cluster_name, desc);
+ return current_stack->s_ops->begin_group_join(&desc, region);
}
-errcode_t o2cb_complete_group_join(const char *cluster_name,
- struct o2cb_region_desc *desc,
+errcode_t o2cb_complete_group_join(struct o2cb_cluster_desc *cluster,
+ struct o2cb_region_desc *region,
int result)
{
errcode_t err;
+ struct o2cb_cluster_desc desc;
char _fake_cluster_name[NAME_MAX];
if (!current_stack)
return O2CB_ET_SERVICE_UNAVAILABLE;
- if (!cluster_name) {
+ err = o2cb_validate_cluster_desc(cluster);
+ if (err)
+ return err;
+
+ desc = *cluster;
+ if (!desc.c_cluster) {
err = _fake_default_cluster(_fake_cluster_name);
if (err)
return err;
- cluster_name = _fake_cluster_name;
+ desc.c_cluster = _fake_cluster_name;
}
- return current_stack->s_ops->complete_group_join(cluster_name,
- desc, result);
+ return current_stack->s_ops->complete_group_join(&desc, region,
+ result);
}
-errcode_t o2cb_group_leave(const char *cluster_name,
- struct o2cb_region_desc *desc)
+errcode_t o2cb_group_leave(struct o2cb_cluster_desc *cluster,
+ struct o2cb_region_desc *region)
{
errcode_t err;
+ struct o2cb_cluster_desc desc;
char _fake_cluster_name[NAME_MAX];
if (!current_stack)
return O2CB_ET_SERVICE_UNAVAILABLE;
- if (!cluster_name) {
+ err = o2cb_validate_cluster_desc(cluster);
+ if (err)
+ return err;
+
+ desc = *cluster;
+ if (!desc.c_cluster) {
err = _fake_default_cluster(_fake_cluster_name);
if (err)
return err;
- cluster_name = _fake_cluster_name;
+ desc.c_cluster = _fake_cluster_name;
}
- return current_stack->s_ops->group_leave(cluster_name, desc);
+ return current_stack->s_ops->group_leave(&desc, region);
}
diff --git a/libo2cb/o2cb_err.et b/libo2cb/o2cb_err.et
index 5fab61a..38a7069 100644
--- a/libo2cb/o2cb_err.et
+++ b/libo2cb/o2cb_err.et
@@ -78,4 +78,7 @@ ec O2CB_ET_NO_SEM,
ec O2CB_ET_BAD_VERSION,
"Revision of OCFS2-Tools is out of date."
+ec O2CB_ET_INVALID_STACK_NAME,
+ "Cluster stack specified does not match the one currently running"
+
end
diff --git a/libocfs2/dlm.c b/libocfs2/dlm.c
index 438e63e..c244cc0 100644
--- a/libocfs2/dlm.c
+++ b/libocfs2/dlm.c
@@ -101,19 +101,55 @@ bail:
return ret;
}
+errcode_t ocfs2_fill_cluster_desc(ocfs2_filesys *fs,
+ struct o2cb_cluster_desc *desc)
+{
+ errcode_t ret = 0;
+
+ if (!ocfs2_userspace_stack(OCFS2_RAW_SB(fs->fs_super))) {
+ desc->c_stack = NULL;
+ desc->c_cluster = NULL;
+ return 0;
+ }
+
+ ret = ocfs2_malloc0(OCFS2_STACK_LABEL_LEN + 1, &desc->c_stack);
+ if (ret)
+ return ret;
+
+ ret = ocfs2_malloc0(OCFS2_CLUSTER_NAME_LEN + 1, &desc->c_cluster);
+ if (ret) {
+ ocfs2_free(&desc->c_stack);
+ return ret;
+ }
+
+ memcpy(desc->c_stack,
+ OCFS2_RAW_SB(fs->fs_super)->s_cluster_info.ci_stack,
+ OCFS2_STACK_LABEL_LEN);
+ memcpy(desc->c_cluster,
+ OCFS2_RAW_SB(fs->fs_super)->s_cluster_info.ci_cluster,
+ OCFS2_CLUSTER_NAME_LEN);
+
+ return 0;
+}
+
errcode_t ocfs2_initialize_dlm(ocfs2_filesys *fs, const char *service)
{
struct o2dlm_ctxt *dlm_ctxt = NULL;
errcode_t ret = 0;
+ struct o2cb_cluster_desc cluster;
struct o2cb_region_desc desc;
+ ret = ocfs2_fill_cluster_desc(fs, &cluster);
+ if (ret)
+ goto bail;
+
ret = ocfs2_fill_heartbeat_desc(fs, &desc);
if (ret)
goto bail;
desc.r_service = (char *)service;
desc.r_persist = 0;
- ret = o2cb_begin_group_join(NULL, &desc);
+ ret = o2cb_begin_group_join(&cluster, &desc);
if (ret)
goto bail;
@@ -123,11 +159,11 @@ errcode_t ocfs2_initialize_dlm(ocfs2_filesys *fs, const char *service)
/* Ignore the result of complete_group_join, as we want
* to propagate our o2dlm_initialize() error */
- o2cb_complete_group_join(NULL, &desc, ret);
+ o2cb_complete_group_join(&cluster, &desc, ret);
goto bail;
}
- ret = o2cb_complete_group_join(NULL, &desc, 0);
+ ret = o2cb_complete_group_join(&cluster, &desc, 0);
if (!ret)
fs->fs_dlm_ctxt = dlm_ctxt;
@@ -141,6 +177,7 @@ bail:
errcode_t ocfs2_shutdown_dlm(ocfs2_filesys *fs, const char *service)
{
errcode_t ret;
+ struct o2cb_cluster_desc cluster;
struct o2cb_region_desc desc;
ret = o2dlm_destroy(fs->fs_dlm_ctxt);
@@ -149,13 +186,17 @@ errcode_t ocfs2_shutdown_dlm(ocfs2_filesys *fs, const char *service)
fs->fs_dlm_ctxt = NULL;
+ ret = ocfs2_fill_cluster_desc(fs, &cluster);
+ if (ret)
+ goto bail;
+
ret = ocfs2_fill_heartbeat_desc(fs, &desc);
if (ret)
goto bail;
desc.r_service = (char *)service;
desc.r_persist = 0;
- ret = o2cb_group_leave(NULL, &desc);
+ ret = o2cb_group_leave(&cluster, &desc);
bail:
return ret;
diff --git a/mount.ocfs2/mount.ocfs2.c b/mount.ocfs2/mount.ocfs2.c
index 4aa76a9..975fc6a 100644
--- a/mount.ocfs2/mount.ocfs2.c
+++ b/mount.ocfs2/mount.ocfs2.c
@@ -260,6 +260,7 @@ int main(int argc, char **argv)
int dev_ro = 0;
char *hbstr = NULL;
ocfs2_filesys *fs = NULL;
+ struct o2cb_cluster_desc cluster;
struct o2cb_region_desc desc;
int clustered = 1;
int hb_started = 0;
@@ -306,6 +307,13 @@ int main(int argc, char **argv)
goto bail;
}
+ ret = ocfs2_fill_cluster_desc(fs, &cluster);
+ if (ret) {
+ com_err(progname, ret,
+ "while trying to determine cluster information");
+ goto bail;
+ }
+
ret = ocfs2_fill_heartbeat_desc(fs, &desc);
if (ret) {
com_err(progname, ret,
@@ -334,11 +342,11 @@ int main(int argc, char **argv)
block_signals (SIG_BLOCK);
if (!(mo.flags & MS_REMOUNT) && !dev_ro && clustered) {
- ret = o2cb_begin_group_join(NULL, &desc);
+ ret = o2cb_begin_group_join(&cluster, &desc);
if (ret) {
block_signals (SIG_UNBLOCK);
com_err(progname, ret,
- "while trying to start heartbeat");
+ "while trying to join the group");
goto bail;
}
hb_started = 1;
@@ -363,7 +371,7 @@ int main(int argc, char **argv)
/* We ignore the return code because the mount
* failure is the important error.
* complete_group_join() will handle cleaning up */
- o2cb_complete_group_join(NULL, &desc, errno);
+ o2cb_complete_group_join(&cluster, &desc, errno);
}
block_signals (SIG_UNBLOCK);
com_err(progname, ret, "while mounting %s on %s. "
@@ -372,10 +380,10 @@ int main(int argc, char **argv)
goto bail;
}
if (hb_started) {
- ret = o2cb_complete_group_join(NULL, &desc, 0);
+ ret = o2cb_complete_group_join(&cluster, &desc, 0);
if (ret) {
com_err(progname, ret,
- "while completing heartbeat startup (WARNING)");
+ "while completing group join (WARNING)");
/*
* XXX: GFS2 allows the mount to continue, so we
* will do the same. I don't know how clean that
diff --git a/mount.ocfs2/umount.ocfs2.c b/mount.ocfs2/umount.ocfs2.c
index e374480..81d1382 100644
--- a/mount.ocfs2/umount.ocfs2.c
+++ b/mount.ocfs2/umount.ocfs2.c
@@ -143,6 +143,7 @@ int main(int argc, char **argv)
errcode_t ret = 0;
struct mount_options mo;
ocfs2_filesys *fs = NULL;
+ struct o2cb_cluster_desc cluster;
struct o2cb_region_desc desc;
int clustered = 1;
@@ -188,6 +189,13 @@ int main(int argc, char **argv)
goto bail;
}
+ ret = ocfs2_fill_cluster_desc(fs, &cluster);
+ if (ret) {
+ com_err(progname, ret,
+ "while loading cluster information");
+ goto bail;
+ }
+
ret = ocfs2_fill_heartbeat_desc(fs, &desc);
if (ret) {
com_err(progname, ret,
@@ -225,10 +233,10 @@ int main(int argc, char **argv)
goto unblock;
if (clustered) {
- ret = o2cb_group_leave(NULL, &desc);
+ ret = o2cb_group_leave(&cluster, &desc);
if (ret) {
com_err(progname, ret,
- "while stopping heartbeat (WARNING)");
+ "while leaving the group (WARNING)");
/* Don't propagate the error, just warn */
ret = 0;
}
diff --git a/ocfs2_hb_ctl/ocfs2_hb_ctl.c b/ocfs2_hb_ctl/ocfs2_hb_ctl.c
index d5aa66e..1cca566 100644
--- a/ocfs2_hb_ctl/ocfs2_hb_ctl.c
+++ b/ocfs2_hb_ctl/ocfs2_hb_ctl.c
@@ -287,21 +287,24 @@ static errcode_t lookup_dev(struct hb_ctl_options *hbo)
static errcode_t start_heartbeat(struct hb_ctl_options *hbo)
{
errcode_t err = 0;
+ struct o2cb_cluster_desc cluster = {
+ .c_stack = NULL, /* classic stack only */
+ };
if (!hbo->dev_str)
err = lookup_dev(hbo);
if (!err) {
region_desc->r_persist = 1; /* hb_ctl is for reals */
region_desc->r_service = hbo->service;
- err = o2cb_begin_group_join(NULL, region_desc);
+ err = o2cb_begin_group_join(&cluster, region_desc);
if (!err) {
/*
* This is a manual start, there is no service
* or mountpoint being started by hb_ctl, so
* we assume success
*/
- err = o2cb_complete_group_join(NULL, region_desc,
- 0);
+ err = o2cb_complete_group_join(&cluster,
+ region_desc, 0);
}
}
@@ -345,6 +348,9 @@ static errcode_t adjust_priority(struct hb_ctl_options *hbo)
static errcode_t stop_heartbeat(struct hb_ctl_options *hbo)
{
errcode_t err = 0;
+ struct o2cb_cluster_desc cluster = {
+ .c_stack = NULL, /* classic stack only */
+ };
if (!hbo->dev_str)
err = lookup_dev(hbo);
--
1.5.3.8
More information about the Ocfs2-tools-devel
mailing list