diff options
Diffstat (limited to 'fs/ocfs2')
-rw-r--r-- | fs/ocfs2/stack_o2cb.c | 38 | ||||
-rw-r--r-- | fs/ocfs2/stackglue.c | 49 | ||||
-rw-r--r-- | fs/ocfs2/stackglue.h | 1 |
3 files changed, 40 insertions, 48 deletions
diff --git a/fs/ocfs2/stack_o2cb.c b/fs/ocfs2/stack_o2cb.c index fb26a7c69c47..765ade5ee84a 100644 --- a/fs/ocfs2/stack_o2cb.c +++ b/fs/ocfs2/stack_o2cb.c | |||
@@ -333,43 +333,6 @@ static int o2cb_cluster_disconnect(struct ocfs2_cluster_connection *conn, | |||
333 | return 0; | 333 | return 0; |
334 | } | 334 | } |
335 | 335 | ||
336 | static void o2hb_stop(const char *group) | ||
337 | { | ||
338 | int ret; | ||
339 | char *argv[5], *envp[3]; | ||
340 | |||
341 | argv[0] = (char *)ocfs2_get_hb_ctl_path(); | ||
342 | argv[1] = "-K"; | ||
343 | argv[2] = "-u"; | ||
344 | argv[3] = (char *)group; | ||
345 | argv[4] = NULL; | ||
346 | |||
347 | mlog(0, "Run: %s %s %s %s\n", argv[0], argv[1], argv[2], argv[3]); | ||
348 | |||
349 | /* minimal command environment taken from cpu_run_sbin_hotplug */ | ||
350 | envp[0] = "HOME=/"; | ||
351 | envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; | ||
352 | envp[2] = NULL; | ||
353 | |||
354 | ret = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC); | ||
355 | if (ret < 0) | ||
356 | mlog_errno(ret); | ||
357 | } | ||
358 | |||
359 | /* | ||
360 | * Hangup is a hack for tools compatibility. Older ocfs2-tools software | ||
361 | * expects the filesystem to call "ocfs2_hb_ctl" during unmount. This | ||
362 | * happens regardless of whether the DLM got started, so we can't do it | ||
363 | * in ocfs2_cluster_disconnect(). We bring the o2hb_stop() function into | ||
364 | * the glue and provide a "hangup" API for super.c to call. | ||
365 | * | ||
366 | * Other stacks will eventually provide a NULL ->hangup() pointer. | ||
367 | */ | ||
368 | static void o2cb_cluster_hangup(const char *group, int grouplen) | ||
369 | { | ||
370 | o2hb_stop(group); | ||
371 | } | ||
372 | |||
373 | static int o2cb_cluster_this_node(unsigned int *node) | 336 | static int o2cb_cluster_this_node(unsigned int *node) |
374 | { | 337 | { |
375 | int node_num; | 338 | int node_num; |
@@ -388,7 +351,6 @@ static int o2cb_cluster_this_node(unsigned int *node) | |||
388 | static struct ocfs2_stack_operations o2cb_stack_ops = { | 351 | static struct ocfs2_stack_operations o2cb_stack_ops = { |
389 | .connect = o2cb_cluster_connect, | 352 | .connect = o2cb_cluster_connect, |
390 | .disconnect = o2cb_cluster_disconnect, | 353 | .disconnect = o2cb_cluster_disconnect, |
391 | .hangup = o2cb_cluster_hangup, | ||
392 | .this_node = o2cb_cluster_this_node, | 354 | .this_node = o2cb_cluster_this_node, |
393 | .dlm_lock = o2cb_dlm_lock, | 355 | .dlm_lock = o2cb_dlm_lock, |
394 | .dlm_unlock = o2cb_dlm_unlock, | 356 | .dlm_unlock = o2cb_dlm_unlock, |
diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c index fb9b8e0db260..5f78ff4c76c7 100644 --- a/fs/ocfs2/stackglue.c +++ b/fs/ocfs2/stackglue.c | |||
@@ -34,11 +34,13 @@ | |||
34 | 34 | ||
35 | #define OCFS2_STACK_PLUGIN_O2CB "o2cb" | 35 | #define OCFS2_STACK_PLUGIN_O2CB "o2cb" |
36 | #define OCFS2_STACK_PLUGIN_USER "user" | 36 | #define OCFS2_STACK_PLUGIN_USER "user" |
37 | #define OCFS2_MAX_HB_CTL_PATH 256 | ||
37 | 38 | ||
38 | static struct ocfs2_locking_protocol *lproto; | 39 | static struct ocfs2_locking_protocol *lproto; |
39 | static DEFINE_SPINLOCK(ocfs2_stack_lock); | 40 | static DEFINE_SPINLOCK(ocfs2_stack_lock); |
40 | static LIST_HEAD(ocfs2_stack_list); | 41 | static LIST_HEAD(ocfs2_stack_list); |
41 | static char cluster_stack_name[OCFS2_STACK_LABEL_LEN + 1]; | 42 | static char cluster_stack_name[OCFS2_STACK_LABEL_LEN + 1]; |
43 | static char ocfs2_hb_ctl_path[OCFS2_MAX_HB_CTL_PATH] = "/sbin/ocfs2_hb_ctl"; | ||
42 | 44 | ||
43 | /* | 45 | /* |
44 | * The stack currently in use. If not null, active_stack->sp_count > 0, | 46 | * The stack currently in use. If not null, active_stack->sp_count > 0, |
@@ -363,6 +365,42 @@ int ocfs2_cluster_disconnect(struct ocfs2_cluster_connection *conn, | |||
363 | } | 365 | } |
364 | EXPORT_SYMBOL_GPL(ocfs2_cluster_disconnect); | 366 | EXPORT_SYMBOL_GPL(ocfs2_cluster_disconnect); |
365 | 367 | ||
368 | /* | ||
369 | * Leave the group for this filesystem. This is executed by a userspace | ||
370 | * program (stored in ocfs2_hb_ctl_path). | ||
371 | */ | ||
372 | static void ocfs2_leave_group(const char *group) | ||
373 | { | ||
374 | int ret; | ||
375 | char *argv[5], *envp[3]; | ||
376 | |||
377 | argv[0] = ocfs2_hb_ctl_path; | ||
378 | argv[1] = "-K"; | ||
379 | argv[2] = "-u"; | ||
380 | argv[3] = (char *)group; | ||
381 | argv[4] = NULL; | ||
382 | |||
383 | /* minimal command environment taken from cpu_run_sbin_hotplug */ | ||
384 | envp[0] = "HOME=/"; | ||
385 | envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; | ||
386 | envp[2] = NULL; | ||
387 | |||
388 | ret = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC); | ||
389 | if (ret < 0) { | ||
390 | printk(KERN_ERR | ||
391 | "ocfs2: Error %d running user helper " | ||
392 | "\"%s %s %s %s\"\n", | ||
393 | ret, argv[0], argv[1], argv[2], argv[3]); | ||
394 | } | ||
395 | } | ||
396 | |||
397 | /* | ||
398 | * Hangup is a required post-umount. ocfs2-tools software expects the | ||
399 | * filesystem to call "ocfs2_hb_ctl" during unmount. This happens | ||
400 | * regardless of whether the DLM got started, so we can't do it | ||
401 | * in ocfs2_cluster_disconnect(). The ocfs2_leave_group() function does | ||
402 | * the actual work. | ||
403 | */ | ||
366 | void ocfs2_cluster_hangup(const char *group, int grouplen) | 404 | void ocfs2_cluster_hangup(const char *group, int grouplen) |
367 | { | 405 | { |
368 | BUG_ON(group == NULL); | 406 | BUG_ON(group == NULL); |
@@ -371,6 +409,8 @@ void ocfs2_cluster_hangup(const char *group, int grouplen) | |||
371 | if (active_stack->sp_ops->hangup) | 409 | if (active_stack->sp_ops->hangup) |
372 | active_stack->sp_ops->hangup(group, grouplen); | 410 | active_stack->sp_ops->hangup(group, grouplen); |
373 | 411 | ||
412 | ocfs2_leave_group(group); | ||
413 | |||
374 | /* cluster_disconnect() was called with hangup_pending==1 */ | 414 | /* cluster_disconnect() was called with hangup_pending==1 */ |
375 | ocfs2_stack_driver_put(); | 415 | ocfs2_stack_driver_put(); |
376 | } | 416 | } |
@@ -559,9 +599,6 @@ error: | |||
559 | 599 | ||
560 | #define FS_OCFS2_NM 1 | 600 | #define FS_OCFS2_NM 1 |
561 | 601 | ||
562 | #define OCFS2_MAX_HB_CTL_PATH 256 | ||
563 | static char ocfs2_hb_ctl_path[OCFS2_MAX_HB_CTL_PATH] = "/sbin/ocfs2_hb_ctl"; | ||
564 | |||
565 | static ctl_table ocfs2_nm_table[] = { | 602 | static ctl_table ocfs2_nm_table[] = { |
566 | { | 603 | { |
567 | .ctl_name = 1, | 604 | .ctl_name = 1, |
@@ -613,12 +650,6 @@ static ctl_table ocfs2_root_table[] = { | |||
613 | 650 | ||
614 | static struct ctl_table_header *ocfs2_table_header = NULL; | 651 | static struct ctl_table_header *ocfs2_table_header = NULL; |
615 | 652 | ||
616 | const char *ocfs2_get_hb_ctl_path(void) | ||
617 | { | ||
618 | return ocfs2_hb_ctl_path; | ||
619 | } | ||
620 | EXPORT_SYMBOL_GPL(ocfs2_get_hb_ctl_path); | ||
621 | |||
622 | 653 | ||
623 | /* | 654 | /* |
624 | * Initialization | 655 | * Initialization |
diff --git a/fs/ocfs2/stackglue.h b/fs/ocfs2/stackglue.h index c9fb01ab6347..fe3fd2a12821 100644 --- a/fs/ocfs2/stackglue.h +++ b/fs/ocfs2/stackglue.h | |||
@@ -258,6 +258,5 @@ void ocfs2_stack_glue_set_locking_protocol(struct ocfs2_locking_protocol *proto) | |||
258 | /* Used by stack plugins */ | 258 | /* Used by stack plugins */ |
259 | int ocfs2_stack_glue_register(struct ocfs2_stack_plugin *plugin); | 259 | int ocfs2_stack_glue_register(struct ocfs2_stack_plugin *plugin); |
260 | void ocfs2_stack_glue_unregister(struct ocfs2_stack_plugin *plugin); | 260 | void ocfs2_stack_glue_unregister(struct ocfs2_stack_plugin *plugin); |
261 | const char *ocfs2_get_hb_ctl_path(void); | ||
262 | 261 | ||
263 | #endif /* STACKGLUE_H */ | 262 | #endif /* STACKGLUE_H */ |