gfs2-utils: master - gfs2_edit savemeta: Don't read rgrps twice
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=bb13054e...
Commit: bb13054ee14016c7f684059978d664ab1a6105c7
Parent: 734893a88b91e8ed87ca20a084bdbbf48a2125f8
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Feb 25 17:01:33 2015 -0600
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Thu Feb 26 16:19:09 2015 +0000
gfs2_edit savemeta: Don't read rgrps twice
By the time savemeta() is called the rindex has already been read into
memory, and before savemeta() processes each resource group it calls
gfs2_rgrp_read() to read in the rgrp header. It frees the rgrp once it's
done with it.
Strangely, before processing the resource groups, savemeta() reads the
superblock a second time and calls ri_update() which reads the rindex
again, as well as reading in every rgrp header to be kept in memory for
the duration. This caused high memory usage and a noticeable performance
reduction when saving metadata of large file systems.
To solve these problems, this patch removes the code which re-reads the
superblock, rindex and the rgrps. The code which reads the rindex has
been reorganised for clarity and the sbd.fssize field is now set
properly at that point.
With this patch, using a large fs, I'm seeing improvements similar to:
Before: 43:36.12elapsed 10822268maxresident k
After: 28:44.67elapsed 226980maxresident k
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/hexedit.c | 15 +++++++++++-
gfs2/edit/savemeta.c | 58 ++++++-------------------------------------------
tests/edit.at | 4 +-
3 files changed, 22 insertions(+), 55 deletions(-)
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index dd4b625..4df1b9f 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -966,8 +966,6 @@ static int block_has_extended_info(void)
/* ------------------------------------------------------------------------ */
static void read_superblock(int fd)
{
- int count, sane;
-
sbd1 = (struct gfs_sb *)&sbd.sd_sb;
ioctl(fd, BLKFLSBUF, 0);
memset(&sbd, 0, sizeof(struct gfs2_sbd));
@@ -1033,9 +1031,20 @@ static void read_superblock(int fd)
gfs2_lookupi(sbd.master_dir, "rindex", 6, &sbd.md.riinode);
}
}
+}
+
+static int read_rindex(void)
+{
+ struct gfs2_rindex *ri;
+ int count, sane;
+
sbd.fssize = sbd.device.length;
if (sbd.md.riinode) /* If we found the rindex */
rindex_read(&sbd, 0, &count, &sane);
+
+ ri = &((struct rgrp_tree *)osi_last(&sbd.rgtree))->ri;
+ sbd.fssize = ri->ri_data0 + ri->ri_data;
+ return 0;
}
/* ------------------------------------------------------------------------ */
@@ -2539,6 +2548,8 @@ int main(int argc, char *argv[])
max_block = lseek(fd, 0, SEEK_END) / sbd.bsize;
read_superblock(fd);
+ if (read_rindex())
+ exit(-1);
max_block = lseek(fd, 0, SEEK_END) / sbd.bsize;
if (sbd.gfs1)
edit_row[GFS2_MODE]++;
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 5d30d28..b68b0ff 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -721,75 +721,32 @@ static int check_header(struct savemeta_header *smh)
void savemeta(char *out_fn, int saveoption, int gziplevel)
{
- int rgcount;
uint64_t jindex_block;
struct gfs2_buffer_head *lbh;
struct metafd mfd;
- int sane;
- struct osi_node *n, *next = NULL;
+ struct osi_node *n;
int err = 0;
sbd.md.journals = 1;
mfd = savemetaopen(out_fn, gziplevel);
- lseek(sbd.device_fd, 0, SEEK_SET);
blks_saved = 0;
- if (!sbd.gfs1)
- sbd.bsize = GFS2_DEFAULT_BSIZE;
- if (lgfs2_get_dev_info(sbd.device_fd, &sbd.dinfo)) {
- perror(device);
- exit(-1);
- }
- fix_device_geometry(&sbd);
- sbd.rgtree.osi_node = NULL;
- if (!sbd.gfs1)
- sbd.sd_sb.sb_bsize = GFS2_DEFAULT_BSIZE;
- if (compute_constants(&sbd)) {
- fprintf(stderr, "Bad constants (1)\n");
- exit(-1);
- }
- if (read_sb(&sbd) < 0) {
- fprintf(stderr, "Unable to read superblock.\n");
- exit(-1);
- }
if (sbd.gfs1)
sbd.bsize = sbd.sd_sb.sb_bsize;
- printf("There are %llu blocks of %u bytes in the destination "
- "device.\n", (unsigned long long)sbd.fssize, sbd.bsize);
- if (sbd.gfs1) {
- sbd.md.riinode = lgfs2_inode_read(&sbd, sbd1->sb_rindex_di.no_addr);
- if (sbd.md.riinode == NULL) {
- fprintf(stderr, "Unable to read rindex: %s.\n", strerror(errno));
- exit(-1);
- }
+ printf("There are %llu blocks of %u bytes in the filesystem.\n",
+ (unsigned long long)sbd.fssize, sbd.bsize);
+ if (sbd.gfs1)
jindex_block = sbd1->sb_jindex_di.no_addr;
- } else {
- sbd.master_dir = lgfs2_inode_read(&sbd,
- sbd.sd_sb.sb_master_dir.no_addr);
- if (sbd.master_dir == NULL) {
- fprintf(stderr, "Unable to read master: %s.\n", strerror(errno));
- exit(-1);
- }
-
- gfs2_lookupi(sbd.master_dir, "rindex", 6, &sbd.md.riinode);
+ else
jindex_block = masterblock("jindex");
- }
lbh = bread(&sbd, jindex_block);
gfs2_dinode_in(&di, lbh);
if (!sbd.gfs1)
do_dinode_extended(&di, lbh);
brelse(lbh);
- printf("Reading resource groups...");
- fflush(stdout);
- if (sbd.gfs1)
- gfs1_ri_update(&sbd, 0, &rgcount, 0);
- else
- ri_update(&sbd, 0, &rgcount, &sane);
- printf("Done. File system size: %s\n\n", anthropomorphize(sbd.fssize * sbd.bsize));
- fflush(stdout);
-
+ printf("Filesystem size: %s\n", anthropomorphize(sbd.fssize * sbd.bsize));
get_journal_inode_blocks();
/* Write the savemeta file header */
@@ -818,10 +775,9 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
}
}
/* Walk through the resource groups saving everything within */
- for (n = osi_first(&sbd.rgtree); n; n = next) {
+ for (n = osi_first(&sbd.rgtree); n; n = osi_next(n)) {
struct rgrp_tree *rgd;
- next = osi_next(n);
rgd = (struct rgrp_tree *)n;
if (gfs2_rgrp_read(&sbd, rgd))
continue;
diff --git a/tests/edit.at b/tests/edit.at
index e3f02e6..3bd4163 100644
--- a/tests/edit.at
+++ b/tests/edit.at
@@ -6,8 +6,8 @@ AT_KEYWORDS(gfs2_edit edit)
GFS_TGT_REGEN
AT_CHECK([$GFS_MKFS -p lock_nolock $GFS_TGT $(($(gfs_max_blocks 4096)/2))], 0, [ignore], [ignore])
AT_CHECK([gfs2_edit savemeta $GFS_TGT test.meta > savemeta.log], 0, [ignore], [ignore])
-AT_CHECK([head -2 savemeta.log], 0, [There are 2621440 blocks of 4096 bytes in the destination device.
-Reading resource groups...Done. File system size: 4.1023GB
+AT_CHECK([head -2 savemeta.log], 0, [There are 1310718 blocks of 4096 bytes in the filesystem.
+Filesystem size: 4.1023GB
], [ignore])
GFS_TGT_REGEN
AT_CHECK([gfs2_edit restoremeta test.meta $GFS_TGT], 0, [ignore], [ignore])
9 years, 1 month
gfs2-utils: master - fsck.gfs2: Fix coverity error in pass4.c
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=734893a8...
Commit: 734893a88b91e8ed87ca20a084bdbbf48a2125f8
Parent: 60c26b020f55e079add1f461897b8f8d36b4e769
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Thu Feb 26 09:49:07 2015 -0600
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Thu Feb 26 09:49:07 2015 -0600
fsck.gfs2: Fix coverity error in pass4.c
This simple patch checks for lf_dip (the lost+found inode) being NULL,
and if it is, returns at the end of function scan_inode_list. This is
fixing a false positive spotted by coverity, but it makes the code a
bit more intuitive.
---
gfs2/fsck/pass4.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/gfs2/fsck/pass4.c b/gfs2/fsck/pass4.c
index f307782..850a2fe 100644
--- a/gfs2/fsck/pass4.c
+++ b/gfs2/fsck/pass4.c
@@ -177,7 +177,9 @@ static int scan_inode_list(struct gfs2_sbd *sdp) {
(unsigned long long)ii->di_num.no_addr, ii->di_nlink);
} /* osi_list_foreach(tmp, list) */
- if (lf_dip && astate_changed(lf_dip, &lf_as))
+ if (lf_dip == NULL)
+ return 0;
+ if (astate_changed(lf_dip, &lf_as))
reprocess_inode(lf_dip, "lost+found");
if (lf_addition) {
9 years, 1 month
cluster: RHEL6 - logt: fix race that could cause a coredump when files are reopened
by Christine Caulfield
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=4c38b8e47f0...
Commit: 4c38b8e47f03c54eee563a11446518c147fa9ec1
Parent: 0031db202e1b6584c5069f7f3139c1303257a3aa
Author: Christine Caulfield <ccaulfie(a)redhat.com>
AuthorDate: Thu Feb 26 10:41:07 2015 +0000
Committer: Christine Caulfield <ccaulfie(a)redhat.com>
CommitterDate: Thu Feb 26 10:41:07 2015 +0000
logt: fix race that could cause a coredump when files are reopened
Open a second fp in the main thread which is then swapped and closed
in the actual log thread. This prevents a closed fp being used if a
log m1133724essage arrives while the a logfile is being closed and
reopened.
rhbz#1133724
Signed-off-by: Christine Caulfield <ccaulfie(a)redhat.com>
---
common/liblogthread/liblogthread.c | 36 +++++++++++++++++++++++++++---------
1 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/common/liblogthread/liblogthread.c b/common/liblogthread/liblogthread.c
index ba96a2a..8c1f422 100644
--- a/common/liblogthread/liblogthread.c
+++ b/common/liblogthread/liblogthread.c
@@ -38,6 +38,7 @@ static int logt_logfile_priority;
static char logt_name[PATH_MAX];
static char logt_logfile[PATH_MAX];
static FILE *logt_logfile_fp;
+static FILE *new_logt_logfile_fp;
static char *_time(time_t *t)
{
@@ -93,6 +94,13 @@ static void *thread_fn(void *arg)
prev_dropped = dropped;
dropped = 0;
+
+ if (new_logt_logfile_fp) {
+ fclose(logt_logfile_fp);
+ logt_logfile_fp = new_logt_logfile_fp;
+ new_logt_logfile_fp = NULL;
+ }
+
pthread_mutex_unlock(&mutex);
if (prev_dropped) {
@@ -170,20 +178,30 @@ static void _conf(const char *name, int mode, int syslog_facility,
strncpy(logt_logfile, logfile, PATH_MAX);
if (logt_mode & LOG_MODE_OUTPUT_FILE && logt_logfile[0]) {
- if (logt_logfile_fp) {
- fclose(logt_logfile_fp);
- logt_logfile_fp = NULL;
- }
- logt_logfile_fp = fopen(logt_logfile, "a+");
- if (logt_logfile_fp != NULL) {
- fd = fileno(logt_logfile_fp);
- fcntl(fd, F_SETFD, fcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
- }
+ /* Don't close the existing fp in this thread, let the main logthread do it later */
+ if (!logt_logfile_fp) {
+ logt_logfile_fp = fopen(logt_logfile, "a+");
+ if (logt_logfile_fp != NULL) {
+ fd = fileno(logt_logfile_fp);
+ fcntl(fd, F_SETFD, fcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
+ }
+ }
+ else {
+ new_logt_logfile_fp = fopen(logt_logfile, "a+");
+ if (new_logt_logfile_fp != NULL) {
+ fd = fileno(new_logt_logfile_fp);
+ fcntl(fd, F_SETFD, fcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
+ }
+ }
} else {
if (logt_logfile_fp) {
fclose(logt_logfile_fp);
logt_logfile_fp = NULL;
}
+ if (new_logt_logfile_fp) {
+ fclose(new_logt_logfile_fp);
+ new_logt_logfile_fp = NULL;
+ }
}
if (logt_mode & LOG_MODE_OUTPUT_SYSLOG) {
9 years, 1 month
fence-agents: master - fencing_snmp: Path to snmp(walk|get|set) can be set at runtime
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=ed573e...
Commit: ed573e384055fe7f80e4bff393fcc1f091127ee3
Parent: 0967113e52b7a4ad1aa67c4bc0bd2ca40a760d03
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Thu Feb 26 11:28:07 2015 +0100
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Thu Feb 26 11:28:07 2015 +0100
fencing_snmp: Path to snmp(walk|get|set) can be set at runtime
---
configure.ac | 9 ++-----
fence/agents/lib/fencing.py.py | 27 +++++++++++++++++++++++++-
fence/agents/lib/fencing_snmp.py.py | 8 +++---
make/fencebuild.mk | 4 ++-
tests/data/metadata/fence_apc_snmp.xml | 15 ++++++++++++++
tests/data/metadata/fence_cisco_mds.xml | 15 ++++++++++++++
tests/data/metadata/fence_eaton_snmp.xml | 15 ++++++++++++++
tests/data/metadata/fence_emerson.xml | 15 ++++++++++++++
tests/data/metadata/fence_ibmblade.xml | 15 ++++++++++++++
tests/data/metadata/fence_ifmib.xml | 15 ++++++++++++++
tests/data/metadata/fence_intelmodular.xml | 15 ++++++++++++++
tests/data/metadata/fence_ipdu.xml | 15 ++++++++++++++
tests/data/metadata/fence_tripplite_snmp.xml | 15 ++++++++++++++
13 files changed, 171 insertions(+), 12 deletions(-)
diff --git a/configure.ac b/configure.ac
index cbf9623..ce2ca46 100644
--- a/configure.ac
+++ b/configure.ac
@@ -108,12 +108,6 @@ AC_ARG_WITH([fenceagentslibdir],
[ FENCEAGENTSLIBDIR="$withval" ],
[ FENCEAGENTSLIBDIR="${datadir}/fence" ])
-AC_ARG_WITH([snmpbin],
- [ --with-snmpbin=PATH
- path to snmp binaries (snmpwalk/get). ],
- [ SNMPBIN="$withval" ],
- [ SNMPBIN="${bindir}" ])
-
AC_ARG_WITH([default-config-dir],
[ --with-default-config-dir=DIR
cluster config directory. ],
@@ -177,6 +171,9 @@ AC_PATH_PROG([SSH_PATH], [ssh], [/usr/bin/ssh])
AC_PATH_PROG([TELNET_PATH], [telnet], [/usr/bin/telnet])
AC_PATH_PROG([MPATH_PATH], [mpathpersist], [/usr/sbin/mpathpersist])
AC_PATH_PROG([SUDO_PATH], [sudo], [/usr/bin/sudo])
+AC_PATH_PROG([SNMPWALK_PATH], [snmpwalk], [/usr/bin/snmpwalk])
+AC_PATH_PROG([SNMPSET_PATH], [snmpset], [/usr/bin/snmpset])
+AC_PATH_PROG([SNMPGET_PATH], [snmpget], [/usr/bin/snmpget])
## do subst
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 4e68879..1b87f21 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -418,6 +418,30 @@ all_opt = {
"shortdesc" : "Path to sudo binary",
"default" : "@SUDO_PATH@",
"order": 300},
+ "snmpwalk_path" : {
+ "getopt" : ":",
+ "longopt" : "snmpwalk-path",
+ "help" : "--snmpwalk-path=[path] Path to snmpwalk binary",
+ "required" : "0",
+ "shortdesc" : "Path to snmpwalk binary",
+ "default" : "@SNMPWALK_PATH@",
+ "order" : 300},
+ "snmpset_path" : {
+ "getopt" : ":",
+ "longopt" : "snmpset-path",
+ "help" : "--snmpset-path=[path] Path to snmpset binary",
+ "required" : "0",
+ "shortdesc" : "Path to snmpset binary",
+ "default" : "@SNMPSET_PATH@",
+ "order" : 300},
+ "snmpget_path" : {
+ "getopt" : ":",
+ "longopt" : "snmpget-path",
+ "help" : "--snmpget-path=[path] Path to snmpget binary",
+ "required" : "0",
+ "shortdesc" : "Path to snmpget binary",
+ "default" : "@SNMPGET_PATH@",
+ "order" : 300},
"snmp": {
"getopt" : "",
"help" : "",
@@ -440,7 +464,8 @@ DEPENDENCY_OPT = {
"port" : ["separator"],
"ssl" : ["ssl_secure", "ssl_insecure", "gnutlscli_path"],
"snmp" : ["snmp_auth_prot", "snmp_sec_level", "snmp_priv_prot", \
- "snmp_priv_passwd", "snmp_priv_passwd_script", "community"]
+ "snmp_priv_passwd", "snmp_priv_passwd_script", "community", \
+ "snmpset_path", "snmpget_path", "snmpwalk_path"]
}
class fspawn(pexpect.spawn):
diff --git a/fence/agents/lib/fencing_snmp.py.py b/fence/agents/lib/fencing_snmp.py.py
index 5c013d8..88700c4 100644
--- a/fence/agents/lib/fencing_snmp.py.py
+++ b/fence/agents/lib/fencing_snmp.py.py
@@ -51,7 +51,7 @@ class FencingSnmp:
exec(val[1])
def prepare_cmd(self, command):
- cmd = "@SNMPBIN@/%s -m '' -Oeqn "% (command)
+ cmd = "%s -m '' -Oeqn "% (command)
self.complete_missed_params()
@@ -105,7 +105,7 @@ class FencingSnmp:
return res_output
def get(self, oid, additional_timemout=0):
- cmd = "%s '%s'"% (self.prepare_cmd("snmpget"), self.quote_for_run(oid))
+ cmd = "%s '%s'"% (self.prepare_cmd(self.options["--snmpget-path"]), self.quote_for_run(oid))
output = self.run_command(cmd, additional_timemout).splitlines()
@@ -121,13 +121,13 @@ class FencingSnmp:
type_of_value = item[1]
break
- cmd = "%s '%s' %s '%s'" % (self.prepare_cmd("snmpset"),
+ cmd = "%s '%s' %s '%s'" % (self.prepare_cmd(self.options["--snmpset-path"]),
self.quote_for_run(oid), type_of_value, self.quote_for_run(str(value)))
self.run_command(cmd, additional_timemout)
def walk(self, oid, additional_timemout=0):
- cmd = "%s '%s'"% (self.prepare_cmd("snmpwalk"), self.quote_for_run(oid))
+ cmd = "%s '%s'"% (self.prepare_cmd(self.options["--snmpwalk-path"]), self.quote_for_run(oid))
output = self.run_command(cmd, additional_timemout).splitlines()
diff --git a/make/fencebuild.mk b/make/fencebuild.mk
index 874ebeb..3a035e9 100644
--- a/make/fencebuild.mk
+++ b/make/fencebuild.mk
@@ -5,7 +5,6 @@ $(TARGET): $(SRC)
$(abs_srcdir) $@ | \
sed \
-e 's#@''FENCEAGENTSLIBDIR@#${FENCEAGENTSLIBDIR}#g' \
- -e 's#@''SNMPBIN@#${SNMPBIN}#g' \
-e 's#@''LOGDIR@#${LOGDIR}#g' \
-e 's#@''SBINDIR@#${sbindir}#g' \
-e 's#@''LIBEXECDIR@#${libexecdir}#g' \
@@ -22,6 +21,9 @@ $(TARGET): $(SRC)
-e 's#@''MPATH_PATH@#${MPATH_PATH}#g' \
-e 's#@''STORE_PATH@#${CLUSTERVARRUN}#g' \
-e 's#@''SUDO_PATH@#${SUDO_PATH}#g' \
+ -e 's#@''SNMPWALK_PATH@#${SNMPWALK_PATH}#g' \
+ -e 's#@''SNMPSET_PATH@#${SNMPSET_PATH}#g' \
+ -e 's#@''SNMPGET_PATH@#${SNMPGET_PATH}#g' \
> $@
if [ 0 -eq `echo "$(SRC)" | grep fence_ &> /dev/null; echo $$?` ]; then \
diff --git a/tests/data/metadata/fence_apc_snmp.xml b/tests/data/metadata/fence_apc_snmp.xml
index d09f851..3601194 100644
--- a/tests/data/metadata/fence_apc_snmp.xml
+++ b/tests/data/metadata/fence_apc_snmp.xml
@@ -152,6 +152,21 @@
<content type="string" default="1" />
<shortdesc lang="en">Count of attempts to retry power on</shortdesc>
</parameter>
+ <parameter name="snmpget_path" unique="0" required="0">
+ <getopt mixed="--snmpget-path=[path]" />
+ <content type="string" default="/usr/bin/snmpget" />
+ <shortdesc lang="en">Path to snmpget binary</shortdesc>
+ </parameter>
+ <parameter name="snmpset_path" unique="0" required="0">
+ <getopt mixed="--snmpset-path=[path]" />
+ <content type="string" default="/usr/bin/snmpset" />
+ <shortdesc lang="en">Path to snmpset binary</shortdesc>
+ </parameter>
+ <parameter name="snmpwalk_path" unique="0" required="0">
+ <getopt mixed="--snmpwalk-path=[path]" />
+ <content type="string" default="/usr/bin/snmpwalk" />
+ <shortdesc lang="en">Path to snmpwalk binary</shortdesc>
+ </parameter>
</parameters>
<actions>
<action name="on" automatic="0"/>
diff --git a/tests/data/metadata/fence_cisco_mds.xml b/tests/data/metadata/fence_cisco_mds.xml
index 4adbf22..e5cfc4a 100644
--- a/tests/data/metadata/fence_cisco_mds.xml
+++ b/tests/data/metadata/fence_cisco_mds.xml
@@ -152,6 +152,21 @@
<content type="string" default="1" />
<shortdesc lang="en">Count of attempts to retry power on</shortdesc>
</parameter>
+ <parameter name="snmpget_path" unique="0" required="0">
+ <getopt mixed="--snmpget-path=[path]" />
+ <content type="string" default="/usr/bin/snmpget" />
+ <shortdesc lang="en">Path to snmpget binary</shortdesc>
+ </parameter>
+ <parameter name="snmpset_path" unique="0" required="0">
+ <getopt mixed="--snmpset-path=[path]" />
+ <content type="string" default="/usr/bin/snmpset" />
+ <shortdesc lang="en">Path to snmpset binary</shortdesc>
+ </parameter>
+ <parameter name="snmpwalk_path" unique="0" required="0">
+ <getopt mixed="--snmpwalk-path=[path]" />
+ <content type="string" default="/usr/bin/snmpwalk" />
+ <shortdesc lang="en">Path to snmpwalk binary</shortdesc>
+ </parameter>
</parameters>
<actions>
<action name="on" automatic="1"/>
diff --git a/tests/data/metadata/fence_eaton_snmp.xml b/tests/data/metadata/fence_eaton_snmp.xml
index bfe05aa..cf1f6dd 100644
--- a/tests/data/metadata/fence_eaton_snmp.xml
+++ b/tests/data/metadata/fence_eaton_snmp.xml
@@ -152,6 +152,21 @@
<content type="string" default="1" />
<shortdesc lang="en">Count of attempts to retry power on</shortdesc>
</parameter>
+ <parameter name="snmpget_path" unique="0" required="0">
+ <getopt mixed="--snmpget-path=[path]" />
+ <content type="string" default="/usr/bin/snmpget" />
+ <shortdesc lang="en">Path to snmpget binary</shortdesc>
+ </parameter>
+ <parameter name="snmpset_path" unique="0" required="0">
+ <getopt mixed="--snmpset-path=[path]" />
+ <content type="string" default="/usr/bin/snmpset" />
+ <shortdesc lang="en">Path to snmpset binary</shortdesc>
+ </parameter>
+ <parameter name="snmpwalk_path" unique="0" required="0">
+ <getopt mixed="--snmpwalk-path=[path]" />
+ <content type="string" default="/usr/bin/snmpwalk" />
+ <shortdesc lang="en">Path to snmpwalk binary</shortdesc>
+ </parameter>
</parameters>
<actions>
<action name="on" automatic="0"/>
diff --git a/tests/data/metadata/fence_emerson.xml b/tests/data/metadata/fence_emerson.xml
index 1aa5474..588d1fa 100644
--- a/tests/data/metadata/fence_emerson.xml
+++ b/tests/data/metadata/fence_emerson.xml
@@ -152,6 +152,21 @@
<content type="string" default="1" />
<shortdesc lang="en">Count of attempts to retry power on</shortdesc>
</parameter>
+ <parameter name="snmpget_path" unique="0" required="0">
+ <getopt mixed="--snmpget-path=[path]" />
+ <content type="string" default="/usr/bin/snmpget" />
+ <shortdesc lang="en">Path to snmpget binary</shortdesc>
+ </parameter>
+ <parameter name="snmpset_path" unique="0" required="0">
+ <getopt mixed="--snmpset-path=[path]" />
+ <content type="string" default="/usr/bin/snmpset" />
+ <shortdesc lang="en">Path to snmpset binary</shortdesc>
+ </parameter>
+ <parameter name="snmpwalk_path" unique="0" required="0">
+ <getopt mixed="--snmpwalk-path=[path]" />
+ <content type="string" default="/usr/bin/snmpwalk" />
+ <shortdesc lang="en">Path to snmpwalk binary</shortdesc>
+ </parameter>
</parameters>
<actions>
<action name="on" automatic="0"/>
diff --git a/tests/data/metadata/fence_ibmblade.xml b/tests/data/metadata/fence_ibmblade.xml
index 42952da..f299e7a 100644
--- a/tests/data/metadata/fence_ibmblade.xml
+++ b/tests/data/metadata/fence_ibmblade.xml
@@ -152,6 +152,21 @@
<content type="string" default="1" />
<shortdesc lang="en">Count of attempts to retry power on</shortdesc>
</parameter>
+ <parameter name="snmpget_path" unique="0" required="0">
+ <getopt mixed="--snmpget-path=[path]" />
+ <content type="string" default="/usr/bin/snmpget" />
+ <shortdesc lang="en">Path to snmpget binary</shortdesc>
+ </parameter>
+ <parameter name="snmpset_path" unique="0" required="0">
+ <getopt mixed="--snmpset-path=[path]" />
+ <content type="string" default="/usr/bin/snmpset" />
+ <shortdesc lang="en">Path to snmpset binary</shortdesc>
+ </parameter>
+ <parameter name="snmpwalk_path" unique="0" required="0">
+ <getopt mixed="--snmpwalk-path=[path]" />
+ <content type="string" default="/usr/bin/snmpwalk" />
+ <shortdesc lang="en">Path to snmpwalk binary</shortdesc>
+ </parameter>
</parameters>
<actions>
<action name="on" automatic="0"/>
diff --git a/tests/data/metadata/fence_ifmib.xml b/tests/data/metadata/fence_ifmib.xml
index 523c510..ea05195 100644
--- a/tests/data/metadata/fence_ifmib.xml
+++ b/tests/data/metadata/fence_ifmib.xml
@@ -154,6 +154,21 @@ It was written with managed ethernet switches in mind, in order to fence iSCSI S
<content type="string" default="1" />
<shortdesc lang="en">Count of attempts to retry power on</shortdesc>
</parameter>
+ <parameter name="snmpget_path" unique="0" required="0">
+ <getopt mixed="--snmpget-path=[path]" />
+ <content type="string" default="/usr/bin/snmpget" />
+ <shortdesc lang="en">Path to snmpget binary</shortdesc>
+ </parameter>
+ <parameter name="snmpset_path" unique="0" required="0">
+ <getopt mixed="--snmpset-path=[path]" />
+ <content type="string" default="/usr/bin/snmpset" />
+ <shortdesc lang="en">Path to snmpset binary</shortdesc>
+ </parameter>
+ <parameter name="snmpwalk_path" unique="0" required="0">
+ <getopt mixed="--snmpwalk-path=[path]" />
+ <content type="string" default="/usr/bin/snmpwalk" />
+ <shortdesc lang="en">Path to snmpwalk binary</shortdesc>
+ </parameter>
</parameters>
<actions>
<action name="on" automatic="1"/>
diff --git a/tests/data/metadata/fence_intelmodular.xml b/tests/data/metadata/fence_intelmodular.xml
index 36b7284..2bd92f1 100644
--- a/tests/data/metadata/fence_intelmodular.xml
+++ b/tests/data/metadata/fence_intelmodular.xml
@@ -154,6 +154,21 @@ Note: Since firmware update version 2.7, SNMP v2 write support is removed, and r
<content type="string" default="1" />
<shortdesc lang="en">Count of attempts to retry power on</shortdesc>
</parameter>
+ <parameter name="snmpget_path" unique="0" required="0">
+ <getopt mixed="--snmpget-path=[path]" />
+ <content type="string" default="/usr/bin/snmpget" />
+ <shortdesc lang="en">Path to snmpget binary</shortdesc>
+ </parameter>
+ <parameter name="snmpset_path" unique="0" required="0">
+ <getopt mixed="--snmpset-path=[path]" />
+ <content type="string" default="/usr/bin/snmpset" />
+ <shortdesc lang="en">Path to snmpset binary</shortdesc>
+ </parameter>
+ <parameter name="snmpwalk_path" unique="0" required="0">
+ <getopt mixed="--snmpwalk-path=[path]" />
+ <content type="string" default="/usr/bin/snmpwalk" />
+ <shortdesc lang="en">Path to snmpwalk binary</shortdesc>
+ </parameter>
</parameters>
<actions>
<action name="on" automatic="0"/>
diff --git a/tests/data/metadata/fence_ipdu.xml b/tests/data/metadata/fence_ipdu.xml
index 476e861..b6972e6 100644
--- a/tests/data/metadata/fence_ipdu.xml
+++ b/tests/data/metadata/fence_ipdu.xml
@@ -152,6 +152,21 @@
<content type="string" default="1" />
<shortdesc lang="en">Count of attempts to retry power on</shortdesc>
</parameter>
+ <parameter name="snmpget_path" unique="0" required="0">
+ <getopt mixed="--snmpget-path=[path]" />
+ <content type="string" default="/usr/bin/snmpget" />
+ <shortdesc lang="en">Path to snmpget binary</shortdesc>
+ </parameter>
+ <parameter name="snmpset_path" unique="0" required="0">
+ <getopt mixed="--snmpset-path=[path]" />
+ <content type="string" default="/usr/bin/snmpset" />
+ <shortdesc lang="en">Path to snmpset binary</shortdesc>
+ </parameter>
+ <parameter name="snmpwalk_path" unique="0" required="0">
+ <getopt mixed="--snmpwalk-path=[path]" />
+ <content type="string" default="/usr/bin/snmpwalk" />
+ <shortdesc lang="en">Path to snmpwalk binary</shortdesc>
+ </parameter>
</parameters>
<actions>
<action name="on" automatic="0"/>
diff --git a/tests/data/metadata/fence_tripplite_snmp.xml b/tests/data/metadata/fence_tripplite_snmp.xml
index eb568d9..bc66dfd 100644
--- a/tests/data/metadata/fence_tripplite_snmp.xml
+++ b/tests/data/metadata/fence_tripplite_snmp.xml
@@ -152,6 +152,21 @@
<content type="string" default="1" />
<shortdesc lang="en">Count of attempts to retry power on</shortdesc>
</parameter>
+ <parameter name="snmpget_path" unique="0" required="0">
+ <getopt mixed="--snmpget-path=[path]" />
+ <content type="string" default="/usr/bin/snmpget" />
+ <shortdesc lang="en">Path to snmpget binary</shortdesc>
+ </parameter>
+ <parameter name="snmpset_path" unique="0" required="0">
+ <getopt mixed="--snmpset-path=[path]" />
+ <content type="string" default="/usr/bin/snmpset" />
+ <shortdesc lang="en">Path to snmpset binary</shortdesc>
+ </parameter>
+ <parameter name="snmpwalk_path" unique="0" required="0">
+ <getopt mixed="--snmpwalk-path=[path]" />
+ <content type="string" default="/usr/bin/snmpwalk" />
+ <shortdesc lang="en">Path to snmpwalk binary</shortdesc>
+ </parameter>
</parameters>
<actions>
<action name="on" automatic="0"/>
9 years, 1 month
fence-agents: master - fencing_snmp: Replace device_opt "community" with "snmp"
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=096711...
Commit: 0967113e52b7a4ad1aa67c4bc0bd2ca40a760d03
Parent: ca6c5f27f828a1d99deeb6724b279fa0f29210a0
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Thu Feb 26 10:52:03 2015 +0100
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Thu Feb 26 10:52:03 2015 +0100
fencing_snmp: Replace device_opt "community" with "snmp"
Previously, all dependencies of SNMP fence agents were dependant on "community". What
is quite confusing. This update makes all original depencies + "community" be dependant
on "snmp".
---
fence/agents/apc_snmp/fence_apc_snmp.py | 2 +-
fence/agents/cisco_mds/fence_cisco_mds.py | 2 +-
fence/agents/eaton_snmp/fence_eaton_snmp.py | 2 +-
fence/agents/emerson/fence_emerson.py | 2 +-
fence/agents/ibmblade/fence_ibmblade.py | 2 +-
fence/agents/ifmib/fence_ifmib.py | 2 +-
fence/agents/intelmodular/fence_intelmodular.py | 2 +-
fence/agents/ipdu/fence_ipdu.py | 2 +-
fence/agents/lib/fencing.py.py | 8 ++++++--
9 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/fence/agents/apc_snmp/fence_apc_snmp.py b/fence/agents/apc_snmp/fence_apc_snmp.py
index 878ac0a..8bb3d48 100644
--- a/fence/agents/apc_snmp/fence_apc_snmp.py
+++ b/fence/agents/apc_snmp/fence_apc_snmp.py
@@ -187,7 +187,7 @@ def get_outlets_status(conn, options):
# Main agent method
def main():
device_opt = ["ipaddr", "login", "passwd", "no_login", "no_password", \
- "port", "snmp_version", "community"]
+ "port", "snmp_version", "snmp"]
atexit.register(atexit_handler)
diff --git a/fence/agents/cisco_mds/fence_cisco_mds.py b/fence/agents/cisco_mds/fence_cisco_mds.py
index 4d2b40c..ba9d917 100644
--- a/fence/agents/cisco_mds/fence_cisco_mds.py
+++ b/fence/agents/cisco_mds/fence_cisco_mds.py
@@ -75,7 +75,7 @@ def main():
global PORT_OID
device_opt = ["fabric_fencing", "ipaddr", "login", "passwd", "no_login", "no_password", \
- "port", "snmp_version", "community"]
+ "port", "snmp_version", "snmp"]
atexit.register(atexit_handler)
diff --git a/fence/agents/eaton_snmp/fence_eaton_snmp.py b/fence/agents/eaton_snmp/fence_eaton_snmp.py
index 0934d48..812790d 100644
--- a/fence/agents/eaton_snmp/fence_eaton_snmp.py
+++ b/fence/agents/eaton_snmp/fence_eaton_snmp.py
@@ -202,7 +202,7 @@ def get_outlets_status(conn, options):
# Main agent method
def main():
device_opt = ["ipaddr", "login", "passwd", "no_login", "no_password", \
- "port", "snmp_version", "community"]
+ "port", "snmp_version", "snmp"]
atexit.register(atexit_handler)
diff --git a/fence/agents/emerson/fence_emerson.py b/fence/agents/emerson/fence_emerson.py
index af7f132..a98351a 100644
--- a/fence/agents/emerson/fence_emerson.py
+++ b/fence/agents/emerson/fence_emerson.py
@@ -46,7 +46,7 @@ def get_outlets_status(conn, _):
def main():
device_opt = ["ipaddr", "login", "passwd", "no_login", "no_password", \
- "port", "snmp_version", "community"]
+ "port", "snmp_version", "snmp"]
atexit.register(atexit_handler)
diff --git a/fence/agents/ibmblade/fence_ibmblade.py b/fence/agents/ibmblade/fence_ibmblade.py
index a42fd26..b4810a5 100644
--- a/fence/agents/ibmblade/fence_ibmblade.py
+++ b/fence/agents/ibmblade/fence_ibmblade.py
@@ -53,7 +53,7 @@ def get_outlets_status(conn, _):
# Main agent method
def main():
device_opt = ["ipaddr", "login", "passwd", "no_login", "no_password", \
- "port", "snmp_version", "community"]
+ "port", "snmp_version", "snmp"]
atexit.register(atexit_handler)
diff --git a/fence/agents/ifmib/fence_ifmib.py b/fence/agents/ifmib/fence_ifmib.py
index a019cec..7df7683 100644
--- a/fence/agents/ifmib/fence_ifmib.py
+++ b/fence/agents/ifmib/fence_ifmib.py
@@ -93,7 +93,7 @@ def get_outlets_status(conn, options):
# Main agent method
def main():
device_opt = ["fabric_fencing", "ipaddr", "login", "passwd", "no_login", "no_password", \
- "port", "snmp_version", "community"]
+ "port", "snmp_version", "snmp"]
atexit.register(atexit_handler)
diff --git a/fence/agents/intelmodular/fence_intelmodular.py b/fence/agents/intelmodular/fence_intelmodular.py
index bbb7dd1..e91ccc0 100644
--- a/fence/agents/intelmodular/fence_intelmodular.py
+++ b/fence/agents/intelmodular/fence_intelmodular.py
@@ -64,7 +64,7 @@ def get_outlets_status(conn, options):
# Main agent method
def main():
device_opt = ["ipaddr", "login", "passwd", "no_login", "no_password",
- "port", "snmp_version", "community"]
+ "port", "snmp_version", "snmp"]
atexit.register(atexit_handler)
diff --git a/fence/agents/ipdu/fence_ipdu.py b/fence/agents/ipdu/fence_ipdu.py
index 351296b..642dc79 100644
--- a/fence/agents/ipdu/fence_ipdu.py
+++ b/fence/agents/ipdu/fence_ipdu.py
@@ -131,7 +131,7 @@ def main():
global device
device_opt = ["ipaddr", "login", "passwd", "no_login", "no_password", \
- "port", "snmp_version", "community"]
+ "port", "snmp_version", "snmp"]
atexit.register(atexit_handler)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 79b9218..4e68879 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -418,6 +418,10 @@ all_opt = {
"shortdesc" : "Path to sudo binary",
"default" : "@SUDO_PATH@",
"order": 300},
+ "snmp": {
+ "getopt" : "",
+ "help" : "",
+ "order" : 1},
"on_target": {
"getopt" : "",
"help" : "",
@@ -435,8 +439,8 @@ DEPENDENCY_OPT = {
"ipaddr" : ["ipport", "inet4_only", "inet6_only"],
"port" : ["separator"],
"ssl" : ["ssl_secure", "ssl_insecure", "gnutlscli_path"],
- "community" : ["snmp_auth_prot", "snmp_sec_level", "snmp_priv_prot", \
- "snmp_priv_passwd", "snmp_priv_passwd_script"]
+ "snmp" : ["snmp_auth_prot", "snmp_sec_level", "snmp_priv_prot", \
+ "snmp_priv_passwd", "snmp_priv_passwd_script", "community"]
}
class fspawn(pexpect.spawn):
9 years, 1 month
fence-agents: master - fence_kdump: [test] Update XML metadata pattern after adding "monitor"
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=ca6c5f...
Commit: ca6c5f27f828a1d99deeb6724b279fa0f29210a0
Parent: 4e791db7f51a32a6a9fa4b48544f43d7d2c4d4ce
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Thu Feb 26 10:31:07 2015 +0100
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Thu Feb 26 10:31:07 2015 +0100
fence_kdump: [test] Update XML metadata pattern after adding "monitor"
---
tests/data/metadata/fence_kdump.xml | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/tests/data/metadata/fence_kdump.xml b/tests/data/metadata/fence_kdump.xml
index c985cac..08967fd 100644
--- a/tests/data/metadata/fence_kdump.xml
+++ b/tests/data/metadata/fence_kdump.xml
@@ -46,6 +46,7 @@
</parameters>
<actions>
<action name="off" />
+ <action name="monitor" />
<action name="metadata" />
</actions>
</resource-agent>
9 years, 1 month
fence-agents: master - fence_kdump: Fix problem in metadata
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=4e791d...
Commit: 4e791db7f51a32a6a9fa4b48544f43d7d2c4d4ce
Parent: 72c6acd167fa7c4a8d19795957f73ee4aae17f60
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Thu Feb 26 10:29:55 2015 +0100
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Thu Feb 26 10:29:55 2015 +0100
fence_kdump: Fix problem in metadata
---
fence/agents/kdump/fence_kdump.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/fence/agents/kdump/fence_kdump.c b/fence/agents/kdump/fence_kdump.c
index 5cea11d..29abbda 100644
--- a/fence/agents/kdump/fence_kdump.c
+++ b/fence/agents/kdump/fence_kdump.c
@@ -233,7 +233,6 @@ do_action_metadata (const char *self)
fprintf (stdout, "\t<parameter name=\"action\" unique=\"0\" required=\"0\">\n");
fprintf (stdout, "\t\t<getopt mixed=\"-o, --action\" />\n");
- fprintf (stdout, "\t\t<content type=\"string\" default=\"monitor\" />\n");
fprintf (stdout, "\t\t<content type=\"string\" default=\"off\" />\n");
fprintf (stdout, "\t\t<shortdesc lang=\"en\">%s</shortdesc>\n",
"Fencing action");
9 years, 1 month
fence-agents: master - fence_kdump: Add 'monitor' action which tests possibility of doing kdump on local node
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=72c6ac...
Commit: 72c6acd167fa7c4a8d19795957f73ee4aae17f60
Parent: 6e2ed26e4e82fac11f5c269b29b0f0c0bedefe6a
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed Feb 25 09:49:21 2015 +0100
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed Feb 25 09:49:21 2015 +0100
fence_kdump: Add 'monitor' action which tests possibility of doing kdump on local node
In case of fence_kdump we can not test if remote 'fencing device' is working because
fence_kdump_send is started only after kernel crash. So, monitor action checks if LOCAL
node can enter kdump. The test looks if crashkernel=.. occurs between boot arguments.
---
fence/agents/kdump/fence_kdump.c | 35 ++++++++++++++++++++++++++++++++++-
fence/agents/kdump/options.h | 2 ++
2 files changed, 36 insertions(+), 1 deletions(-)
diff --git a/fence/agents/kdump/fence_kdump.c b/fence/agents/kdump/fence_kdump.c
index cae9842..5cea11d 100644
--- a/fence/agents/kdump/fence_kdump.c
+++ b/fence/agents/kdump/fence_kdump.c
@@ -114,6 +114,34 @@ out:
}
static int
+do_action_monitor (void)
+{
+ const char cmdline_path[] = "/proc/cmdline";
+ FILE *procFile;
+ size_t sz;
+ char *lines;
+ int result;
+
+ procFile = fopen(cmdline_path, "r");
+ sz = 0;
+
+ while (!feof (procFile)) {
+ getline (&lines, &sz, procFile);
+ }
+
+ if (strstr(lines, "crashkernel=") == NULL) {
+ result = 1;
+ } else {
+ result = 0;
+ }
+
+ free (lines);
+ fclose (procFile);
+
+ return result;
+}
+
+static int
do_action_off (const fence_kdump_opts_t *opts)
{
int error;
@@ -205,6 +233,7 @@ do_action_metadata (const char *self)
fprintf (stdout, "\t<parameter name=\"action\" unique=\"0\" required=\"0\">\n");
fprintf (stdout, "\t\t<getopt mixed=\"-o, --action\" />\n");
+ fprintf (stdout, "\t\t<content type=\"string\" default=\"monitor\" />\n");
fprintf (stdout, "\t\t<content type=\"string\" default=\"off\" />\n");
fprintf (stdout, "\t\t<shortdesc lang=\"en\">%s</shortdesc>\n",
"Fencing action");
@@ -242,6 +271,7 @@ do_action_metadata (const char *self)
fprintf (stdout, "<actions>\n");
fprintf (stdout, "\t<action name=\"off\" />\n");
+ fprintf (stdout, "\t<action name=\"monitor\" />\n");
fprintf (stdout, "\t<action name=\"metadata\" />\n");
fprintf (stdout, "</actions>\n");
@@ -264,7 +294,7 @@ print_usage (const char *self)
fprintf (stdout, "%s\n",
" -f, --family=FAMILY Network family: ([auto], ipv4, ipv6)");
fprintf (stdout, "%s\n",
- " -o, --action=ACTION Fencing action: ([off], metadata)");
+ " -o, --action=ACTION Fencing action: ([off], monitor, metadata)");
fprintf (stdout, "%s\n",
" -t, --timeout=TIMEOUT Timeout in seconds (default: 60)");
fprintf (stdout, "%s\n",
@@ -501,6 +531,9 @@ main (int argc, char **argv)
case FENCE_KDUMP_ACTION_METADATA:
error = do_action_metadata (argv[0]);
break;
+ case FENCE_KDUMP_ACTION_MONITOR:
+ error = do_action_monitor ();
+ break;
default:
break;
}
diff --git a/fence/agents/kdump/options.h b/fence/agents/kdump/options.h
index 10fa2a2..22731d7 100644
--- a/fence/agents/kdump/options.h
+++ b/fence/agents/kdump/options.h
@@ -189,6 +189,8 @@ set_option_action (fence_kdump_opts_t *opts, const char *arg)
opts->action = FENCE_KDUMP_ACTION_OFF;
} else if (!strcasecmp (arg, "metadata")) {
opts->action = FENCE_KDUMP_ACTION_METADATA;
+ } else if (!strcasecmp (arg, "monitor")) {
+ opts->action = FENCE_KDUMP_ACTION_MONITOR;
} else {
fprintf (stderr, "[error]: unsupported action '%s'\n", arg);
exit (1);
9 years, 1 month
cluster: RHEL6 - libgfs2: Use a matching context mount option in mount_gfs2_meta
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=0031db202e1...
Commit: 0031db202e1b6584c5069f7f3139c1303257a3aa
Parent: 407dbe2a3df3882a1e936e37e7c0a8505a2d44ac
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Mon Feb 23 14:12:46 2015 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Mon Feb 23 18:39:22 2015 +0000
libgfs2: Use a matching context mount option in mount_gfs2_meta
On a system with SELinux enabled, if a gfs2 file system is mounted with
a context= option, the tools gfs2_quota, gfs2_tool, gfs2_grow and
gfs2_jadd will fail with "Device or resource busy". This is due to
SELinux failing the mount due to a mismatched context ("SELinux: mount
invalid. Same superblock, different security settings").
In order to work around this, parse the context option of the gfs2 mount
point in is_pathname_mounted() and use it in mount_gfs2_meta().
Resolves: rhbz#1121693
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/libgfs2.h | 1 +
gfs2/libgfs2/misc.c | 21 ++++++++++++++++++++-
2 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 9c20f11..25286d1 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -217,6 +217,7 @@ struct gfs2_sbd {
int device_fd;
int path_fd;
+ char *secontext;
uint64_t sb_addr;
diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c
index 8e0ca6f..5ef4a2a 100644
--- a/gfs2/libgfs2/misc.c
+++ b/gfs2/libgfs2/misc.c
@@ -100,6 +100,24 @@ int compute_constants(struct gfs2_sbd *sdp)
return 0;
}
+/**
+ * Returns a duplicate of the 'context' mount option, or NULL if not found.
+ */
+static char *copy_context_opt(struct mntent *mnt)
+{
+ char *ctx, *end;
+
+ ctx = hasmntopt(mnt, "context");
+ if (ctx == NULL)
+ return NULL;
+
+ end = strchr(ctx, ',');
+ if (end == NULL)
+ return NULL;
+
+ return strndup(ctx, end - ctx);
+}
+
int is_pathname_mounted(struct gfs2_sbd *sdp, int *ro_mount)
{
FILE *fp;
@@ -161,6 +179,7 @@ int is_pathname_mounted(struct gfs2_sbd *sdp, int *ro_mount)
return 0;
if (hasmntopt(mnt, MNTOPT_RO))
*ro_mount = 1;
+ sdp->secontext = copy_context_opt(mnt);
return 1; /* mounted */
}
@@ -319,7 +338,7 @@ int mount_gfs2_meta(struct gfs2_sbd *sdp)
sigaction(SIGCONT, &sa, NULL);
sigaction(SIGUSR1, &sa, NULL);
sigaction(SIGUSR2, &sa, NULL);
- ret = mount(sdp->path_name, sdp->metafs_path, "gfs2meta", 0, NULL);
+ ret = mount(sdp->path_name, sdp->metafs_path, "gfs2meta", 0, sdp->secontext);
if (ret) {
rmdir(sdp->metafs_path);
return -1;
9 years, 1 month
gfs2-utils: master - gfs2_grow/jadd: Use a matching context mount option in mount_gfs2_meta
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=60c26b02...
Commit: 60c26b020f55e079add1f461897b8f8d36b4e769
Parent: 3c2f9a8bf7a03cec32a1e11792a7dc493fb4917b
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Mon Feb 23 17:36:12 2015 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Mon Feb 23 18:40:57 2015 +0000
gfs2_grow/jadd: Use a matching context mount option in mount_gfs2_meta
On a system with SELinux enabled, if a gfs2 file system is mounted with
a context= option, the tools gfs2_grow and gfs2_jadd will fail with
"Invalid argument". This is due to SELinux failing the mount due to an
mismatched context ("SELinux: mount invalid. Same superblock, different
security settings").
In order to work around this, parse the context option of the mntent
relating to the gfs2 mount point and use it in mount_gfs2_meta().
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/mkfs/main_grow.c | 1 +
gfs2/mkfs/main_jadd.c | 2 +-
gfs2/mkfs/metafs.c | 23 ++++++++++++++++++++++-
gfs2/mkfs/metafs.h | 2 ++
4 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index c3ae4b7..6ba14b0 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -396,6 +396,7 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
fix_device_geometry(sdp);
+ mfs.context = copy_context_opt(mnt);
if (mount_gfs2_meta(&mfs, mnt->mnt_dir, (print_level > MSG_NOTICE))) {
perror(_("Failed to mount GFS2 meta file system"));
exit(EXIT_FAILURE);
diff --git a/gfs2/mkfs/main_jadd.c b/gfs2/mkfs/main_jadd.c
index d83ec2b..9190d44 100644
--- a/gfs2/mkfs/main_jadd.c
+++ b/gfs2/mkfs/main_jadd.c
@@ -520,7 +520,7 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
gather_info(sdp, &opts);
-
+ mfs.context = copy_context_opt(mnt);
if (mount_gfs2_meta(&mfs, mnt->mnt_dir, opts.debug)) {
perror("GFS2 metafs");
exit(EXIT_FAILURE);
diff --git a/gfs2/mkfs/metafs.c b/gfs2/mkfs/metafs.c
index 12b1cdb..112ce2d 100644
--- a/gfs2/mkfs/metafs.c
+++ b/gfs2/mkfs/metafs.c
@@ -9,6 +9,7 @@
#include <fcntl.h>
#include <errno.h>
#include <signal.h>
+#include <mntent.h>
#include <libintl.h>
#include <locale.h>
#define _(String) gettext(String)
@@ -70,7 +71,7 @@ int mount_gfs2_meta(struct metafs *mfs, const char *path, int debug)
setsigs(sighandler);
- ret = mount(path, mfs->path, "gfs2meta", 0, NULL);
+ ret = mount(path, mfs->path, "gfs2meta", 0, mfs->context);
if (ret)
goto err_rmdir;
@@ -115,4 +116,24 @@ void cleanup_metafs(struct metafs *mfs)
free(mfs->path);
mfs->path = NULL;
+ free(mfs->context);
+ mfs->context = NULL;
+}
+
+/**
+ * Returns a duplicate of the 'context' mount option, or NULL if not found.
+ */
+char *copy_context_opt(struct mntent *mnt)
+{
+ char *ctx, *end;
+
+ ctx = hasmntopt(mnt, "context");
+ if (ctx == NULL)
+ return NULL;
+
+ end = strchr(ctx, ',');
+ if (end == NULL)
+ return NULL;
+
+ return strndup(ctx, end - ctx);
}
diff --git a/gfs2/mkfs/metafs.h b/gfs2/mkfs/metafs.h
index a765634..1372977 100644
--- a/gfs2/mkfs/metafs.h
+++ b/gfs2/mkfs/metafs.h
@@ -6,9 +6,11 @@ extern int metafs_interrupted;
struct metafs {
int fd;
char *path;
+ char *context; /* 'context=' mount option */
};
extern int mount_gfs2_meta(struct metafs *mfs, const char *path, int debug);
extern void cleanup_metafs(struct metafs *mfs);
+extern char *copy_context_opt(struct mntent *mnt);
#endif /* METAFS_H */
9 years, 1 month