gfs2-utils: master - gfs2_edit: Add "journals" option to print journal info
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=97fbdb22...
Commit: 97fbdb22e1ddfc313bf3266eb4a02769e2eb2190
Parent: d7cb51dcc918323af0ed85fc054372da6dd640b0
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Fri Aug 30 08:02:15 2013 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Fri Aug 30 09:08:38 2013 -0500
gfs2_edit: Add "journals" option to print journal info
This patch adds a keyword "journals" to gfs2_edit. Its purpose is
to print information about the GFS2 journals: location, size, and
whether they're clean, dirty or damaged.
---
gfs2/edit/extended.c | 45 +++++++++++++++++++++++++++++++++++++++------
gfs2/edit/hexedit.c | 27 +++++++++++++++++++++++----
gfs2/edit/hexedit.h | 8 ++++++++
3 files changed, 70 insertions(+), 10 deletions(-)
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index 27c32a9..ac1e5d7 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -427,7 +427,7 @@ static void gfs_jindex_print(struct gfs_jindex *ji)
pv(ji, ji_pad, "%u", "0x%x");
}
-static int print_jindex(struct gfs2_inode *dij)
+static int print_gfs_jindex(struct gfs2_inode *dij)
{
int error, start_line;
struct gfs_jindex ji;
@@ -467,6 +467,35 @@ static int print_jindex(struct gfs2_inode *dij)
return error;
}
+static int print_gfs2_jindex(void)
+{
+ int d, error;
+ struct gfs2_log_header head;
+ struct gfs2_inode *ip;
+
+ for (d = 0; d < indirect->ii[0].dirents; d++) {
+ if (strncmp(indirect->ii[0].dirent[d].filename, "journal", 7))
+ continue;
+ ip = lgfs2_inode_read(&sbd, indirect->ii[0].dirent[d].block);
+ print_gfs2("%s: 0x%-5x %dMB ",
+ indirect->ii[0].dirent[d].filename,
+ indirect->ii[0].dirent[d].block,
+ ip->i_di.di_size / 1048576);
+ error = gfs2_find_jhead(ip, &head);
+ if (error) {
+ print_gfs2("corrupt.");
+ } else {
+ if (head.lh_flags & GFS2_LOG_HEAD_UNMOUNT)
+ print_gfs2("clean.");
+ else
+ print_gfs2("dirty.");
+ }
+ eol(0);
+ inode_put(&ip);
+ }
+ return 0;
+}
+
static int parse_rindex(struct gfs2_inode *dip, int print_rindex)
{
int error, start_line;
@@ -618,8 +647,13 @@ int display_extended(void)
parse_rindex(tmp_inode, TRUE);
inode_put(&tmp_inode);
brelse(tmp_bh);
- }
- else if (has_indirect_blocks() && !indirect_blocks &&
+ } else if (block_is_journals()) {
+ if (sbd.gfs1)
+ block = sbd1->sb_jindex_di.no_addr;
+ else
+ block = masterblock("jindex");
+ print_gfs2_jindex();
+ } else if (has_indirect_blocks() && !indirect_blocks &&
!display_leaf(indirect))
return -1;
else if (display_indirect(indirect, indirect_blocks, 0, 0) == 0)
@@ -635,13 +669,12 @@ int display_extended(void)
parse_rindex(tmp_inode, FALSE);
inode_put(&tmp_inode);
brelse(tmp_bh);
- }
- else if (block_is_jindex()) {
+ } else if (block_is_jindex()) {
tmp_bh = bread(&sbd, block);
tmp_inode = lgfs2_inode_get(&sbd, tmp_bh);
if (tmp_inode == NULL)
return -1;
- print_jindex(tmp_inode);
+ print_gfs_jindex(tmp_inode);
inode_put(&tmp_inode);
brelse(tmp_bh);
}
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index f0d9789..738dc4e 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -592,6 +592,8 @@ int display_block_type(int from_restore)
}
if (block == RGLIST_DUMMY_BLOCK)
print_gfs2("RG List ");
+ else if (block == JOURNALS_DUMMY_BLOCK)
+ print_gfs2("Journal Status: ");
else
print_gfs2("%lld (0x%llx)", block, block);
if (termlines) {
@@ -605,6 +607,9 @@ int display_block_type(int from_restore)
ret_type = GFS2_METATYPE_RG;
struct_len = sbd.gfs1 ? sizeof(struct gfs_rgrp) :
sizeof(struct gfs2_rgrp);
+ } else if (block == JOURNALS_DUMMY_BLOCK) {
+ ret_type = GFS2_METATYPE_DI;
+ struct_len = 0;
} else {
ret_type = get_block_type(bh);
switch (ret_type) {
@@ -777,6 +782,8 @@ int display_block_type(int from_restore)
print_gfs2("-------------- Master directory -----------------");
else if (!sbd.gfs1 && block == RGLIST_DUMMY_BLOCK)
print_gfs2("------------------ RG List ----------------------");
+ else if (!sbd.gfs1 && block == JOURNALS_DUMMY_BLOCK)
+ print_gfs2("-------------------- Journal List --------------------");
else {
if (sbd.gfs1) {
if (block == sbd1->sb_rindex_di.no_addr)
@@ -1215,6 +1222,7 @@ static int block_has_extended_info(void)
if (has_indirect_blocks() ||
block_is_rindex() ||
block_is_rgtree() ||
+ block_is_journals() ||
block_is_jindex() ||
block_is_inum_file() ||
block_is_statfs_file() ||
@@ -1334,6 +1342,11 @@ int display(int identify_only)
blk = sbd1->sb_rindex_di.no_addr;
else
blk = masterblock("rindex");
+ } else if (block == JOURNALS_DUMMY_BLOCK) {
+ if (sbd.gfs1)
+ blk = sbd1->sb_jindex_di.no_addr;
+ else
+ blk = masterblock("jindex");
} else
blk = block;
if (termlines) {
@@ -1400,6 +1413,7 @@ int display(int identify_only)
else if (gfs2_struct_type == GFS2_METATYPE_LF) { /* directory leaf */
do_leaf_extended(bh->b_data, indirect);
}
+
last_entry_onscreen[dmode] = 0;
if (dmode == EXTENDED_MODE && !block_has_extended_info())
dmode = HEX_MODE;
@@ -1415,9 +1429,10 @@ int display(int identify_only)
if (dmode == HEX_MODE) /* if hex display mode */
hexdump(dev_offset, (gfs2_struct_type == GFS2_METATYPE_DI)?
struct_len + di.di_size:sbd.bsize);
- else if (dmode == GFS2_MODE) /* if structure display */
- display_gfs2(); /* display the gfs2 structure */
- else
+ else if (dmode == GFS2_MODE) { /* if structure display */
+ if (block != JOURNALS_DUMMY_BLOCK)
+ display_gfs2(); /* display the gfs2 structure */
+ } else
display_extended(); /* display extended blocks */
/* No else here because display_extended can switch back to hex mode */
if (termlines)
@@ -1748,6 +1763,8 @@ uint64_t check_keywords(const char *kword)
rgnum = atoi(kword + 3);
blk = get_rg_addr(rgnum);
+ } else if (!strncmp(kword, "journals", 8)) {
+ blk = JOURNALS_DUMMY_BLOCK;
} else if (!strncmp(kword, "journal", 7) && isdigit(kword[7])) {
uint64_t j_size;
@@ -1783,7 +1800,8 @@ static uint64_t goto_block(void)
temp_blk = block + delta;
}
- if (temp_blk == RGLIST_DUMMY_BLOCK || temp_blk < max_block) {
+ if (temp_blk == RGLIST_DUMMY_BLOCK ||
+ temp_blk == JOURNALS_DUMMY_BLOCK || temp_blk < max_block) {
offset = 0;
block = temp_blk;
push_block(block);
@@ -2832,6 +2850,7 @@ static void usage(void)
fprintf(stderr," master - prints the master directory.\n");
fprintf(stderr," root - prints the root directory.\n");
fprintf(stderr," jindex - prints the journal index directory.\n");
+ fprintf(stderr," journals - prints the journal status.\n");
fprintf(stderr," per_node - prints the per_node directory.\n");
fprintf(stderr," inum - prints the inum file.\n");
fprintf(stderr," statfs - prints the statfs file.\n");
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index 706909c..21cf70a 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -25,6 +25,7 @@ enum dsp_mode { HEX_MODE = 0, GFS2_MODE = 1, EXTENDED_MODE = 2, INIT_MODE = 3 };
print_it(" "#member, fmt, fmt2, struct->member); \
} while (FALSE);
#define RGLIST_DUMMY_BLOCK -2
+#define JOURNALS_DUMMY_BLOCK -3
extern struct gfs2_sb sb;
extern uint64_t block;
@@ -121,6 +122,13 @@ static inline int block_is_rgtree(void)
return FALSE;
}
+static inline int block_is_journals(void)
+{
+ if (block == JOURNALS_DUMMY_BLOCK)
+ return TRUE;
+ return FALSE;
+}
+
#define SCREEN_HEIGHT (16)
#define SCREEN_WIDTH (16)
10 years, 8 months
fence-agents: RHEL6 - fence_bladecenter: Fix telnet login failure
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=ca652f...
Commit: ca652f4da2d9319c2b04000531745873613f4b2e
Parent: aad5c7524d6842e7a276c7d75044ccfe86646b4c
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed Aug 28 14:17:04 2013 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed Aug 28 14:17:04 2013 +0200
fence_bladecenter: Fix telnet login failure
Problem occured due to fact that welcome message contains string which looks like login prompt.
Resolves: rhbz#997416
---
fence/agents/bladecenter/fence_bladecenter.py | 2 +-
fence/agents/lib/fencing.py.py | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/fence/agents/bladecenter/fence_bladecenter.py b/fence/agents/bladecenter/fence_bladecenter.py
index 958ceb0..09f4a86 100644
--- a/fence/agents/bladecenter/fence_bladecenter.py
+++ b/fence/agents/bladecenter/fence_bladecenter.py
@@ -123,7 +123,7 @@ and uses the command line interface to power on and off blades."
##
## Operate the fencing device
######
- conn = fence_login(options)
+ conn = fence_login(options, "(username: )")
result = fence_action(conn, options, set_power_status, get_power_status, get_blades_list)
##
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 0316b58..1de9a15 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -861,7 +861,7 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None
return result
-def fence_login(options):
+def fence_login(options, re_login_string = "(login\s*: )|(Login Name: )|(username: )|(User Name :)"):
force_ipvx=""
if (options.has_key("-6")):
@@ -879,7 +879,6 @@ def fence_login(options):
time.sleep(int(options["-f"]))
try:
- re_login_string = "(login\s*: )|(Login Name: )|(username: )|(User Name :)"
re_login = re.compile(re_login_string, re.IGNORECASE)
re_pass = re.compile("(password)|(pass phrase)", re.IGNORECASE)
10 years, 8 months
fence-agents: RHEL6 - fence_cisco_ucs: Fix problem with --login-timeout
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=aad5c7...
Commit: aad5c7524d6842e7a276c7d75044ccfe86646b4c
Parent: e91f58c8a4a69f0a13b0fd388f90458ec91c68df
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed Aug 28 09:44:39 2013 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed Aug 28 09:44:39 2013 +0200
fence_cisco_ucs: Fix problem with --login-timeout
Resolves: rhbz#978325
---
fence/agents/cisco_ucs/fence_cisco_ucs.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/fence/agents/cisco_ucs/fence_cisco_ucs.py b/fence/agents/cisco_ucs/fence_cisco_ucs.py
index d1d8501..ea21e6c 100644
--- a/fence/agents/cisco_ucs/fence_cisco_ucs.py
+++ b/fence/agents/cisco_ucs/fence_cisco_ucs.py
@@ -102,7 +102,7 @@ def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
"ssl", "inet4_only", "inet6_only", "ipport", "port",
- "web", "separator", "power_wait", "power_timeout",
+ "web", "separator", "power_wait", "power_timeout", "login_timeout",
"shell_timeout", "suborg" ]
atexit.register(atexit_handler)
@@ -121,7 +121,7 @@ used with Cisco UCS to fence machines."
time.sleep(int(options["-f"]))
try:
- res = send_command(options, "<aaaLogin inName=\"" + options["-l"] + "\" inPassword=\"" + options["-p"] + "\" />", int(options("-y")))
+ res = send_command(options, "<aaaLogin inName=\"" + options["-l"] + "\" inPassword=\"" + options["-p"] + "\" />", int(options["-y"]))
result = re_cookie.search(res)
if (result == None):
10 years, 8 months
fence-agents: master - fence_bladecenter: Fix telnet login failure
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=5d31cb...
Commit: 5d31cbaee51eb77795a3d91dae5da5f3c46c64af
Parent: d1baa1ba63f92a00f78ae3c344886dfbc08ca1d5
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed Aug 28 14:17:04 2013 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Thu Aug 29 18:30:11 2013 +0200
fence_bladecenter: Fix telnet login failure
Problem occured due to fact that welcome message contains string which looks like login prompt.
Resolves: rhbz#997416
---
fence/agents/bladecenter/fence_bladecenter.py | 2 +-
fence/agents/lib/fencing.py.py | 5 ++---
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/fence/agents/bladecenter/fence_bladecenter.py b/fence/agents/bladecenter/fence_bladecenter.py
index 43c5076..14a152b 100644
--- a/fence/agents/bladecenter/fence_bladecenter.py
+++ b/fence/agents/bladecenter/fence_bladecenter.py
@@ -100,7 +100,7 @@ and uses the command line interface to power on and off blades."
##
## Operate the fencing device
######
- conn = fence_login(options)
+ conn = fence_login(options, "(username: )")
result = fence_action(conn, options, set_power_status, get_power_status, get_blades_list)
##
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 097c167..bb144bb 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -892,8 +892,8 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None
return result
-def fence_login(options):
- force_ipvx = ""
+def fence_login(options, re_login_string = "(login\s*: )|(Login Name: )|(username: )|(User Name :)"):
+ force_ipvx=""
if (options.has_key("--inet6-only")):
force_ipvx = "-6 "
@@ -913,7 +913,6 @@ def fence_login(options):
time.sleep(int(options["--delay"]))
try:
- re_login_string = "(login\s*: )|(Login Name: )|(username: )|(User Name :)"
re_login = re.compile(re_login_string, re.IGNORECASE)
re_pass = re.compile("(password)|(pass phrase)", re.IGNORECASE)
10 years, 8 months
fence-agents: master - fence_brocade: Port fencing agent to fencing library
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=d1baa1...
Commit: d1baa1ba63f92a00f78ae3c344886dfbc08ca1d5
Parent: 5fa456d4075033384ea67ea3dfb257a48d981f4a
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Thu Aug 29 16:22:15 2013 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Thu Aug 29 16:22:15 2013 +0200
fence_brocade: Port fencing agent to fencing library
Resolves: rhbz#641632 rhbz#642232 rhbz#841556
---
fence/agents/brocade/Makefile.am | 4 +-
fence/agents/brocade/fence_brocade.pl | 322 ---------------------------------
fence/agents/brocade/fence_brocade.py | 86 +++++++++
3 files changed, 88 insertions(+), 324 deletions(-)
diff --git a/fence/agents/brocade/Makefile.am b/fence/agents/brocade/Makefile.am
index 3338804..171425f 100644
--- a/fence/agents/brocade/Makefile.am
+++ b/fence/agents/brocade/Makefile.am
@@ -2,7 +2,7 @@ MAINTAINERCLEANFILES = Makefile.in
TARGET = fence_brocade
-SRC = $(TARGET).pl
+SRC = $(TARGET).py
EXTRA_DIST = $(SRC)
@@ -11,7 +11,7 @@ sbin_SCRIPTS = $(TARGET)
man_MANS = $(TARGET).8
include $(top_srcdir)/make/fencebuild.mk
-include $(top_srcdir)/make/fencemanperl.mk
+include $(top_srcdir)/make/fenceman.mk
clean-local: clean-man
rm -f $(TARGET)
diff --git a/fence/agents/brocade/fence_brocade.pl b/fence/agents/brocade/fence_brocade.pl
deleted file mode 100644
index 4be0436..0000000
--- a/fence/agents/brocade/fence_brocade.pl
+++ /dev/null
@@ -1,322 +0,0 @@
-#!/usr/bin/perl
-
-use Getopt::Std;
-use Net::Telnet ();
-
-my $ME = $0;
-
-END {
- defined fileno STDOUT or return;
- close STDOUT and return;
- warn "$ME: failed to close standard output: $!\n";
- $? ||= 1;
-}
-
-# Get the program name from $0 and strip directory names
-$_=$0;
-s/.*\///;
-my $pname = $_;
-
-$opt_o = 'disable'; # Default fence action
-
-# WARNING!! Do not add code bewteen "#BEGIN_VERSION_GENERATION" and
-# "#END_VERSION_GENERATION" It is generated by the Makefile
-
-#BEGIN_VERSION_GENERATION
-$RELEASE_VERSION="";
-$REDHAT_COPYRIGHT="";
-$BUILD_DATE="";
-#END_VERSION_GENERATION
-
-
-sub usage
-{
- print "Usage:\n";
- print "\n";
- print "$pname [options]\n";
- print "\n";
- print "Options:\n";
- print " -a <ip> IP address or hostname of switch\n";
- print " -h usage\n";
- print " -l <name> Login name\n";
- print " -n <num> Port number to operate on\n";
- print " -o <string> Action: disable (default), enable or metadata\n";
- print " -p <string> Password for login\n";
- print " -S <path> Script to run to retrieve password\n";
- print " -q quiet mode\n";
- print " -V version\n";
-
- exit 0;
-}
-
-sub fail
-{
- ($msg) = @_;
- print $msg."\n" unless defined $opt_q;
- $t->close if defined $t;
- exit 1;
-}
-
-sub fail_usage
-{
- ($msg)=@_;
- print STDERR $msg."\n" if $msg;
- print STDERR "Please use '-h' for usage.\n";
- exit 1;
-}
-
-sub version
-{
- print "$pname $RELEASE_VERSION $BUILD_DATE\n";
- print "$REDHAT_COPYRIGHT\n" if ( $REDHAT_COPYRIGHT );
-
- exit 0;
-}
-
-sub print_metadata
-{
-print '<?xml version="1.0" ?>
-<resource-agent name="fence_brocade" shortdesc="Fence agent for Brocade over telnet" >
-<longdesc>
-fence_brocade is an I/O Fencing agent which can be used with Brocade FC switches. It logs into a Brocade switch via telnet and disables a specified port. Disabling the port which a machine is connected to effectively fences that machine. Lengthy telnet connections to the switch should be avoided while a GFS cluster is running because the connection will block any necessary fencing actions.
-
-After a fence operation has taken place the fenced machine can no longer connect to the Brocade FC switch. When the fenced machine is ready to be brought back into the GFS cluster (after reboot) the port on the Brocade FC switch needs to be enabled. This can be done by running fence_brocade and specifying the enable action.
-</longdesc>
-<vendor-url>http://www.brocade.com</vendor-url>
-<parameters>
- <parameter name="action" unique="0" required="1">
- <getopt mixed="-o [action]" />
- <content type="string" default="disable" />
- <shortdesc lang="en">Fencing Action</shortdesc>
- </parameter>
- <parameter name="ipaddr" unique="0" required="1">
- <getopt mixed="-a [ip]" />
- <content type="string" />
- <shortdesc lang="en">IP Address or Hostname</shortdesc>
- </parameter>
- <parameter name="login" unique="0" required="1">
- <getopt mixed="-l [name]" />
- <content type="string" />
- <shortdesc lang="en">Login Name</shortdesc>
- </parameter>
- <parameter name="passwd" unique="0" required="0">
- <getopt mixed="-p [password]" />
- <content type="string" />
- <shortdesc lang="en">Login password or passphrase</shortdesc>
- </parameter>
- <parameter name="passwd_script" unique="0" required="0">
- <getopt mixed="-S [script]" />
- <content type="string" />
- <shortdesc lang="en">Script to retrieve password</shortdesc>
- </parameter>
- <parameter name="port" unique="0" required="1">
- <getopt mixed="-n [id]" />
- <content type="string" />
- <shortdesc lang="en">Physical plug number or name of virtual machine</shortdesc>
- </parameter>
- <parameter name="help" unique="0" required="0">
- <getopt mixed="-h" />
- <content type="string" />
- <shortdesc lang="en">Display help and exit</shortdesc>
- </parameter>
-</parameters>
-<actions>
- <action name="enable" />
- <action name="disable" />
- <action name="status" />
- <action name="metadata" />
-</actions>
-</resource-agent>
-';
-}
-
-
-if (@ARGV > 0) {
- getopts("a:hl:n:o:p:S:qV") || fail_usage ;
-
- usage if defined $opt_h;
- version if defined $opt_V;
-
- fail_usage "Unknown parameter." if (@ARGV > 0);
-
- if ((defined $opt_o) && ($opt_o =~ /metadata/i)) {
- print_metadata();
- exit 0;
- }
-
- if (defined $opt_S) {
- $pwd_script_out = `$opt_S`;
- chomp($pwd_script_out);
- if ($pwd_script_out) {
- $opt_p = $pwd_script_out;
- }
- }
-
- fail_usage "No '-a' flag specified." unless defined $opt_a;
- fail_usage "No '-n' flag specified." unless defined $opt_n;
- fail_usage "No '-l' flag specified." unless defined $opt_l;
- fail_usage "No '-p' or '-S' flag specified." unless defined $opt_p;
- fail_usage "Unrecognised action '$opt_o' for '-o' flag"
- unless $opt_o =~ /^(disable|enable)$/i;
-
-} else {
- get_options_stdin();
-
- if ((defined $opt_o) && ($opt_o =~ /metadata/i)) {
- print_metadata();
- exit 0;
- }
-
- fail "failed: no IP address" unless defined $opt_a;
- fail "failed: no plug number" unless defined $opt_n;
- fail "failed: no login name" unless defined $opt_l;
-
- if (defined $opt_S) {
- $pwd_script_out = `$opt_S`;
- chomp($pwd_script_out);
- if ($pwd_script_out) {
- $opt_p = $pwd_script_out;
- }
- }
-
- fail "failed: no password" unless defined $opt_p;
- fail "failed: unrecognised action: $opt_o"
- unless $opt_o =~ /^(disable|enable)$/i;
-}
-
-if ( $opt_o =~ /^(disable|enable)$/i )
-{
- $opt_o = "port".$1;
-}
-
-
-#
-# Set up and log in
-#
-
-$t = new Net::Telnet;
-
-$t->open($opt_a);
-
-$t->waitfor('/login:/');
-
-$t->print($opt_l);
-
-$t->waitfor('/assword:/');
-
-$t->print($opt_p);
-
-$t->waitfor('/\>/');
-
-
-
-#
-# Do the command
-#
-
-$cmd = "$opt_o $opt_n";
-$t->print($cmd);
-
-
-#
-# Assume here that the word "error" will appear after errors (bad assumption! see next check)
-#
-
-($text, $match) = $t->waitfor('/\>/');
-if ($text =~ /error/)
-{
- fail "failed: error from switch\n";
-}
-
-
-#
-# Do a portshow on the port and look for the DISABLED string to verify success
-#
-
-$t->print("portshow $opt_n");
-($text, $match) = $t->waitfor('/\>/');
-
-if ( $opt_o eq "portdisable" && !($text =~ /DISABLED/) )
-{
- fail "failed: portshow $opt_n does not show DISABLED\n";
-}
-elsif ( $opt_o eq "portenable" && ($text =~ /DISABLED/) )
-{
- fail "failed: portshow $opt_n shows DISABLED\n";
-}
-
-
-print "success: $opt_o $opt_n\n" unless defined $opt_q;
-exit 0;
-
-sub get_options_stdin
-{
- my $opt;
- my $line = 0;
- while( defined($in = <>) )
- {
- $_ = $in;
- chomp;
-
- # strip leading and trailing whitespace
- s/^\s*//;
- s/\s*$//;
-
- # skip comments
- next if /^#/;
-
- $line+=1;
- $opt=$_;
- next unless $opt;
-
- ($name,$val)=split /\s*=\s*/, $opt;
-
- if ( $name eq "" )
- {
- print STDERR "parse error: illegal name in option $line\n";
- exit 2;
- }
-
- # DO NOTHING -- this field is used by fenced
- elsif ($name eq "agent" ) { }
-
- # FIXME -- depricated. use "port" instead.
- elsif ($name eq "fm" )
- {
- (my $dummy,$opt_n) = split /\s+/,$val;
- print STDERR "Depricated \"fm\" entry detected. refer to man page.\n";
- }
-
- elsif ($name eq "ipaddr" )
- {
- $opt_a = $val;
- }
- elsif ($name eq "login" )
- {
- $opt_l = $val;
- }
-
- # FIXME -- depreicated residue of old fencing system
- elsif ($name eq "name" ) { }
-
- elsif (($name eq "option" ) || ($name eq "action"))
- {
- $opt_o = $val;
- }
- elsif ($name eq "passwd" )
- {
- $opt_p = $val;
- }
- elsif ($name eq "passwd_script") {
- $opt_S = $val;
- }
- elsif ($name eq "port" )
- {
- $opt_n = $val;
- }
- # elsif ($name eq "test" )
- # {
- # $opt_T = $val;
- # }
- }
-}
diff --git a/fence/agents/brocade/fence_brocade.py b/fence/agents/brocade/fence_brocade.py
new file mode 100644
index 0000000..25581fd
--- /dev/null
+++ b/fence/agents/brocade/fence_brocade.py
@@ -0,0 +1,86 @@
+#!/usr/bin/python
+
+import sys, re, pexpect, exceptions
+sys.path.append("@FENCEAGENTSLIBDIR@")
+from fencing import *
+
+#BEGIN_VERSION_GENERATION
+RELEASE_VERSION="New Brocade Agent - test release on steroids"
+REDHAT_COPYRIGHT=""
+BUILD_DATE="March, 20013"
+#END_VERSION_GENERATION
+
+def get_power_status(conn, options):
+ conn.send_eol("portCfgShow " + options["--plug"])
+
+ exp_result = conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
+
+ show_re = re.compile('^\s*Persistent Disable\s*(ON|OFF)\s*$', re.IGNORECASE)
+ lines = conn.before.split("\n")
+
+ for x in lines:
+ res = show_re.search(x)
+ if (res != None):
+ # We queried if it is disabled, so we have to negate answer
+ if res.group(1) == "ON":
+ return "off"
+ else:
+ return "on"
+
+ fail(EC_STATUS)
+def set_power_status(conn, options):
+ action = {
+ 'on' : "portCfgPersistentEnable",
+ 'off': "portCfgPersistentDisable"
+ }[options["--action"]]
+
+ conn.send_eol(action + " " + options["--plug"])
+ conn.log_expect(options, options["--command-prompt"], int(options["--power-timeout"]))
+
+def main():
+ device_opt = [ "ipaddr", "login", "passwd", "cmd_prompt", "secure", "port", "fabric_fencing" ]
+
+ atexit.register(atexit_handler)
+
+ all_opt["cmd_prompt"]["default"] = [ "> " ]
+
+ options = check_input(device_opt, process_input(device_opt))
+ options["eol"] = "\n"
+
+ docs = { }
+ docs["shortdesc"] = "Fence agent for HP Brocade over telnet/ssh"
+ docs["longdesc"] = "fence_brocade is an I/O Fencing agent which can be used with Brocade FC switches. \
+It logs into a Brocade switch via telnet and disables a specified port. Disabling the port which a machine is \
+connected to effectively fences that machine. Lengthy telnet connections to the switch should be avoided while \
+a GFS cluster is running because the connection will block any necessary fencing actions. \
+\
+After a fence operation has taken place the fenced machine can no longer connect to the Brocade FC switch. \
+When the fenced machine is ready to be brought back into the GFS cluster (after reboot) the port on the Brocade \
+FC switch needs to be enabled. This can be done by running fence_brocade and specifying the enable action"
+ docs["vendorurl"] = "http://www.brocade.com"
+ show_docs(options, docs)
+
+ ##
+ ## Operate the fencing device
+ ####
+ conn = fence_login(options)
+
+ result = fence_action(conn, options, set_power_status, get_power_status, None)
+
+ ##
+ ## Logout from system
+ ##
+ ## In some special unspecified cases it is possible that
+ ## connection will be closed before we run close(). This is not
+ ## a problem because everything is checked before.
+ ######
+ try:
+ conn.send_eol("exit")
+ conn.close()
+ except:
+ pass
+
+ sys.exit(result)
+
+if __name__ == "__main__":
+ main()
10 years, 8 months
cluster: RHEL64 - gfs2_grow: report bad return codes on error
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=e2a9e7c3cfe...
Commit: e2a9e7c3cfece6aa7f4582337d45ff880e8ba686
Parent: a40dd4574da7881ff980498f834f27aded844454
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Mon Dec 17 09:05:30 2012 -0600
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Thu Aug 29 11:57:43 2013 +0100
gfs2_grow: report bad return codes on error
This patch changes gfs2_grow so that if errors are encountered
during the gfs2_grow process, the return code for the command
will more accurately reflect the error. It will no longer report
a good return code if an error occurred.
rhbz#1001504
---
gfs2/mkfs/main_grow.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index 72bc7f9..831239e 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -294,6 +294,7 @@ main_grow(int argc, char *argv[])
struct gfs2_sbd sbd, *sdp = &sbd;
int rgcount, rindex_fd;
char rindex_name[PATH_MAX];
+ int error = EXIT_SUCCESS;
memset(sdp, 0, sizeof(struct gfs2_sbd));
sdp->bsize = GFS2_DEFAULT_BSIZE;
@@ -377,6 +378,7 @@ main_grow(int argc, char *argv[])
fssize = filesystem_size(sdp);
if (!sdp->rgtree.osi_node) {
log_err(_("Error: No resource groups found.\n"));
+ error = -EXIT_FAILURE;
goto out;
}
last_rgrp = (struct rgrp_tree *)osi_last(&sdp->rgtree);
@@ -390,8 +392,9 @@ main_grow(int argc, char *argv[])
fsgrowth / MB);
log_err( _("One RG is %uMB for this file system.\n"),
(rgsize * sdp->bsize) / MB);
- }
- else {
+ error = -EXIT_FAILURE;
+ goto out;
+ } else {
int old_rg_count;
if (metafs_interrupted)
10 years, 8 months
cluster: RHEL64 - libgfs2: Set umask before calling mkstemp
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=a40dd4574da...
Commit: a40dd4574da7881ff980498f834f27aded844454
Parent: 1177eedd0f1681cf3e6cc0271bcb8d65c7f75b52
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Fri Aug 16 10:37:40 2013 +0100
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Thu Aug 29 11:21:07 2013 +0100
libgfs2: Set umask before calling mkstemp
Coverity highlighted a case where mkstemp() was being called without the
umask being set. This sets the umask to create the file with 0600
permissions and then restores it after mkstemp() is called.
rhbz#1001504
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/misc.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c
index 6807f60..3989bf1 100644
--- a/gfs2/libgfs2/misc.c
+++ b/gfs2/libgfs2/misc.c
@@ -219,13 +219,16 @@ static void remove_mtab_entry(struct gfs2_sbd *sdp)
struct mntent *mountent;
char mtab_tmpfn[PATH_MAX];
int error, fd;
+ mode_t mask;
mtab = setmntent("/etc/mtab", "rt");
if (mtab == NULL)
die("Couldn't open /etc/mtab for writing: %s\n",
strerror(errno));
strcpy(mtab_tmpfn, "/etc/mtab.XXXXXX");
+ mask = umask(S_IXUSR | S_IRWXG | S_IRWXO);
fd = mkstemp(mtab_tmpfn);
+ umask(mask);
if (fd < 0)
die("Couldn't open temporary mtab file for writing: %s\n",
strerror(errno));
10 years, 8 months
cluster: RHEL64 - libgfs2: Correct error message in mtab update code
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=1177eedd0f1...
Commit: 1177eedd0f1681cf3e6cc0271bcb8d65c7f75b52
Parent: cf62f1ff9ec1a9d3aae6a9c473c3e002467b220a
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Thu Aug 15 07:41:56 2013 -0500
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Thu Aug 29 11:20:44 2013 +0100
libgfs2: Correct error message in mtab update code
If we encounter an error while trying to update the /etc/mtab file
the code was reporting that the problem in adding an entry. The
problem is, it's really trying to add the entries to the temp file,
which will be renamed to /etc/mtab, for the sake of removing an
entry from mtab. Therefore, I'm correcting the error message so that
it makes more sense.
rhbz#1001504
---
gfs2/libgfs2/misc.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c
index f7fab7e..6807f60 100644
--- a/gfs2/libgfs2/misc.c
+++ b/gfs2/libgfs2/misc.c
@@ -240,14 +240,14 @@ static void remove_mtab_entry(struct gfs2_sbd *sdp)
continue;
error = addmntent(mtabnew, mountent);
if (error)
- die("Unable to add mount entry to mtab.\n");
+ die("Unable to remove mount entry from mtab.\n");
}
endmntent(mtab);
fclose(mtabnew);
close(fd);
if (rename(mtab_tmpfn, "/etc/mtab"))
- fprintf(stderr, "Unable to add mount entry to mtab.\n");
+ fprintf(stderr, "Unable to remove mount entry from mtab.\n");
}
void cleanup_metafs(struct gfs2_sbd *sdp)
10 years, 8 months
cluster: RHEL64 - libgfs2: check return code of rename
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=cf62f1ff9ec...
Commit: cf62f1ff9ec1a9d3aae6a9c473c3e002467b220a
Parent: 8a67d7986d5ee4de27d89200cf1195cd427bb5f0
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Thu Aug 15 07:34:26 2013 -0500
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Thu Aug 29 11:19:47 2013 +0100
libgfs2: check return code of rename
This patch adds code to check the return code of 'rename' while
trying to update /etc/mtab.
rhbz#1001504
---
gfs2/libgfs2/misc.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c
index a6738b6..f7fab7e 100644
--- a/gfs2/libgfs2/misc.c
+++ b/gfs2/libgfs2/misc.c
@@ -246,7 +246,8 @@ static void remove_mtab_entry(struct gfs2_sbd *sdp)
endmntent(mtab);
fclose(mtabnew);
close(fd);
- rename(mtab_tmpfn, "/etc/mtab");
+ if (rename(mtab_tmpfn, "/etc/mtab"))
+ fprintf(stderr, "Unable to add mount entry to mtab.\n");
}
void cleanup_metafs(struct gfs2_sbd *sdp)
10 years, 8 months
cluster: RHEL64 - gfs2_tool: Update /etc/mtab with metafs mounts, handle interrupts
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=8a67d7986d5...
Commit: 8a67d7986d5ee4de27d89200cf1195cd427bb5f0
Parent: a2c3594467af4c1a8742a52aee7ae4fea6f0a9d1
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Thu Aug 8 14:50:04 2013 -0500
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Thu Aug 29 11:18:47 2013 +0100
gfs2_tool: Update /etc/mtab with metafs mounts, handle interrupts
This patch gives libgfs2 the ability to add the metafs to the
/etc/mtab file, so that a "mount" will show it and "umount -a -tgfs2"
will unmount it. At the same time, it also catches interrupt signals
while gfs2_tool df is running, and if interrupted, it unmounts the
metafs.
rhbz#1001504
---
gfs2/libgfs2/libgfs2.h | 2 +
gfs2/libgfs2/misc.c | 110 +++++++++++++++++++++++++++++++++++++++++-------
gfs2/mkfs/main_grow.c | 12 +++++-
gfs2/mkfs/main_jadd.c | 4 ++
gfs2/quota/check.c | 4 ++
gfs2/quota/main.c | 32 ++++++++------
gfs2/tool/misc.c | 8 ++++
7 files changed, 142 insertions(+), 30 deletions(-)
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 1b0b98d..3820ab7 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -665,6 +665,8 @@ extern int gfs2_query(int *setonabort, struct gfs2_options *opts,
/* misc.c */
+extern int metafs_interrupted;
+
extern int compute_heightsize(struct gfs2_sbd *sdp, uint64_t *heightsize,
uint32_t *maxheight, uint32_t bsize1, int diptrs, int inptrs);
extern int compute_constants(struct gfs2_sbd *sdp);
diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c
index 31fc665..a6738b6 100644
--- a/gfs2/libgfs2/misc.c
+++ b/gfs2/libgfs2/misc.c
@@ -17,6 +17,7 @@
#include <sys/sysmacros.h>
#include <mntent.h>
#include <sys/time.h>
+#include <signal.h>
#include "libgfs2.h"
@@ -25,6 +26,7 @@
#define DIV_RU(x, y) (((x) + (y) - 1) / (y))
static char sysfs_buf[PAGE_SIZE];
+int metafs_interrupted = 0;
int compute_heightsize(struct gfs2_sbd *sdp, uint64_t *heightsize,
uint32_t *maxheight, uint32_t bsize1, int diptrs, int inptrs)
@@ -211,30 +213,46 @@ static int lock_for_admin(struct gfs2_sbd *sdp)
return 0;
}
-
-int mount_gfs2_meta(struct gfs2_sbd *sdp)
+static void remove_mtab_entry(struct gfs2_sbd *sdp)
{
- int ret;
-
- memset(sdp->metafs_path, 0, PATH_MAX);
- snprintf(sdp->metafs_path, PATH_MAX - 1, "/tmp/.gfs2meta.XXXXXX");
+ FILE *mtab, *mtabnew;
+ struct mntent *mountent;
+ char mtab_tmpfn[PATH_MAX];
+ int error, fd;
+
+ mtab = setmntent("/etc/mtab", "rt");
+ if (mtab == NULL)
+ die("Couldn't open /etc/mtab for writing: %s\n",
+ strerror(errno));
+ strcpy(mtab_tmpfn, "/etc/mtab.XXXXXX");
+ fd = mkstemp(mtab_tmpfn);
+ if (fd < 0)
+ die("Couldn't open temporary mtab file for writing: %s\n",
+ strerror(errno));
- if(!mkdtemp(sdp->metafs_path))
- return -1;
+ mtabnew = fdopen(fd, "wt");
+ if (mtabnew == NULL)
+ die("Couldn't open %s for writing : %s\n", mtab_tmpfn,
+ strerror(errno));
- ret = mount(sdp->path_name, sdp->metafs_path, "gfs2meta", 0, NULL);
- if (ret) {
- rmdir(sdp->metafs_path);
- return -1;
+ while ((mountent = getmntent(mtab)) != NULL) {
+ if (!strcmp(mountent->mnt_dir, sdp->metafs_path))
+ continue;
+ error = addmntent(mtabnew, mountent);
+ if (error)
+ die("Unable to add mount entry to mtab.\n");
}
- if (lock_for_admin(sdp))
- return -1;
- return 0;
+
+ endmntent(mtab);
+ fclose(mtabnew);
+ close(fd);
+ rename(mtab_tmpfn, "/etc/mtab");
}
void cleanup_metafs(struct gfs2_sbd *sdp)
{
int ret;
+ struct sigaction sa = { .sa_handler = SIG_DFL };
if (sdp->metafs_fd <= 0)
return;
@@ -247,6 +265,68 @@ void cleanup_metafs(struct gfs2_sbd *sdp)
sdp->metafs_path, strerror(errno));
else
rmdir(sdp->metafs_path);
+ sigaction(SIGINT, &sa, NULL);
+ sigaction(SIGILL, &sa, NULL);
+ sigaction(SIGTERM, &sa, NULL);
+ sigaction(SIGHUP, &sa, NULL);
+ sigaction(SIGABRT, &sa, NULL);
+ sigaction(SIGSEGV, &sa, NULL);
+ sigaction(SIGCONT, &sa, NULL);
+ sigaction(SIGUSR1, &sa, NULL);
+ sigaction(SIGUSR2, &sa, NULL);
+ metafs_interrupted = 0;
+ remove_mtab_entry(sdp);
+}
+
+static void sighandler(int error)
+{
+ metafs_interrupted = 1;
+}
+
+int mount_gfs2_meta(struct gfs2_sbd *sdp)
+{
+ int ret;
+ struct mntent ment;
+ char mnt_type[5] = "gfs2";
+ char mnt_opts[9] = "gfs2meta";
+ FILE *mtab;
+ struct sigaction sa = { .sa_handler = &sighandler };
+
+ memset(sdp->metafs_path, 0, PATH_MAX);
+ snprintf(sdp->metafs_path, PATH_MAX - 1, "/tmp/.gfs2meta.XXXXXX");
+
+ if(!mkdtemp(sdp->metafs_path))
+ return -1;
+
+ mtab = setmntent("/etc/mtab", "at");
+ if (mtab == NULL) {
+ rmdir(sdp->metafs_path);
+ return -1;
+ }
+
+ sigaction(SIGINT, &sa, NULL);
+ sigaction(SIGILL, &sa, NULL);
+ sigaction(SIGTERM, &sa, NULL);
+ sigaction(SIGHUP, &sa, NULL);
+ sigaction(SIGABRT, &sa, NULL);
+ sigaction(SIGSEGV, &sa, NULL);
+ sigaction(SIGCONT, &sa, NULL);
+ sigaction(SIGUSR1, &sa, NULL);
+ sigaction(SIGUSR2, &sa, NULL);
+ ret = mount(sdp->path_name, sdp->metafs_path, "gfs2meta", 0, NULL);
+ if (ret) {
+ rmdir(sdp->metafs_path);
+ return -1;
+ }
+ ment.mnt_fsname = sdp->path_name;
+ ment.mnt_dir = sdp->metafs_path;
+ ment.mnt_type = mnt_type;
+ ment.mnt_opts = mnt_opts;
+ addmntent(mtab, &ment);
+ endmntent(mtab);
+ if (lock_for_admin(sdp))
+ return -1;
+ return 0;
}
static char *__get_sysfs(const char *fsname, const char *filename)
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index 06d8cba..72bc7f9 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -372,6 +372,8 @@ main_grow(int argc, char *argv[])
/* we're only going to write out new RG information after */
/* the existing RGs, and only write to the index at EOF. */
ri_update(sdp, rindex_fd, &rgcount, &sane);
+ if (metafs_interrupted)
+ goto out;
fssize = filesystem_size(sdp);
if (!sdp->rgtree.osi_node) {
log_err(_("Error: No resource groups found.\n"));
@@ -392,9 +394,15 @@ main_grow(int argc, char *argv[])
else {
int old_rg_count;
+ if (metafs_interrupted)
+ goto out;
compute_rgrp_layout(sdp, &sdp->rgtree, TRUE);
+ if (metafs_interrupted)
+ goto out;
print_info(sdp);
initialize_new_portion(sdp, &old_rg_count);
+ if (metafs_interrupted)
+ goto out;
fix_rindex(sdp, rindex_fd, old_rg_count);
}
out:
@@ -406,5 +414,7 @@ main_grow(int argc, char *argv[])
}
close(sdp->path_fd);
sync();
- log_notice( _("gfs2_grow complete.\n"));
+ if (!metafs_interrupted)
+ log_notice( _("gfs2_grow complete.\n"));
+ exit(error);
}
diff --git a/gfs2/mkfs/main_jadd.c b/gfs2/mkfs/main_jadd.c
index be13271..3e44fca 100644
--- a/gfs2/mkfs/main_jadd.c
+++ b/gfs2/mkfs/main_jadd.c
@@ -523,6 +523,10 @@ void main_jadd(int argc, char *argv[])
for (sdp->md.journals = sdp->orig_journals;
sdp->md.journals < total;
sdp->md.journals++) {
+ if (metafs_interrupted) {
+ cleanup_metafs(&sbd);
+ exit(130);
+ }
add_ir(sdp);
add_sc(sdp);
add_qc(sdp);
diff --git a/gfs2/quota/check.c b/gfs2/quota/check.c
index 81a4364..2208d2a 100644
--- a/gfs2/quota/check.c
+++ b/gfs2/quota/check.c
@@ -247,6 +247,8 @@ read_quota_file(struct gfs2_sbd *sdp, commandline_t *comline,
uint64_t end = fe->fe_logical + fe->fe_length, val_off;
unsigned int v_off;
+ if (metafs_interrupted)
+ break;
end = end > quota_file_size ? quota_file_size : end;
/* we only need to get the value fields, not the whole quota
* This also works when struct gfs2_quota straddle page
@@ -497,6 +499,8 @@ set_list(struct gfs2_sbd *sdp, commandline_t *comline, int user,
}
for (tmp = list->next; tmp != list; tmp = tmp->next) {
+ if (metafs_interrupted)
+ goto out;
v = osi_list_entry(tmp, values_t, v_list);
offset = (2 * (uint64_t)v->v_id + ((user) ? 0 : 1)) *
diff --git a/gfs2/quota/main.c b/gfs2/quota/main.c
index 0625b7d..d9f56ab 100644
--- a/gfs2/quota/main.c
+++ b/gfs2/quota/main.c
@@ -401,18 +401,20 @@ do_reset(struct gfs2_sbd *sdp, commandline_t *comline)
strerror(errno));
}
- read_quota_internal(fd, 0, GQ_ID_USER, &q);
- write_quota_internal(fd, 0, GQ_ID_USER, &q);
+ if (!metafs_interrupted) {
+ read_quota_internal(fd, 0, GQ_ID_USER, &q);
+ write_quota_internal(fd, 0, GQ_ID_USER, &q);
- read_quota_internal(fd, 0, GQ_ID_GROUP, &q);
- write_quota_internal(fd, 0, GQ_ID_GROUP, &q);
+ read_quota_internal(fd, 0, GQ_ID_GROUP, &q);
+ write_quota_internal(fd, 0, GQ_ID_GROUP, &q);
- /* truncate the quota file such that only the first
- * two quotas(uid=0 and gid=0) remain.
- */
- if (ftruncate(fd, (sizeof(struct gfs2_quota)) * 2))
- die("couldn't truncate quota file %s\n", strerror(errno));
-
+ /* truncate the quota file such that only the first
+ * two quotas(uid=0 and gid=0) remain.
+ */
+ if (ftruncate(fd, (sizeof(struct gfs2_quota)) * 2))
+ die("couldn't truncate quota file %s\n",
+ strerror(errno));
+ }
close(fd);
close(sdp->metafs_fd);
cleanup_metafs(sdp);
@@ -508,6 +510,8 @@ do_list(struct gfs2_sbd *sdp, commandline_t *comline)
struct fiemap_extent *fe = &fmap2->fm_extents[i];
uint64_t end = fe->fe_logical + fe->fe_length;
+ if (metafs_interrupted)
+ goto fmap2_free;
end = end > quota_file_size ? quota_file_size : end;
startid = DIV_RU(fe->fe_logical, sizeof(struct gfs2_quota));
if (startid % 2 != pass)
@@ -582,7 +586,7 @@ do_get_one(struct gfs2_sbd *sdp, commandline_t *comline, char *filesystem)
strcat(quota_file, "/quota");
fd = open(quota_file, O_RDONLY);
- if (fd < 0) {
+ if (fd < 0 || metafs_interrupted) {
close(sdp->metafs_fd);
cleanup_metafs(sdp);
die("can't open file %s: %s\n", quota_file,
@@ -756,7 +760,7 @@ do_set(struct gfs2_sbd *sdp, commandline_t *comline)
strcat(quota_file, "/quota");
fd = open(quota_file, O_RDWR);
- if (fd < 0) {
+ if (fd < 0 || metafs_interrupted) {
close(sdp->metafs_fd);
cleanup_metafs(sdp);
die("can't open file %s: %s\n", quota_file,
diff --git a/gfs2/tool/misc.c b/gfs2/tool/misc.c
index 359567c..37c81cd 100644
--- a/gfs2/tool/misc.c
+++ b/gfs2/tool/misc.c
@@ -276,11 +276,19 @@ void print_journals(int argc, char **argv)
sprintf(jindex_name, "%s/jindex", sbd.metafs_path);
jindex = opendir(jindex_name);
+ if (metafs_interrupted) {
+ cleanup_metafs(&sbd);
+ exit(130);
+ }
if (!jindex) {
die( _("Can't open %s\n"), jindex_name);
} else {
jcount = 0;
while ((journal = readdir(jindex))) {
+ if (metafs_interrupted) {
+ cleanup_metafs(&sbd);
+ exit(130);
+ }
if (journal->d_name[0] == '.')
continue;
sprintf(jname, "%s/%s", jindex_name, journal->d_name);
10 years, 8 months