From efa483c599f23d10160c2b7e9c3b4e75812b9b41 Mon Sep 17 00:00:00 2001 From: Patrick Caulfield Date: Mon, 9 Oct 2006 14:11:57 +0000 Subject: [PATCH] Add clvmd call to return the cluster name. --- WHATS_NEW | 1 + daemons/clvmd/clvm.h | 1 + daemons/clvmd/clvmd-cman.c | 13 +++++++++++++ daemons/clvmd/clvmd-command.c | 9 +++++++++ daemons/clvmd/clvmd-comms.h | 2 ++ daemons/clvmd/clvmd-gulm.c | 7 +++++++ daemons/clvmd/clvmd.c | 2 +- 7 files changed, 34 insertions(+), 1 deletion(-) diff --git a/WHATS_NEW b/WHATS_NEW index d9100d6bf..2d49b357d 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.11 - ===================================== + Add clvmd function to return the cluster name. not used by LVM yet. Add cling allocation policy. Change _check_contiguous() to use _for_each_pv(). Extend _for_each_pv() to allow termination without error. diff --git a/daemons/clvmd/clvm.h b/daemons/clvmd/clvm.h index c8106019a..3eff0ce18 100644 --- a/daemons/clvmd/clvm.h +++ b/daemons/clvmd/clvm.h @@ -65,5 +65,6 @@ static const char CLVMD_SOCKNAME[] = "\0clvmd"; /* Misc functions */ #define CLVMD_CMD_REFRESH 40 +#define CLVMD_CMD_GET_CLUSTERNAME 41 #endif diff --git a/daemons/clvmd/clvmd-cman.c b/daemons/clvmd/clvmd-cman.c index b2c32e2b9..0dc005dc3 100644 --- a/daemons/clvmd/clvmd-cman.c +++ b/daemons/clvmd/clvmd-cman.c @@ -471,6 +471,18 @@ static int _sync_unlock(const char *resource /* UNUSED */, int lockid) } +static int _get_cluster_name(char *buf, int buflen) +{ + cman_cluster_t cluster_info; + int status; + + status = cman_get_cluster(c_handle, &cluster_info); + if (!status) { + strncpy(buf, cluster_info.ci_name, buflen); + } + return status; +} + static struct cluster_ops _cluster_cman_ops = { .cluster_init_completed = _cluster_init_completed, .cluster_send_message = _cluster_send_message, @@ -484,6 +496,7 @@ static struct cluster_ops _cluster_cman_ops = { .get_our_csid = _get_our_csid, .add_up_node = _add_up_node, .cluster_closedown = _cluster_closedown, + .get_cluster_name = _get_cluster_name, .sync_lock = _sync_lock, .sync_unlock = _sync_unlock, }; diff --git a/daemons/clvmd/clvmd-command.c b/daemons/clvmd/clvmd-command.c index 9ba6e49b4..936ca7e0a 100644 --- a/daemons/clvmd/clvmd-command.c +++ b/daemons/clvmd/clvmd-command.c @@ -75,6 +75,8 @@ #include "clvmd.h" #include "libdlm.h" +extern struct cluster_ops *clops; + /* This is where all the real work happens: NOTE: client will be NULL when this is executed on a remote node */ int do_command(struct local_client *client, struct clvm_header *msg, int msglen, @@ -126,6 +128,12 @@ int do_command(struct local_client *client, struct clvm_header *msg, int msglen, do_refresh_cache(); break; + case CLVMD_CMD_GET_CLUSTERNAME: + status = clops->get_cluster_name(*buf, buflen); + if (!status) + *retlen = strlen(*buf); + break; + default: /* Won't get here because command is validated in pre_command */ break; @@ -227,6 +235,7 @@ int do_pre_command(struct local_client *client) break; case CLVMD_CMD_REFRESH: + case CLVMD_CMD_GET_CLUSTERNAME: break; default: diff --git a/daemons/clvmd/clvmd-comms.h b/daemons/clvmd/clvmd-comms.h index 39b286e6f..6bfcd562d 100644 --- a/daemons/clvmd/clvmd-comms.h +++ b/daemons/clvmd/clvmd-comms.h @@ -43,6 +43,8 @@ struct cluster_ops { void (*reread_config) (void); void (*cluster_closedown) (void); + int (*get_cluster_name)(char *buf, int buflen); + int (*sync_lock) (const char *resource, int mode, int flags, int *lockid); int (*sync_unlock) (const char *resource, int lockid); diff --git a/daemons/clvmd/clvmd-gulm.c b/daemons/clvmd/clvmd-gulm.c index 058138cca..ebf066e3b 100644 --- a/daemons/clvmd/clvmd-gulm.c +++ b/daemons/clvmd/clvmd-gulm.c @@ -973,6 +973,12 @@ static int _cluster_send_message(void *buf, int msglen, char *csid, const char * return gulm_cluster_send_message(buf, msglen, csid, errtext); } +static int _get_cluster_name(char *buf, int buflen) +{ + strncpy(buf, cluster_name, buflen); + return 0; +} + static struct cluster_ops _cluster_gulm_ops = { .cluster_init_completed = NULL, .cluster_send_message = _cluster_send_message, @@ -987,6 +993,7 @@ static struct cluster_ops _cluster_gulm_ops = { .add_up_node = gulm_add_up_node, .reread_config = _reread_config, .cluster_closedown = _cluster_closedown, + .get_cluster_name = _get_cluster_name, .sync_lock = _sync_lock, .sync_unlock = _sync_unlock, }; diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c index a8e037aa8..17c7a22c0 100644 --- a/daemons/clvmd/clvmd.c +++ b/daemons/clvmd/clvmd.c @@ -67,7 +67,7 @@ static struct local_client local_client_head; static unsigned short global_xid = 0; /* Last transaction ID issued */ -static struct cluster_ops *clops = NULL; +struct cluster_ops *clops = NULL; static char our_csid[MAX_CSID_LEN]; static unsigned max_csid_len;