cluster: RHEL510 - fsck.gfs2: Log to syslog on start and exit
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=0654d2fe9d7...
Commit: 0654d2fe9d7d23c716c2ef5b272659aa646af1aa
Parent: 2626fb3ca90e285ab703f0da96955e3d0f5190c7
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Tue May 6 15:59:39 2014 +0100
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Tue May 20 18:40:32 2014 +0100
fsck.gfs2: Log to syslog on start and exit
In order to piece together the order in which fsck.gfs2 runs and
gfs2_edit savemeta were done it's useful to keep a log of the command
line options used and the fsck.gfs2 start and end times and exit status.
Log these to syslog.
Resolves: rhbz#1099592
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/main.c | 35 +++++++++++++++++++++++++++++++++++
gfs2/man/fsck.gfs2.8 | 2 ++
2 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
index 40aaaab..055ed96 100644
--- a/gfs2/fsck/main.c
+++ b/gfs2/fsck/main.c
@@ -22,6 +22,7 @@
#include <libintl.h>
#include <locale.h>
#define _(String) gettext(String)
+#include <syslog.h>
#include "copyright.cf"
#include "libgfs2.h"
@@ -227,6 +228,36 @@ static void check_statfs(struct gfs2_sbd *sdp)
errors_corrected++;
}
+static void exitlog(int status, void *unused)
+{
+ syslog(LOG_INFO, "exit: %d", status);
+}
+
+static void startlog(int argc, char **argv)
+{
+ int i;
+ char *cmd, *p;
+ size_t len;
+
+ for (len = i = 0; i < argc; i++)
+ len += strlen(argv[i]);
+ len += argc; /* Add spaces and '\0' */
+
+ cmd = malloc(len);
+ if (cmd == NULL) {
+ perror(argv[0]);
+ exit(FSCK_ERROR);
+ }
+ p = cmd;
+ for (i = 0; i < argc; i++, p++) {
+ p = stpcpy(p, argv[i]);
+ *p = ' ';
+ }
+ *(--p) = '\0';
+ syslog(LOG_INFO, "started: %s", cmd);
+ free(cmd);
+}
+
int main(int argc, char **argv)
{
struct gfs2_sbd sb;
@@ -238,6 +269,10 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
textdomain("gfs2-utils");
+ openlog("fsck.gfs2", LOG_CONS|LOG_PID, LOG_USER);
+ startlog(argc - 1, &argv[1]);
+ on_exit(exitlog, NULL);
+
memset(sdp, 0, sizeof(*sdp));
if ((error = read_cmdline(argc, argv, &opts)))
diff --git a/gfs2/man/fsck.gfs2.8 b/gfs2/man/fsck.gfs2.8
index 6910760..580cb4d 100644
--- a/gfs2/man/fsck.gfs2.8
+++ b/gfs2/man/fsck.gfs2.8
@@ -37,6 +37,8 @@ computer. Therefore, fsck.gfs2 will always check the file system unless
the -p (preen) option is used, in which case it follows special rules
(see below).
+fsck.gfs2 will log to the system log on start and exit to aid debugging and
+administration.
.SH OPTIONS
.TP
\fB-a\fP
9 years, 11 months
cluster: RHEL511 - fsck.gfs2: Log to syslog on start and exit
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=a5e527aff7b...
Commit: a5e527aff7b29382a546137f5eb8b48bf68b7355
Parent: a70d8ebc0abfd2110214a93e29bc5d4bf5eb9c38
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Tue May 6 15:59:39 2014 +0100
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Tue May 20 16:52:16 2014 +0100
fsck.gfs2: Log to syslog on start and exit
In order to piece together the order in which fsck.gfs2 runs and
gfs2_edit savemeta were done it's useful to keep a log of the command
line options used and the fsck.gfs2 start and end times and exit status.
Log these to syslog.
Resolves: rhbz#1097348
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/main.c | 35 +++++++++++++++++++++++++++++++++++
gfs2/man/fsck.gfs2.8 | 2 ++
2 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
index 3d9f79c..bd8c30f 100644
--- a/gfs2/fsck/main.c
+++ b/gfs2/fsck/main.c
@@ -10,6 +10,7 @@
#include <libintl.h>
#include <locale.h>
#define _(String) gettext(String)
+#include <syslog.h>
#include "copyright.cf"
#include "libgfs2.h"
@@ -223,6 +224,36 @@ static void check_statfs(struct gfs2_sbd *sdp)
errors_corrected++;
}
+static void exitlog(int status, void *unused)
+{
+ syslog(LOG_INFO, "exit: %d", status);
+}
+
+static void startlog(int argc, char **argv)
+{
+ int i;
+ char *cmd, *p;
+ size_t len;
+
+ for (len = i = 0; i < argc; i++)
+ len += strlen(argv[i]);
+ len += argc; /* Add spaces and '\0' */
+
+ cmd = malloc(len);
+ if (cmd == NULL) {
+ perror(argv[0]);
+ exit(FSCK_ERROR);
+ }
+ p = cmd;
+ for (i = 0; i < argc; i++, p++) {
+ p = stpcpy(p, argv[i]);
+ *p = ' ';
+ }
+ *(--p) = '\0';
+ syslog(LOG_INFO, "started: %s", cmd);
+ free(cmd);
+}
+
int main(int argc, char **argv)
{
struct gfs2_sbd sb;
@@ -234,6 +265,10 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
textdomain("gfs2-utils");
+ openlog("fsck.gfs2", LOG_CONS|LOG_PID, LOG_USER);
+ startlog(argc - 1, &argv[1]);
+ on_exit(exitlog, NULL);
+
memset(sdp, 0, sizeof(*sdp));
/* brdfp = fopen("brd-log.txt", "w"); */
diff --git a/gfs2/man/fsck.gfs2.8 b/gfs2/man/fsck.gfs2.8
index 6910760..580cb4d 100644
--- a/gfs2/man/fsck.gfs2.8
+++ b/gfs2/man/fsck.gfs2.8
@@ -37,6 +37,8 @@ computer. Therefore, fsck.gfs2 will always check the file system unless
the -p (preen) option is used, in which case it follows special rules
(see below).
+fsck.gfs2 will log to the system log on start and exit to aid debugging and
+administration.
.SH OPTIONS
.TP
\fB-a\fP
9 years, 11 months
fence-agents: master - fence_zvm: Add a zvmsys option to fence_zvm to support distributed z/VM systems
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=09ced9...
Commit: 09ced953ea11599d3b59ebf0c038c04f82a14d18
Parent: 7b31dcce8c124f1ae396b5d63fa0e31af31b7ffa
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed May 14 17:03:24 2014 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed May 14 17:03:24 2014 +0200
fence_zvm: Add a zvmsys option to fence_zvm to support distributed z/VM systems
Also emove spurious crlf in CRLF
Author: Neale Ferguson
---
fence/agents/zvm/fence_zvm.8 | 3 +++
fence/agents/zvm/fence_zvm.c | 26 +++++++++++++++++++++++---
fence/agents/zvm/fence_zvm.h | 1 +
fence/agents/zvm/fence_zvmip.c | 4 ++--
4 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/fence/agents/zvm/fence_zvm.8 b/fence/agents/zvm/fence_zvm.8
index 46bfe3f..2c54e75 100644
--- a/fence/agents/zvm/fence_zvm.8
+++ b/fence/agents/zvm/fence_zvm.8
@@ -33,6 +33,9 @@ Print out a help message describing available options, then exit.
\fB-a --ip\fP \fIsmapi Server\fP
\fBName\fP of SMAPI server virtual machine. To be consistent with other fence agents thisname is a little misleading: it is the name of the virtual machine not its IP address or hostname.
.TP
+\fB--zvmsys\fP \fIz/VM System\fP
+\fBName\fP of z/VM on which the SMAPI server virtual machine resides. Optional - defaults to system on which the node is running.
+.TP
\fB-h --help\fP
Display usage information
.TP
diff --git a/fence/agents/zvm/fence_zvm.c b/fence/agents/zvm/fence_zvm.c
index e553b85..6fbbb12 100644
--- a/fence/agents/zvm/fence_zvm.c
+++ b/fence/agents/zvm/fence_zvm.c
@@ -58,6 +58,7 @@ static struct option longopts[] = {
{"ip", required_argument, NULL, 'a'},
{"plug", required_argument, NULL, 'n'},
{"timeout", required_argument, NULL, 'T'},
+ {"zvmsys", required_argument, NULL, 'z'},
{NULL, 0, NULL, 0}
};
@@ -93,6 +94,7 @@ zvm_smapi_open(zvm_driver_t *zvm)
if ((rc = bind(zvm->sd,siucv_ptr,sockaddrlen)) != -1) {
memcpy(&siucv_addr.siucv_user_id,zvm->smapiSrv,strlen(zvm->smapiSrv));
memcpy(&siucv_addr.siucv_name,&iucvprog,8);
+ memcpy(&siucv_addr.siucv_nodeid,zvm->node,strlen(zvm->node));
rc = connect(zvm->sd,(__CONST_SOCKADDR_ARG)siucv_ptr,sockaddrlen);
}
if (rc == -1) {
@@ -372,6 +374,13 @@ zvm_metadata()
"Name of the SMAPI IUCV Server Virtual Machine");
fprintf (stdout, "\t</parameter>\n");
+ fprintf (stdout, "\t<parameter name=\"zvmsys\" unique=\"1\" required=\"0\">\n");
+ fprintf (stdout, "\t\t<getopt mixed=\"--zvmsys\" />\n");
+ fprintf (stdout, "\t\t<content type=\"string\" />\n");
+ fprintf (stdout, "\t\t<shortdesc lang=\"en\">%s</shortdesc>\n",
+ "Node of the SMAPI IUCV Server Virtual Machine");
+ fprintf (stdout, "\t</parameter>\n");
+
fprintf (stdout, "\t<parameter name=\"action\" unique=\"1\" required=\"0\">\n");
fprintf (stdout, "\t\t<getopt mixed=\"-o, --action\" />\n");
fprintf (stdout, "\t\t<content type=\"string\" default=\"off\" />\n");
@@ -412,6 +421,7 @@ get_options_stdin (zvm_driver_t *zvm)
*opt,
*arg;
int32_t lSrvName,
+ lSrvNode,
lTarget;
int fence = 0;
@@ -459,6 +469,10 @@ get_options_stdin (zvm_driver_t *zvm)
arg, DEFAULT_TIMEOUT);
zvm->timeOut = DEFAULT_TIMEOUT;
}
+ } else if (!strcasecmp (opt, "zvmsys")) {
+ lSrvNode = MIN(strlen(arg), sizeof(zvm->node));
+ memcpy(zvm->node, arg, lSrvNode);
+ continue;
} else if (!strcasecmp (opt, "help")) {
fence = 2;
}
@@ -479,6 +493,7 @@ get_options(int argc, char **argv, zvm_driver_t *zvm)
int c,
fence = 0;
int32_t lSrvName,
+ lSrvNode,
lTarget;
char *endPtr;
@@ -497,11 +512,11 @@ get_options(int argc, char **argv, zvm_driver_t *zvm)
fence = 2;
}
break;
- case 's' :
+ case 'a' :
lSrvName = MIN(strlen(optarg), sizeof(zvm->smapiSrv));
memcpy(zvm->smapiSrv, optarg, lSrvName);
break;
- case 't' :
+ case 'T' :
zvm->timeOut = strtoul(optarg, &endPtr, 10);
if (*endPtr != 0) {
syslog(LOG_WARNING, "Invalid timeout value specified: %s - "
@@ -510,6 +525,10 @@ get_options(int argc, char **argv, zvm_driver_t *zvm)
zvm->timeOut = DEFAULT_TIMEOUT;
}
break;
+ case 'z' :
+ lSrvNode = MIN(strlen(optarg), sizeof(zvm->node));
+ memcpy(zvm->node, optarg, lSrvNode);
+ break;
default :
fence = 2;
}
@@ -528,8 +547,9 @@ usage()
"\tWhere [options] =\n"
"\t-o --action [action] - \"off\", \"metadata\"\n"
"\t-n --plug [target] - Name of virtual machine to fence\n"
- "\t-s --server [server] - Name of SMAPI IUCV Request server\n"
+ "\t-a --ip [server] - Name of SMAPI IUCV Request server\n"
"\t-T --timeout [secs] - Time to wait for fence in seconds - currently ignored\n"
+ "\t--zvmsys [node] - z/VM Node on which SMAPI server lives\n"
"\t-h --help - Display this usage information\n");
return(1);
}
diff --git a/fence/agents/zvm/fence_zvm.h b/fence/agents/zvm/fence_zvm.h
index 3c00c1c..0a86af3 100644
--- a/fence/agents/zvm/fence_zvm.h
+++ b/fence/agents/zvm/fence_zvm.h
@@ -565,6 +565,7 @@ typedef struct {
char target[9];
char authUser[9];
char authPass[9];
+ char node[9];
char smapiSrv[128];
} zvm_driver_t;
diff --git a/fence/agents/zvm/fence_zvmip.c b/fence/agents/zvm/fence_zvmip.c
index 1fa2119..28c9726 100644
--- a/fence/agents/zvm/fence_zvmip.c
+++ b/fence/agents/zvm/fence_zvmip.c
@@ -529,14 +529,14 @@ zvm_metadata()
fprintf (stdout, "\t\t<getopt mixed=\"-u, --username\" />\n");
fprintf (stdout, "\t\t<content type=\"string\" />\n");
fprintf (stdout, "\t\t<shortdesc lang=\"en\">%s</shortdesc>\n",
- "Name of authorized SMAPI user\n");
+ "Name of authorized SMAPI user");
fprintf (stdout, "\t</parameter>\n");
fprintf (stdout, "\t<parameter name=\"passwd\" unique=\"1\" required=\"1\">\n");
fprintf (stdout, "\t\t<getopt mixed=\"-p, --password\" />\n");
fprintf (stdout, "\t\t<content type=\"string\" />\n");
fprintf (stdout, "\t\t<shortdesc lang=\"en\">%s</shortdesc>\n",
- "Password of authorized SMAPI user\n");
+ "Password of authorized SMAPI user");
fprintf (stdout, "\t</parameter>\n");
fprintf (stdout, "\t<parameter name=\"action\" unique=\"1\" required=\"0\">\n");
9 years, 11 months
fence-agents: master - fence_scsi: --delay should be applied before attempt to test available devices
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=7b31dc...
Commit: 7b31dcce8c124f1ae396b5d63fa0e31af31b7ffa
Parent: 01efc45eec1a8142f5809984a94c175702685514
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed May 14 17:00:38 2014 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed May 14 17:00:38 2014 +0200
fence_scsi: --delay should be applied before attempt to test available devices
---
fence/agents/scsi/Makefile.am | 2 ++
fence/agents/scsi/fence_scsi.py | 7 +++----
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/fence/agents/scsi/Makefile.am b/fence/agents/scsi/Makefile.am
index 89e3581..5722e18 100644
--- a/fence/agents/scsi/Makefile.am
+++ b/fence/agents/scsi/Makefile.am
@@ -10,6 +10,8 @@ sbin_SCRIPTS = $(TARGET) fence_scsi_check
man_MANS = $(TARGET).8
+FENCE_TEST_ARGS = -k 1
+
fence_scsi_check: $(TARGET)
cp -s $^ $@
diff --git a/fence/agents/scsi/fence_scsi.py b/fence/agents/scsi/fence_scsi.py
index f837faa..d22bb86 100644
--- a/fence/agents/scsi/fence_scsi.py
+++ b/fence/agents/scsi/fence_scsi.py
@@ -10,6 +10,7 @@ import atexit
import hashlib
sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import fail_usage, run_command, atexit_handler, check_input, process_input, show_docs, fence_action, all_opt
+from fencing import run_delay
#BEGIN_VERSION_GENERATION
RELEASE_VERSION=""
@@ -407,6 +408,8 @@ longer be able to write to the device(s). A manual reboot is required."
docs["vendorurl"] = ""
show_docs(options, docs)
+ run_delay(options)
+
# backward compatibility layer BEGIN
if "--logfile" in options:
try:
@@ -441,10 +444,6 @@ longer be able to write to the device(s). A manual reboot is required."
fail_usage("Failed: No devices found")
# Input control END
- # backward compatibility layer
- if "--delay" in options and options["--delay"].isdigit():
- time.sleep(int(options["--delay"]))
-
result = fence_action(None, options, set_status, get_status)
sys.exit(result)
9 years, 11 months
fence-agents: master - fence_scsi: Do not use SYMTARGET for fence_scsi_check
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=01efc4...
Commit: 01efc45eec1a8142f5809984a94c175702685514
Parent: 531764486d0c149285962b90dd36b5c64b57276f
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed May 14 16:55:50 2014 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed May 14 16:55:50 2014 +0200
fence_scsi: Do not use SYMTARGET for fence_scsi_check
SYMTARGET in Makefile.am should not be used becasue fence_scsi_check is not a
fence agent and so the tests will fail.
---
fence/agents/scsi/Makefile.am | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/fence/agents/scsi/Makefile.am b/fence/agents/scsi/Makefile.am
index 896406a..89e3581 100644
--- a/fence/agents/scsi/Makefile.am
+++ b/fence/agents/scsi/Makefile.am
@@ -2,18 +2,16 @@ MAINTAINERCLEANFILES = Makefile.in
TARGET = fence_scsi
-SYMTARGET = fence_scsi_check
-
SRC = $(TARGET).py
EXTRA_DIST = $(SRC)
-sbin_SCRIPTS = $(TARGET) $(SYMTARGET)
+sbin_SCRIPTS = $(TARGET) fence_scsi_check
man_MANS = $(TARGET).8
-$(SYMTARGET): $(TARGET)
- ln -s $^ $@
+fence_scsi_check: $(TARGET)
+ cp -s $^ $@
include $(top_srcdir)/make/fencebuild.mk
include $(top_srcdir)/make/fenceman.mk
9 years, 11 months
fence-agents: master - fence_scsi: port to fencing library
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=531764...
Commit: 531764486d0c149285962b90dd36b5c64b57276f
Parent: 5551d8c2d6975927899c086985f19ebb29f5684e
Author: Ondrej Mular <omular(a)redhat.com>
AuthorDate: Mon May 12 09:29:50 2014 -0400
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed May 14 15:45:19 2014 +0200
fence_scsi: port to fencing library
---
configure.ac | 8 +
fence/agents/scsi/Makefile.am | 20 +-
fence/agents/scsi/fence_scsi.8 | 119 -----
fence/agents/scsi/fence_scsi.pl | 875 ---------------------------------
fence/agents/scsi/fence_scsi.py | 452 +++++++++++++++++
fence/agents/scsi/fence_scsi_check.pl | 170 -------
make/fencebuild.mk | 4 +
7 files changed, 475 insertions(+), 1173 deletions(-)
diff --git a/configure.ac b/configure.ac
index 5e37ee5..f208bef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -163,6 +163,10 @@ CLUSTERDATA=${datadir}/cluster
AC_PATH_PROG([IPMITOOL_PATH], [ipmitool], [/usr/bin/ipmitool])
AC_PATH_PROG([AMTTOOL_PATH], [amttool], [/usr/bin/amttool])
AC_PATH_PROG([GNUTLSCLI_PATH], [gnutlscli], [/usr/bin/gnutls-cli])
+AC_PATH_PROG([COROSYNC_CMAPCTL_PATH], [corosync-cmapctl], [/usr/sbin/corosync-cmapctl])
+AC_PATH_PROG([SG_PERSIST_PATH], [sg_persist], [/usr/bin/sg_persist])
+AC_PATH_PROG([SG_TURS_PATH], [sg_turs], [/usr/bin/sg_turs])
+AC_PATH_PROG([VGS_PATH], [vgs], [/usr/sbin/vgs])
## do subst
AC_SUBST([DEFAULT_CONFIG_DIR])
@@ -189,6 +193,10 @@ AM_CONDITIONAL(BUILD_XENAPILIB, test $XENAPILIB -eq 1)
AC_SUBST([IPMITOOL_PATH])
AC_SUBST([AMTTOOL_PATH])
+AC_SUBST([COROSYNC_CMAPCTL_PATH])
+AC_SUBST([SG_PERSIST_PATH])
+AC_SUBST([SG_TURS_PATH])
+AC_SUBST([VGS_PATH])
## *FLAGS handling
diff --git a/fence/agents/scsi/Makefile.am b/fence/agents/scsi/Makefile.am
index 5652bda..896406a 100644
--- a/fence/agents/scsi/Makefile.am
+++ b/fence/agents/scsi/Makefile.am
@@ -2,20 +2,22 @@ MAINTAINERCLEANFILES = Makefile.in
TARGET = fence_scsi
-SRC = $(TARGET).pl
+SYMTARGET = fence_scsi_check
-EXTRA_DIST = $(SRC) \
- $(TARGET)_check.pl
+SRC = $(TARGET).py
-scsidatadir = $(CLUSTERDATA)
+EXTRA_DIST = $(SRC)
-scsidata_SCRIPTS = $(TARGET)_check.pl
+sbin_SCRIPTS = $(TARGET) $(SYMTARGET)
-sbin_SCRIPTS = $(TARGET)
+man_MANS = $(TARGET).8
-dist_man_MANS = $(TARGET).8
+$(SYMTARGET): $(TARGET)
+ ln -s $^ $@
include $(top_srcdir)/make/fencebuild.mk
+include $(top_srcdir)/make/fenceman.mk
+include $(top_srcdir)/make/agentpycheck.mk
-clean-local:
- rm -f $(TARGET)
+clean-local: clean-man
+ rm -f $(TARGET) $(SYMTARGET)
diff --git a/fence/agents/scsi/fence_scsi.8 b/fence/agents/scsi/fence_scsi.8
deleted file mode 100644
index 180de4f..0000000
--- a/fence/agents/scsi/fence_scsi.8
+++ /dev/null
@@ -1,119 +0,0 @@
-.TH fence_scsi 8
-
-.SH NAME
-fence_scsi - I/O fencing agent for SCSI persistent reservations
-
-.SH SYNOPSIS
-.B
-fence_scsi
-[\fIOPTION\fR]...
-
-.SH DESCRIPTION
-fence_scsi is an I/O fencing agent that uses SCSI-3 persistent
-reservations to control access to shared storage devices. These
-devices must support SCSI-3 persistent reservations (SPC-3 or greater)
-as well as the "preempt-and-abort" subcommand.
-
-The fence_scsi agent works by having each node in the cluster register
-a unique key with the SCSI devive(s). Once registered, a single node
-will become the reservation holder by creating a "write exclusive,
-registrants only" reservation on the device(s). The result is that
-only registered nodes may write to the device(s). When a node failure
-occurs, the fence_scsi agent will remove the key belonging to the
-failed node from the device(s). The failed node will no longer be able
-to write to the device(s). A manual reboot is required. In the cluster
-environment unfence action should be configured also.
-
-Keys are either be specified manually (see -k option) or generated
-automatically (see -n option). Automatic key generation requires that
-cman be running. Keys will then be generated using the cluster ID and
-node ID such that each node has a unique key that can be determined by
-any other node in the cluster.
-
-Devices can either be specified manually (see -d option) or discovered
-automatically. Multiple devices can be specified manually by using a
-comma-separated list. If no devices are specified, the fence_scsi
-agent will attempt to discover devices by looking for cluster volumes
-and extracting the underlying devices. Devices may be device-mapper
-multipath devices or raw devices. If using a device-mapper multipath
-device, the fence_scsi agent will find the underlying devices (paths)
-and created registrations for each path.
-
-.SH OPTIONS
-.TP
-\fB-o\fP \fIaction\fR
-Fencing action. This value can be "on", "off", "status", or
-"metadata". The "on", "off", and "status" actions require either a key
-(see -k option) or node name (see -n option). For "on", the agent will
-attempt to register with the device(s) and create a reservation if
-none exists. The "off" action will attempt to remove a node's key from
-the device(s). The "status" action will report whether or not a node's
-key is currently register with one or more of the devices. The
-"metadata" action will display the XML metadata. The default action if
-"off".
-.TP
-\fB-d\fP \fIdevices\fR
-List of devices to use for current operation. Devices can be
-comma-separated list of raw device (eg. /dev/sdc) or device-mapper
-multipath devices (eg. /dev/dm-3). Each device must support SCSI-3
-persistent reservations.
-.TP
-\fB-f\fP \fIlogfile\fR
-Log output to file.
-.TP
-\fB-n\fP \fInodename\fR
-Name of the node to be fenced. The node name is used to generate the
-key value used for the current operation. This option will be ignored
-when used with the -k option.
-.TP
-\fB-k\fP \fIkey\fR
-Key to use for the current operation. This key should be unique to a
-node. For the "on" action, the key specifies the key use to register
-the local node. For the "off" action, this key specifies the key to be
-removed from the device(s).
-.TP
-\fB-H\fP \fIdelay\fR
-Wait X seconds before fencing is started (Default Value: 0)
-
-.TP
-\fB-a\fP
-Use the APTPL flag for registrations. This option is only used for the
-"on" action.
-.TP
-\fB-h\fP
-Print out a help message describing available options, then exit.
-.TP
-\fB-v\fP
-Verbose output.
-.TP
-\fB-V\fP
-Print out a version message, then exit.
-
-.SH STDIN PARAMETERS
-.TP
-\fIagent = "param"\fR
-This option is used by fence_node(8) and is ignored by fence_scsi.
-.TP
-\fInodename = "param"\fR
-Same as -n option.
-.TP
-\fIaction = "param" \fR
-Same as -o option.
-.TP
-\fIdevices = "param"\fR
-Same as -d option.
-.TP
-\fIlogfile = "param"\fR
-Same as -f option
-.TP
-\fIkey = "param"\fR
-Same as -k option.
-.TP
-\fIdelay = "param"\fR
-Same as -H option.
-.TP
-\fIaptpl = "1"
-Enable the APTPL flag. Default is 0 (disable).
-
-.SH SEE ALSO
-fence(8), fence_node(8), sg_persist(8), vgs(8), cman_tool(8), cman(5)
diff --git a/fence/agents/scsi/fence_scsi.pl b/fence/agents/scsi/fence_scsi.pl
deleted file mode 100644
index 6808ff5..0000000
--- a/fence/agents/scsi/fence_scsi.pl
+++ /dev/null
@@ -1,875 +0,0 @@
-#!/usr/bin/perl
-
-use Cwd 'realpath';
-use File::Basename;
-use File::Path;
-use Getopt::Std;
-use POSIX;
-use B;
-
-#BEGIN_VERSION_GENERATION
-$RELEASE_VERSION="";
-$REDHAT_COPYRIGHT="";
-$BUILD_DATE="";
-#END_VERSION_GENERATION
-
-my $ME = fileparse ($0, ".pl");
-
-################################################################################
-
-sub log_debug ($)
-{
- my $time = strftime "%b %e %T", localtime;
- my ($msg) = @_;
-
- print STDOUT "$time $ME: [debug] $msg\n" unless defined ($opt_q);
-
- return;
-}
-
-sub log_error ($)
-{
- my $time = strftime "%b %e %T", localtime;
- my ($msg) = @_;
-
- print STDERR "$time $ME: [error] $msg\n" unless defined ($opt_q);
-
- exit (1);
-}
-
-sub do_action_on ($@)
-{
- my $self = (caller(0))[3];
- my ($node_key, @devices) = @_;
-
- key_write ($node_key);
-
- foreach $dev (@devices) {
- log_error ("device $dev does not exist") if (! -e $dev);
- log_error ("device $dev is not a block device") if (! -b $dev);
-
- if (do_register_ignore ($node_key, $dev) != 0) {
- log_error ("failed to create registration (key=$node_key, device=$dev)");
- }
-
- if (!get_reservation_key ($dev)) {
- if (do_reserve ($node_key, $dev) != 0) {
- if (!get_reservation_key ($dev)) {
- log_error ("failed to create reservation (key=$node_key, device=$dev)");
- }
- }
- }
- }
-
- return;
-}
-
-sub do_action_off ($@)
-{
- my $self = (caller(0))[3];
- my ($node_key, @devices) = @_;
-
- my $host_key = key_read ();
-
- if ($host_key eq $node_key) {
- log_error ($self);
- }
-
- foreach $dev (@devices) {
- log_error ("device $dev does not exist") if (! -e $dev);
- log_error ("device $dev is not a block device") if (! -b $dev);
-
- my @keys = grep { /^$node_key$/i } get_registration_keys ($dev);
-
- if (scalar (@keys) != 0) {
- do_preempt_abort ($host_key, $node_key, $dev);
- }
- }
-
- return;
-}
-
-sub do_action_status ($@)
-{
- my $self = (caller(0))[3];
- my ($node_key, @devices) = @_;
-
- my $dev_count = 0;
- my $key_count = 0;
-
- foreach $dev (@devices) {
- log_error ("device $dev does not exist") if (! -e $dev);
- log_error ("device $dev is not a block device") if (! -b $dev);
-
- do_reset ($dev);
-
- my @keys = grep { /^$node_key$/i } get_registration_keys ($dev);
-
- if (scalar (@keys) != 0) {
- $dev_count++;
- }
- }
-
- if ($dev_count != 0) {
- exit (0);
- } else {
- exit (2);
- }
-}
-
-sub do_verify_on ($@)
-{
- my $self = (caller(0))[3];
- my ($node_key, @devices) = @_;
- my $count = 0;
-
- for $dev (@devices) {
- my @keys = grep { /^$node_key$/i } get_registration_keys ($dev);
-
- ## check that our key is registered
- if (scalar (@keys) == 0) {
- log_debug ("failed to register key $node_key on device $dev");
- $count++;
- next;
- }
-
- ## write dev to device file once registration is verified
- dev_write ($dev);
-
- ## check that a reservation exists
- if (!get_reservation_key ($dev)) {
- log_debug ("no reservation exists on device $dev");
- $count++;
- }
- }
-
- if ($count != 0) {
- log_error ("$self: failed to verify $count devices");
- }
-}
-
-sub do_verify_off ($@)
-{
- my $self = (caller(0))[3];
- my ($node_key, @devices) = @_;
- my $count = 0;
-
- for $dev (@devices) {
- my @keys = grep { /^$node_key$/i } get_registration_keys ($dev);
-
- ## check that our key is not registered
- if (scalar (@keys) != 0) {
- log_debug ("failed to remove key $node_key from device $dev");
- $count++;
- next;
- }
-
- ## check that a reservation exists
- if (!get_reservation_key ($dev)) {
- log_debug ("no reservation exists on device $dev");
- $count++;
- }
- }
-
- if ($count != 0) {
- log_error ("$self: failed to verify $count devices");
- }
-}
-
-sub do_register ($$$)
-{
- my $self = (caller(0))[3];
- my ($host_key, $node_key, $dev) = @_;
-
- $dev = realpath ($dev);
-
- if (substr ($dev, 5) =~ /^dm/) {
- my @slaves = get_mpath_slaves ($dev);
- foreach (@slaves) {
- do_register ($node_key, $_);
- }
- return;
- }
-
- log_debug ("$self (host_key=$host_key, node_key=$node_key, dev=$dev)");
-
- my $cmd;
- my $out;
- my $err;
-
- do_reset ($dev);
-
- $cmd = "sg_persist -n -o -G -K $host_key -S $node_key -d $dev";
- $cmd .= " -Z" if (defined $opt_a);
- $out = qx { $cmd 2> /dev/null };
- $err = ($?>>8);
-
- # if ($err != 0) {
- # log_error ("$self (err=$err)");
- # }
-
- log_debug ("$self (err=$err)");
-
- return ($err);
-}
-
-sub do_register_ignore ($$)
-{
- my $self = (caller(0))[3];
- my ($node_key, $dev) = @_;
-
- $dev = realpath ($dev);
-
- if (substr ($dev, 5) =~ /^dm/) {
- my @slaves = get_mpath_slaves ($dev);
- foreach (@slaves) {
- do_register_ignore ($node_key, $_);
- }
- return;
- }
-
- log_debug ("$self (node_key=$node_key, dev=$dev)");
-
- my $cmd;
- my $out;
- my $err;
-
- do_reset ($dev);
-
- $cmd = "sg_persist -n -o -I -S $node_key -d $dev";
- $cmd .= " -Z" if (defined $opt_a);
- $out = qx { $cmd 2> /dev/null };
- $err = ($?>>8);
-
- # if ($err != 0) {
- # log_error ("$self (err=$err)");
- # }
-
- log_debug ("$self (err=$err)");
-
- return ($err);
-}
-
-sub do_reserve ($$)
-{
- my $self = (caller(0))[3];
- my ($host_key, $dev) = @_;
-
- log_debug ("$self (host_key=$host_key, dev=$dev)");
-
- my $cmd = "sg_persist -n -o -R -T 5 -K $host_key -d $dev";
- my $out = qx { $cmd 2> /dev/null };
- my $err = ($?>>8);
-
- # if ($err != 0) {
- # log_error ("$self (err=$err)");
- # }
-
- log_debug ("$self (err=$err)");
-
- return ($err);
-}
-
-sub do_release ($$)
-{
- my $self = (caller(0))[3];
- my ($host_key, $dev) = @_;
-
- log_debug ("$self (host_key=$host_key, dev=$dev)");
-
- my $cmd = "sg_persist -n -o -L -T 5 -K $host_key -d $dev";
- my $out = qx { $cmd 2> /dev/null };
- my $err = ($?>>8);
-
- # if ($err != 0) {
- # log_error ("$self (err=$err)");
- # }
-
- log_debug ("$self (err=$err)");
-
- return ($err);
-}
-
-sub do_preempt ($$$)
-{
- my $self = (caller(0))[3];
- my ($host_key, $node_key, $dev) = @_;
-
- log_debug ("$self (host_key=$host_key, node_key=$node_key, dev=$dev)");
-
- my $cmd = "sg_persist -n -o -P -T 5 -K $host_key -S $node_key -d $dev";
- my $out = qx { $cmd 2> /dev/null };
- my $err = ($?>>8);
-
- # if ($err != 0) {
- # log_error ("$self (err=$err)");
- # }
-
- log_debug ("$self (err=$err)");
-
- return ($err);
-}
-
-sub do_preempt_abort ($$$)
-{
- my $self = (caller(0))[3];
- my ($host_key, $node_key, $dev) = @_;
-
- log_debug ("$self (host_key=$host_key, node_key=$node_key, dev=$dev)");
-
- my $cmd = "sg_persist -n -o -A -T 5 -K $host_key -S $node_key -d $dev";
- my $out = qx { $cmd 2> /dev/null };
- my $err = ($?>>8);
-
- # if ($err != 0) {
- # log_error ("$self (err=$err)");
- # }
-
- log_debug ("$self (err=$err)");
-
- return ($err);
-}
-
-sub do_reset (S)
-{
- my $self = (caller(0))[3];
- my ($dev) = @_;
-
- my $cmd = "sg_turs $dev";
- my @out = qx { $cmd 2> /dev/null };
- my $err = ($?>>8);
-
- ## note that it is not necessarily an error is $err is non-zero,
- ## so just log the device and status and continue.
-
- log_debug ("$self (dev=$dev, status=$err)");
-
- return ($err);
-}
-
-sub dev_unlink ()
-{
- my $self = (caller(0))[3];
- my $file = "/var/run/cluster/fence_scsi.dev";
-
- if (-e $file) {
- unlink ($file) or die "$!\n";
- }
-
- return;
-}
-
-sub dev_write ($)
-{
- my $self = (caller(0))[3];
- my $file = "/var/run/cluster/fence_scsi.dev";
- my $dev = shift;
-
- if (! -d "/var/run/cluster") {
- mkpath ("/var/run/cluster");
- }
-
- open (\*FILE, "+>>$file") or die "$!\n";
-
- ## since the file is opened for read, write and append,
- ## we need to seek to the beginning of the file before grep.
-
- seek (FILE, 0, 0);
-
- if (! grep { /^$dev$/ } <FILE>) {
- print FILE "$dev\n";
- }
-
- close (FILE);
-
- return;
-}
-
-sub key_read ()
-{
- my $self = (caller(0))[3];
- my $file = "/var/run/cluster/fence_scsi.key";
- my $key;
-
- open (\*FILE, "<$file") or die "$!\n";
- chomp ($key = <FILE>);
- close (FILE);
-
- return ($key);
-}
-
-sub key_write ($)
-{
- my $self = (caller(0))[3];
- my $file = "/var/run/cluster/fence_scsi.key";
- my $key = shift;
-
- if (! -d "/var/run/cluster") {
- mkpath ("/var/run/cluster");
- }
-
- open (\*FILE, ">$file") or die "$!\n";
- print FILE "$key\n";
- close (FILE);
-
- return;
-}
-
-sub get_key ($)
-{
- my $self = (caller(0))[3];
-
- my $key = sprintf ("%.4x%.4x", get_cluster_id (), get_node_id ($_[0]));
-
- return ($key);
-}
-
-sub get_node_id ($)
-{
- my $self = (caller(0))[3];
- my $node = $_[0];
-
- my $cmd = "/usr/sbin/corosync-cmapctl nodelist.";
- my @out = qx { $cmd 2> /dev/null };
- my $err = ($?>>8);
-
- if ($err != 0) {
- log_error ("$self (err=$err)");
- }
-
- # die "[error]: $self\n" if ($?>>8);
-
- foreach my $line (@out) {
- chomp($line);
- if ($line =~ /.(\d+?).ring._addr \(str\) = ${node}$/) {
- return $1;
- }
- }
-
- log_error("$self (unable to parse output of corosync-cmapctl or node does not exist)");
-}
-
-sub get_cluster_id ()
-{
- my $self = (caller(0))[3];
- my $cluster_id;
-
- my $cmd = "/usr/sbin/corosync-cmapctl totem.cluster_name";
- my $out = qx { $cmd 2> /dev/null };
- my $err = ($?>>8);
-
- if ($err != 0) {
- log_error ("$self (err=$err)");
- }
-
- # die "[error]: $self\n" if ($?>>8);
-
- chomp($out);
-
- if ($out =~ /=\s(.*?)$/) {
- my $cluster_name = $1;
- # tranform string to a number
- $cluster_id = (hex B::hash($cluster_name)) % 65536;
- } else {
- log_error("$self (unable to parse output of corosync-cmapctl)");
- }
-
- return ($cluster_id);
-}
-
-sub get_devices_clvm ()
-{
- my $self = (caller(0))[3];
- my @devices;
-
- my $cmd = "vgs --noheadings " .
- " --separator : " .
- " --sort pv_uuid " .
- " --options vg_attr,pv_name " .
- " --config 'global { locking_type = 0 } " .
- " devices { preferred_names = [ \"^/dev/dm\" ] }'";
-
- my @out = qx { $cmd 2> /dev/null };
- my $err = ($?>>8);
-
- if ($err != 0) {
- log_error ("$self (err=$err)");
- }
-
- # die "[error]: $self\n" if ($?>>8);
-
- foreach (@out) {
- chomp;
- my ($vg_attr, $pv_name) = split (/:/, $_);
- if ($vg_attr =~ /c$/) {
- push (@devices, $pv_name);
- }
- }
-
- return (@devices);
-}
-
-sub get_devices_scsi ()
-{
- my $self = (caller(0))[3];
- my @devices;
-
- opendir (\*DIR, "/sys/block/") or die "$!\n";
- @devices = grep { /^sd/ } readdir (DIR);
- closedir (DIR);
-
- return (@devices);
-}
-
-sub get_mpath_name ($)
-{
- my $self = (caller(0))[3];
- my ($dev) = @_;
- my $name;
-
- if ($dev =~ /^\/dev\//) {
- $dev = substr ($dev, 5);
- }
-
- open (\*FILE, "/sys/block/$dev/dm/name") or die "$!\n";
- chomp ($name = <FILE>);
- close (FILE);
-
- return ($name);
-}
-
-sub get_mpath_uuid ($)
-{
- my $self = (caller(0))[3];
- my ($dev) = @_;
- my $uuid;
-
- if ($dev =~ /^\/dev\//) {
- $dev = substr ($dev, 5);
- }
-
- open (\*FILE, "/sys/block/$dev/dm/uuid") or die "$!\n";
- chomp ($uuid = <FILE>);
- close (FILE);
-
- return ($name);
-}
-
-sub get_mpath_slaves ($)
-{
- my $self = (caller(0))[3];
- my ($dev) = @_;
- my @slaves;
-
- if ($dev =~ /^\/dev\//) {
- $dev = substr ($dev, 5);
- }
-
- opendir (\*DIR, "/sys/block/$dev/slaves/") or die "$!\n";
-
- @slaves = grep { !/^\./ } readdir (DIR);
- if ($slaves[0] =~ /^dm/) {
- @slaves = get_mpath_slaves ($slaves[0]);
- } else {
- @slaves = map { "/dev/$_" } @slaves;
- }
-
- closedir (DIR);
-
- return (@slaves);
-}
-
-sub get_registration_keys ($)
-{
- my $self = (caller(0))[3];
- my ($dev) = @_;
- my @keys;
-
- my $cmd = "sg_persist -n -i -k -d $dev";
- my @out = qx { $cmd 2> /dev/null };
- my $err = ($?>>8);
-
- if ($err != 0) {
- log_error ("$self (err=$err)");
- }
-
- # die "[error]: $self\n" if ($?>>8);
-
- foreach (@out) {
- chomp;
- if ($_ =~ s/^\s+0x//i) {
- push (@keys, $_);
- }
- }
-
- return (@keys);
-}
-
-sub get_reservation_key ($)
-{
- my $self = (caller(0))[3];
- my ($dev) = @_;
- my $key;
-
- my $cmd = "sg_persist -n -i -r -d $dev";
- my @out = qx { $cmd 2> /dev/null };
- my $err = ($?>>8);
-
- if ($err != 0) {
- log_error ("$self (err=$err)");
- }
-
- # die "[error]: $self\n" if ($?>>8);
-
- foreach (@out) {
- chomp;
- if ($_ =~ s/^\s+key=0x//i) {
- $key = $_;
- last;
- }
- }
-
- return ($key)
-}
-
-sub get_options_stdin ()
-{
- my $num = 0;
-
- while (<STDIN>) {
- chomp;
- s/^\s*//;
- s/\s*$//;
-
- next if (/^#/);
-
- $num++;
-
- next unless ($_);
-
- my ($opt, $arg) = split (/\s*=\s*/, $_);
-
- if ($opt eq "") {
- exit (1);
- }
- elsif ($opt eq "aptpl") {
- $opt_a = $arg;
- }
- elsif ($opt eq "devices") {
- $opt_d = $arg;
- }
- elsif ($opt eq "logfile") {
- $opt_f = $arg;
- }
- elsif ($opt eq "key") {
- $opt_k = $arg;
- }
- elsif ($opt eq "nodename") {
- $opt_n = $arg;
- }
- elsif ($opt eq "action") {
- $opt_o = $arg;
- }
- elsif ($opt eq "delay") {
- $opt_H = $arg;
- }
- }
-}
-
-sub print_usage ()
-{
- print "Usage:\n";
- print "\n";
- print "$ME [options]\n";
- print "\n";
- print "Options:\n";
- print " -a Use APTPL flag\n";
- print " -d <devices> Devices to be used for action\n";
- print " -f <logfile> File to write debug/error output\n";
- print " -H <timeout> Wait X seconds before fencing is started\n";
- print " -h Usage\n";
- print " -k <key> Key to be used for current action\n";
- print " -n <nodename> Name of node to operate on\n";
- print " -o <action> Action: off (default), on, or status\n";
- print " -q Quiet mode\n";
- print " -V Version\n";
-
- exit (0);
-}
-
-sub print_version ()
-{
- print "$ME $RELEASE_VERSION $BUILD_DATE\n";
- print "$REDHAT_COPYRIGHT\n" if ( $REDHAT_COPYRIGHT );
-
- exit (0);
-}
-
-sub print_metadata ()
-{
- print "<?xml version=\"1.0\" ?>\n";
- print "<resource-agent name=\"fence_scsi\"" .
- " shortdesc=\"fence agent for SCSI-3 persistent reservations\">\n";
- print "<longdesc>fence_scsi</longdesc>\n";
- print "<vendor-url>http://www.t10.org</vendor-url>\n";
- print "<parameters>\n";
- print "\t<parameter name=\"aptpl\" unique=\"0\" required=\"0\">\n";
- print "\t\t<getopt mixed=\"-a\"/>\n";
- print "\t\t<content type=\"boolean\"/>\n";
- print "\t\t<shortdesc lang=\"en\">" .
- "Use APTPL flag for registrations" .
- "</shortdesc>\n";
- print "\t</parameter>\n";
- print "\t<parameter name=\"devices\" unique=\"0\" required=\"0\">\n";
- print "\t\t<getopt mixed=\"-d\"/>\n";
- print "\t\t<content type=\"string\"/>\n";
- print "\t\t<shortdesc lang=\"en\">" .
- "List of devices to be used for fencing action" .
- "</shortdesc>\n";
- print "\t</parameter>\n";
- print "\t<parameter name=\"logfile\" unique=\"0\" required=\"0\">\n";
- print "\t\t<getopt mixed=\"-f\"/>\n";
- print "\t\t<content type=\"string\"/>\n";
- print "\t\t<shortdesc lang=\"en\">" .
- "File to write error/debug messages" .
- "</shortdesc>\n";
- print "\t</parameter>\n";
- print "\t<parameter name=\"delay\" unique=\"0\" required=\"0\">\n";
- print "\t\t<getopt mixed=\"-H\"/>\n";
- print "\t\t<content type=\"string\"/>\n";
- print "\t\t<shortdesc lang=\"en\">" .
- "Wait X seconds before fencing is started" .
- "</shortdesc>\n";
- print "\t</parameter>\n";
- print "\t<parameter name=\"key\" unique=\"0\" required=\"0\">\n";
- print "\t\t<getopt mixed=\"-k\"/>\n";
- print "\t\t<content type=\"string\"/>\n";
- print "\t\t<shortdesc lang=\"en\">" .
- "Key value to be used for fencing action" .
- "</shortdesc>\n";
- print "\t</parameter>\n";
- print "\t<parameter name=\"action\" unique=\"0\" required=\"0\">\n";
- print "\t\t<getopt mixed=\"-o\"/>\n";
- print "\t\t<content type=\"string\" default=\"off\"/>\n";
- print "\t\t<shortdesc lang=\"en\">" .
- "Fencing action" .
- "</shortdesc>\n";
- print "\t</parameter>\n";
- print "\t<parameter name=\"nodename\" unique=\"0\" required=\"0\">\n";
- print "\t\t<getopt mixed=\"-n\"/>\n";
- print "\t\t<content type=\"string\"/>\n";
- print "\t\t<shortdesc lang=\"en\">" .
- "Name of node" .
- "</shortdesc>\n";
- print "\t</parameter>\n";
- print "</parameters>\n";
- print "<actions>\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";
- print "</actions>\n";
- print "</resource-agent>\n";
-
- exit (0);
-}
-
-################################################################################
-
-if (@ARGV > 0) {
- getopts ("ad:f:H:hk:n:o:qV") or print_usage;
- print_usage if (defined $opt_h);
- print_version if (defined $opt_V);
-} else {
- get_options_stdin ();
-}
-
-## handle the metadata action here to avoid other parameter checks
-##
-if ($opt_o =~ /^metadata$/i) {
- print_metadata;
-}
-
-## if the logfile (-f) parameter was specified, open the logfile
-## and redirect STDOUT and STDERR to the logfile.
-##
-if (defined $opt_f) {
- open (LOG, ">>$opt_f") or die "$!\n";
- open (STDOUT, ">&LOG");
- open (STDERR, ">&LOG");
-}
-
-## verify that either key or nodename have been specified
-##
-if ((!defined $opt_n) && (!defined $opt_k)) {
- print_usage ();
-}
-
-## determine key value
-##
-if (defined $opt_k) {
- $key = $opt_k;
-} else {
- $key = get_key ($opt_n);
-}
-
-## verify that key is not zero
-##
-if (hex($key) == 0) {
- log_error ("key cannot be zero");
-}
-
-## remove any leading zeros from key
-##
-if ($key =~ /^0/) {
- $key =~ s/^0+//;
-}
-
-## get devices
-##
-if (defined $opt_d) {
- @devices = split (/\s*,\s*/, $opt_d);
-} else {
- @devices = get_devices_clvm ();
-}
-
-## verify that device list is not empty
-##
-if (scalar (@devices) == 0) {
- log_error ("no devices found");
-}
-
-## default action is "off"
-##
-if (!defined $opt_o) {
- $opt_o = "off";
-}
-
-## Wait for defined period (-H / delay= )
-##
-if ((defined $opt_H) && ($opt_H =~ /^[0-9]+/)) {
- sleep($opt_H);
-}
-
-## determine the action to perform
-##
-if ($opt_o =~ /^on$/i) {
- do_action_on ($key, @devices);
- do_verify_on ($key, @devices);
-}
-elsif ($opt_o =~ /^off$/i) {
- do_action_off ($key, @devices);
- do_verify_off ($key, @devices);
-}
-elsif ($opt_o =~ /^status/i) {
- do_action_status ($key, @devices);
-} else {
- log_error ("unknown action '$opt_o'");
- exit (1);
-}
-
-## close the logfile
-##
-if (defined $opt_f) {
- close (LOG);
-}
diff --git a/fence/agents/scsi/fence_scsi.py b/fence/agents/scsi/fence_scsi.py
new file mode 100644
index 0000000..f837faa
--- /dev/null
+++ b/fence/agents/scsi/fence_scsi.py
@@ -0,0 +1,452 @@
+#!/usr/bin/python -tt
+
+import sys
+import stat
+import re
+import os
+import time
+import logging
+import atexit
+import hashlib
+sys.path.append("@FENCEAGENTSLIBDIR@")
+from fencing import fail_usage, run_command, atexit_handler, check_input, process_input, show_docs, fence_action, all_opt
+
+#BEGIN_VERSION_GENERATION
+RELEASE_VERSION=""
+REDHAT_COPYRIGHT=""
+BUILD_DATE=""
+#END_VERSION_GENERATION
+
+STORE_PATH = "/var/run/cluster/fence_scsi"
+
+
+def get_status(conn, options):
+ del conn
+ status = "off"
+ for dev in options["devices"]:
+ is_block_device(dev)
+ reset_dev(options, dev)
+ if options["--key"] in get_registration_keys(options, dev):
+ status = "on"
+ else:
+ logging.debug("No registration for key "\
+ + options["--key"] + " on device " + dev + "\n")
+ return status
+
+
+def set_status(conn, options):
+ del conn
+ count = 0
+ if options["--action"] == "on":
+ set_key(options)
+ for dev in options["devices"]:
+ is_block_device(dev)
+
+ register_dev(options, dev)
+ if options["--key"] not in get_registration_keys(options, dev):
+ count += 1
+ logging.debug("Failed to register key "\
+ + options["--key"] + "on device " + dev + "\n")
+ continue
+ dev_write(dev, options)
+
+ if get_reservation_key(options, dev) is None \
+ and not reserve_dev(options, dev) \
+ and get_reservation_key(options, dev) is None:
+ count += 1
+ logging.debug("Failed to create reservation (key="\
+ + options["--key"] + ", device=" + dev + ")\n")
+
+ else:
+ host_key = get_key()
+ if host_key == options["--key"].lower():
+ fail_usage("Failed: keys cannot be same. You can not fence yourself.")
+ for dev in options["devices"]:
+ is_block_device(dev)
+
+ if options["--key"] in get_registration_keys(options, dev):
+ preempt_abort(options, host_key, dev)
+
+ for dev in options["devices"]:
+ if options["--key"] in get_registration_keys(options, dev):
+ count += 1
+ logging.debug("Failed to remove key "\
+ + options["--key"] + " on device " + dev + "\n")
+ continue
+
+ if not get_reservation_key(options, dev):
+ count += 1
+ logging.debug("No reservation exists on device " + dev + "\n")
+ if count:
+ logging.error("Failed to verify " + str(count) + " device(s)")
+ sys.exit(1)
+
+
+#run command, returns dict, ret["err"] = exit code; ret["out"] = output
+def run_cmd(options, cmd):
+ ret = {}
+ (ret["err"], ret["out"], _) = run_command(options, cmd)
+ ret["out"] = "".join([i for i in ret["out"] if i is not None])
+ return ret
+
+
+# check if device exist and is block device
+def is_block_device(dev):
+ if not os.path.exists(dev):
+ fail_usage("Failed: device \"" + dev + "\" does not exist")
+ if not stat.S_ISBLK(os.stat(dev).st_mode):
+ fail_usage("Failed: device \"" + dev + "\" is not a block device")
+
+
+# cancel registration
+def preempt_abort(options, host, dev):
+ cmd = options["--sg_persist-path"] + " -n -o -A -T 5 -K " + host + " -S " + options["--key"] + " -d " + dev
+ return not bool(run_cmd(options, cmd)["err"])
+
+
+def reset_dev(options, dev):
+ return run_cmd(options, options["--sg_turs-path"] + " " + dev)["err"]
+
+
+def register_dev(options, dev):
+ dev = os.path.realpath(dev)
+ if re.search(r"^dm", dev[5:]):
+ for slave in get_mpath_slaves(dev):
+ register_dev(options, slave)
+ return True
+ reset_dev(options, dev)
+ cmd = options["--sg_persist-path"] + " -n -o -I -S " + options["--key"] + " -d " + dev
+ cmd += " -Z" if "--aptpl" in options else ""
+ #cmd return code != 0 but registration can be successful
+ return not bool(run_cmd(options, cmd)["err"])
+
+
+def reserve_dev(options, dev):
+ cmd = options["--sg_persist-path"] + " -n -o -R -T 5 -K " + options["--key"] + " -d " + dev
+ return not bool(run_cmd(options, cmd)["err"])
+
+
+def get_reservation_key(options, dev):
+ cmd = options["--sg_persist-path"] + " -n -i -r -d " + dev
+ out = run_cmd(options, cmd)
+ if out["err"]:
+ fail_usage("Cannot get reservation key")
+ match = re.search(r"\s+key=0x(\S+)\s+", out["out"], re.IGNORECASE)
+ return match.group(1) if match else None
+
+
+def get_registration_keys(options, dev):
+ keys = []
+ cmd = options["--sg_persist-path"] + " -n -i -k -d " + dev
+ out = run_cmd(options, cmd)
+ if out["err"]:
+ fail_usage("Cannot get registration keys")
+ for line in out["out"].split("\n"):
+ match = re.search(r"\s+0x(\S+)\s*", line)
+ if match:
+ keys.append(match.group(1))
+ return keys
+
+
+def get_cluster_id(options):
+ cmd = options["--corosync-cmap-path"] + " totem.cluster_name"
+
+ match = re.search(r"\(str\) = (\S+)\n", run_cmd(options, cmd)["out"])
+ return hashlib.md5(match.group(1)).hexdigest() if match else fail_usage("Failed: cannot get cluster name")
+
+
+def get_node_id(options):
+ cmd = options["--corosync-cmap-path"] + " nodelist."
+
+ match = re.search(r".(\d).ring._addr \(str\) = " + options["--nodename"] + "\n", run_cmd(options, cmd)["out"])
+ return match.group(1) if match else fail_usage("Failed: unable to parse output of corosync-cmapctl or node does not exist")
+
+
+def generate_key(options):
+ return "%.4s%.4d" % (get_cluster_id(options), int(get_node_id(options)))
+
+
+# save node key to file
+def set_key(options):
+ file_path = options["store_path"] + ".key"
+ if not os.path.isdir(os.path.dirname(options["store_path"])):
+ os.makedirs(os.path.dirname(options["store_path"]))
+ try:
+ f = open(file_path, "w")
+ except IOError:
+ fail_usage("Failed: Cannot open file \""+ file_path + "\"")
+ f.write(options["--key"].lower() + "\n")
+ f.close()
+
+
+# read node key from file
+def get_key():
+ file_path = STORE_PATH + ".key"
+ try:
+ f = open(file_path, "r")
+ except IOError:
+ fail_usage("Failed: Cannot open file \""+ file_path + "\"")
+ return f.readline().strip().lower()
+
+
+def dev_write(dev, options):
+ file_path = options["store_path"] + ".dev"
+ if not os.path.isdir(os.path.dirname(options["store_path"])):
+ os.makedirs(os.path.dirname(options["store_path"]))
+ try:
+ f = open(file_path, "a+")
+ except IOError:
+ fail_usage("Failed: Cannot open file \""+ file_path + "\"")
+ out = f.read()
+ if not re.search(r"^" + dev + "\s+", out):
+ f.write(dev + "\n")
+ f.close()
+
+
+def dev_read():
+ file_path = STORE_PATH + ".dev"
+ try:
+ f = open(file_path, "r")
+ except IOError:
+ fail_usage("Failed: Cannot open file \"" + file_path + "\"")
+ # get not empty lines from file
+ devs = [line.strip() for line in f if line.strip()]
+ f.close()
+ return devs
+
+
+def dev_delete(options):
+ file_path = options["store_path"] + ".dev"
+ os.remove(file_path) if os.path.exists(file_path) else None
+
+
+def get_clvm_devices(options):
+ devs = []
+ cmd = options["--vgs-path"] + " " +\
+ "--noheadings " +\
+ "--separator : " +\
+ "--sort pv_uuid " +\
+ "--options vg_attr,pv_name "+\
+ "--config 'global { locking_type = 0 } devices { preferred_names = [ \"^/dev/dm\" ] }'"
+ out = run_cmd(options, cmd)
+ if out["err"]:
+ fail_usage("Failed: Cannot get clvm devices")
+ for line in out["out"].split("\n"):
+ if 'c' in line.split(":")[0]:
+ devs.append(line.split(":")[1])
+ return devs
+
+
+def get_mpath_slaves(dev):
+ if dev[:5] == "/dev/":
+ dev = dev[5:]
+ slaves = [i for i in os.listdir("/sys/block/" + dev + "/slaves/") if i[:1] != "."]
+ if slaves[0][:2] == "dm":
+ slaves = get_mpath_slaves(slaves[0])
+ else:
+ slaves = ["/dev/" + x for x in slaves]
+ return slaves
+
+
+def define_new_opts():
+ all_opt["devices"] = {
+ "getopt" : "d:",
+ "longopt" : "devices",
+ "help" : "-d, --devices=[devices] List of devices to use for current operation",
+ "required" : "0",
+ "shortdesc" : "List of devices to use for current operation. Devices can \
+be comma-separated list of raw device (eg. /dev/sdc) or device-mapper multipath \
+devices (eg. /dev/dm-3). Each device must support SCSI-3 persistent reservations.",
+ "order": 1
+ }
+ all_opt["nodename"] = {
+ "getopt" : "n:",
+ "longopt" : "nodename",
+ "help" : "-n, --nodename=[nodename] Name of the node to be fenced",
+ "required" : "0",
+ "shortdesc" : "Name of the node to be fenced. The node name is used to \
+generate the key value used for the current operation. This option will be \
+ignored when used with the -k option.",
+ "order": 1
+ }
+ all_opt["key"] = {
+ "getopt" : "k:",
+ "longopt" : "key",
+ "help" : "-k, --key=[key] Key to use for the current operation",
+ "required" : "0",
+ "shortdesc" : "Key to use for the current operation. This key should be \
+unique to a node. For the \"on\" action, the key specifies the key use to \
+register the local node. For the \"off\" action, this key specifies the key to \
+be removed from the device(s).",
+ "order": 1
+ }
+ all_opt["aptpl"] = {
+ "getopt" : "a",
+ "longopt" : "aptpl",
+ "help" : "-a, --aptpl Use the APTPL flag for registrations",
+ "required" : "0",
+ "shortdesc" : "Use the APTPL flag for registrations. This option is only used for the 'on' action.",
+ "order": 1
+ }
+ all_opt["logfile"] = {
+ "getopt" : "f:",
+ "longopt" : "logfile",
+ "help" : "-a, --logfile Log output (stdout and stderr) to file",
+ "required" : "0",
+ "shortdesc" : "Log output (stdout and stderr) to file",
+ "order": 5
+ }
+ all_opt["corosync-cmap_path"] = {
+ "getopt" : "Z:",
+ "longopt" : "corosync-cmap-path",
+ "help" : "--corosync-cmap-path=[path] Path to corosync-cmapctl binary",
+ "required" : "0",
+ "shortdesc" : "Path to corosync-cmapctl binary",
+ "default" : "@COROSYNC_CMAPCTL_PATH@",
+ "order": 200
+ }
+ all_opt["sg_persist_path"] = {
+ "getopt" : "X:",
+ "longopt" : "sg_persist-path",
+ "help" : "--sg_persist-path=[path] Path to sg_persist binary",
+ "required" : "0",
+ "shortdesc" : "Path to sg_persist binary",
+ "default" : "@SG_PERSIST_PATH@",
+ "order": 200
+ }
+ all_opt["sg_turs_path"] = {
+ "getopt" : "I:",
+ "longopt" : "sg_turs-path",
+ "help" : "--sg_turs-path=[path] Path to sg_turs binary",
+ "required" : "0",
+ "shortdesc" : "Path to sg_turs binary",
+ "default" : "@SG_TURS_PATH@",
+ "order": 200
+ }
+ all_opt["vgs_path"] = {
+ "getopt" : "J:",
+ "longopt" : "vgs-path",
+ "help" : "--vgs-path=[path] Path to vgs binary",
+ "required" : "0",
+ "shortdesc" : "Path to vgs binary",
+ "default" : "@VGS_PATH@",
+ "order": 200
+ }
+
+
+def scsi_check_get_verbose():
+ try:
+ f = open("/etc/sysconfig/watchdog", "r")
+ except IOError:
+ return False
+ match = re.search(r"^\s*verbose=yes", "".join(f.readlines()), re.MULTILINE)
+ f.close()
+ return bool(match)
+
+
+def scsi_check():
+ if len(sys.argv) >= 3 and sys.argv[1] == "repair":
+ return int(sys.argv[2])
+ options = {}
+ options["--sg_turs-path"] = "@SG_TURS_PATH@"
+ options["--sg_persist-path"] = "@SG_PERSIST_PATH@"
+ options["--power-timeout"] = "5"
+ if scsi_check_get_verbose():
+ logging.getLogger().setLevel(logging.DEBUG)
+ devs = dev_read()
+ if not devs:
+ logging.error("No devices found")
+ return 0
+ key = get_key()
+ if not key:
+ logging.error("Key not found")
+ return 0
+ for dev in devs:
+ if key in get_registration_keys(options, dev):
+ logging.debug("key " + key + " registered with device " + dev)
+ return 0
+ else:
+ logging.debug("key " + key + " not registered with device " + dev)
+ logging.debug("key " + key + " registered with any devices")
+ return 2
+
+
+def main():
+
+ atexit.register(atexit_handler)
+
+ device_opt = ["no_login", "no_password", "devices", "nodename", "key",\
+ "aptpl", "fabric_fencing", "on_target", "corosync-cmap_path",\
+ "sg_persist_path", "sg_turs_path", "logfile", "vgs_path"]
+
+ define_new_opts()
+
+ all_opt["action"]["help"] = "-o, --action=[action] Action: status, off (default) or on"
+ all_opt["action"]["default"] = "off"
+ all_opt["delay"]["getopt"] = "H:"
+
+ #fence_scsi_check
+ if os.path.basename(sys.argv[0]) == "fence_scsi_check":
+ sys.exit(scsi_check())
+
+ options = check_input(device_opt, process_input(device_opt))
+
+ docs = {}
+ docs["shortdesc"] = "Fence agent for SCSI persistentl reservation"
+ docs["longdesc"] = "fence_scsi is an I/O fencing agent that uses SCSI-3 \
+persistent reservations to control access to shared storage devices. These \
+devices must support SCSI-3 persistent reservations (SPC-3 or greater) as \
+well as the \"preempt-and-abort\" subcommand.\nThe fence_scsi agent works by \
+having each node in the cluster register a unique key with the SCSI \
+devive(s). Once registered, a single node will become the reservation holder \
+by creating a \"write exclusive, registrants only\" reservation on the \
+device(s). The result is that only registered nodes may write to the \
+device(s). When a node failure occurs, the fence_scsi agent will remove the \
+key belonging to the failed node from the device(s). The failed node will no \
+longer be able to write to the device(s). A manual reboot is required."
+ docs["vendorurl"] = ""
+ show_docs(options, docs)
+
+ # backward compatibility layer BEGIN
+ if "--logfile" in options:
+ try:
+ logfile = open(options["--logfile"], 'w')
+ sys.stderr = logfile
+ sys.stdout = logfile
+ except IOError:
+ fail_usage("Failed: Unable to create file " + options["--logfile"])
+ # backward compatibility layer END
+
+ options["store_path"] = STORE_PATH
+
+ # Input control BEGIN
+ if not (("--nodename" in options and options["--nodename"])\
+ or ("--key" in options and options["--key"])):
+ fail_usage("Failed: nodename or key is required")
+
+ if not ("--key" in options and options["--key"]):
+ options["--key"] = generate_key(options)
+
+ if options["--key"] == "0" or not options["--key"]:
+ fail_usage("Failed: key cannot be 0")
+
+ options["--key"] = options["--key"].lstrip('0')
+
+ if not ("--devices" in options and options["--devices"].split(",")):
+ options["devices"] = get_clvm_devices(options)
+ else:
+ options["devices"] = options["--devices"].split(",")
+
+ if not options["devices"]:
+ fail_usage("Failed: No devices found")
+ # Input control END
+
+ # backward compatibility layer
+ if "--delay" in options and options["--delay"].isdigit():
+ time.sleep(int(options["--delay"]))
+
+ result = fence_action(None, options, set_status, get_status)
+ sys.exit(result)
+
+if __name__ == "__main__":
+ main()
diff --git a/fence/agents/scsi/fence_scsi_check.pl b/fence/agents/scsi/fence_scsi_check.pl
deleted file mode 100644
index 9ecd7a5..0000000
--- a/fence/agents/scsi/fence_scsi_check.pl
+++ /dev/null
@@ -1,170 +0,0 @@
-#!/usr/bin/perl
-
-use POSIX;
-
-################################################################################
-
-my $dev_file = "/var/run/cluster/fence_scsi.dev";
-my $key_file = "/var/run/cluster/fence_scsi.key";
-
-################################################################################
-
-sub log_debug ($)
-{
- my $time = strftime ("%b %e %T", localtime);
- my $msg = shift;
-
- print STDOUT "$time [$0] debug: $msg\n" if ($verbose);
-
- return;
-}
-
-sub log_error ($)
-{
- my $time = strftime ("%b %e %T", localtime);
- my $msg = shift;
-
- print STDERR "$time [$0] error: $msg\n";
-
- return;
-}
-
-sub do_reset ($)
-{
- my $dev = shift;
-
- my $cmd = "sg_turs $dev";
- my @out = qx { $cmd 2> /dev/null };
-
- return;
-}
-
-sub get_registration_keys ($)
-{
- my $dev = shift;
- my @keys = ();
-
- do_reset ($dev);
-
- my $cmd = "sg_persist -n -i -k -d $dev";
- my @out = qx { $cmd 2> /dev/null };
-
- if ($?>>8 != 0) {
- log_error ("$cmd");
- exit (0);
- }
-
- foreach (@out) {
- chomp;
- if (s/^\s+0x//i) {
- push (@keys, $_);
- }
- }
-
- return (@keys);
-}
-
-sub get_reservation_keys ($)
-{
- my $dev = shift;
- my @keys = ();
-
- do_reset ($dev);
-
- my $cmd = "sg_persist -n -i -r -d $dev";
- my @out = qx { $cmd 2> /dev/null };
-
- if ($?>>8 != 0) {
- log_error ("$cmd");
- exit (0);
- }
-
- foreach (@out) {
- chomp;
- if (s/^\s+key=0x//i) {
- push (@keys, $_);
- }
- }
-
- return (@keys);
-}
-
-sub get_verbose ()
-{
- open (\*FILE, "</etc/sysconfig/watchdog") or return;
- chomp (my @opt = <FILE>);
- close (FILE);
-
- foreach (@opt) {
- next if (/^#/);
- next unless ($_);
-
- if (/^verbose=yes$/i) {
- return (1);
- }
- }
-
- return (0);
-}
-
-sub key_read ()
-{
- open (\*FILE, "<$key_file") or exit (0);
- chomp (my $key = <FILE>);
- close (FILE);
-
- return ($key);
-}
-
-sub dev_read ()
-{
- open (\*FILE, "<$dev_file") or exit (0);
- chomp (my @dev = <FILE>);
- close (FILE);
-
- return (@dev);
-}
-
-################################################################################
-
-if ($ARGV[0] =~ /^repair$/i) {
- exit ($ARGV[1]);
-}
-
-if (-e "/etc/sysconfig/watchdog") {
- $verbose = get_verbose ();
-}
-
-if (! -e $dev_file) {
- log_debug ("$dev_file does not exit");
- exit (0);
-} elsif (-z $dev_file) {
- log_debug ("$dev_file is empty");
- exit (0);
-}
-
-if (! -e $key_file) {
- log_debug ("$key_file does not exist");
- exit (0);
-} elsif (-z $key_file) {
- log_debug ("$key_file is empty");
- exit (0);
-}
-
-my $key = key_read ();
-my @dev = dev_read ();
-
-foreach (@dev) {
- my @keys = grep { /^$key$/i } get_registration_keys ($_);
-
- if (scalar (@keys) != 0) {
- log_debug ("key $key registered with device $_");
- exit (0);
- } else {
- log_debug ("key $key not registered with device $_");
- }
-}
-
-log_debug ("key $key not registered with any devices");
-
-exit (2);
diff --git a/make/fencebuild.mk b/make/fencebuild.mk
index 819ac36..1c4be6b 100644
--- a/make/fencebuild.mk
+++ b/make/fencebuild.mk
@@ -12,6 +12,10 @@ $(TARGET): $(SRC)
-e 's#@''IPMITOOL_PATH@#${IPMITOOL_PATH}#g' \
-e 's#@''AMTTOOL_PATH@#${AMTTOOL_PATH}#g' \
-e 's#@''GNUTLSCLI_PATH@#${GNUTLSCLI_PATH}#g' \
+ -e 's#@''COROSYNC_CMAPCTL_PATH@#${COROSYNC_CMAPCTL_PATH}#g' \
+ -e 's#@''SG_PERSIST_PATH@#${SG_PERSIST_PATH}#g' \
+ -e 's#@''SG_TURS_PATH@#${SG_TURS_PATH}#g' \
+ -e 's#@''VGS_PATH@#${VGS_PATH}#g' \
> $@
if [ 0 -eq `echo "$(SRC)" | grep fence_ &> /dev/null; echo $$?` ]; then \
9 years, 11 months
fence-agents: v4.0.9 annotated tag has been created
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=098557...
Commit: 09855704275b6687f104bbacc7c10dbf85782134
Parent: 0000000000000000000000000000000000000000
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: 2014-05-14 12:48 +0000
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: 2014-05-14 12:48 +0000
annotated tag: v4.0.9 has been created
at 09855704275b6687f104bbacc7c10dbf85782134 (tag)
tagging 5551d8c2d6975927899c086985f19ebb29f5684e (commit)
replaces v4.0.8
v4.0.9 release
Marek 'marx' Grac (49):
testing: Add regression tests for XML metadata of python fence agents
testing: Add regression tests for XML metadata of C fence agents
[cleanup] Add missing spaces and fix tab/spaces indentation
[cleanup] Proper import of atexit
[cleanup] Remove unused variables
[cleanup] Split lines that were too long
[cleanup] Remove unused dependencies
[cleanup] Remove problems with redefining variables/functions
[cleanup] Only symbols that should be used are exported from fencing library
[cleanup] Mark raw strings with r""
[cleanup] Only symbols that should be used are exported from fencing_snmp library
[cleanup] Errors when encountering mixed space/tab in python
[cleanup] Mark raw strings with r"" in fence_virsh
[cleanup] Remove snmp_define_defaults()
[cleanup] Remove unused arguments
[cleanup] Remove transfer script used in transition 3.x->4.x
[cleanup] Fix invalid names of variables
[cleanup] Fixing small issues created during cleaning phase
fence_wti: Action 'list' prints also named groups
[cleanup] fence_wti: Fix variables that can be used before assignement
[cleanup] remove LOG_MODE_*
fencing: Refactor access to 3rd-party binaries
[cleanup] Add missing spaces
[cleanup] Define parent class even if it is object
fence_vmware: Invalid arguments for vmware_get_outlets_vi()
[cleanup] Cleaning in fence_raritan
[cleanup] Replace map/filter by list comprehensions
[cleanup] Remove additional parentheses
[cleanup] Replace vmware_log() with direct call of logging
fencing: ipport defaults was set after defaults were used
fencing: Fix invalid parsing in XML metadata
fencing: Pexpect problems - missing return statement
[cleanup] Remove warning logging-not-lazy
[cleanup] Remove method log_command() from FencingSnmp as it was replaced by logging.debug()
[cleanup] Removing unused part which was replaced by proper 'default' values for 'ipport'
fencing: Introduce new device option 'no_status'
fencing: Add support for --delay for all python non-SNMP fence agents
fencing: Add support for --delay for all python SNMP fence agents
[cleanup] Add broad exception specification for each except
[cleanup] Remove unused import of modules
[cleanup] Create function fence_logout()
[cleanup] Simplify 'if' statements to use 'not' and 'get'
[cleanup] '--action' should be normalized to lowercase at one place only
[cleanup] function array_to_dict() from agents to library
[cleanup] Fix whitespace according to PEP8
testing: python agents are tested for working delay function
fence_ovh: Fix problems according to patch in mailing list.
fence_ovh: --delay should be applied before attempt to login
fence_pve: Add testing arguments for --delay test
Ondrej Mular (5):
fence_ipmilan: send empty password, if password is not entered
fencing: added timeout and env parameters to run_command function
fence_amt: sending password over env
fencing: added option "on_target"
fence_pve: new fence-agent for Proxmox VE
9 years, 11 months
cluster: RHEL511 - rgmanager: Forcibly remove pid file if sending SIGTERM
by Ryan McCabe
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=a70d8ebc0ab...
Commit: a70d8ebc0abfd2110214a93e29bc5d4bf5eb9c38
Parent: d77a25c817c985f3200b1676c659683e3984564c
Author: Ryan McCabe <rmccabe(a)redhat.com>
AuthorDate: Mon May 12 10:40:21 2014 -0400
Committer: Ryan McCabe <rmccabe(a)redhat.com>
CommitterDate: Mon May 12 10:40:21 2014 -0400
rgmanager: Forcibly remove pid file if sending SIGTERM
If a daemon is sent SIGTERM to stop it, forcibly
remove the pid file after verifying the process no longer exists. This
fixes a bug that causes future starts to fail if a new process happens
to exist with the same pid when the resource is restarted.
Resolves: rhbz#1035034
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
---
rgmanager/src/resources/utils/ra-skelet.sh | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/rgmanager/src/resources/utils/ra-skelet.sh b/rgmanager/src/resources/utils/ra-skelet.sh
index 93a8ac3..3a502d5 100644
--- a/rgmanager/src/resources/utils/ra-skelet.sh
+++ b/rgmanager/src/resources/utils/ra-skelet.sh
@@ -96,6 +96,10 @@ stop_generic()
return $OCF_ERR_GENERIC
fi
+ # If we had to send a SIGTERM, the pid file may not have been
+ # cleaned up by the daemon. Make sure it's removed so that future
+ # resource starts do not fail.
+ rm -f -- "$pid_file"
return 0;
}
9 years, 12 months
cluster: RHEL6 - fsck.gfs2: Log to syslog on start and exit
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=3edb19cd844...
Commit: 3edb19cd844028885baa643d7b118860b2e7a186
Parent: 6739cf6a6cc6c24d20d58f68acdc6d886bff01e7
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Tue May 6 15:59:39 2014 +0100
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Thu May 8 14:12:51 2014 +0100
fsck.gfs2: Log to syslog on start and exit
In order to piece together the order in which fsck.gfs2 runs and
gfs2_edit savemeta were done it's useful to keep a log of the command
line options used and the fsck.gfs2 start and end times and exit status.
Log these to syslog.
Resolves: rhbz#1081517
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/main.c | 35 +++++++++++++++++++++++++++++++++++
gfs2/man/fsck.gfs2.8 | 2 ++
2 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
index 5259bae..85e6775 100644
--- a/gfs2/fsck/main.c
+++ b/gfs2/fsck/main.c
@@ -10,6 +10,7 @@
#include <libintl.h>
#include <locale.h>
#define _(String) gettext(String)
+#include <syslog.h>
#include "copyright.cf"
#include "libgfs2.h"
@@ -223,6 +224,36 @@ static void check_statfs(struct gfs2_sbd *sdp)
errors_corrected++;
}
+static void exitlog(int status, void *unused)
+{
+ syslog(LOG_INFO, "exit: %d", status);
+}
+
+static void startlog(int argc, char **argv)
+{
+ int i;
+ char *cmd, *p;
+ size_t len;
+
+ for (len = i = 0; i < argc; i++)
+ len += strlen(argv[i]);
+ len += argc; /* Add spaces and '\0' */
+
+ cmd = malloc(len);
+ if (cmd == NULL) {
+ perror(argv[0]);
+ exit(FSCK_ERROR);
+ }
+ p = cmd;
+ for (i = 0; i < argc; i++, p++) {
+ p = stpcpy(p, argv[i]);
+ *p = ' ';
+ }
+ *(--p) = '\0';
+ syslog(LOG_INFO, "started: %s", cmd);
+ free(cmd);
+}
+
int main(int argc, char **argv)
{
struct gfs2_sbd sb;
@@ -234,6 +265,10 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
textdomain("gfs2-utils");
+ openlog("fsck.gfs2", LOG_CONS|LOG_PID, LOG_USER);
+ startlog(argc - 1, &argv[1]);
+ on_exit(exitlog, NULL);
+
memset(sdp, 0, sizeof(*sdp));
/* brdfp = fopen("brd-log.txt", "w"); */
diff --git a/gfs2/man/fsck.gfs2.8 b/gfs2/man/fsck.gfs2.8
index 3ecfbe3..56dcddc 100644
--- a/gfs2/man/fsck.gfs2.8
+++ b/gfs2/man/fsck.gfs2.8
@@ -35,6 +35,8 @@ computer. Therefore, fsck.gfs2 will always check the file system unless
the -p (preen) option is used, in which case it follows special rules
(see below).
+fsck.gfs2 will log to the system log on start and exit to aid debugging and
+administration.
.SH OPTIONS
.TP
\fB-a\fP
9 years, 12 months
gfs2-utils: master - libgfs2: Remove logging API
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=2d5ba02f...
Commit: 2d5ba02f1c22e22a502b7fe3bc06bb73da52cfcf
Parent: 7065121d12074bf2be99ae908b9301f7a97684b0
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed May 7 15:24:22 2014 +0100
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Thu May 8 12:20:03 2014 +0100
libgfs2: Remove logging API
libgfs2 was exposing a logging API (log_info, etc.) but wasn't using it
itself. Remove the logging bits and move them into
gfs2/include/logging.h
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 2 ++
gfs2/edit/savemeta.c | 2 ++
gfs2/fsck/fs_recovery.c | 1 +
gfs2/fsck/initialize.c | 1 +
gfs2/fsck/inode_hash.c | 1 +
gfs2/fsck/link.c | 1 +
gfs2/fsck/lost_n_found.c | 1 +
gfs2/fsck/main.c | 2 ++
gfs2/fsck/metawalk.c | 1 +
gfs2/fsck/pass1.c | 1 +
gfs2/fsck/pass1b.c | 1 +
gfs2/fsck/pass1c.c | 1 +
gfs2/fsck/pass2.c | 1 +
gfs2/fsck/pass3.c | 1 +
gfs2/fsck/pass4.c | 1 +
gfs2/fsck/pass5.c | 1 +
gfs2/fsck/rgrepair.c | 1 +
gfs2/fsck/util.c | 1 +
gfs2/include/Makefile.am | 2 +-
gfs2/include/logging.h | 36 ++++++++++++++++++++++++++++++++++++
gfs2/libgfs2/Makefile.am | 2 +-
gfs2/libgfs2/fs_geometry.c | 8 ++++----
gfs2/libgfs2/gfs2_log.c | 24 ------------------------
gfs2/libgfs2/libgfs2.h | 34 ----------------------------------
gfs2/mkfs/main_grow.c | 2 ++
25 files changed, 65 insertions(+), 64 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 15a16ef..87bec8c 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -30,6 +30,7 @@
#include <linux/types.h>
#include <linux/gfs2_ondisk.h>
+#include <logging.h>
#include "osi_list.h"
#include "copyright.cf"
#include "libgfs2.h"
@@ -112,6 +113,7 @@ uint64_t gfs2_jheightsize[GFS2_MAX_META_HEIGHT];
uint32_t gfs2_max_height;
uint32_t gfs2_max_jheight;
uint64_t jindex_addr = 0, rindex_addr = 0;
+int print_level = MSG_NOTICE;
/* ------------------------------------------------------------------------- */
/* This function is for libgfs's sake. */
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index c9f2d0a..ab7f86f 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -20,6 +20,7 @@
#include <linux/gfs2_ondisk.h>
#include <zlib.h>
+#include <logging.h>
#include "osi_list.h"
#include "gfs2hex.h"
#include "hexedit.h"
@@ -47,6 +48,7 @@ uint64_t last_reported_block, blks_saved, total_out, pct;
uint64_t journal_blocks[MAX_JOURNALS_SAVED];
uint64_t gfs1_journal_size = 0; /* in blocks */
int journals_found = 0;
+int print_level = MSG_NOTICE;
extern void read_superblock(void);
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index 54a8c5f..a052487 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -9,6 +9,7 @@
#include <libintl.h>
#define _(String) gettext(String)
+#include <logging.h>
#include "fsck.h"
#include "fs_recovery.h"
#include "libgfs2.h"
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 9ada7d2..f7ea45f 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -15,6 +15,7 @@
#define _(String) gettext(String)
+#include <logging.h>
#include "libgfs2.h"
#include "fsck.h"
#include "util.h"
diff --git a/gfs2/fsck/inode_hash.c b/gfs2/fsck/inode_hash.c
index aca5e61..eeb0a84 100644
--- a/gfs2/fsck/inode_hash.c
+++ b/gfs2/fsck/inode_hash.c
@@ -5,6 +5,7 @@
#include <libintl.h>
#include <string.h>
+#include <logging.h>
#include "libgfs2.h"
#include "osi_list.h"
#include "inode_hash.h"
diff --git a/gfs2/fsck/link.c b/gfs2/fsck/link.c
index 72fe7d5..9a958b4 100644
--- a/gfs2/fsck/link.c
+++ b/gfs2/fsck/link.c
@@ -8,6 +8,7 @@
#include <libintl.h>
#define _(String) gettext(String)
+#include <logging.h>
#include "libgfs2.h"
#include "fsck.h"
#include "inode_hash.h"
diff --git a/gfs2/fsck/lost_n_found.c b/gfs2/fsck/lost_n_found.c
index 919cb2f..9672c7a 100644
--- a/gfs2/fsck/lost_n_found.c
+++ b/gfs2/fsck/lost_n_found.c
@@ -10,6 +10,7 @@
#include <libintl.h>
#define _(String) gettext(String)
+#include <logging.h>
#include "fsck.h"
#include "libgfs2.h"
#include "lost_n_found.h"
diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
index b4ae57e..81b7dd5 100644
--- a/gfs2/fsck/main.c
+++ b/gfs2/fsck/main.c
@@ -14,6 +14,7 @@
#define _(String) gettext(String)
#include <syslog.h>
+#include <logging.h>
#include "copyright.cf"
#include "libgfs2.h"
#include "fsck.h"
@@ -39,6 +40,7 @@ struct osi_root inodetree = (struct osi_root) { NULL, };
int dups_found = 0, dups_found_first = 0;
struct gfs_sb *sbd1 = NULL;
int sb_fixed = 0;
+int print_level = MSG_NOTICE;
/* This function is for libgfs2's sake. */
void print_it(const char *label, const char *fmt, const char *fmt2, ...)
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 594fbfa..659af4e 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -12,6 +12,7 @@
#include <fcntl.h>
#define _(String) gettext(String)
+#include <logging.h>
#include "libgfs2.h"
#include "osi_tree.h"
#include "fsck.h"
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index df778ef..4f1b77a 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -20,6 +20,7 @@
#include <libintl.h>
#define _(String) gettext(String)
+#include <logging.h>
#include "libgfs2.h"
#include "fsck.h"
#include "inode_hash.h"
diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c
index e3da20a..f82f43b 100644
--- a/gfs2/fsck/pass1b.c
+++ b/gfs2/fsck/pass1b.c
@@ -8,6 +8,7 @@
#include <sys/stat.h>
#define _(String) gettext(String)
+#include <logging.h>
#include "libgfs2.h"
#include "fsck.h"
#include "osi_list.h"
diff --git a/gfs2/fsck/pass1c.c b/gfs2/fsck/pass1c.c
index b918de1..ce9ca96 100644
--- a/gfs2/fsck/pass1c.c
+++ b/gfs2/fsck/pass1c.c
@@ -7,6 +7,7 @@
#include <libintl.h>
#define _(String) gettext(String)
+#include <logging.h>
#include "libgfs2.h"
#include "fsck.h"
#include "util.h"
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index c8c047e..2474ccb 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -9,6 +9,7 @@
#include <libintl.h>
#define _(String) gettext(String)
+#include <logging.h>
#include "libgfs2.h"
#include "fsck.h"
#include "util.h"
diff --git a/gfs2/fsck/pass3.c b/gfs2/fsck/pass3.c
index 6448da3..9582b5b 100644
--- a/gfs2/fsck/pass3.c
+++ b/gfs2/fsck/pass3.c
@@ -8,6 +8,7 @@
#include <libintl.h>
#define _(String) gettext(String)
+#include <logging.h>
#include "libgfs2.h"
#include "osi_list.h"
#include "fsck.h"
diff --git a/gfs2/fsck/pass4.c b/gfs2/fsck/pass4.c
index 311b96b..7b3cb87 100644
--- a/gfs2/fsck/pass4.c
+++ b/gfs2/fsck/pass4.c
@@ -6,6 +6,7 @@
#include <libintl.h>
#define _(String) gettext(String)
+#include <logging.h>
#include "libgfs2.h"
#include "fsck.h"
#include "lost_n_found.h"
diff --git a/gfs2/fsck/pass5.c b/gfs2/fsck/pass5.c
index 49ab682..68b1373 100644
--- a/gfs2/fsck/pass5.c
+++ b/gfs2/fsck/pass5.c
@@ -7,6 +7,7 @@
#include <libintl.h>
#define _(String) gettext(String)
+#include <logging.h>
#include "libgfs2.h"
#include "fsck.h"
#include "util.h"
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index cb39541..0466dd8 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -10,6 +10,7 @@
#include <libintl.h>
#define _(String) gettext(String)
+#include <logging.h>
#include "libgfs2.h"
#include "osi_list.h"
#include "fsck.h"
diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c
index f8ccb3e..8b439a9 100644
--- a/gfs2/fsck/util.c
+++ b/gfs2/fsck/util.c
@@ -12,6 +12,7 @@
#include <ctype.h>
#define _(String) gettext(String)
+#include <logging.h>
#include "libgfs2.h"
#include "metawalk.h"
#include "util.h"
diff --git a/gfs2/include/Makefile.am b/gfs2/include/Makefile.am
index a017cb3..c755181 100644
--- a/gfs2/include/Makefile.am
+++ b/gfs2/include/Makefile.am
@@ -1,3 +1,3 @@
MAINTAINERCLEANFILES = Makefile.in
-noinst_HEADERS = osi_list.h osi_tree.h linux_endian.h
+noinst_HEADERS = osi_list.h osi_tree.h linux_endian.h logging.h
diff --git a/gfs2/include/logging.h b/gfs2/include/logging.h
new file mode 100644
index 0000000..18b5832
--- /dev/null
+++ b/gfs2/include/logging.h
@@ -0,0 +1,36 @@
+#ifndef __LOGGING_H__
+#define __LOGGING_H__
+
+extern int print_level;
+#define increase_verbosity() do { print_level++; } while(0)
+#define decrease_verbosity() do { print_level--; } while(0)
+
+#define MSG_DEBUG 7
+#define MSG_INFO 6
+#define MSG_NOTICE 5
+#define MSG_WARN 4
+#define MSG_ERROR 3
+#define MSG_CRITICAL 2
+#define MSG_NULL 1
+
+#define log_debug(format...) \
+ do { if (print_level >= MSG_DEBUG) { \
+ printf("(%s:%d) ", __FUNCTION__, __LINE__); \
+ printf(format); } } while(0)
+
+#define log_info(format...) \
+ do { if (print_level >= MSG_INFO) printf(format); } while(0)
+
+#define log_notice(format...) \
+ do { if (print_level >= MSG_NOTICE) printf(format); } while(0)
+
+#define log_warn(format...) \
+ do { if (print_level >= MSG_WARN) printf(format); } while(0)
+
+#define log_err(format...) \
+ do { if (print_level >= MSG_ERROR) fprintf(stderr, format); } while(0)
+
+#define log_crit(format...) \
+ do { if (print_level >= MSG_CRITICAL) fprintf(stderr, format); } while(0)
+
+#endif /* __LOGGING_H__ */
diff --git a/gfs2/libgfs2/Makefile.am b/gfs2/libgfs2/Makefile.am
index 2d197f0..4af27be 100644
--- a/gfs2/libgfs2/Makefile.am
+++ b/gfs2/libgfs2/Makefile.am
@@ -13,7 +13,7 @@ noinst_PROGRAMS = gfs2l
libgfs2_la_SOURCES = block_list.c fs_bits.c gfs1.c misc.c rgrp.c super.c \
buf.c fs_geometry.c gfs2_disk_hash.c ondisk.c config.c \
- device_geometry.c fs_ops.c gfs2_log.c recovery.c \
+ device_geometry.c fs_ops.c recovery.c \
structures.c meta.c lang.c parser.y lexer.l
libgfs2_la_CPPFLAGS = -D_FILE_OFFSET_BITS=64 \
diff --git a/gfs2/libgfs2/fs_geometry.c b/gfs2/libgfs2/fs_geometry.c
index 9c9085f..587ceb8 100644
--- a/gfs2/libgfs2/fs_geometry.c
+++ b/gfs2/libgfs2/fs_geometry.c
@@ -97,12 +97,12 @@ void compute_rgrp_layout(struct gfs2_sbd *sdp, struct osi_root *rgtree,
} else {
uint64_t old_length, new_chunk;
- log_info("Existing resource groups:\n");
+ printf("Existing resource groups:\n");
for (rgrp = 0, n = osi_first(rgtree); n; n = next, rgrp++) {
next = osi_next(n);
rl = (struct rgrp_tree *)n;
- log_info("%d: start: %" PRIu64 " (0x%"
+ printf("%d: start: %" PRIu64 " (0x%"
PRIx64 "), length = %"PRIu64" (0x%"
PRIx64 ")\n", rgrp + 1, rl->start, rl->start,
rl->length, rl->length);
@@ -118,7 +118,7 @@ void compute_rgrp_layout(struct gfs2_sbd *sdp, struct osi_root *rgtree,
}
if (rgrp < nrgrp)
- log_info("\nNew resource groups:\n");
+ printf("\nNew resource groups:\n");
for (; rgrp < nrgrp; rgrp++) {
if (rgrp) {
rgaddr = rlast->start + rlast->length;
@@ -131,7 +131,7 @@ void compute_rgrp_layout(struct gfs2_sbd *sdp, struct osi_root *rgtree,
(nrgrp - 1) * (dev->length / nrgrp);
}
rl->start = rgaddr;
- log_info("%d: start: %" PRIu64 " (0x%"
+ printf("%d: start: %" PRIu64 " (0x%"
PRIx64 "), length = %"PRIu64" (0x%"
PRIx64 ")\n", rgrp + 1, rl->start, rl->start,
rl->length, rl->length);
diff --git a/gfs2/libgfs2/gfs2_log.c b/gfs2/libgfs2/gfs2_log.c
deleted file mode 100644
index da5f489..0000000
--- a/gfs2/libgfs2/gfs2_log.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "clusterautoconfig.h"
-
-#include <stdio.h>
-#include <stdarg.h>
-#include <ctype.h>
-#include <sys/select.h>
-#include <signal.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "libgfs2.h"
-
-int print_level = MSG_NOTICE;
-
-void increase_verbosity(void)
-{
- print_level++;
-}
-
-void decrease_verbosity(void)
-{
- print_level--;
-}
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index b269357..041e5fd 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -671,40 +671,6 @@ extern void gfs_jindex_in(struct gfs_jindex *jindex, char *buf);
extern void gfs_rgrp_in(struct gfs_rgrp *rg, struct gfs2_buffer_head *bh);
extern void gfs_rgrp_out(struct gfs_rgrp *rg, struct gfs2_buffer_head *bh);
-/* gfs2_log.c */
-
-extern int print_level;
-
-#define MSG_DEBUG 7
-#define MSG_INFO 6
-#define MSG_NOTICE 5
-#define MSG_WARN 4
-#define MSG_ERROR 3
-#define MSG_CRITICAL 2
-#define MSG_NULL 1
-
-#define log_debug(format...) \
- do { if (print_level >= MSG_DEBUG) { \
- printf("(%s:%d) ", __FUNCTION__, __LINE__); \
- printf(format); } } while(0)
-
-#define log_info(format...) \
- do { if (print_level >= MSG_INFO) printf(format); } while(0)
-
-#define log_notice(format...) \
- do { if (print_level >= MSG_NOTICE) printf(format); } while(0)
-
-#define log_warn(format...) \
- do { if (print_level >= MSG_WARN) printf(format); } while(0)
-
-#define log_err(format...) \
- do { if (print_level >= MSG_ERROR) fprintf(stderr, format); } while(0)
-
-#define log_crit(format...) \
- do { if (print_level >= MSG_CRITICAL) fprintf(stderr, format); } while(0)
-
-extern void increase_verbosity(void);
-extern void decrease_verbosity(void);
/* misc.c */
extern int metafs_interrupted;
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index 7e005e9..5da809a 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -23,6 +23,7 @@
#include <libintl.h>
#define _(String) gettext(String)
+#include <logging.h>
#include "libgfs2.h"
#include "gfs2_mkfs.h"
@@ -33,6 +34,7 @@ static uint64_t override_device_size = 0;
static int test = 0;
static uint64_t fssize = 0, fsgrowth;
static unsigned int rgsize = 0;
+int print_level = MSG_NOTICE;
extern int create_new_inode(struct gfs2_sbd *sdp);
extern int rename2system(struct gfs2_sbd *sdp, char *new_dir, char *new_name);
9 years, 12 months