fence-agents: master - fence_netio: new fence-agent for the Koukaam NETIO-230B PDU
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=05c4b2...
Commit: 05c4b2cfaaba95f86cdc5c983937648970a1a8c9
Parent: 003fcf63623fe42b5879908eaec8b87da160be9c
Author: Niels de Vos <ndevos(a)redhat.com>
AuthorDate: Sat Sep 28 12:15:32 2013 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Mon Sep 30 13:15:07 2013 +0200
fence_netio: new fence-agent for the Koukaam NETIO-230B PDU
The Koukaam NETIO-230B is a power distribution unit with four normal
(European) sockets. The device has a webui and a telnet interface. Each
socket can be given a custom name, which is returned with '-o list'.
Link to the device, its specifications and API:
- http://www.koukaam.se/kkm/showproduct.php?article_id=1502
Signed-off-by: Niels de Vos <ndevos(a)redhat.com>
---
.gitignore | 1 +
configure.ac | 1 +
fence/agents/netio/Makefile.am | 17 +++++
fence/agents/netio/fence_netio.py | 119 +++++++++++++++++++++++++++++++++++++
4 files changed, 138 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
index 245592f..0c19556 100644
--- a/.gitignore
+++ b/.gitignore
@@ -59,6 +59,7 @@ fence/agents/lib/fencing_snmp.pyc
fence/agents/lpar/fence_lpar
fence/agents/manual/fence_ack_manual
fence/agents/mcdata/fence_mcdata
+fence/agents/netio/fence_netio
fence/agents/node_assassin/fence_na
fence/agents/node_assassin/fence_na.conf
fence/agents/node_assassin/fence_na.lib
diff --git a/configure.ac b/configure.ac
index 910cab8..6f4baa0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -276,6 +276,7 @@ AC_CONFIG_FILES([Makefile
fence/agents/lpar/Makefile
fence/agents/manual/Makefile
fence/agents/mcdata/Makefile
+ fence/agents/netio/Makefile
fence/agents/nss_wrapper/Makefile
fence/agents/rackswitch/Makefile
fence/agents/ovh/Makefile
diff --git a/fence/agents/netio/Makefile.am b/fence/agents/netio/Makefile.am
new file mode 100644
index 0000000..3e1a1d9
--- /dev/null
+++ b/fence/agents/netio/Makefile.am
@@ -0,0 +1,17 @@
+MAINTAINERCLEANFILES = Makefile.in
+
+TARGET = fence_netio
+
+SRC = $(TARGET).py
+
+EXTRA_DIST = $(SRC)
+
+sbin_SCRIPTS = $(TARGET)
+
+man_MANS = $(TARGET).8
+
+include $(top_srcdir)/make/fencebuild.mk
+include $(top_srcdir)/make/fenceman.mk
+
+clean-local: clean-man
+ rm -f $(TARGET)
diff --git a/fence/agents/netio/fence_netio.py b/fence/agents/netio/fence_netio.py
new file mode 100755
index 0000000..ffb6e30
--- /dev/null
+++ b/fence/agents/netio/fence_netio.py
@@ -0,0 +1,119 @@
+#!/usr/bin/python
+
+import sys, re, pexpect, exceptions
+sys.path.append("@FENCEAGENTSLIBDIR@")
+from fencing import *
+
+#BEGIN_VERSION_GENERATION
+RELEASE_VERSION=""
+REDHAT_COPYRIGHT=""
+BUILD_DATE=""
+#END_VERSION_GENERATION
+
+def get_power_status(conn, options):
+ conn.send_eol("port %s" % options["--plug"])
+ re_status = re.compile("250 [01imt]")
+ conn.log_expect(options, re_status, int(options["--shell-timeout"]))
+ status = {
+ "0" : "off",
+ "1" : "on",
+ "i" : "reboot",
+ "m" : "manual",
+ "t" : "timer"
+ }[conn.after.split()[1]]
+
+ return status
+
+def set_power_status(conn, options):
+ action = {
+ "on" : "1",
+ "off" : "0",
+ "reboot" : "i"
+ }[options["--action"]]
+
+ conn.send_eol("port %s %s" % (options["--plug"], action))
+ conn.log_expect(options, "250 OK", int(options["--shell-timeout"]))
+
+def get_outlet_list(conn, options):
+ result = {}
+
+ try:
+ # the NETIO-230B has 4 ports, counting start at 1
+ for plug in ["1", "2", "3", "4"]:
+ conn.send_eol("port setup %s" % plug)
+ conn.log_expect(options, "250 .+", int(options["--shell-timeout"]))
+ # the name is enclosed in "", drop those with [1:-1]
+ name = conn.after.split()[1][1:-1]
+ result[plug] = (name, "unknown")
+ except Exception, exn:
+ print str(exn)
+
+ return result
+
+def main():
+ device_opt = [ "ipaddr", "login", "passwd", "port" ]
+
+ atexit.register(atexit_handler)
+
+ opt = process_input(device_opt)
+
+ # set default port for telnet only
+ if 0 == opt.has_key("--ipport"):
+ opt["--ipport"] = "1234"
+
+ opt["eol"] = "\r\n"
+ options = check_input(device_opt, opt)
+
+ docs = { }
+ docs["shortdesc"] = "I/O Fencing agent for Koukaam NETIO-230B"
+ docs["longdesc"] = "fence_netio is an I/O Fencing agent which can be \
+used with the Koukaam NETIO-230B Power Distribution Unit. It logs into \
+device via telnet and reboots a specified outlet. Lengthy telnet connections \
+should be avoided while a GFS cluster is running because the connection will \
+block any necessary fencing actions."
+ docs["vendorurl"] = "http://www.koukaam.se/"
+ show_docs(options, docs)
+
+ ##
+ ## Operate the fencing device
+ ## We can not use fence_login(), username and passwd are sent on one line
+ ####
+ try:
+ try:
+ conn = fspawn(options, TELNET_PATH)
+ conn.send("set binary\n")
+ conn.send("open %s -%s\n"%(options["--ip"], options["--ipport"]))
+ except pexpect.ExceptionPexpect, ex:
+ sys.stderr.write(str(ex) + "\n")
+ sys.stderr.write("Due to limitations, binary dependencies on fence agents "
+ "are not in the spec file and must be installed separately." + "\n")
+ sys.exit(EC_GENERIC_ERROR)
+
+ screen = conn.read_nonblocking(size=100, timeout=int(options["--shell-timeout"]))
+ conn.log_expect(options, "100 HELLO .*", int(options["--shell-timeout"]))
+ conn.send_eol("login %s %s" % (options["--username"], options["--password"]))
+ conn.log_expect(options, "250 OK", int(options["--shell-timeout"]))
+ except pexpect.EOF:
+ fail(EC_LOGIN_DENIED)
+ except pexpect.TIMEOUT:
+ fail(EC_LOGIN_DENIED)
+ result = fence_action(conn, options, set_power_status, get_power_status, get_outlet_list)
+
+ ##
+ ## Logout from system
+ ##
+ ## In some special unspecified cases it is possible that
+ ## connection will be closed before we run close(). This is not
+ ## a problem because everything is checked before.
+ ######
+ try:
+ conn.send("quit\n")
+ conn.log_expect(options, "110 BYE", int(options["--shell-timeout"]))
+ conn.close()
+ except:
+ pass
+
+ sys.exit(result)
+
+if __name__ == "__main__":
+ main()
10 years, 6 months
fence-agents: master - fencing: Add information about automatic "unfence" to metadata
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=003fcf...
Commit: 003fcf63623fe42b5879908eaec8b87da160be9c
Parent: 5d31cbaee51eb77795a3d91dae5da5f3c46c64af
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Fri Sep 27 16:31:44 2013 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Fri Sep 27 16:31:44 2013 +0200
fencing: Add information about automatic "unfence" to metadata
Resolves: rhbz#1012994
---
fence/agents/lib/fencing.py.py | 6 +++++-
fence/agents/scsi/fence_scsi.pl | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index bb144bb..d6b02d3 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -487,7 +487,11 @@ def metadata(avail_opt, options, docs):
print "\t</parameter>"
print "</parameters>"
print "<actions>"
- print "\t<action name=\"on\" />"
+ if avail_opt.count("fabric_fencing") == 1:
+ ## do 'unfence' at the start
+ print "\t<action name=\"on\" automatic=\"1\"/>"
+ else:
+ print "\t<action name=\"on\" automatic=\"0\"/>"
print "\t<action name=\"off\" />"
if avail_opt.count("fabric_fencing") == 0:
diff --git a/fence/agents/scsi/fence_scsi.pl b/fence/agents/scsi/fence_scsi.pl
index 4e5cc96..2585f9e 100644
--- a/fence/agents/scsi/fence_scsi.pl
+++ b/fence/agents/scsi/fence_scsi.pl
@@ -757,7 +757,7 @@ sub print_metadata ()
print "\t</parameter>\n";
print "</parameters>\n";
print "<actions>\n";
- print "\t<action name=\"on\" on_target=\"1\"/>\n";
+ print "\t<action name=\"on\" on_target=\"1\" automatic=\"1\"/>\n";
print "\t<action name=\"off\"/>\n";
print "\t<action name=\"status\"/>\n";
print "\t<action name=\"metadata\"/>\n";
10 years, 6 months
cluster: RHEL511 - fence_cisco_ucs: fence agent does not respect "delay" attribute
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=bb3cf23ad92...
Commit: bb3cf23ad9214086ec497f2368649501d8546c9e
Parent: 0efa69dbc533017d02dea73646841c97fca91525
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed Sep 25 10:58:11 2013 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed Sep 25 10:58:11 2013 +0200
fence_cisco_ucs: fence agent does not respect "delay" attribute
Resolves: rhbz#994228
Based on commit 2424d8c71413d6ba4ace2c002ee80c1f4517b4c8 in fence-agents.git
---
fence/agents/cisco_ucs/fence_cisco_ucs.py | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/fence/agents/cisco_ucs/fence_cisco_ucs.py b/fence/agents/cisco_ucs/fence_cisco_ucs.py
index beecd3a..499a79a 100755
--- a/fence/agents/cisco_ucs/fence_cisco_ucs.py
+++ b/fence/agents/cisco_ucs/fence_cisco_ucs.py
@@ -116,6 +116,11 @@ used with Cisco UCS to fence machines."
docs["vendorurl"] = "http://www.cisco.com"
show_docs(options, docs)
+ ## Do the delay of the fence device before logging in
+ ## Delay is important for two-node clusters fencing but we do not need to delay 'status' operations
+ if options["-o"] in ["off", "reboot"]:
+ time.sleep(int(options["-f"]))
+
### Login
res = send_command(options, "<aaaLogin inName=\"" + options["-l"] + "\" inPassword=\"" + options["-p"] + "\" />")
result = re_cookie.search(res)
10 years, 6 months
cluster: RHEL59 - fs.sh: Avoid failures caused by /tmp being full
by Ryan McCabe
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=d0c5a3be2b1...
Commit: d0c5a3be2b15eedfc4c964d91f71a5d51c238fb2
Parent: 7c1eff97fde6b899904a97e366380a470c3f50a3
Author: Ryan McCabe <rmccabe(a)redhat.com>
AuthorDate: Tue Sep 17 22:22:13 2013 -0400
Committer: Ryan McCabe <rmccabe(a)redhat.com>
CommitterDate: Wed Sep 18 09:58:35 2013 -0400
fs.sh: Avoid failures caused by /tmp being full
This patch prevents fs.sh resource agent failures when /tmp is full
by eliminating the need to write a temporary file to /tmp while
parsing /proc/mounts.
This same fix has been made upstream and in RHEL6 in the filesystem
resource agent for the codepath that is hit when 'findmnt' is
either not available or not used.
Resolves: rhbz#1009245
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
---
rgmanager/src/resources/fs.sh | 10 ++--------
1 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/rgmanager/src/resources/fs.sh b/rgmanager/src/resources/fs.sh
index e55e77f..5dc7000 100755
--- a/rgmanager/src/resources/fs.sh
+++ b/rgmanager/src/resources/fs.sh
@@ -560,8 +560,6 @@ mountInUse () {
dev=$1
mp=$2
- typeset proc_mounts=$(mktemp /tmp/fs.proc.mounts.XXXXXX)
- cat /proc/mounts > $proc_mounts
while read tmp_dev tmp_mp junka junkb junkc junkd; do
if [ -n "$tmp_dev" -a "$tmp_dev" = "$dev" ]; then
return $YES
@@ -570,8 +568,7 @@ mountInUse () {
if [ -n "$tmp_mp" -a "$tmp_mp" = "$mp" ]; then
return $YES
fi
- done < $proc_mounts
- rm -f $proc_mounts
+ done < <(cat /proc/mounts)
return $NO
}
@@ -612,8 +609,6 @@ isMounted () {
ret=$NO
- typeset proc_mounts=$(mktemp /tmp/fs.proc.mounts.XXXXXX)
- cat /proc/mounts > $proc_mounts
while read tmp_dev tmp_mp junk_a junk_b junk_c junk_d
do
real_device $tmp_dev
@@ -638,8 +633,7 @@ isMounted () {
fi
ret=$YES
fi
- done < $proc_mounts
- rm -f $proc_mounts
+ done < <(cat /proc/mounts)
if [ $ret -eq $YES ] && [ $found -ne 0 ]; then
ocf_log warn "Device $dev is mounted on $poss_mp instead of $mp"
10 years, 7 months
cluster: RHEL510 - fs.sh: Avoid failures caused by /tmp being full
by Ryan McCabe
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=ba5cc65fe17...
Commit: ba5cc65fe172c34c78c884f2bef96a6e9a45d20b
Parent: c5a838ac74d1099ade298f1cca602e8f7bd7a283
Author: Ryan McCabe <rmccabe(a)redhat.com>
AuthorDate: Tue Sep 17 22:22:13 2013 -0400
Committer: Ryan McCabe <rmccabe(a)redhat.com>
CommitterDate: Wed Sep 18 09:50:27 2013 -0400
fs.sh: Avoid failures caused by /tmp being full
This patch prevents fs.sh resource agent failures when /tmp is full
by eliminating the need to write a temporary file to /tmp while
parsing /proc/mounts.
This same fix has been made upstream and in RHEL6 in the filesystem
resource agent for the codepath that is hit when 'findmnt' is
either not available or not used.
Resolves: rhbz#1009246
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
---
rgmanager/src/resources/fs.sh | 10 ++--------
1 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/rgmanager/src/resources/fs.sh b/rgmanager/src/resources/fs.sh
index e55e77f..5dc7000 100755
--- a/rgmanager/src/resources/fs.sh
+++ b/rgmanager/src/resources/fs.sh
@@ -560,8 +560,6 @@ mountInUse () {
dev=$1
mp=$2
- typeset proc_mounts=$(mktemp /tmp/fs.proc.mounts.XXXXXX)
- cat /proc/mounts > $proc_mounts
while read tmp_dev tmp_mp junka junkb junkc junkd; do
if [ -n "$tmp_dev" -a "$tmp_dev" = "$dev" ]; then
return $YES
@@ -570,8 +568,7 @@ mountInUse () {
if [ -n "$tmp_mp" -a "$tmp_mp" = "$mp" ]; then
return $YES
fi
- done < $proc_mounts
- rm -f $proc_mounts
+ done < <(cat /proc/mounts)
return $NO
}
@@ -612,8 +609,6 @@ isMounted () {
ret=$NO
- typeset proc_mounts=$(mktemp /tmp/fs.proc.mounts.XXXXXX)
- cat /proc/mounts > $proc_mounts
while read tmp_dev tmp_mp junk_a junk_b junk_c junk_d
do
real_device $tmp_dev
@@ -638,8 +633,7 @@ isMounted () {
fi
ret=$YES
fi
- done < $proc_mounts
- rm -f $proc_mounts
+ done < <(cat /proc/mounts)
if [ $ret -eq $YES ] && [ $found -ne 0 ]; then
ocf_log warn "Device $dev is mounted on $poss_mp instead of $mp"
10 years, 7 months
cluster: RHEL511 - fs.sh: Avoid failures caused by /tmp being full
by Ryan McCabe
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=0efa69dbc53...
Commit: 0efa69dbc533017d02dea73646841c97fca91525
Parent: c5a838ac74d1099ade298f1cca602e8f7bd7a283
Author: Ryan McCabe <rmccabe(a)redhat.com>
AuthorDate: Tue Sep 17 22:22:13 2013 -0400
Committer: Ryan McCabe <rmccabe(a)redhat.com>
CommitterDate: Tue Sep 17 22:22:13 2013 -0400
fs.sh: Avoid failures caused by /tmp being full
This patch prevents fs.sh resource agent failures when /tmp is full
by eliminating the need to write a temporary file to /tmp while
parsing /proc/mounts.
This same fix has been made upstream and in RHEL6 in the filesystem
resource agent for the codepath that is hit when 'findmnt' is
either not available or not used.
Resolves: rhbz#997546
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
---
rgmanager/src/resources/fs.sh | 10 ++--------
1 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/rgmanager/src/resources/fs.sh b/rgmanager/src/resources/fs.sh
index e55e77f..5dc7000 100755
--- a/rgmanager/src/resources/fs.sh
+++ b/rgmanager/src/resources/fs.sh
@@ -560,8 +560,6 @@ mountInUse () {
dev=$1
mp=$2
- typeset proc_mounts=$(mktemp /tmp/fs.proc.mounts.XXXXXX)
- cat /proc/mounts > $proc_mounts
while read tmp_dev tmp_mp junka junkb junkc junkd; do
if [ -n "$tmp_dev" -a "$tmp_dev" = "$dev" ]; then
return $YES
@@ -570,8 +568,7 @@ mountInUse () {
if [ -n "$tmp_mp" -a "$tmp_mp" = "$mp" ]; then
return $YES
fi
- done < $proc_mounts
- rm -f $proc_mounts
+ done < <(cat /proc/mounts)
return $NO
}
@@ -612,8 +609,6 @@ isMounted () {
ret=$NO
- typeset proc_mounts=$(mktemp /tmp/fs.proc.mounts.XXXXXX)
- cat /proc/mounts > $proc_mounts
while read tmp_dev tmp_mp junk_a junk_b junk_c junk_d
do
real_device $tmp_dev
@@ -638,8 +633,7 @@ isMounted () {
fi
ret=$YES
fi
- done < $proc_mounts
- rm -f $proc_mounts
+ done < <(cat /proc/mounts)
if [ $ret -eq $YES ] && [ $found -ne 0 ]; then
ocf_log warn "Device $dev is mounted on $poss_mp instead of $mp"
10 years, 7 months
cluster: RHEL6 - mkfs.gfs2: Add missing 'K' option
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=e8a40d5346c...
Commit: e8a40d5346ced4898137ffee58f93e145c1bae7c
Parent: 136be5fd39fc6a2f1a277e5f8c9be542e514a538
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Fri Sep 13 11:39:42 2013 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Fri Sep 13 11:39:42 2013 -0500
mkfs.gfs2: Add missing 'K' option
Before this patch, we tested for the 'K' option, but we were not
allowing it in the options to mkfs.gfs2. This patch adds the missing
'K' option to the call to getopt.
rhbz#1007970
---
gfs2/mkfs/main_mkfs.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 7163cf1..b132af8 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -108,7 +108,7 @@ static void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
sdp->orig_fssize = 0;
while (cont) {
- optchar = getopt(argc, argv, "-b:c:DhJ:j:Op:qr:t:u:VX");
+ optchar = getopt(argc, argv, "-b:c:DhJ:j:KOp:qr:t:u:VX");
switch (optchar) {
case 'b':
10 years, 7 months
cluster: STABLE32 - build: workaround gcc __FILE__ macro expansion to save fdata size at runtime
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=6e2dd4f0129...
Commit: 6e2dd4f0129c8b1635bf401668dcb10dca29a9a6
Parent: b4408e050960c35793afb33b6c589bf579252609
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Tue Sep 10 20:41:16 2013 +0200
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Thu Sep 12 09:49:27 2013 +0200
build: workaround gcc __FILE__ macro expansion to save fdata size at runtime
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
Acked-by: Jan Friesse <jfriesse(a)redhat.com>
---
configure | 4 ++++
make/cobj.mk | 34 +++++++++++++++++++++++++++++++---
make/defines.mk.input | 3 +++
3 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/configure b/configure
index 1e6356e..677d305 100755
--- a/configure
+++ b/configure
@@ -19,6 +19,8 @@ my $ret = 0;
# eg. only the first 3 digits
my $required_kernelversion = '2.6.31';
+my $outoftree = '';
+
my %options = (
help => \$help,
cc => \$cc,
@@ -356,6 +358,7 @@ if (! -d "$objdir/make") {
symlinks("bindings","*.PL");
symlinks("bindings","MANIFEST");
symlinks("bindings","typemap");
+ $outoftree = 1;
} else {
print "nothing to do\n";
}
@@ -614,6 +617,7 @@ while (<IFILE>) {
$_ =~ s/\@DISABLE_FENCE\@/$without_fence/;
$_ =~ s/\@DISABLE_RGMANAGER\@/$without_rgmanager/;
$_ =~ s/\@DISABLE_BINDINGS\@/$without_bindings/;
+ $_ =~ s/\@OUTOFTREEBUILD\@/$outoftree/;
print OFILE "$_\n";
}
diff --git a/make/cobj.mk b/make/cobj.mk
index c018293..514e487 100644
--- a/make/cobj.mk
+++ b/make/cobj.mk
@@ -1,10 +1,38 @@
+ifdef outoftreebuild
+
+%.o: $(S)/%.c
+ cd $(S) > /dev/null 2>&1 && \
+ src=$(shell basename $<) && \
+ $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(REENT_CFLAGS) -c -o $(O)/$@ $$src && \
+ cd - >/dev/null 2>&1;
+
+# used by dlm/libdlm
+%_lt.o: $(S)/%.c
+ cd $(S) > /dev/null 2>&1 && \
+ src=$(shell basename $<) && \
+ $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $(O)/$@ $$src && \
+ cd - >/dev/null 2>&1;
+
+# used by rgmanager/src/daemons
+%-noccs.o: $(S)/%.c
+ cd $(S) > /dev/null 2>&1 && \
+ src=$(shell basename $<) && \
+ $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(NOCCS_CFLAGS) -c -o $(O)/$@ $$src && \
+ cd - >/dev/null 2>&1;
+
+else
%.o: $(S)/%.c
- $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(REENT_CFLAGS) -c -o $@ $<
+ src=$(shell basename $<) && \
+ $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(REENT_CFLAGS) -c -o $@ $$src
# used by dlm/libdlm
%_lt.o: $(S)/%.c
- $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
+ src=$(shell basename $<) && \
+ $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $$src
# used by rgmanager/src/daemons
%-noccs.o: $(S)/%.c
- $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(NOCCS_CFLAGS) -c -o $@ $<
+ src=$(shell basename $<) && \
+ $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(NOCCS_CFLAGS) -c -o $@ $$src
+
+endif
diff --git a/make/defines.mk.input b/make/defines.mk.input
index ee5f852..919697f 100644
--- a/make/defines.mk.input
+++ b/make/defines.mk.input
@@ -70,6 +70,9 @@ without_bindings ?= @DISABLE_BINDINGS@
THISDIR = $(shell echo $(CURDIR) | sed -e 's|$(OBJDIR)/||g')
S=$(SRCDIR)/$(THISDIR)
+O=$(OBJDIR)/$(THISDIR)
+
+outoftreebuild ?= @OUTOFTREEBUILD@
CONFDIR=@CONFDIR@
CONFFILE=@CONFFILE@
10 years, 7 months
gfs2-utils: RHEL7 - fsck.gfs2: Check and repair per_node contents such as quota_changeX
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=e6c114ba...
Commit: e6c114baac5102d0ac8cc542565d56657593e3c5
Parent: f485b63bc2c0daa6b84d0c376fecb74c2d3784bd
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Tue Sep 3 11:21:00 2013 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Fri Sep 6 14:34:49 2013 -0500
fsck.gfs2: Check and repair per_node contents such as quota_changeX
This patch gives fsck.gfs2 the ability to check the system files that
are in the per_node directory: All the inum_rangeX, statfs_changeX
and quota_changeX files. If they're found to be corrupt, they are
deleted and rebuilt.
rhbz#1003059
---
gfs2/fsck/pass2.c | 131 ++++++++++++++++++++++++++++++++++++++++++++-
gfs2/libgfs2/libgfs2.h | 4 ++
gfs2/libgfs2/structures.c | 6 +-
gfs2/libgfs2/super.c | 1 +
4 files changed, 138 insertions(+), 4 deletions(-)
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index 727cc18..26f7d48 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -1595,6 +1595,116 @@ struct metawalk_fxns pass2_fxns = {
.repair_leaf = pass2_repair_leaf,
};
+static int check_metalist_qc(struct gfs2_inode *ip, uint64_t block,
+ struct gfs2_buffer_head **bh, int h,
+ int *is_valid, int *was_duplicate, void *private)
+{
+ *was_duplicate = 0;
+ *is_valid = 1;
+ *bh = bread(ip->i_sbd, block);
+ return meta_is_good;
+}
+
+static int check_data_qc(struct gfs2_inode *ip, uint64_t metablock,
+ uint64_t block, void *private)
+{
+ struct gfs2_buffer_head *bh;
+
+ /* At this point, basic data block checks have already been done,
+ so we only need to make sure they're QC blocks. */
+ if (!valid_block(ip->i_sbd, block))
+ return -1;
+
+ bh = bread(ip->i_sbd, block);
+ if (gfs2_check_meta(bh, GFS2_METATYPE_QC) != 0) {
+ log_crit(_("Error: quota_change block at %lld (0x%llx) is "
+ "the wrong metadata type.\n"),
+ (unsigned long long)block, (unsigned long long)block);
+ brelse(bh);
+ return -1;
+ }
+ brelse(bh);
+ return 0;
+}
+
+struct metawalk_fxns quota_change_fxns = {
+ .check_metalist = check_metalist_qc,
+ .check_data = check_data_qc,
+};
+
+/* check_pernode_for - verify a file within the system per_node directory
+ * @x - index number X
+ * @per_node - pointer to the per_node inode
+ * @fn - system file name
+ * @filelen - the file length the system file needs to be
+ * @multiple - the file length must be a multiple (versus the exact value)
+ * @pass - a metawalk function for checking the data blocks (if any)
+ * @builder - a rebuild function for the file
+ *
+ * Returns: 0 if all went well, else error. */
+static int check_pernode_for(int x, struct gfs2_inode *pernode, const char *fn,
+ unsigned long long filelen, int multiple,
+ struct metawalk_fxns *pass,
+ int builder(struct gfs2_inode *per_node,
+ unsigned int j))
+{
+ struct gfs2_inode *ip;
+ int error, valid_size = 1;
+
+ log_debug(_("Checking system file %s\n"), fn);
+ error = gfs2_lookupi(pernode, fn, strlen(fn), &ip);
+ if (error) {
+ log_err(_("System file %s is missing.\n"), fn);
+ if (!query( _("Rebuild the system file? (y/n) ")))
+ return 0;
+ goto build_it;
+ }
+ if (!ip->i_di.di_size)
+ valid_size = 0;
+ else if (!multiple && ip->i_di.di_size != filelen)
+ valid_size = 0;
+ else if (multiple && (ip->i_di.di_size % filelen))
+ valid_size = 0;
+ if (!valid_size) {
+ log_err(_("System file %s has an invalid size. Is %llu, "
+ "should be %llu.\n"), fn, ip->i_di.di_size, filelen);
+ if (!query( _("Rebuild the system file? (y/n) ")))
+ goto out_good;
+ fsck_inode_put(&ip);
+ goto build_it;
+ }
+ if (pass) {
+ error = check_metatree(ip, pass);
+ if (!error)
+ goto out_good;
+ log_err(_("System file %s has bad contents.\n"), fn);
+ if (!query( _("Delete and rebuild the system file? (y/n) ")))
+ goto out_good;
+ check_metatree(ip, &pass2_fxns_delete);
+ fsck_inode_put(&ip);
+ gfs2_dirent_del(pernode, fn, strlen(fn));
+ goto build_it;
+ }
+out_good:
+ fsck_inode_put(&ip);
+ return 0;
+
+build_it:
+ if (builder(pernode, x)) {
+ log_err(_("Error building %s\n"), fn);
+ return -1;
+ }
+ error = gfs2_lookupi(pernode, fn, strlen(fn), &ip);
+ if (error) {
+ log_err(_("Error rebuilding %s.\n"), fn);
+ return -1;
+ }
+ fsck_blockmap_set(ip, ip->i_di.di_num.no_addr, fn, gfs2_inode_file);
+ reprocess_inode(ip, fn);
+ log_err(_("System file %s rebuilt.\n"), fn);
+ goto out_good;
+}
+
/* Check system directory inode */
/* Should work for all system directories: root, master, jindex, per_node */
static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
@@ -1707,7 +1817,26 @@ static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
sysinode->i_di.di_num.no_addr);
}
}
- return 0;
+ error = 0;
+ if (sysinode == sysinode->i_sbd->md.pinode) {
+ int j;
+ char fn[64];
+
+ /* Make sure all the per_node files are there, and valid */
+ for (j = 0; j < sysinode->i_sbd->md.journals; j++) {
+ sprintf(fn, "inum_range%d", j);
+ error += check_pernode_for(j, sysinode, fn, 16, 0,
+ NULL, build_inum_range);
+ sprintf(fn, "statfs_change%d", j);
+ error += check_pernode_for(j, sysinode, fn, 24, 0,
+ NULL, build_statfs_change);
+ sprintf(fn, "quota_change%d", j);
+ error += check_pernode_for(j, sysinode, fn, 1048576, 1,
+ "a_change_fxns,
+ build_quota_change);
+ }
+ }
+ return error;
}
/**
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 1548cf3..f864a08 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -770,6 +770,10 @@ extern int do_init_statfs(struct gfs2_sbd *sdp);
extern int gfs2_check_meta(struct gfs2_buffer_head *bh, int type);
extern unsigned lgfs2_bm_scan(struct rgrp_tree *rgd, unsigned idx,
uint64_t *buf, uint8_t state);
+extern int build_inum_range(struct gfs2_inode *per_node, unsigned int j);
+extern int build_statfs_change(struct gfs2_inode *per_node, unsigned int j);
+extern int build_quota_change(struct gfs2_inode *per_node, unsigned int j);
+
/* super.c */
extern int check_sb(struct gfs2_sb *sb);
extern int read_sb(struct gfs2_sbd *sdp);
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index 2a8c6f7..e888f1e 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -180,7 +180,7 @@ int build_jindex(struct gfs2_sbd *sdp)
return 0;
}
-static int build_inum_range(struct gfs2_inode *per_node, unsigned int j)
+int build_inum_range(struct gfs2_inode *per_node, unsigned int j)
{
struct gfs2_sbd *sdp = per_node->i_sbd;
char name[256];
@@ -204,7 +204,7 @@ static int build_inum_range(struct gfs2_inode *per_node, unsigned int j)
return 0;
}
-static int build_statfs_change(struct gfs2_inode *per_node, unsigned int j)
+int build_statfs_change(struct gfs2_inode *per_node, unsigned int j)
{
struct gfs2_sbd *sdp = per_node->i_sbd;
char name[256];
@@ -228,7 +228,7 @@ static int build_statfs_change(struct gfs2_inode *per_node, unsigned int j)
return 0;
}
-static int build_quota_change(struct gfs2_inode *per_node, unsigned int j)
+int build_quota_change(struct gfs2_inode *per_node, unsigned int j)
{
struct gfs2_sbd *sdp = per_node->i_sbd;
struct gfs2_meta_header mh;
diff --git a/gfs2/libgfs2/super.c b/gfs2/libgfs2/super.c
index eb97c40..f87734a 100644
--- a/gfs2/libgfs2/super.c
+++ b/gfs2/libgfs2/super.c
@@ -119,6 +119,7 @@ int read_sb(struct gfs2_sbd *sdp)
sdp->sb_addr = GFS2_SB_ADDR * GFS2_BASIC_BLOCK / sdp->bsize;
sdp->sd_blocks_per_bitmap = (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header))
* GFS2_NBBY;
+ sdp->qcsize = GFS2_DEFAULT_QCSIZE;
return 0;
}
10 years, 7 months
gfs2-utils: master - fsck.gfs2: Check and repair per_node contents such as quota_changeX
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=fa32906a...
Commit: fa32906a9869d3a78a450a724376e919bbc29dd5
Parent: 97fbdb22e1ddfc313bf3266eb4a02769e2eb2190
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Tue Sep 3 11:21:00 2013 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Thu Sep 5 10:18:12 2013 -0500
fsck.gfs2: Check and repair per_node contents such as quota_changeX
This patch gives fsck.gfs2 the ability to check the system files that
are in the per_node directory: All the inum_rangeX, statfs_changeX
and quota_changeX files. If they're found to be corrupt, they are
deleted and rebuilt.
---
gfs2/fsck/pass2.c | 131 ++++++++++++++++++++++++++++++++++++++++++++-
gfs2/libgfs2/libgfs2.h | 4 ++
gfs2/libgfs2/structures.c | 6 +-
gfs2/libgfs2/super.c | 1 +
4 files changed, 138 insertions(+), 4 deletions(-)
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index 727cc18..26f7d48 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -1595,6 +1595,116 @@ struct metawalk_fxns pass2_fxns = {
.repair_leaf = pass2_repair_leaf,
};
+static int check_metalist_qc(struct gfs2_inode *ip, uint64_t block,
+ struct gfs2_buffer_head **bh, int h,
+ int *is_valid, int *was_duplicate, void *private)
+{
+ *was_duplicate = 0;
+ *is_valid = 1;
+ *bh = bread(ip->i_sbd, block);
+ return meta_is_good;
+}
+
+static int check_data_qc(struct gfs2_inode *ip, uint64_t metablock,
+ uint64_t block, void *private)
+{
+ struct gfs2_buffer_head *bh;
+
+ /* At this point, basic data block checks have already been done,
+ so we only need to make sure they're QC blocks. */
+ if (!valid_block(ip->i_sbd, block))
+ return -1;
+
+ bh = bread(ip->i_sbd, block);
+ if (gfs2_check_meta(bh, GFS2_METATYPE_QC) != 0) {
+ log_crit(_("Error: quota_change block at %lld (0x%llx) is "
+ "the wrong metadata type.\n"),
+ (unsigned long long)block, (unsigned long long)block);
+ brelse(bh);
+ return -1;
+ }
+ brelse(bh);
+ return 0;
+}
+
+struct metawalk_fxns quota_change_fxns = {
+ .check_metalist = check_metalist_qc,
+ .check_data = check_data_qc,
+};
+
+/* check_pernode_for - verify a file within the system per_node directory
+ * @x - index number X
+ * @per_node - pointer to the per_node inode
+ * @fn - system file name
+ * @filelen - the file length the system file needs to be
+ * @multiple - the file length must be a multiple (versus the exact value)
+ * @pass - a metawalk function for checking the data blocks (if any)
+ * @builder - a rebuild function for the file
+ *
+ * Returns: 0 if all went well, else error. */
+static int check_pernode_for(int x, struct gfs2_inode *pernode, const char *fn,
+ unsigned long long filelen, int multiple,
+ struct metawalk_fxns *pass,
+ int builder(struct gfs2_inode *per_node,
+ unsigned int j))
+{
+ struct gfs2_inode *ip;
+ int error, valid_size = 1;
+
+ log_debug(_("Checking system file %s\n"), fn);
+ error = gfs2_lookupi(pernode, fn, strlen(fn), &ip);
+ if (error) {
+ log_err(_("System file %s is missing.\n"), fn);
+ if (!query( _("Rebuild the system file? (y/n) ")))
+ return 0;
+ goto build_it;
+ }
+ if (!ip->i_di.di_size)
+ valid_size = 0;
+ else if (!multiple && ip->i_di.di_size != filelen)
+ valid_size = 0;
+ else if (multiple && (ip->i_di.di_size % filelen))
+ valid_size = 0;
+ if (!valid_size) {
+ log_err(_("System file %s has an invalid size. Is %llu, "
+ "should be %llu.\n"), fn, ip->i_di.di_size, filelen);
+ if (!query( _("Rebuild the system file? (y/n) ")))
+ goto out_good;
+ fsck_inode_put(&ip);
+ goto build_it;
+ }
+ if (pass) {
+ error = check_metatree(ip, pass);
+ if (!error)
+ goto out_good;
+ log_err(_("System file %s has bad contents.\n"), fn);
+ if (!query( _("Delete and rebuild the system file? (y/n) ")))
+ goto out_good;
+ check_metatree(ip, &pass2_fxns_delete);
+ fsck_inode_put(&ip);
+ gfs2_dirent_del(pernode, fn, strlen(fn));
+ goto build_it;
+ }
+out_good:
+ fsck_inode_put(&ip);
+ return 0;
+
+build_it:
+ if (builder(pernode, x)) {
+ log_err(_("Error building %s\n"), fn);
+ return -1;
+ }
+ error = gfs2_lookupi(pernode, fn, strlen(fn), &ip);
+ if (error) {
+ log_err(_("Error rebuilding %s.\n"), fn);
+ return -1;
+ }
+ fsck_blockmap_set(ip, ip->i_di.di_num.no_addr, fn, gfs2_inode_file);
+ reprocess_inode(ip, fn);
+ log_err(_("System file %s rebuilt.\n"), fn);
+ goto out_good;
+}
+
/* Check system directory inode */
/* Should work for all system directories: root, master, jindex, per_node */
static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
@@ -1707,7 +1817,26 @@ static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
sysinode->i_di.di_num.no_addr);
}
}
- return 0;
+ error = 0;
+ if (sysinode == sysinode->i_sbd->md.pinode) {
+ int j;
+ char fn[64];
+
+ /* Make sure all the per_node files are there, and valid */
+ for (j = 0; j < sysinode->i_sbd->md.journals; j++) {
+ sprintf(fn, "inum_range%d", j);
+ error += check_pernode_for(j, sysinode, fn, 16, 0,
+ NULL, build_inum_range);
+ sprintf(fn, "statfs_change%d", j);
+ error += check_pernode_for(j, sysinode, fn, 24, 0,
+ NULL, build_statfs_change);
+ sprintf(fn, "quota_change%d", j);
+ error += check_pernode_for(j, sysinode, fn, 1048576, 1,
+ "a_change_fxns,
+ build_quota_change);
+ }
+ }
+ return error;
}
/**
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 1548cf3..f864a08 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -770,6 +770,10 @@ extern int do_init_statfs(struct gfs2_sbd *sdp);
extern int gfs2_check_meta(struct gfs2_buffer_head *bh, int type);
extern unsigned lgfs2_bm_scan(struct rgrp_tree *rgd, unsigned idx,
uint64_t *buf, uint8_t state);
+extern int build_inum_range(struct gfs2_inode *per_node, unsigned int j);
+extern int build_statfs_change(struct gfs2_inode *per_node, unsigned int j);
+extern int build_quota_change(struct gfs2_inode *per_node, unsigned int j);
+
/* super.c */
extern int check_sb(struct gfs2_sb *sb);
extern int read_sb(struct gfs2_sbd *sdp);
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index 2a8c6f7..e888f1e 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -180,7 +180,7 @@ int build_jindex(struct gfs2_sbd *sdp)
return 0;
}
-static int build_inum_range(struct gfs2_inode *per_node, unsigned int j)
+int build_inum_range(struct gfs2_inode *per_node, unsigned int j)
{
struct gfs2_sbd *sdp = per_node->i_sbd;
char name[256];
@@ -204,7 +204,7 @@ static int build_inum_range(struct gfs2_inode *per_node, unsigned int j)
return 0;
}
-static int build_statfs_change(struct gfs2_inode *per_node, unsigned int j)
+int build_statfs_change(struct gfs2_inode *per_node, unsigned int j)
{
struct gfs2_sbd *sdp = per_node->i_sbd;
char name[256];
@@ -228,7 +228,7 @@ static int build_statfs_change(struct gfs2_inode *per_node, unsigned int j)
return 0;
}
-static int build_quota_change(struct gfs2_inode *per_node, unsigned int j)
+int build_quota_change(struct gfs2_inode *per_node, unsigned int j)
{
struct gfs2_sbd *sdp = per_node->i_sbd;
struct gfs2_meta_header mh;
diff --git a/gfs2/libgfs2/super.c b/gfs2/libgfs2/super.c
index eb97c40..f87734a 100644
--- a/gfs2/libgfs2/super.c
+++ b/gfs2/libgfs2/super.c
@@ -119,6 +119,7 @@ int read_sb(struct gfs2_sbd *sdp)
sdp->sb_addr = GFS2_SB_ADDR * GFS2_BASIC_BLOCK / sdp->bsize;
sdp->sd_blocks_per_bitmap = (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header))
* GFS2_NBBY;
+ sdp->qcsize = GFS2_DEFAULT_QCSIZE;
return 0;
}
10 years, 7 months