Skip to content

Commit 9b66491

Browse files
authored
Merge pull request #1253 from gmelikov/zfs
ZFS: cleanup different indentations
2 parents d524a5f + bb71539 commit 9b66491

1 file changed

Lines changed: 83 additions & 83 deletions

File tree

heartbeat/ZFS

Lines changed: 83 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ USAGE="usage: $0 {start|stop|status|monitor|validate-all|meta-data}";
3131
#######################################################################
3232

3333
meta_data() {
34-
cat <<END
34+
cat <<END
3535
<?xml version="1.0"?>
3636
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
3737
<resource-agent name="ZFS">
@@ -75,125 +75,125 @@ zpool import is given the -f option.
7575
</actions>
7676
</resource-agent>
7777
END
78-
exit $OCF_SUCCESS
78+
exit $OCF_SUCCESS
7979
}
8080

8181
zpool_is_imported () {
82-
zpool list -H "$OCF_RESKEY_pool" > /dev/null
82+
zpool list -H "$OCF_RESKEY_pool" > /dev/null
8383
}
8484

8585
# Forcibly imports a ZFS pool, mounting all of its auto-mounted filesystems
8686
# (as configured in the 'mountpoint' and 'canmount' properties)
8787
# If the pool is already imported, no operation is taken.
8888
zpool_import () {
89-
if ! zpool_is_imported; then
90-
ocf_log debug "${OCF_RESKEY_pool}:starting import"
91-
92-
# The meanings of the options to import are as follows:
93-
# -f : import even if the pool is marked as imported to another
94-
# system - the system may have failed and not exported it
95-
# cleanly.
96-
# -o cachefile=none : the import should be temporary, so do not
97-
# cache it persistently (across machine reboots). We want
98-
# the CRM to explicitly control imports of this pool.
89+
if ! zpool_is_imported; then
90+
ocf_log debug "${OCF_RESKEY_pool}:starting import"
91+
92+
# The meanings of the options to import are as follows:
93+
# -f : import even if the pool is marked as imported to another
94+
# system - the system may have failed and not exported it
95+
# cleanly.
96+
# -o cachefile=none : the import should be temporary, so do not
97+
# cache it persistently (across machine reboots). We want
98+
# the CRM to explicitly control imports of this pool.
9999
if ocf_is_true "${OCF_RESKEY_importforce}"; then
100-
FORCE=-f
100+
FORCE=-f
101101
else
102-
FORCE=""
102+
FORCE=""
103+
fi
104+
if zpool import $FORCE $OCF_RESKEY_importargs -o cachefile=none "$OCF_RESKEY_pool" ; then
105+
ocf_log debug "${OCF_RESKEY_pool}:import successful"
106+
return $OCF_SUCCESS
107+
else
108+
ocf_log debug "${OCF_RESKEY_pool}:import failed"
109+
return $OCF_ERR_GENERIC
110+
fi
103111
fi
104-
if zpool import $FORCE $OCF_RESKEY_importargs -o cachefile=none "$OCF_RESKEY_pool" ; then
105-
ocf_log debug "${OCF_RESKEY_pool}:import successful"
106-
return $OCF_SUCCESS
107-
else
108-
ocf_log debug "${OCF_RESKEY_pool}:import failed"
109-
return $OCF_ERR_GENERIC
110-
fi
111-
fi
112112
}
113113

114114
# Forcibly exports a ZFS pool, unmounting all of its filesystems in the process
115115
# If the pool is not imported, no operation is taken.
116116
zpool_export () {
117-
if zpool_is_imported; then
118-
ocf_log debug "${OCF_RESKEY_pool}:starting export"
119-
120-
# -f : force the export, even if we have mounted filesystems
121-
# Please note that this may fail with a "busy" error if there are
122-
# other kernel subsystems accessing the pool (e.g. SCSI targets).
123-
# Always make sure the pool export is last in your failover logic.
124-
if zpool export -f "$OCF_RESKEY_pool" ; then
125-
ocf_log debug "${OCF_RESKEY_pool}:export successful"
126-
return $OCF_SUCCESS
127-
else
128-
ocf_log debug "${OCF_RESKEY_pool}:export failed"
129-
return $OCF_ERR_GENERIC
117+
if zpool_is_imported; then
118+
ocf_log debug "${OCF_RESKEY_pool}:starting export"
119+
120+
# -f : force the export, even if we have mounted filesystems
121+
# Please note that this may fail with a "busy" error if there are
122+
# other kernel subsystems accessing the pool (e.g. SCSI targets).
123+
# Always make sure the pool export is last in your failover logic.
124+
if zpool export -f "$OCF_RESKEY_pool" ; then
125+
ocf_log debug "${OCF_RESKEY_pool}:export successful"
126+
return $OCF_SUCCESS
127+
else
128+
ocf_log debug "${OCF_RESKEY_pool}:export failed"
129+
return $OCF_ERR_GENERIC
130+
fi
130131
fi
131-
fi
132132
}
133133

134134
# Monitors the health of a ZFS pool resource. Please note that this only
135135
# checks whether the pool is imported and functional, not whether it has
136136
# any degraded devices (use monitoring systems such as Zabbix for that).
137137
zpool_monitor () {
138-
# If the pool is not imported, then we can't monitor its health
139-
if ! zpool_is_imported; then
140-
return $OCF_NOT_RUNNING
141-
fi
142-
143-
# Check the pool status
144-
# Since version 0.7.10 status can be obtained without locks
145-
# https://github.com/zfsonlinux/zfs/pull/7563
146-
if [ -f /proc/spl/kstat/zfs/$OCF_RESKEY_pool/state ] ; then
147-
HEALTH=$(</proc/spl/kstat/zfs/$OCF_RESKEY_pool/state)
148-
else
149-
HEALTH=$(zpool list -H -o health "$OCF_RESKEY_pool")
150-
fi
151-
152-
case "$HEALTH" in
153-
ONLINE|DEGRADED) return $OCF_SUCCESS;;
154-
FAULTED) return $OCF_NOT_RUNNING;;
155-
*) return $OCF_ERR_GENERIC;;
156-
esac
138+
# If the pool is not imported, then we can't monitor its health
139+
if ! zpool_is_imported; then
140+
return $OCF_NOT_RUNNING
141+
fi
142+
143+
# Check the pool status
144+
# Since version 0.7.10 status can be obtained without locks
145+
# https://github.com/zfsonlinux/zfs/pull/7563
146+
if [ -f /proc/spl/kstat/zfs/$OCF_RESKEY_pool/state ] ; then
147+
HEALTH=$(</proc/spl/kstat/zfs/$OCF_RESKEY_pool/state)
148+
else
149+
HEALTH=$(zpool list -H -o health "$OCF_RESKEY_pool")
150+
fi
151+
152+
case "$HEALTH" in
153+
ONLINE|DEGRADED) return $OCF_SUCCESS;;
154+
FAULTED) return $OCF_NOT_RUNNING;;
155+
*) return $OCF_ERR_GENERIC;;
156+
esac
157157
}
158158

159159
# Validates whether we can import a given ZFS pool
160160
zpool_validate () {
161-
# Check that the 'zpool' command is known
162-
if ! which zpool > /dev/null; then
163-
return $OCF_ERR_INSTALLED
164-
fi
165-
166-
# If the pool is imported, then it is obviously valid
167-
if zpool_is_imported; then
168-
return $OCF_SUCCESS
169-
fi
170-
171-
# Check that the pool can be imported
172-
if zpool import $OCF_RESKEY_importargs | grep 'pool:' | grep "\\<$OCF_RESKEY_pool\\>" > /dev/null;
173-
then
174-
return $OCF_SUCCESS
175-
else
176-
return $OCF_ERR_CONFIGURED
177-
fi
161+
# Check that the 'zpool' command is known
162+
if ! which zpool > /dev/null; then
163+
return $OCF_ERR_INSTALLED
164+
fi
165+
166+
# If the pool is imported, then it is obviously valid
167+
if zpool_is_imported; then
168+
return $OCF_SUCCESS
169+
fi
170+
171+
# Check that the pool can be imported
172+
if zpool import $OCF_RESKEY_importargs | grep 'pool:' | grep "\\<$OCF_RESKEY_pool\\>" > /dev/null;
173+
then
174+
return $OCF_SUCCESS
175+
else
176+
return $OCF_ERR_CONFIGURED
177+
fi
178178
}
179179

180180
usage () {
181-
echo "$USAGE" >&2
182-
return $1
181+
echo "$USAGE" >&2
182+
return $1
183183
}
184184

185185
if [ $# -ne 1 ]; then
186-
usage $OCF_ERR_ARGS
186+
usage $OCF_ERR_ARGS
187187
fi
188188

189189
case $1 in
190-
meta-data) meta_data;;
191-
start) zpool_import;;
192-
stop) zpool_export;;
193-
status|monitor) zpool_monitor;;
194-
validate-all) zpool_validate;;
195-
usage) usage $OCF_SUCCESS;;
196-
*) usage $OCF_ERR_UNIMPLEMENTED;;
190+
meta-data) meta_data;;
191+
start) zpool_import;;
192+
stop) zpool_export;;
193+
status|monitor) zpool_monitor;;
194+
validate-all) zpool_validate;;
195+
usage) usage $OCF_SUCCESS;;
196+
*) usage $OCF_ERR_UNIMPLEMENTED;;
197197
esac
198198

199199
exit $?

0 commit comments

Comments
 (0)