aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/stackglue.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2/stackglue.c')
-rw-r--r--fs/ocfs2/stackglue.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c
index 814686356cc6..670fa945c212 100644
--- a/fs/ocfs2/stackglue.c
+++ b/fs/ocfs2/stackglue.c
@@ -20,12 +20,14 @@
20 20
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/crc32.h> 22#include <linux/crc32.h>
23#include <linux/kmod.h>
23 24
24/* Needed for AOP_TRUNCATED_PAGE in mlog_errno() */ 25/* Needed for AOP_TRUNCATED_PAGE in mlog_errno() */
25#include <linux/fs.h> 26#include <linux/fs.h>
26 27
27#include "cluster/masklog.h" 28#include "cluster/masklog.h"
28#include "cluster/nodemanager.h" 29#include "cluster/nodemanager.h"
30#include "cluster/heartbeat.h"
29 31
30#include "stackglue.h" 32#include "stackglue.h"
31 33
@@ -301,6 +303,13 @@ int ocfs2_cluster_connect(const char *group,
301 goto out; 303 goto out;
302 } 304 }
303 305
306 /* for now we only have one cluster/node, make sure we see it
307 * in the heartbeat universe */
308 if (!o2hb_check_local_node_heartbeating()) {
309 rc = -EINVAL;
310 goto out;
311 }
312
304 new_conn = kzalloc(sizeof(struct ocfs2_cluster_connection), 313 new_conn = kzalloc(sizeof(struct ocfs2_cluster_connection),
305 GFP_KERNEL); 314 GFP_KERNEL);
306 if (!new_conn) { 315 if (!new_conn) {
@@ -359,6 +368,7 @@ out:
359 return rc; 368 return rc;
360} 369}
361 370
371
362int ocfs2_cluster_disconnect(struct ocfs2_cluster_connection *conn) 372int ocfs2_cluster_disconnect(struct ocfs2_cluster_connection *conn)
363{ 373{
364 struct dlm_ctxt *dlm = conn->cc_lockspace; 374 struct dlm_ctxt *dlm = conn->cc_lockspace;
@@ -373,6 +383,46 @@ int ocfs2_cluster_disconnect(struct ocfs2_cluster_connection *conn)
373 return 0; 383 return 0;
374} 384}
375 385
386static void o2hb_stop(const char *group)
387{
388 int ret;
389 char *argv[5], *envp[3];
390
391 argv[0] = (char *)o2nm_get_hb_ctl_path();
392 argv[1] = "-K";
393 argv[2] = "-u";
394 argv[3] = (char *)group;
395 argv[4] = NULL;
396
397 mlog(0, "Run: %s %s %s %s\n", argv[0], argv[1], argv[2], argv[3]);
398
399 /* minimal command environment taken from cpu_run_sbin_hotplug */
400 envp[0] = "HOME=/";
401 envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
402 envp[2] = NULL;
403
404 ret = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC);
405 if (ret < 0)
406 mlog_errno(ret);
407}
408
409/*
410 * Hangup is a hack for tools compatibility. Older ocfs2-tools software
411 * expects the filesystem to call "ocfs2_hb_ctl" during unmount. This
412 * happens regardless of whether the DLM got started, so we can't do it
413 * in ocfs2_cluster_disconnect(). We bring the o2hb_stop() function into
414 * the glue and provide a "hangup" API for super.c to call.
415 *
416 * Other stacks will eventually provide a NULL ->hangup() pointer.
417 */
418void ocfs2_cluster_hangup(const char *group, int grouplen)
419{
420 BUG_ON(group == NULL);
421 BUG_ON(group[grouplen] != '\0');
422
423 o2hb_stop(group);
424}
425
376int ocfs2_cluster_this_node(unsigned int *node) 426int ocfs2_cluster_this_node(unsigned int *node)
377{ 427{
378 int node_num; 428 int node_num;