Skip to content

Commit c74a3bd

Browse files
Goldwyn Rodriguestorvalds
authored andcommitted
ocfs2: add clustername to cluster connection
This is an effort of removing ocfs2_controld.pcmk and getting ocfs2 DLM handling up to the times with respect to DLM (>=4.0.1) and corosync (2.3.x). AFAIK, cman also is being phased out for a unified corosync cluster stack. fs/dlm performs all the functions with respect to fencing and node management and provides the API's to do so for ocfs2. For all future references, DLM stands for fs/dlm code. The advantages are: + No need to run an additional userspace daemon (ocfs2_controld) + No controld device handling and controld protocol + Shifting responsibilities of node management to DLM layer For backward compatibility, we are keeping the controld handling code. Once enough time has passed we can remove a significant portion of the code. This was tested by using the kernel with changes on older unmodified tools. The kernel used ocfs2_controld as expected, and displayed the appropriate warning message. This feature requires modification in the userspace ocfs2-tools. The changes can be found at: https://github.com/goldwynr/ocfs2-tools branch: nocontrold Currently, not many checks are present in the userspace code, but that would change soon. This patch (of 6): Add clustername to cluster connection. Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Reviewed-by: Mark Fasheh <mfasheh@suse.de> Cc: Joel Becker <jlbec@evilplan.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent ff8fb33 commit c74a3bd

File tree

5 files changed

+24
-7
lines changed

5 files changed

+24
-7
lines changed

fs/ocfs2/dlmglue.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2996,6 +2996,8 @@ int ocfs2_dlm_init(struct ocfs2_super *osb)
29962996

29972997
/* for now, uuid == domain */
29982998
status = ocfs2_cluster_connect(osb->osb_cluster_stack,
2999+
osb->osb_cluster_name,
3000+
strlen(osb->osb_cluster_name),
29993001
osb->uuid_str,
30003002
strlen(osb->uuid_str),
30013003
&lproto, ocfs2_do_node_down, osb,

fs/ocfs2/ocfs2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ struct ocfs2_super
387387
u8 osb_stackflags;
388388

389389
char osb_cluster_stack[OCFS2_STACK_LABEL_LEN + 1];
390+
char osb_cluster_name[OCFS2_CLUSTER_NAME_LEN + 1];
390391
struct ocfs2_cluster_connection *cconn;
391392
struct ocfs2_lock_res osb_super_lockres;
392393
struct ocfs2_lock_res osb_rename_lockres;

fs/ocfs2/stackglue.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,8 @@ int ocfs2_plock(struct ocfs2_cluster_connection *conn, u64 ino,
309309
EXPORT_SYMBOL_GPL(ocfs2_plock);
310310

311311
int ocfs2_cluster_connect(const char *stack_name,
312+
const char *cluster_name,
313+
int cluster_name_len,
312314
const char *group,
313315
int grouplen,
314316
struct ocfs2_locking_protocol *lproto,
@@ -342,8 +344,10 @@ int ocfs2_cluster_connect(const char *stack_name,
342344
goto out;
343345
}
344346

345-
memcpy(new_conn->cc_name, group, grouplen);
347+
strlcpy(new_conn->cc_name, group, GROUP_NAME_MAX + 1);
346348
new_conn->cc_namelen = grouplen;
349+
strlcpy(new_conn->cc_cluster_name, cluster_name, CLUSTER_NAME_MAX + 1);
350+
new_conn->cc_cluster_name_len = cluster_name_len;
347351
new_conn->cc_recovery_handler = recovery_handler;
348352
new_conn->cc_recovery_data = recovery_data;
349353

@@ -386,8 +390,9 @@ int ocfs2_cluster_connect_agnostic(const char *group,
386390

387391
if (cluster_stack_name[0])
388392
stack_name = cluster_stack_name;
389-
return ocfs2_cluster_connect(stack_name, group, grouplen, lproto,
390-
recovery_handler, recovery_data, conn);
393+
return ocfs2_cluster_connect(stack_name, NULL, 0, group, grouplen,
394+
lproto, recovery_handler, recovery_data,
395+
conn);
391396
}
392397
EXPORT_SYMBOL_GPL(ocfs2_cluster_connect_agnostic);
393398

fs/ocfs2/stackglue.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ struct file_lock;
4545
*/
4646
#define GROUP_NAME_MAX 64
4747

48+
/* This shadows OCFS2_CLUSTER_NAME_LEN */
49+
#define CLUSTER_NAME_MAX 16
50+
4851

4952
/*
5053
* ocfs2_protocol_version changes when ocfs2 does something different in
@@ -97,8 +100,10 @@ struct ocfs2_locking_protocol {
97100
* locking compatibility.
98101
*/
99102
struct ocfs2_cluster_connection {
100-
char cc_name[GROUP_NAME_MAX];
103+
char cc_name[GROUP_NAME_MAX + 1];
101104
int cc_namelen;
105+
char cc_cluster_name[CLUSTER_NAME_MAX + 1];
106+
int cc_cluster_name_len;
102107
struct ocfs2_protocol_version cc_version;
103108
struct ocfs2_locking_protocol *cc_proto;
104109
void (*cc_recovery_handler)(int node_num, void *recovery_data);
@@ -239,6 +244,8 @@ struct ocfs2_stack_plugin {
239244

240245
/* Used by the filesystem */
241246
int ocfs2_cluster_connect(const char *stack_name,
247+
const char *cluster_name,
248+
int cluster_name_len,
242249
const char *group,
243250
int grouplen,
244251
struct ocfs2_locking_protocol *lproto,

fs/ocfs2/super.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,10 +2223,9 @@ static int ocfs2_initialize_super(struct super_block *sb,
22232223
if (ocfs2_clusterinfo_valid(osb)) {
22242224
osb->osb_stackflags =
22252225
OCFS2_RAW_SB(di)->s_cluster_info.ci_stackflags;
2226-
memcpy(osb->osb_cluster_stack,
2226+
strlcpy(osb->osb_cluster_stack,
22272227
OCFS2_RAW_SB(di)->s_cluster_info.ci_stack,
2228-
OCFS2_STACK_LABEL_LEN);
2229-
osb->osb_cluster_stack[OCFS2_STACK_LABEL_LEN] = '\0';
2228+
OCFS2_STACK_LABEL_LEN + 1);
22302229
if (strlen(osb->osb_cluster_stack) != OCFS2_STACK_LABEL_LEN) {
22312230
mlog(ML_ERROR,
22322231
"couldn't mount because of an invalid "
@@ -2235,6 +2234,9 @@ static int ocfs2_initialize_super(struct super_block *sb,
22352234
status = -EINVAL;
22362235
goto bail;
22372236
}
2237+
strlcpy(osb->osb_cluster_name,
2238+
OCFS2_RAW_SB(di)->s_cluster_info.ci_cluster,
2239+
OCFS2_CLUSTER_NAME_LEN + 1);
22382240
} else {
22392241
/* The empty string is identical with classic tools that
22402242
* don't know about s_cluster_info. */

0 commit comments

Comments
 (0)