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.5</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="" />
62 <parameter name="reload_cron" unique="1">
63 <longdesc lang="en">Reload CRON configuration after mounting OCFS2 filesystem</longdesc>
64 <shortdesc lang="en">Reload CRON configuration</shortdesc>
65 <content type="boolean" default="0" />
70 <action name="start" timeout="90" />
71 <action name="stop" timeout="90" />
72 <action name="monitor" timeout="20" interval="30" depth="0" start-delay="10" />
73 <action name="meta-data" timeout="5" />
74 <action name="validate-all" timeout="30" />
80 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
83 echo "usage: $0 {start|stop|monitor|validate-all|meta-data}"
87 mkdir -p "$OCF_RESKEY_mountpoint"
88 drbdadm primary "$OCF_RESKEY_drbd"
90 return $OCF_ERR_GENERIC
92 mount -t ocfs2 -o noatime \
93 "$OCF_RESKEY_drbd_dev" "$OCF_RESKEY_mountpoint"
95 return $OCF_ERR_GENERIC
97 if [ "$OCF_RESKEY_reload_cron" = "1" ]; then
98 [ -d /etc/cron.d ] && touch /etc/cron.d
104 mount | grep "$OCF_RESKEY_drbd_dev on " >/dev/null
105 if [ $? -eq 0 ]; then
106 umount "$OCF_RESKEY_mountpoint"
107 if [ $? -ne 0 ]; then
108 # try harder, kill processes on this filesystem
109 pids=$(ps ax|awk "{print \$1}"|grep -v PID)
111 lsof -p $p -n | grep " $OCF_RESKEY_mountpoint" \
113 [ $? -eq 0 ] || continue
117 pids=$(ps ax|awk "{print \$1}"|grep -v PID)
119 lsof -p $p -n | grep " $OCF_RESKEY_mountpoint" \
121 [ $? -eq 0 ] || continue
125 umount "$OCF_RESKEY_mountpoint"
126 if [ $? -ne 0 ]; then
127 return $OCF_ERR_GENERIC
131 drbdadm secondary "$OCF_RESKEY_drbd"
132 if [ "$OCF_RESKEY_reload_cron" = "1" ]; then
133 [ -d /etc/cron.d ] && touch /etc/cron.d
138 ClusterFS_monitor() {
139 mount | grep "$OCF_RESKEY_drbd_dev on " >/dev/null
140 if [ $? -eq 0 ]; then
143 return $OCF_NOT_RUNNING
146 ClusterFS_validate() {
147 if [ -z "$OCF_RESKEY_drbd" ]; then
150 if [ -z "$OCF_RESKEY_drbd_dev" ]; then
153 if [ -z "$OCF_RESKEY_mountpoint" ]; then
159 case $__OCF_ACTION in
182 exit $OCF_ERR_UNIMPLEMENTED
187 ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"