cluster: RHEL6 - libfenced: make fenced_external() also write to fifo
by Christine Caulfield
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=cbbe13ce1fa...
Commit: cbbe13ce1fafe0ecd9adb01473825f78da7291f2
Parent: bcd9f9378cbc41afbfd82ce84febbaa91f29e7af
Author: Christine Caulfield <ccaulfie(a)redhat.com>
AuthorDate: Mon Mar 10 10:05:06 2014 +0000
Committer: Christine Caulfield <ccaulfie(a)redhat.com>
CommitterDate: Mon Mar 10 10:05:06 2014 +0000
libfenced: make fenced_external() also write to fifo
fenced doesn't listen to the library socket (or anything) else
while in fence_victions(). So if pacemaker tries to acknowledge
a manual fence using that call it will not reach the daemon while
it is failing to fence a node.
This patch adds code to fence_external() to also write to the
fence_ack_manual FIFO soo, which fenced *does* poll, so that the
message gets through.
rhbz#105926910592691059269
Signed-off-by: Christine Caulfield <ccaulfie(a)redhat.com>
---
fence/fenced/recover.c | 29 ++++++++++++++---------------
fence/libfenced/main.c | 18 ++++++++++++++++++
2 files changed, 32 insertions(+), 15 deletions(-)
diff --git a/fence/fenced/recover.c b/fence/fenced/recover.c
index 0b5e2b2..c9786fe 100644
--- a/fence/fenced/recover.c
+++ b/fence/fenced/recover.c
@@ -1,6 +1,7 @@
#include "fd.h"
#include "config.h"
+
void free_node_list(struct list_head *head)
{
struct node *node;
@@ -80,14 +81,11 @@ static int reduce_victims(struct fd *fd)
return num_victims;
}
-static inline void close_override(int *fd, const char *path)
+static inline void close_override(int fd, const char *path)
{
unlink(path);
- if (fd) {
- if (*fd >= 0)
- close(*fd);
- *fd = -1;
- }
+ if (fd >= 0)
+ close(fd);
}
static int open_override(const char *path)
@@ -339,7 +337,7 @@ void fence_victims(struct fd *fd)
{
struct node *node;
int error, i, ll, flog_count, prev_flog_count;
- int override = -1;
+ int override_fd = -1;
int cluster_member, cpg_member, ext;
unsigned int limit, retries;
@@ -404,6 +402,9 @@ void fence_victims(struct fd *fd)
if (!limit)
log_level(LOG_INFO, "fencing node %s", node->name);
+ if (override_fd == -1)
+ override_fd = open_override(cfgd_override_path);
+
query_unlock();
error = fence_node(node->name, flog, FL_SIZE, &flog_count);
query_lock();
@@ -447,7 +448,7 @@ void fence_victims(struct fd *fd)
continue;
}
- if (!cfgd_override_path) {
+ if (!cfgd_override_path || (override_fd == -1)) {
query_unlock();
sleep(5);
query_lock();
@@ -456,22 +457,20 @@ void fence_victims(struct fd *fd)
}
/* Check for manual intervention */
- override = open_override(cfgd_override_path);
- if (check_override(override, node->name,
- cfgd_override_time) > 0) {
- log_level(LOG_WARNING, "fence %s overridden by "
- "administrator intervention", node->name);
+ if (check_override(override_fd, node->name, cfgd_override_time) > 0) {
+ log_level(LOG_WARNING, "fence %s overridden by administrator intervention", node->name);
node->local_victim_done = 1;
victim_done(fd, node->nodeid, VIC_DONE_OVERRIDE);
- close_override(&override, cfgd_override_path);
continue;
} else {
- close_override(&override, cfgd_override_path);
retries++;
goto retry;
}
}
fd->current_victim = 0;
+
+ if (override_fd >= 0)
+ close_override(override_fd, cfgd_override_path);
}
diff --git a/fence/libfenced/main.c b/fence/libfenced/main.c
index 9537953..319a2d6 100644
--- a/fence/libfenced/main.c
+++ b/fence/libfenced/main.c
@@ -3,6 +3,7 @@
#include <unistd.h>
#include <stdint.h>
#include <errno.h>
+#include <fcntl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
@@ -119,6 +120,19 @@ int fenced_leave(void)
return rv;
}
+static void local_override(char *name)
+{
+ int fd;
+
+ fd = open("/var/run/cluster/fenced_override", O_WRONLY|O_NONBLOCK);
+ if (fd < 0)
+ return;
+
+ write(fd, name, strlen(name));
+
+ close(fd);
+}
+
int fenced_external(char *name)
{
char msg[sizeof(struct fenced_header) + MAX_NODENAME_LEN + 1];
@@ -143,6 +157,10 @@ int fenced_external(char *name)
rv = do_write(fd, hd, sizeof(msg));
close(fd);
+
+ /* When fenced is busy fencing it won't receive/process messages,
+ but it does check the local override fifo. */
+ local_override(name);
out:
return rv;
}
10 years, 1 month
fence-agents: RHEL6 - fencing: All defaults values are translated to strings
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=b06d38...
Commit: b06d381452aa739e47682644bfea80ef1b834bcb
Parent: 043791cfd1dbf5cb0cc9e2ddfe3a39029942e365
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Thu Feb 27 15:37:12 2014 +0100
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Thu Feb 27 15:37:12 2014 +0100
fencing: All defaults values are translated to strings
Previously, we defaults were not translated to strings before printing metadata but
as we wish to replace a special characters, defaults have to be strings.
---
fence/agents/lib/fencing.py.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 4f59694..576140e 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -495,7 +495,7 @@ def metadata(avail_opt, options, docs):
elif options.has_key("-" + all_opt[option]["getopt"][:-1]):
if options["-" + all_opt[option]["getopt"][:-1]]:
try:
- default = options["-" + all_opt[option]["getopt"][:-1]]
+ default = str(options["-" + all_opt[option]["getopt"][:-1]])
except TypeError:
## @todo/@note: Currently there is no clean way how to handle lists
## we can create a string from it but we can't set it on command line
10 years, 1 month
fence-agents: RHEL6 - fencing: XML output should escape special characters
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=043791...
Commit: 043791cfd1dbf5cb0cc9e2ddfe3a39029942e365
Parent: 1deb5e348b286c1432743bcdfe372403325849cc
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed Feb 26 17:50:17 2014 +0100
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed Feb 26 17:50:17 2014 +0100
fencing: XML output should escape special characters
Based on 402d7eed3e7b9648ee8cc38e420e481800b03309 (upstream)
---
fence/agents/lib/fencing.py.py | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 3cd481b..4f59694 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -491,17 +491,25 @@ def metadata(avail_opt, options, docs):
default = ""
if all_opt[option].has_key("default"):
- default = "default=\""+str(all_opt[option]["default"])+"\""
+ default = str(all_opt[option]["default"])
elif options.has_key("-" + all_opt[option]["getopt"][:-1]):
if options["-" + all_opt[option]["getopt"][:-1]]:
try:
- default = "default=\"" + options["-" + all_opt[option]["getopt"][:-1]] + "\""
+ default = options["-" + all_opt[option]["getopt"][:-1]]
except TypeError:
## @todo/@note: Currently there is no clean way how to handle lists
## we can create a string from it but we can't set it on command line
- default = "default=\"" + str(options["-" + all_opt[option]["getopt"][:-1]]) +"\""
+ default = str(options["-" + all_opt[option]["getopt"][:-1]])
elif options.has_key("-" + all_opt[option]["getopt"]):
- default = "default=\"true\" "
+ default = "true"
+
+ if default:
+ default = default.replace("&", "&" )
+ default = default.replace('"', """ )
+ default = default.replace('<', "<" )
+ default = default.replace('>', ">" )
+ default = default.replace("'", "'" )
+ default = "default=\"" + default + "\" "
mixed = all_opt[option]["help"]
## split it between option and help text
10 years, 1 month
fence-agents: RHEL6 - fencing: Add option --ssh-options
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=1deb5e...
Commit: 1deb5e348b286c1432743bcdfe372403325849cc
Parent: da403ab459474ba70303b2b46c9459c2872d6d68
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed Feb 26 17:42:25 2014 +0100
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed Feb 26 17:42:25 2014 +0100
fencing: Add option --ssh-options
Resolves: rhbz#1069618
---
fence/agents/apc/fence_apc.py | 8 ++------
fence/agents/lib/fencing.py.py | 15 +++++++++++----
fence/agents/rsa/fence_rsa.py | 8 ++++----
fence/agents/virsh/fence_virsh.py | 6 +++---
4 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/fence/agents/apc/fence_apc.py b/fence/agents/apc/fence_apc.py
index 78e709f..d79f7f3 100644
--- a/fence/agents/apc/fence_apc.py
+++ b/fence/agents/apc/fence_apc.py
@@ -218,19 +218,15 @@ def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
"secure", "port", "identity_file", "switch", "test", "separator",
- "inet4_only", "inet6_only", "ipport", "cmd_prompt",
+ "inet4_only", "inet6_only", "ipport", "cmd_prompt", "ssh_options",
"power_timeout", "shell_timeout", "login_timeout", "power_wait" ]
atexit.register(atexit_handler)
all_opt["cmd_prompt"]["default"] = [ "\n>", "\napc>" ]
+ all_opt["ssh_options"]["default"] = "-1 -c blowfish"
options = check_input(device_opt, process_input(device_opt))
- ##
- ## Fence agent specific defaults
- #####
- options["ssh_options"] = "-1 -c blowfish"
-
docs = { }
docs["shortdesc"] = "Fence agent for APC over telnet/ssh"
docs["longdesc"] = "fence_apc is an I/O Fencing agent \
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 1de9a15..3cd481b 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -189,6 +189,13 @@ all_opt = {
"shortdesc" : "SSH connection",
"required" : "0",
"order" : 1 },
+ "ssh_options" : {
+ "getopt" : "X:",
+ "longopt" : "ssh-options",
+ "help" : "--ssh-options=<options> SSH options to use",
+ "shortdesc" : "SSH options to use",
+ "required" : "0",
+ "order" : 1 },
"ssl" : {
"getopt" : "z",
"longopt" : "ssl",
@@ -892,8 +899,8 @@ def fence_login(options, re_login_string = "(login\s*: )|(Login Name: )|(userna
sys.exit(EC_GENERIC_ERROR)
elif options.has_key("-x") and 0 == options.has_key("-k"):
command = '%s %s %s@%s -p %s' % (SSH_PATH, force_ipvx, options["-l"], options["-a"], options["-u"])
- if options.has_key("ssh_options"):
- command += ' ' + options["ssh_options"]
+ if options.has_key("-X"):
+ command += ' ' + options["-X"]
try:
conn = fspawn(options, command)
except pexpect.ExceptionPexpect, ex:
@@ -921,8 +928,8 @@ def fence_login(options, re_login_string = "(login\s*: )|(Login Name: )|(userna
conn.log_expect(options, options["-c"], int(options["-y"]))
elif options.has_key("-x") and 1 == options.has_key("-k"):
command = '%s %s %s@%s -i %s -p %s' % (SSH_PATH, force_ipvx, options["-l"], options["-a"], options["-k"], options["-u"])
- if options.has_key("ssh_options"):
- command += ' ' + options["ssh_options"]
+ if options.has_key("-X"):
+ command += ' ' + options["-X"]
try:
conn = fspawn(options, command)
except pexpect.ExceptionPexpect, ex:
diff --git a/fence/agents/rsa/fence_rsa.py b/fence/agents/rsa/fence_rsa.py
index e9f87cd..eb9555f 100644
--- a/fence/agents/rsa/fence_rsa.py
+++ b/fence/agents/rsa/fence_rsa.py
@@ -46,12 +46,15 @@ def set_power_status(conn, options):
def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
- "cmd_prompt", "secure", "identity_file", "ipport",
+ "cmd_prompt", "secure", "identity_file", "ipport", "ssh_options",
"power_timeout", "shell_timeout", "login_timeout", "power_wait" ]
atexit.register(atexit_handler)
all_opt["login_timeout"]["default"] = 10
+ # This device will not allow us to login even with LANG=C
+ all_opt["ssh_options"]["default"] = "-F /dev/null"
+
options = check_input(device_opt, process_input(device_opt))
##
@@ -59,9 +62,6 @@ def main():
#####
if 0 == options.has_key("-c"):
options["-c"] = ">"
-
- # This device will not allow us to login even with LANG=C
- options["ssh_options"] = "-F /dev/null"
docs = { }
docs["shortdesc"] = "Fence agent for IBM RSA"
diff --git a/fence/agents/virsh/fence_virsh.py b/fence/agents/virsh/fence_virsh.py
index 13099da..ea5a785 100644
--- a/fence/agents/virsh/fence_virsh.py
+++ b/fence/agents/virsh/fence_virsh.py
@@ -63,11 +63,13 @@ def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
"secure", "identity_file", "test", "port", "separator",
- "inet4_only", "inet6_only", "ipport",
+ "inet4_only", "inet6_only", "ipport", "ssh_options",
"power_timeout", "shell_timeout", "login_timeout", "power_wait" ]
atexit.register(atexit_handler)
+ all_opt["ssh_options"]["default"] = "-t '/bin/bash -c \"PS1=\[EXPECT\]#\ /bin/bash --noprofile --norc\"'"
+
pinput = process_input(device_opt)
pinput["-x"] = 1
options = check_input(device_opt, pinput)
@@ -76,8 +78,6 @@ def main():
if 0 == options.has_key("-c"):
options["-c"] = "\[EXPECT\]#\ "
- options["ssh_options"]="-t '/bin/bash -c \"PS1=\[EXPECT\]#\ /bin/bash --noprofile --norc\"'"
-
docs = { }
docs["shortdesc"] = "Fence agent for virsh"
docs["longdesc"] = "fence_virsh is an I/O Fencing agent \
10 years, 1 month
gfs2-utils: master - gfs2_edit: mark log headers with the unmounted flag
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=dce63a15...
Commit: dce63a150565f91d1386e2444d6cb378e8be1dd5
Parent: caa139f3ea058581bb50ef919e6c412c3da4dfc2
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Mon Mar 3 16:17:02 2014 -0500
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Fri Mar 7 13:23:32 2014 +0000
gfs2_edit: mark log headers with the unmounted flag
This patch prints out "[UNMOUNTED]" next to log headers that have the
unmounted flag set. That makes it much easier to determine the active
part of a journal.
Signed-off-by: Bob Peterson <rpeterso(a)redhat.com>
---
gfs2/edit/journal.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/gfs2/edit/journal.c b/gfs2/edit/journal.c
index dc8a3ed..e012bc3 100644
--- a/gfs2/edit/journal.c
+++ b/gfs2/edit/journal.c
@@ -573,10 +573,13 @@ void dump_journal(const char *journal, int tblk)
check_journal_wrap(lh.lh_sequence,
&highest_seq);
print_gfs2("0x%llx (j+%4llx): Log header: Seq"
- ": 0x%x, tail: 0x%x, blk: 0x%x",
+ ": 0x%x, tail: 0x%x, blk: 0x%x%s",
abs_block, ((jb + wrappt) % j_size)
/ sbd.bsize, lh.lh_sequence,
- lh.lh_tail, lh.lh_blkno);
+ lh.lh_tail, lh.lh_blkno,
+ lh.lh_flags ==
+ GFS2_LOG_HEAD_UNMOUNT ?
+ " [UNMOUNTED]" : "");
}
eol(0);
} else if (sbd.gfs1 && ld_blocks > 0) {
10 years, 1 month
cluster: RHEL511 - libgfs2: Fix up remove_mtab_entry
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=1c64c531196...
Commit: 1c64c5311961697a66ba3ee745e7b1d847409c8c
Parent: 9f44c21fe98880937eb53f1e9e2c237520f86961
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Tue Feb 4 00:00:05 2014 -0600
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Thu Mar 6 10:35:59 2014 +0000
libgfs2: Fix up remove_mtab_entry
mkstemp was creating the temporary mtab file with overly tight
permissions causing /etc/mtab to end up with an 0600 mode instead of the
regular 0644. This patch resets the mode to 0644 by calling fchmod on
the file descriptor returned by mkstemp.
It also removes a superfluous close() call and sets the temp filename
char array on initialisation instead of using strcpy().
Resolves: rhbz#1073384
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/misc.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c
index 6a1f07f..838209e 100644
--- a/gfs2/libgfs2/misc.c
+++ b/gfs2/libgfs2/misc.c
@@ -227,7 +227,7 @@ static void remove_mtab_entry(struct gfs2_sbd *sdp)
{
FILE *mtab, *mtabnew;
struct mntent *mountent;
- char mtab_tmpfn[PATH_MAX];
+ char mtab_tmpfn[] = "/etc/mtab.XXXXXX";
int error, fd;
mode_t mask;
@@ -235,7 +235,7 @@ static void remove_mtab_entry(struct gfs2_sbd *sdp)
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);
@@ -243,6 +243,9 @@ static void remove_mtab_entry(struct gfs2_sbd *sdp)
die("Couldn't open temporary mtab file for writing: %s\n",
strerror(errno));
+ if (fchmod(fd, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH))
+ die("Couldn't change mode of temporary mtab: %s\n", strerror(errno));
+
mtabnew = fdopen(fd, "wt");
if (mtabnew == NULL)
die("Couldn't open %s for writing : %s\n", mtab_tmpfn,
@@ -257,8 +260,7 @@ static void remove_mtab_entry(struct gfs2_sbd *sdp)
}
endmntent(mtab);
- fclose(mtabnew);
- close(fd);
+ fclose(mtabnew); /* Closes underlying fd */
if (rename(mtab_tmpfn, "/etc/mtab"))
fprintf(stderr, "Unable to remove mount entry from mtab.\n");
}
10 years, 1 month
gfs2-utils: master - gfs2_edit: Improve log descriptor reference code
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=caa139f3...
Commit: caa139f3ea058581bb50ef919e6c412c3da4dfc2
Parent: 02b1f7d0feeb7e948a77501752ee872d9cfed9c4
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Mon Mar 3 18:31:58 2014 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Mon Mar 3 18:31:58 2014 +0000
gfs2_edit: Improve log descriptor reference code
The previous journal dumping code to determine log descriptor references
was convoluted and didn't work properly in all cases. This version adds
a get_ldref function to read ld references from the journal and removes
the need to store addresses in a large static array.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/journal.c | 48 +++++++++++++++++++++++++++++++++++-------------
1 files changed, 35 insertions(+), 13 deletions(-)
diff --git a/gfs2/edit/journal.c b/gfs2/edit/journal.c
index 5000c2e..dc8a3ed 100644
--- a/gfs2/edit/journal.c
+++ b/gfs2/edit/journal.c
@@ -198,8 +198,7 @@ static int ld_is_pertinent(const uint64_t *b, const char *end, uint64_t tblk,
static int print_ld_blks(const uint64_t *b, const char *end, int start_line,
uint64_t tblk, uint64_t *tblk_off, uint64_t bitblk,
struct rgrp_tree *rgd, uint64_t abs_block, int prnt,
- uint64_t *bblk_off, int is_meta_ld,
- uint64_t ld_blk_refs[])
+ uint64_t *bblk_off, int is_meta_ld)
{
int bcount = 0, found_tblk = 0, found_bblk = 0;
static char str[256];
@@ -217,8 +216,6 @@ static int print_ld_blks(const uint64_t *b, const char *end, int start_line,
eol(0);
print_gfs2(" ");
}
- if (ld_blk_refs)
- ld_blk_refs[bcount] = be64_to_cpu(*b);
bcount++;
if (prnt) {
sprintf(str, "0x%llx",
@@ -342,8 +339,7 @@ static uint64_t find_wrap_pt(struct gfs2_inode *j_inode, char *jbuf,
static int process_ld(uint64_t abs_block, uint64_t wrappt, uint64_t j_size,
uint64_t jb, struct gfs2_buffer_head *dummy_bh, int tblk,
uint64_t *tblk_off, uint64_t bitblk,
- struct rgrp_tree *rgd, int *prnt, uint64_t *bblk_off,
- uint64_t ld_blk_refs[])
+ struct rgrp_tree *rgd, int *prnt, uint64_t *bblk_off)
{
uint64_t *b;
struct gfs2_log_descriptor ld;
@@ -391,7 +387,7 @@ static int process_ld(uint64_t abs_block, uint64_t wrappt, uint64_t j_size,
is_meta_ld = 1;
ld_blocks -= print_ld_blks(b, (dummy_bh->b_data + sbd.bsize), line,
tblk, tblk_off, bitblk, rgd, abs_block,
- *prnt, bblk_off, is_meta_ld, ld_blk_refs);
+ *prnt, bblk_off, is_meta_ld);
return ld_blocks;
}
@@ -423,6 +419,27 @@ static int meta_has_ref(uint64_t abs_block, int tblk)
return has_ref;
}
+
+/**
+ * get_ldref - get a log descriptor reference block, given a block number
+ *
+ * Note that we can't pass in abs_block here, because journal wrap may
+ * mean that the block we're interested in, in the journal, is before the
+ * log descriptor that holds the reference we need.
+ */
+static uint64_t get_ldref(uint64_t abs_ld, int offset_from_ld)
+{
+ struct gfs2_buffer_head *jbh;
+ uint64_t *b, refblk;
+
+ jbh = bread(&sbd, abs_ld);
+ b = (uint64_t *)(jbh->b_data + sizeof(struct gfs2_log_descriptor));
+ b += offset_from_ld - 1;
+ refblk = be64_to_cpu(*b);
+ brelse(jbh);
+ return refblk;
+}
+
/**
* dump_journal - dump a journal file's contents.
* @journal: name of the journal to dump
@@ -444,7 +461,7 @@ void dump_journal(const char *journal, int tblk)
uint64_t highest_seq = 0;
char *jbuf = NULL;
struct rgrp_tree *rgd = NULL;
- uint64_t ld_blk_refs[503]; /* The most blks a LD can have */
+ uint64_t abs_ld = 0;
start_line = line;
lines_per_row[dmode] = 1;
@@ -533,8 +550,9 @@ void dump_journal(const char *journal, int tblk)
ld_blocks = process_ld(abs_block, wrappt, j_size, jb,
&dummy_bh, tblk, &tblk_off,
bitblk, rgd, &is_pertinent,
- &bblk_off, ld_blk_refs);
+ &bblk_off);
offset_from_ld = 0;
+ abs_ld = abs_block;
} else if (!tblk && block_type == GFS2_METATYPE_LH) {
struct gfs2_log_header lh;
struct gfs_log_header lh1;
@@ -570,7 +588,7 @@ void dump_journal(const char *journal, int tblk)
(dummy_bh.b_data +
sbd.bsize), start_line,
tblk, &tblk_off, 0, rgd,
- 0, 1, NULL, 1, NULL);
+ 0, 1, NULL, 1);
} else if (block_type == 0) {
continue;
}
@@ -580,12 +598,16 @@ void dump_journal(const char *journal, int tblk)
((tblk_off && offset_from_ld == tblk_off) ||
(bblk_off && offset_from_ld == bblk_off))) ||
meta_has_ref(abs_block, tblk)))) {
+ uint64_t ref_blk = 0;
+
saveblk = block;
block = abs_block;
- if (tblk)
- display(0, 1, tblk, ld_blk_refs[offset_from_ld]);
- else
+ if (tblk && !details) {
+ ref_blk = get_ldref(abs_ld, offset_from_ld);
+ display(0, 1, tblk, ref_blk);
+ } else {
display(0, 0, 0, 0);
+ }
block = saveblk;
}
}
10 years, 1 month
gfs2-utils: master - gfs2-utils: Fail to configure if flex is not found
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=02b1f7d0...
Commit: 02b1f7d0feeb7e948a77501752ee872d9cfed9c4
Parent: 5bb5b3e8078886d3fd614f00c467a846b89ec23f
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Fri Feb 28 10:31:02 2014 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Fri Feb 28 11:00:57 2014 +0000
gfs2-utils: Fail to configure if flex is not found
We require flex to build so the configure script should not succeed if
flex is not installed. We use flex-specific features so check for flex
specifically.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
configure.ac | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/configure.ac b/configure.ac
index 80310be..b93eec9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,6 +58,7 @@ AC_PROG_LN_S
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_LEX
+test "$LEX" != "flex" && AC_MSG_ERROR([flex not found])
AC_CHECK_PROG([YACC], [bison], [bison -y])
test x"$YACC" = x && AC_MSG_ERROR([bison not found])
10 years, 1 month
gfs2-utils: master - gfs2_edit: More static analysis fixes
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=5bb5b3e8...
Commit: 5bb5b3e8078886d3fd614f00c467a846b89ec23f
Parent: 9d1c4678ce559f774e7bb3eb349e9ddef0650289
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Thu Feb 27 20:19:52 2014 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Fri Feb 28 00:40:15 2014 +0000
gfs2_edit: More static analysis fixes
Fix some more minor issues found by Coverity and Clang, including
unchecked lseek()s, unbound strcpy()s, branching based on an
uninitialised variable, potential NULL pointer derefs, some dead
assignments and a dangling reference to a local variable.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/extended.c | 5 +----
gfs2/edit/gfs2hex.c | 7 ++++---
gfs2/edit/hexedit.c | 13 +++++++------
gfs2/edit/journal.c | 36 +++++++++++++++---------------------
gfs2/edit/savemeta.c | 18 ++++++------------
5 files changed, 33 insertions(+), 46 deletions(-)
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index 793ef6b..e5cb12c 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -391,9 +391,8 @@ static void print_block_details(struct iinfo *ind, int level, int cur_height,
return;
}
while (thisblk) {
- lseek(sbd.device_fd, thisblk * sbd.bsize, SEEK_SET);
/* read in the desired block */
- if (read(sbd.device_fd, tmpbuf, sbd.bsize) != sbd.bsize) {
+ if (pread(sbd.device_fd, tmpbuf, sbd.bsize, thisblk * sbd.bsize) != sbd.bsize) {
fprintf(stderr, "bad read: %s from %s:%d: block %lld "
"(0x%llx)\n", strerror(errno), __FUNCTION__,
__LINE__,
@@ -446,7 +445,6 @@ static int print_gfs_jindex(struct gfs2_inode *dij)
char jbuf[sizeof(struct gfs_jindex)];
start_line = line;
- error = 0;
print_gfs2("Journal index entries found: %d.",
dij->i_di.di_size / sizeof(struct gfs_jindex));
eol(0);
@@ -516,7 +514,6 @@ static int parse_rindex(struct gfs2_inode *dip, int print_rindex)
char highlighted_addr[32];
start_line = line;
- error = 0;
print_gfs2("RG index entries found: %d.", dip->i_di.di_size /
sizeof(struct gfs2_rindex));
eol(0);
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index 979aee0..b6075f4 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -38,7 +38,6 @@ char efield[64];
int edit_mode = 0;
int edit_row[DMODES], edit_col[DMODES];
int edit_size[DMODES], last_entry_onscreen[DMODES];
-char edit_fmt[80];
enum dsp_mode dmode = HEX_MODE; /* display mode */
uint64_t block = 0;
int blockhist = 0;
@@ -201,9 +200,11 @@ void print_it(const char *label, const char *fmt, const char *fmt2, ...)
if (termlines) {
refresh();
if (line == (edit_row[dmode] * lines_per_row[dmode]) + 4) {
- strcpy(efield, label + 2); /* it's indented */
+ strncpy(efield, label + 2, 63); /* it's indented */
+ efield[63] = '\0';
strcpy(estring, tmp_string);
- strcpy(edit_fmt, fmt);
+ strncpy(edit_fmt, fmt, 79);
+ edit_fmt[79] = '\0';
edit_size[dmode] = strlen(estring);
COLORS_NORMAL;
}
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 5c5ac89..bc3ca35 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -1583,7 +1583,7 @@ static uint64_t find_metablockoftype_rg(uint64_t startblk, int metatype, int pri
struct osi_node *next = NULL;
uint64_t blk, errblk;
int first = 1, found = 0;
- struct rgrp_tree *rgd;
+ struct rgrp_tree *rgd = NULL;
struct gfs2_rindex *ri;
blk = 0;
@@ -1726,7 +1726,7 @@ uint64_t check_keywords(const char *kword)
blk = get_rg_addr(rgnum);
} else if (!strncmp(kword, "journals", 8)) {
blk = JOURNALS_DUMMY_BLOCK;
- } else if (!strncmp(kword, "journal", 7) && isdigit(kword[7])) {
+ } else if (strlen(kword) > 7 && !strncmp(kword, "journal", 7) && isdigit(kword[7])) {
uint64_t j_size;
blk = find_journal_block(kword, &j_size);
@@ -1837,8 +1837,7 @@ static void hex_edit(int *exitch)
ch += (estring[i+1] - 'A' + 0x0a);
bh->b_data[offset + hexoffset] = ch;
}
- lseek(sbd.device_fd, dev_offset, SEEK_SET);
- if (write(sbd.device_fd, bh->b_data, sbd.bsize) !=
+ if (pwrite(sbd.device_fd, bh->b_data, sbd.bsize, dev_offset) !=
sbd.bsize) {
fprintf(stderr, "write error: %s from %s:%d: "
"offset %lld (0x%llx)\n",
@@ -2676,8 +2675,10 @@ static void parameterpass1(int argc, char *argv[], int i)
termlines = 0;
else if (!strcasecmp(argv[i], "-x"))
dmode = HEX_MODE;
- else if (!device[0] && strchr(argv[i],'/'))
- strcpy(device, argv[i]);
+ else if (!device[0] && strchr(argv[i],'/')) {
+ strncpy(device, argv[i], NAME_MAX-1);
+ device[NAME_MAX-1] = '\0';
+ }
}
/* ------------------------------------------------------------------------ */
diff --git a/gfs2/edit/journal.c b/gfs2/edit/journal.c
index 3c2f5c7..5000c2e 100644
--- a/gfs2/edit/journal.c
+++ b/gfs2/edit/journal.c
@@ -98,16 +98,6 @@ static void check_journal_wrap(uint64_t seq, uint64_t *highest_seq)
*highest_seq = seq;
}
-static int is_meta(struct gfs2_buffer_head *lbh)
-{
- uint32_t check_magic = ((struct gfs2_meta_header *)(lbh->b_data))->mh_magic;
-
- check_magic = be32_to_cpu(check_magic);
- if (check_magic == GFS2_MAGIC)
- return 1;
- return 0;
-}
-
/**
* fsck_readi - same as libgfs2's gfs2_readi, but sets absolute block #
* of the first bit of data read.
@@ -115,16 +105,20 @@ static int is_meta(struct gfs2_buffer_head *lbh)
static int fsck_readi(struct gfs2_inode *ip, void *rbuf, uint64_t roffset,
unsigned int size, uint64_t *abs_block)
{
- struct gfs2_sbd *sdp = ip->i_sbd;
+ struct gfs2_sbd *sdp;
struct gfs2_buffer_head *lbh;
uint64_t lblock, dblock;
unsigned int o;
uint32_t extlen = 0;
unsigned int amount;
int not_new = 0;
- int isdir = !!(S_ISDIR(ip->i_di.di_mode));
+ int isdir;
int copied = 0;
+ if (ip == NULL)
+ return 0;
+ sdp = ip->i_sbd;
+ isdir = !!(S_ISDIR(ip->i_di.di_mode));
*abs_block = 0;
if (roffset >= ip->i_di.di_size)
return 0;
@@ -287,9 +281,9 @@ static int print_ld_blks(const uint64_t *b, const char *end, int start_line,
}
if (prnt)
eol(0);
- if (!found_tblk || !is_meta_ld)
+ if (tblk_off && (!found_tblk || !is_meta_ld))
*tblk_off = 0;
- if (!found_bblk || !is_meta_ld)
+ if (bblk_off && (!found_bblk || !is_meta_ld))
*bblk_off = 0;
return bcount;
}
@@ -443,7 +437,7 @@ void dump_journal(const char *journal, int tblk)
{
struct gfs2_buffer_head *j_bh = NULL, dummy_bh;
uint64_t jblock, j_size, jb, abs_block, saveblk, wrappt = 0;
- int error, start_line, journal_num;
+ int start_line, journal_num;
struct gfs2_inode *j_inode = NULL;
int ld_blocks = 0, offset_from_ld = 0;
uint64_t tblk_off = 0, bblk_off = 0, bitblk = 0;
@@ -454,7 +448,6 @@ void dump_journal(const char *journal, int tblk)
start_line = line;
lines_per_row[dmode] = 1;
- error = 0;
journal_num = atoi(journal + 7);
print_gfs2("Dumping journal #%d.", journal_num);
if (tblk) {
@@ -518,6 +511,7 @@ void dump_journal(const char *journal, int tblk)
for (jb = 0; jb < j_size; jb += (sbd.gfs1 ? 1 : sbd.bsize)) {
int is_pertinent = 1;
+ uint32_t block_type = 0;
if (sbd.gfs1) {
if (j_bh)
@@ -526,7 +520,7 @@ void dump_journal(const char *journal, int tblk)
j_bh = bread(&sbd, abs_block);
dummy_bh.b_data = j_bh->b_data;
} else {
- error = fsck_readi(j_inode, (void *)jbuf,
+ int error = fsck_readi(j_inode, (void *)jbuf,
((jb + wrappt) % j_size),
sbd.bsize, &abs_block);
if (!error) /* end of file */
@@ -534,14 +528,14 @@ void dump_journal(const char *journal, int tblk)
dummy_bh.b_data = jbuf;
}
offset_from_ld++;
- if (get_block_type(&dummy_bh, NULL) == GFS2_METATYPE_LD) {
+ block_type = get_block_type(&dummy_bh, NULL);
+ if (block_type == GFS2_METATYPE_LD) {
ld_blocks = process_ld(abs_block, wrappt, j_size, jb,
&dummy_bh, tblk, &tblk_off,
bitblk, rgd, &is_pertinent,
&bblk_off, ld_blk_refs);
offset_from_ld = 0;
- } else if (!tblk &&
- get_block_type(&dummy_bh, NULL) == GFS2_METATYPE_LH) {
+ } else if (!tblk && block_type == GFS2_METATYPE_LH) {
struct gfs2_log_header lh;
struct gfs_log_header lh1;
@@ -577,7 +571,7 @@ void dump_journal(const char *journal, int tblk)
sbd.bsize), start_line,
tblk, &tblk_off, 0, rgd,
0, 1, NULL, 1, NULL);
- } else if (!is_meta(&dummy_bh)) {
+ } else if (block_type == 0) {
continue;
}
/* Check if this metadata block references the block we're
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 5bf7963..c9f2d0a 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -662,7 +662,7 @@ static void save_allocated(struct rgrp_tree *rgd, struct metafd *mfd)
* If we don't, we may run into metadata allocation issues. */
m = lgfs2_bm_scan(rgd, i, ibuf, GFS2_BLKST_UNLINKED);
for (j = 0; j < m; j++) {
- blktype = save_block(sbd.device_fd, mfd, block);
+ save_block(sbd.device_fd, mfd, block);
}
}
free(ibuf);
@@ -933,6 +933,7 @@ static int restore_data(int fd, gzFile gzin_fd, int printblocksonly,
if (printblocksonly > 1 && printblocksonly == block) {
block_in_mem = block;
display(0, 0, 0, 0);
+ bh = NULL;
return 0;
} else if (printblocksonly == 1) {
print_gfs2("%d (l=0x%x): ", blks_saved,
@@ -944,19 +945,10 @@ static int restore_data(int fd, gzFile gzin_fd, int printblocksonly,
if (savedata->blk >= sbd.fssize) {
printf("\nOut of space on the destination "
"device; quitting.\n");
+ bh = NULL;
break;
}
- if (lseek(fd, savedata->blk * sbd.bsize, SEEK_SET) !=
- savedata->blk * sbd.bsize) {
- fprintf(stderr, "bad seek: %s from %s:"
- "%d: block %lld (0x%llx)\n",
- strerror(errno), __FUNCTION__,
- __LINE__,
- (unsigned long long)savedata->blk,
- (unsigned long long)savedata->blk);
- exit(-1);
- }
- if (write(fd, savedata->buf, sbd.bsize) != sbd.bsize) {
+ if (pwrite(fd, savedata->buf, sbd.bsize, savedata->blk * sbd.bsize) != sbd.bsize) {
fprintf(stderr, "write error: %s from "
"%s:%d: block %lld (0x%llx)\n",
strerror(errno), __FUNCTION__,
@@ -970,6 +962,8 @@ static int restore_data(int fd, gzFile gzin_fd, int printblocksonly,
fsync(fd);
}
blks_saved++;
+ /* Don't leave a dangling reference to our local dummy_bh */
+ bh = NULL;
}
if (!printblocksonly && !find_highblk)
warm_fuzzy_stuff(sbd.fssize, TRUE);
10 years, 1 month
gfs2-utils: master - gfs2_edit: Report referencing block address in the new journal code
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=9d1c4678...
Commit: 9d1c4678ce559f774e7bb3eb349e9ddef0650289
Parent: 0d3b6ed1eb4bb102f5f763596d0cb14a434559ae
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Fri Feb 28 00:08:43 2014 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Fri Feb 28 00:08:43 2014 +0000
gfs2_edit: Report referencing block address in the new journal code
When a block is referenced in the journal, the address of the "real"
referencing block is now printed (as well as the address of the block in
the journal).
Also, when a dinode references a block as a extended attribute, it
wasn't properly flagging it as a reference. Now it does.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/hexedit.c | 19 ++++++++++---------
gfs2/edit/hexedit.h | 3 ++-
gfs2/edit/journal.c | 37 ++++++++++++++++++++++++-------------
gfs2/edit/savemeta.c | 2 +-
4 files changed, 37 insertions(+), 24 deletions(-)
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index ac91c83..5c5ac89 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -833,7 +833,7 @@ static const struct lgfs2_metadata *find_mtype(uint32_t mtype, const unsigned ve
/* hexdump - hex dump the filesystem block to the screen */
/* ------------------------------------------------------------------------ */
static int hexdump(uint64_t startaddr, int len, int trunc_zeros,
- uint64_t flagref)
+ uint64_t flagref, uint64_t ref_blk)
{
const unsigned char *pointer, *ptr2;
int i;
@@ -983,12 +983,12 @@ static int hexdump(uint64_t startaddr, int len, int trunc_zeros,
if (line - 3 > last_entry_onscreen[dmode])
last_entry_onscreen[dmode] = line - 3;
if (flagref && be64_to_cpu(*ref) == flagref)
- print_gfs2("<------------------------- ref to 0x%llx",
- flagref);
+ print_gfs2("<------------------------- ref in 0x%llx "
+ "to 0x%llx", ref_blk, flagref);
ref++;
if (flagref && be64_to_cpu(*ref) == flagref)
- print_gfs2("<------------------------- ref to 0x%llx",
- flagref);
+ print_gfs2("<------------------------- ref in 0x%llx "
+ "to 0x%llx", ref_blk, flagref);
ref++;
eol(0);
l += 16;
@@ -1347,7 +1347,8 @@ static void read_master_dir(void)
/* ------------------------------------------------------------------------ */
/* display */
/* ------------------------------------------------------------------------ */
-int display(int identify_only, int trunc_zeros, uint64_t flagref)
+int display(int identify_only, int trunc_zeros, uint64_t flagref,
+ uint64_t ref_blk)
{
uint64_t blk;
@@ -1443,7 +1444,7 @@ int display(int identify_only, int trunc_zeros, uint64_t flagref)
if (dmode == HEX_MODE) /* if hex display mode */
hexdump(dev_offset, (gfs2_struct_type == GFS2_METATYPE_DI)?
struct_len + di.di_size:sbd.bsize, trunc_zeros,
- flagref);
+ flagref, ref_blk);
else if (dmode == GFS2_MODE) { /* if structure display */
if (block != JOURNALS_DUMMY_BLOCK)
display_gfs2(); /* display the gfs2 structure */
@@ -2248,7 +2249,7 @@ static void interactive_mode(void)
Quit = FALSE;
editing = FALSE;
while (!Quit) {
- display(FALSE, 0, 0);
+ display(FALSE, 0, 0, 0);
if (editing) {
if (edit_row[dmode] == -1)
block = goto_block();
@@ -2930,7 +2931,7 @@ int main(int argc, char *argv[])
block = blockstack[i + 1].block;
if (!block)
break;
- display(identify, 0, 0);
+ display(identify, 0, 0, 0);
if (!identify) {
display_extended();
printf("-------------------------------------" \
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index 715e3f2..541684a 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -233,7 +233,8 @@ extern void gfs_dinode_in(struct gfs_dinode *di, struct gfs2_buffer_head *bh);
extern void savemeta(char *out_fn, int saveoption, int gziplevel);
extern void restoremeta(const char *in_fn, const char *out_device,
uint64_t printblocksonly);
-extern int display(int identify_only, int trunc_zeros, uint64_t flagref);
+extern int display(int identify_only, int trunc_zeros, uint64_t flagref,
+ uint64_t ref_blk);
extern uint64_t check_keywords(const char *kword);
extern uint64_t masterblock(const char *fn);
extern void gfs_rgrp_print(struct gfs_rgrp *rg);
diff --git a/gfs2/edit/journal.c b/gfs2/edit/journal.c
index c69f349..3c2f5c7 100644
--- a/gfs2/edit/journal.c
+++ b/gfs2/edit/journal.c
@@ -204,7 +204,8 @@ static int ld_is_pertinent(const uint64_t *b, const char *end, uint64_t tblk,
static int print_ld_blks(const uint64_t *b, const char *end, int start_line,
uint64_t tblk, uint64_t *tblk_off, uint64_t bitblk,
struct rgrp_tree *rgd, uint64_t abs_block, int prnt,
- uint64_t *bblk_off, int is_meta_ld)
+ uint64_t *bblk_off, int is_meta_ld,
+ uint64_t ld_blk_refs[])
{
int bcount = 0, found_tblk = 0, found_bblk = 0;
static char str[256];
@@ -222,6 +223,8 @@ static int print_ld_blks(const uint64_t *b, const char *end, int start_line,
eol(0);
print_gfs2(" ");
}
+ if (ld_blk_refs)
+ ld_blk_refs[bcount] = be64_to_cpu(*b);
bcount++;
if (prnt) {
sprintf(str, "0x%llx",
@@ -345,7 +348,8 @@ static uint64_t find_wrap_pt(struct gfs2_inode *j_inode, char *jbuf,
static int process_ld(uint64_t abs_block, uint64_t wrappt, uint64_t j_size,
uint64_t jb, struct gfs2_buffer_head *dummy_bh, int tblk,
uint64_t *tblk_off, uint64_t bitblk,
- struct rgrp_tree *rgd, int *prnt, uint64_t *bblk_off)
+ struct rgrp_tree *rgd, int *prnt, uint64_t *bblk_off,
+ uint64_t ld_blk_refs[])
{
uint64_t *b;
struct gfs2_log_descriptor ld;
@@ -393,7 +397,7 @@ static int process_ld(uint64_t abs_block, uint64_t wrappt, uint64_t j_size,
is_meta_ld = 1;
ld_blocks -= print_ld_blks(b, (dummy_bh->b_data + sbd.bsize), line,
tblk, tblk_off, bitblk, rgd, abs_block,
- *prnt, bblk_off, is_meta_ld);
+ *prnt, bblk_off, is_meta_ld, ld_blk_refs);
return ld_blocks;
}
@@ -406,15 +410,19 @@ static int meta_has_ref(uint64_t abs_block, int tblk)
struct gfs2_buffer_head *mbh;
int structlen, ty, has_ref = 0;
uint64_t *b;
+ struct gfs2_dinode *dinode;
mbh = bread(&sbd, abs_block);
ty = get_block_type(mbh, &structlen);
+ if (ty == GFS2_METATYPE_DI) {
+ dinode = (struct gfs2_dinode *)mbh->b_data;
+ if (be64_to_cpu(dinode->di_eattr) == tblk)
+ has_ref = 1;
+ }
b = (uint64_t *)(mbh->b_data + structlen);
- while (ty && (char *)b < mbh->b_data + sbd.bsize) {
- if (be64_to_cpu(*b) == tblk) {
+ while (!has_ref && ty && (char *)b < mbh->b_data + sbd.bsize) {
+ if (be64_to_cpu(*b) == tblk)
has_ref = 1;
- break;
- }
b++;
}
brelse(mbh);
@@ -442,6 +450,7 @@ void dump_journal(const char *journal, int tblk)
uint64_t highest_seq = 0;
char *jbuf = NULL;
struct rgrp_tree *rgd = NULL;
+ uint64_t ld_blk_refs[503]; /* The most blks a LD can have */
start_line = line;
lines_per_row[dmode] = 1;
@@ -529,7 +538,7 @@ void dump_journal(const char *journal, int tblk)
ld_blocks = process_ld(abs_block, wrappt, j_size, jb,
&dummy_bh, tblk, &tblk_off,
bitblk, rgd, &is_pertinent,
- &bblk_off);
+ &bblk_off, ld_blk_refs);
offset_from_ld = 0;
} else if (!tblk &&
get_block_type(&dummy_bh, NULL) == GFS2_METATYPE_LH) {
@@ -567,20 +576,22 @@ void dump_journal(const char *journal, int tblk)
(dummy_bh.b_data +
sbd.bsize), start_line,
tblk, &tblk_off, 0, rgd,
- 0, 1, NULL, 1);
+ 0, 1, NULL, 1, NULL);
} else if (!is_meta(&dummy_bh)) {
continue;
}
/* Check if this metadata block references the block we're
trying to trace. */
- if (details ||
- (is_pertinent && tblk &&
+ if (details || (tblk && ((is_pertinent &&
((tblk_off && offset_from_ld == tblk_off) ||
(bblk_off && offset_from_ld == bblk_off))) ||
- meta_has_ref(abs_block, tblk)) {
+ meta_has_ref(abs_block, tblk)))) {
saveblk = block;
block = abs_block;
- display(0, tblk ? 1 : 0, tblk);
+ if (tblk)
+ display(0, 1, tblk, ld_blk_refs[offset_from_ld]);
+ else
+ display(0, 0, 0, 0);
block = saveblk;
}
}
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index c5a33db..5bf7963 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -932,7 +932,7 @@ static int restore_data(int fd, gzFile gzin_fd, int printblocksonly,
block = savedata->blk;
if (printblocksonly > 1 && printblocksonly == block) {
block_in_mem = block;
- display(0, 0, 0);
+ display(0, 0, 0, 0);
return 0;
} else if (printblocksonly == 1) {
print_gfs2("%d (l=0x%x): ", blks_saved,
10 years, 1 month