cluster: RHEL57 - gfs2_edit: handle corrupt file systems better
Bob Peterson
rpeterso at fedoraproject.org
Wed Feb 2 21:16:07 UTC 2011
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=ac1d1033af634d97e266f35d419233266ea782d8
Commit: ac1d1033af634d97e266f35d419233266ea782d8
Parent: dff0fe59568e9b4b09191f05ab7c718fc1b19b7e
Author: Bob Peterson <rpeterso at redhat.com>
AuthorDate: Wed Feb 2 13:19:54 2011 -0600
Committer: Bob Peterson <rpeterso at redhat.com>
CommitterDate: Wed Feb 2 14:36:09 2011 -0600
gfs2_edit: handle corrupt file systems better
This patch adds some checks to gfs2_edit so that it will not segfault
when it encounters certain types of file system corruption. This makes
it a more useful tool for examining corrupt metadata sets.
rhbz#656371
---
gfs2/edit/hexedit.c | 7 ++++++-
gfs2/libgfs2/fs_bits.c | 2 ++
gfs2/libgfs2/rgrp.c | 7 +++++--
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 5a05114..6668f89 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -1811,7 +1811,12 @@ static void read_superblock(int fd)
if (!sbd.bsize)
sbd.bsize = GFS2_DEFAULT_BSIZE;
compute_constants(&sbd);
- block = 0x10 * (GFS2_DEFAULT_BSIZE / sbd.bsize);
+ if (gfs1 || (sbd.sd_sb.sb_header.mh_magic == GFS2_MAGIC &&
+ sbd.sd_sb.sb_header.mh_type == GFS2_METATYPE_SB))
+ block = 0x10 * (GFS2_DEFAULT_BSIZE / sbd.bsize);
+ else {
+ block = starting_blk = 0;
+ }
device_geometry(&sbd);
fix_device_geometry(&sbd);
if(gfs1) {
diff --git a/gfs2/libgfs2/fs_bits.c b/gfs2/libgfs2/fs_bits.c
index 69b16e9..5b55cec 100644
--- a/gfs2/libgfs2/fs_bits.c
+++ b/gfs2/libgfs2/fs_bits.c
@@ -243,6 +243,8 @@ int gfs2_get_bitmap(struct gfs2_sbd *sdp, uint64_t blkno,
if (i >= rgd->ri.ri_length)
return -1;
+ if (!rgd->bh || !rgd->bh[i])
+ return 0;
byte = (unsigned char *)(rgd->bh[i]->b_data + bits->bi_offset) +
(rgrp_block/GFS2_NBBY - bits->bi_start);
bit = (rgrp_block % GFS2_NBBY) * GFS2_BIT_SIZE;
diff --git a/gfs2/libgfs2/rgrp.c b/gfs2/libgfs2/rgrp.c
index 3cb049b..438d320 100644
--- a/gfs2/libgfs2/rgrp.c
+++ b/gfs2/libgfs2/rgrp.c
@@ -169,8 +169,11 @@ void gfs2_rgrp_relse(struct rgrp_list *rgd)
int x, length = rgd->ri.ri_length;
for (x = 0; x < length; x++) {
- brelse(rgd->bh[x]);
- rgd->bh[x] = NULL;
+ if (rgd->bh) {
+ if (rgd->bh[x])
+ brelse(rgd->bh[x]);
+ rgd->bh[x] = NULL;
+ }
}
}
More information about the cluster-commits
mailing list