Gitweb:
http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=790a299e775...
Commit: 790a299e775f2a4aab64b37c3cdf03e11e52ccf5
Parent: 97389a0558db6d316c766dcb4cbadeae7fee3688
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Tue Apr 2 12:49:50 2013 -0700
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Fri May 17 15:17:02 2013 -0500
fsck.gfs2: separate function to calculate metadata block header size
This patch creates a new function hdr_size that calculates the size
of a GFS2 metadata header depending on the height and type of block.
rhbz#902920
---
gfs2/fsck/metawalk.c | 44 +++++++++++++++++++++++---------------------
1 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 1f0c221..e0fbd33 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -1329,6 +1329,23 @@ static int check_data(struct gfs2_inode *ip, struct metawalk_fxns
*pass,
return error;
}
+static int hdr_size(struct gfs2_buffer_head *bh, int height)
+{
+ if (height > 1) {
+ if (gfs2_check_meta(bh, GFS2_METATYPE_IN))
+ return 0;
+ if (bh->sdp->gfs1)
+ return sizeof(struct gfs_indirect);
+ else
+ return sizeof(struct gfs2_meta_header);
+ }
+ /* if this isn't really a dinode, skip it */
+ if (gfs2_check_meta(bh, GFS2_METATYPE_DI))
+ return 0;
+
+ return sizeof(struct gfs2_dinode);
+}
+
/**
* check_metatree
* @ip: inode structure in memory
@@ -1399,28 +1416,13 @@ int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns
*pass)
bh = osi_list_entry(list->next, struct gfs2_buffer_head,
b_altlist);
- if (height > 1) {
- if (gfs2_check_meta(bh, GFS2_METATYPE_IN)) {
- if (bh == ip->i_bh)
- osi_list_del(&bh->b_altlist);
- else
- brelse(bh);
- continue;
- }
- if (ip->i_sbd->gfs1)
- head_size = sizeof(struct gfs_indirect);
+ head_size = hdr_size(bh, height);
+ if (!head_size) {
+ if (bh == ip->i_bh)
+ osi_list_del(&bh->b_altlist);
else
- head_size = sizeof(struct gfs2_meta_header);
- } else {
- /* if this isn't really a dinode, skip it */
- if (gfs2_check_meta(bh, GFS2_METATYPE_DI)) {
- if (bh == ip->i_bh)
- osi_list_del(&bh->b_altlist);
- else
- brelse(bh);
- continue;
- }
- head_size = sizeof(struct gfs2_dinode);
+ brelse(bh);
+ continue;
}
if (pass->check_data)