ocfs2: Move the call of ocfs2_hb_ctl into the stack glue.

Take o2hb_stop() out of the o2cb code and make it part of the generic
stack glue as ocfs2_leave_group(). This also allows us to remove the
ocfs2_get_hb_ctl_path() function - everything to do with hb_ctl is now
part of stackglue.c. o2cb no longer needs a ->hangup() function.

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>

authored by Joel Becker and committed by Mark Fasheh 9f9a99f4 3878f110

+40 -48
-38
fs/ocfs2/stack_o2cb.c
··· 333 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 336 static int o2cb_cluster_this_node(unsigned int *node) 374 337 { 375 338 int node_num; ··· 351 388 static struct ocfs2_stack_operations o2cb_stack_ops = { 352 389 .connect = o2cb_cluster_connect, 353 390 .disconnect = o2cb_cluster_disconnect, 354 - .hangup = o2cb_cluster_hangup, 355 391 .this_node = o2cb_cluster_this_node, 356 392 .dlm_lock = o2cb_dlm_lock, 357 393 .dlm_unlock = o2cb_dlm_unlock,
+40 -9
fs/ocfs2/stackglue.c
··· 34 34 35 35 #define OCFS2_STACK_PLUGIN_O2CB "o2cb" 36 36 #define OCFS2_STACK_PLUGIN_USER "user" 37 + #define OCFS2_MAX_HB_CTL_PATH 256 37 38 38 39 static struct ocfs2_locking_protocol *lproto; 39 40 static DEFINE_SPINLOCK(ocfs2_stack_lock); 40 41 static LIST_HEAD(ocfs2_stack_list); 41 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 46 * The stack currently in use. If not null, active_stack->sp_count > 0, ··· 365 363 } 366 364 EXPORT_SYMBOL_GPL(ocfs2_cluster_disconnect); 367 365 366 + /* 367 + * Leave the group for this filesystem. This is executed by a userspace 368 + * program (stored in ocfs2_hb_ctl_path). 369 + */ 370 + static void ocfs2_leave_group(const char *group) 371 + { 372 + int ret; 373 + char *argv[5], *envp[3]; 374 + 375 + argv[0] = ocfs2_hb_ctl_path; 376 + argv[1] = "-K"; 377 + argv[2] = "-u"; 378 + argv[3] = (char *)group; 379 + argv[4] = NULL; 380 + 381 + /* minimal command environment taken from cpu_run_sbin_hotplug */ 382 + envp[0] = "HOME=/"; 383 + envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; 384 + envp[2] = NULL; 385 + 386 + ret = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC); 387 + if (ret < 0) { 388 + printk(KERN_ERR 389 + "ocfs2: Error %d running user helper " 390 + "\"%s %s %s %s\"\n", 391 + ret, argv[0], argv[1], argv[2], argv[3]); 392 + } 393 + } 394 + 395 + /* 396 + * Hangup is a required post-umount. ocfs2-tools software expects the 397 + * filesystem to call "ocfs2_hb_ctl" during unmount. This happens 398 + * regardless of whether the DLM got started, so we can't do it 399 + * in ocfs2_cluster_disconnect(). The ocfs2_leave_group() function does 400 + * the actual work. 401 + */ 368 402 void ocfs2_cluster_hangup(const char *group, int grouplen) 369 403 { 370 404 BUG_ON(group == NULL); ··· 408 370 409 371 if (active_stack->sp_ops->hangup) 410 372 active_stack->sp_ops->hangup(group, grouplen); 373 + 374 + ocfs2_leave_group(group); 411 375 412 376 /* cluster_disconnect() was called with hangup_pending==1 */ 413 377 ocfs2_stack_driver_put(); ··· 599 559 600 560 #define FS_OCFS2_NM 1 601 561 602 - #define OCFS2_MAX_HB_CTL_PATH 256 603 - static char ocfs2_hb_ctl_path[OCFS2_MAX_HB_CTL_PATH] = "/sbin/ocfs2_hb_ctl"; 604 - 605 562 static ctl_table ocfs2_nm_table[] = { 606 563 { 607 564 .ctl_name = 1, ··· 649 612 }; 650 613 651 614 static struct ctl_table_header *ocfs2_table_header = NULL; 652 - 653 - const char *ocfs2_get_hb_ctl_path(void) 654 - { 655 - return ocfs2_hb_ctl_path; 656 - } 657 - EXPORT_SYMBOL_GPL(ocfs2_get_hb_ctl_path); 658 615 659 616 660 617 /*
-1
fs/ocfs2/stackglue.h
··· 258 258 /* Used by stack plugins */ 259 259 int ocfs2_stack_glue_register(struct ocfs2_stack_plugin *plugin); 260 260 void ocfs2_stack_glue_unregister(struct ocfs2_stack_plugin *plugin); 261 - const char *ocfs2_get_hb_ctl_path(void); 262 261 263 262 #endif /* STACKGLUE_H */