aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2008-01-29 19:59:56 -0500
committerMark Fasheh <mfasheh@suse.com>2008-04-18 11:56:04 -0400
commit6953b4c008628b945bfe0cee97f6e78a98773859 (patch)
treede00a19f59466d9e83b00112696afa5b02abbd9c /fs/ocfs2
parent19fdb624dc8ccb663f6e48b3a3a3fa4e4e567fc1 (diff)
ocfs2: Move o2hb functionality into the stack glue.
The last bit of classic stack used directly in ocfs2 code is o2hb. Specifically, the check for heartbeat during mount and the call to ocfs2_hb_ctl during unmount. We create an extra API, ocfs2_cluster_hangup(), to encapsulate the call to ocfs2_hb_ctl. Other stacks will just leave hangup() empty. The check for heartbeat is moved into ocfs2_cluster_connect(). It will be matched by a similar check for other stacks. With this change, only stackglue.c includes cluster/ headers. Signed-off-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r--fs/ocfs2/dlmglue.c4
-rw-r--r--fs/ocfs2/heartbeat.c33
-rw-r--r--fs/ocfs2/heartbeat.h1
-rw-r--r--fs/ocfs2/ioctl.c1
-rw-r--r--fs/ocfs2/ocfs2.h4
-rw-r--r--fs/ocfs2/stackglue.c50
-rw-r--r--fs/ocfs2/stackglue.h1
-rw-r--r--fs/ocfs2/super.c23
8 files changed, 62 insertions, 55 deletions
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 6652a48cbe0f..05fd016ba4bf 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -32,10 +32,6 @@
32#include <linux/debugfs.h> 32#include <linux/debugfs.h>
33#include <linux/seq_file.h> 33#include <linux/seq_file.h>
34 34
35#include <cluster/heartbeat.h>
36#include <cluster/nodemanager.h>
37#include <cluster/tcp.h>
38
39#define MLOG_MASK_PREFIX ML_DLM_GLUE 35#define MLOG_MASK_PREFIX ML_DLM_GLUE
40#include <cluster/masklog.h> 36#include <cluster/masklog.h>
41 37
diff --git a/fs/ocfs2/heartbeat.c b/fs/ocfs2/heartbeat.c
index dcac1a487288..c6e7213db868 100644
--- a/fs/ocfs2/heartbeat.c
+++ b/fs/ocfs2/heartbeat.c
@@ -28,7 +28,6 @@
28#include <linux/types.h> 28#include <linux/types.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/highmem.h> 30#include <linux/highmem.h>
31#include <linux/kmod.h>
32 31
33#define MLOG_MASK_PREFIX ML_SUPER 32#define MLOG_MASK_PREFIX ML_SUPER
34#include <cluster/masklog.h> 33#include <cluster/masklog.h>
@@ -83,38 +82,6 @@ void ocfs2_do_node_down(int node_num, void *data)
83 ocfs2_recovery_thread(osb, node_num); 82 ocfs2_recovery_thread(osb, node_num);
84} 83}
85 84
86void ocfs2_stop_heartbeat(struct ocfs2_super *osb)
87{
88 int ret;
89 char *argv[5], *envp[3];
90
91 if (ocfs2_mount_local(osb))
92 return;
93
94 if (!osb->uuid_str) {
95 /* This can happen if we don't get far enough in mount... */
96 mlog(0, "No UUID with which to stop heartbeat!\n\n");
97 return;
98 }
99
100 argv[0] = (char *)o2nm_get_hb_ctl_path();
101 argv[1] = "-K";
102 argv[2] = "-u";
103 argv[3] = osb->uuid_str;
104 argv[4] = NULL;
105
106 mlog(0, "Run: %s %s %s %s\n", argv[0], argv[1], argv[2], argv[3]);
107
108 /* minimal command environment taken from cpu_run_sbin_hotplug */
109 envp[0] = "HOME=/";
110 envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
111 envp[2] = NULL;
112
113 ret = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC);
114 if (ret < 0)
115 mlog_errno(ret);
116}
117
118static inline void __ocfs2_node_map_set_bit(struct ocfs2_node_map *map, 85static inline void __ocfs2_node_map_set_bit(struct ocfs2_node_map *map,
119 int bit) 86 int bit)
120{ 87{
diff --git a/fs/ocfs2/heartbeat.h b/fs/ocfs2/heartbeat.h
index 38e2450bf14c..74b9c5dda28d 100644
--- a/fs/ocfs2/heartbeat.h
+++ b/fs/ocfs2/heartbeat.h
@@ -29,7 +29,6 @@
29void ocfs2_init_node_maps(struct ocfs2_super *osb); 29void ocfs2_init_node_maps(struct ocfs2_super *osb);
30 30
31void ocfs2_do_node_down(int node_num, void *data); 31void ocfs2_do_node_down(int node_num, void *data);
32void ocfs2_stop_heartbeat(struct ocfs2_super *osb);
33 32
34/* node map functions - used to keep track of mounted and in-recovery 33/* node map functions - used to keep track of mounted and in-recovery
35 * nodes. */ 34 * nodes. */
diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c
index 5177fba5162b..ab1c2167d7f4 100644
--- a/fs/ocfs2/ioctl.c
+++ b/fs/ocfs2/ioctl.c
@@ -7,6 +7,7 @@
7 7
8#include <linux/fs.h> 8#include <linux/fs.h>
9#include <linux/mount.h> 9#include <linux/mount.h>
10#include <linux/smp_lock.h>
10 11
11#define MLOG_MASK_PREFIX ML_INODE 12#define MLOG_MASK_PREFIX ML_INODE
12#include <cluster/masklog.h> 13#include <cluster/masklog.h>
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
index 7006abaffd47..31dc28b48392 100644
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -36,10 +36,6 @@
36#include <linux/mutex.h> 36#include <linux/mutex.h>
37#include <linux/jbd.h> 37#include <linux/jbd.h>
38 38
39#include "cluster/nodemanager.h"
40#include "cluster/heartbeat.h"
41#include "cluster/tcp.h"
42
43/* For union ocfs2_dlm_lksb */ 39/* For union ocfs2_dlm_lksb */
44#include "stackglue.h" 40#include "stackglue.h"
45 41
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;
diff --git a/fs/ocfs2/stackglue.h b/fs/ocfs2/stackglue.h
index ccb03991b514..22af77b9a690 100644
--- a/fs/ocfs2/stackglue.h
+++ b/fs/ocfs2/stackglue.h
@@ -74,6 +74,7 @@ int ocfs2_cluster_connect(const char *group,
74 void *recovery_data, 74 void *recovery_data,
75 struct ocfs2_cluster_connection **conn); 75 struct ocfs2_cluster_connection **conn);
76int ocfs2_cluster_disconnect(struct ocfs2_cluster_connection *conn); 76int ocfs2_cluster_disconnect(struct ocfs2_cluster_connection *conn);
77void ocfs2_cluster_hangup(const char *group, int grouplen);
77int ocfs2_cluster_this_node(unsigned int *node); 78int ocfs2_cluster_this_node(unsigned int *node);
78 79
79int ocfs2_dlm_lock(struct ocfs2_cluster_connection *conn, 80int ocfs2_dlm_lock(struct ocfs2_cluster_connection *conn,
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index d3c4d323fab5..8f536b39ce5b 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -40,8 +40,7 @@
40#include <linux/crc32.h> 40#include <linux/crc32.h>
41#include <linux/debugfs.h> 41#include <linux/debugfs.h>
42#include <linux/mount.h> 42#include <linux/mount.h>
43 43#include <linux/seq_file.h>
44#include <cluster/nodemanager.h>
45 44
46#define MLOG_MASK_PREFIX ML_SUPER 45#define MLOG_MASK_PREFIX ML_SUPER
47#include <cluster/masklog.h> 46#include <cluster/masklog.h>
@@ -579,15 +578,6 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
579 goto read_super_error; 578 goto read_super_error;
580 } 579 }
581 580
582 /* for now we only have one cluster/node, make sure we see it
583 * in the heartbeat universe */
584 if (parsed_options.mount_opt & OCFS2_MOUNT_HB_LOCAL) {
585 if (!o2hb_check_local_node_heartbeating()) {
586 status = -EINVAL;
587 goto read_super_error;
588 }
589 }
590
591 /* probe for superblock */ 581 /* probe for superblock */
592 status = ocfs2_sb_probe(sb, &bh, &sector_size); 582 status = ocfs2_sb_probe(sb, &bh, &sector_size);
593 if (status < 0) { 583 if (status < 0) {
@@ -1275,8 +1265,15 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err)
1275 1265
1276 debugfs_remove(osb->osb_debug_root); 1266 debugfs_remove(osb->osb_debug_root);
1277 1267
1278 if (!mnt_err) 1268 /*
1279 ocfs2_stop_heartbeat(osb); 1269 * This is a small hack to move ocfs2_hb_ctl into stackglue.
1270 * If we're dismounting due to mount error, mount.ocfs2 will clean
1271 * up heartbeat. If we're a local mount, there is no heartbeat.
1272 * If we failed before we got a uuid_str yet, we can't stop
1273 * heartbeat. Otherwise, do it.
1274 */
1275 if (!mnt_err && !ocfs2_mount_local(osb) && osb->uuid_str)
1276 ocfs2_cluster_hangup(osb->uuid_str, strlen(osb->uuid_str));
1280 1277
1281 atomic_set(&osb->vol_state, VOLUME_DISMOUNTED); 1278 atomic_set(&osb->vol_state, VOLUME_DISMOUNTED);
1282 1279