Skip to content

Commit 9f9a99f

Browse files
Joel BeckerMark Fasheh
authored andcommitted
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>
1 parent 3878f11 commit 9f9a99f

3 files changed

Lines changed: 40 additions & 48 deletions

File tree

‎fs/ocfs2/stack_o2cb.c‎

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -333,43 +333,6 @@ static int o2cb_cluster_disconnect(struct ocfs2_cluster_connection *conn,
333333
return 0;
334334
}
335335

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-
373336
static int o2cb_cluster_this_node(unsigned int *node)
374337
{
375338
int node_num;
@@ -388,7 +351,6 @@ static int o2cb_cluster_this_node(unsigned int *node)
388351
static struct ocfs2_stack_operations o2cb_stack_ops = {
389352
.connect = o2cb_cluster_connect,
390353
.disconnect = o2cb_cluster_disconnect,
391-
.hangup = o2cb_cluster_hangup,
392354
.this_node = o2cb_cluster_this_node,
393355
.dlm_lock = o2cb_dlm_lock,
394356
.dlm_unlock = o2cb_dlm_unlock,

‎fs/ocfs2/stackglue.c‎

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@
3434

3535
#define OCFS2_STACK_PLUGIN_O2CB "o2cb"
3636
#define OCFS2_STACK_PLUGIN_USER "user"
37+
#define OCFS2_MAX_HB_CTL_PATH 256
3738

3839
static struct ocfs2_locking_protocol *lproto;
3940
static DEFINE_SPINLOCK(ocfs2_stack_lock);
4041
static LIST_HEAD(ocfs2_stack_list);
4142
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";
4244

4345
/*
4446
* 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,
363365
}
364366
EXPORT_SYMBOL_GPL(ocfs2_cluster_disconnect);
365367

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+
*/
366404
void ocfs2_cluster_hangup(const char *group, int grouplen)
367405
{
368406
BUG_ON(group == NULL);
@@ -371,6 +409,8 @@ void ocfs2_cluster_hangup(const char *group, int grouplen)
371409
if (active_stack->sp_ops->hangup)
372410
active_stack->sp_ops->hangup(group, grouplen);
373411

412+
ocfs2_leave_group(group);
413+
374414
/* cluster_disconnect() was called with hangup_pending==1 */
375415
ocfs2_stack_driver_put();
376416
}
@@ -559,9 +599,6 @@ static int ocfs2_sysfs_init(void)
559599

560600
#define FS_OCFS2_NM 1
561601

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-
565602
static ctl_table ocfs2_nm_table[] = {
566603
{
567604
.ctl_name = 1,
@@ -613,12 +650,6 @@ static ctl_table ocfs2_root_table[] = {
613650

614651
static struct ctl_table_header *ocfs2_table_header = NULL;
615652

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-
622653

623654
/*
624655
* Initialization

‎fs/ocfs2/stackglue.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,5 @@ void ocfs2_stack_glue_set_locking_protocol(struct ocfs2_locking_protocol *proto)
258258
/* Used by stack plugins */
259259
int ocfs2_stack_glue_register(struct ocfs2_stack_plugin *plugin);
260260
void ocfs2_stack_glue_unregister(struct ocfs2_stack_plugin *plugin);
261-
const char *ocfs2_get_hb_ctl_path(void);
262261

263262
#endif /* STACKGLUE_H */

0 commit comments

Comments
 (0)