3 # OCF RA for OCFS2 on DRBD
5 # Copyright (c) 2008,2009 Barton IT-Consulting
6 # Copyright (c) 2004 SUSE LINUX AG, Lars Marowsky-Brée
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of version 2 of the GNU General Public License as
11 # published by the Free Software Foundation.
13 # This program is distributed in the hope that it would be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 # Further, this software is distributed without any warranty that it is
18 # free of the rightful claim of any third person regarding infringement
19 # or the like. Any license provided herein, whether implied or
20 # otherwise, applies only to this software file. Patent licenses, if
21 # any, provided herein do not apply to combinations of this program with
22 # other software, or any other product whatsoever.
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write the Free Software Foundation,
26 # Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
30 . ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs
32 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
37 <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
38 <resource-agent name="OCFS2_DRBD">
39 <version>1.4</version>
42 This Resource Agent starts and stops OCFS2 file systems located on DRBD devices.
44 <shortdesc lang="en">OCFS2 on DRBD resource agent</shortdesc>
47 <parameter name="drbd" unique="1">
48 <longdesc lang="en">ID of the DRBD resource</longdesc>
49 <shortdesc lang="en">ID of the DRBD resource</shortdesc>
50 <content type="string" default="" />
52 <parameter name="drbd_dev" unique="1">
53 <longdesc lang="en">DRBD device</longdesc>
54 <shortdesc lang="en">DRBD device</shortdesc>
55 <content type="string" default="" />
57 <parameter name="mountpoint" unique="1">
58 <longdesc lang="en">Mountpoint for OCFS2 filesystem</longdesc>
59 <shortdesc lang="en">Mountpoint for OCFS2 filesystem</shortdesc>
60 <content type="string" default="" />
65 <action name="start" timeout="90" />
66 <action name="stop" timeout="90" />
67 <action name="monitor" timeout="20" interval="30" depth="0" start-delay="10" />
68 <action name="meta-data" timeout="5" />
69 <action name="verify-all" timeout="30" />
75 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
78 echo "usage: $0 {start|stop|monitor|validate-all|meta-data}"
82 mkdir -p "$OCF_RESKEY_mountpoint"
83 drbdadm primary "$OCF_RESKEY_drbd"
85 return $OCF_ERR_GENERIC
87 mount -t ocfs2 "$OCF_RESKEY_drbd_dev" "$OCF_RESKEY_mountpoint"
89 return $OCF_ERR_GENERIC
95 mount | grep "$OCF_RESKEY_drbd_dev on " >/dev/null
97 umount "$OCF_RESKEY_mountpoint"
99 # try harder, kill processes on this filesystem
100 pids=$(ps ax|awk "{print \$1}"|grep -v PID)
102 lsof -p $p -n | grep " $OCF_RESKEY_mountpoint" \
104 [ $? -eq 0 ] || continue
108 pids=$(ps ax|awk "{print \$1}"|grep -v PID)
110 lsof -p $p -n | grep " $OCF_RESKEY_mountpoint" \
112 [ $? -eq 0 ] || continue
116 umount "$OCF_RESKEY_mountpoint"
117 if [ $? -ne 0 ]; then
118 return $OCF_ERR_GENERIC
122 drbdadm secondary "$OCF_RESKEY_drbd"
126 ClusterFS_monitor() {
127 mount | grep "$OCF_RESKEY_drbd_dev on " >/dev/null
128 if [ $? -eq 0 ]; then
131 return $OCF_NOT_RUNNING
134 ClusterFS_validate() {
135 if [ -z "$OCF_RESKEY_drbd" ]; then
138 if [ -z "$OCF_RESKEY_drbd_dev" ]; then
141 if [ -z "$OCF_RESKEY_mountpoint" ]; then
147 case $__OCF_ACTION in
170 exit $OCF_ERR_UNIMPLEMENTED
175 ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"