From mboxrd@z Thu Jan 1 00:00:00 1970 From: rpeterso@redhat.com Date: Mon, 8 Apr 2013 07:40:55 -0700 Subject: [Cluster-devel] [PATCH 23/42] fsck.gfs2: separate function to calculate metadata block header size In-Reply-To: <1365432074-17615-1-git-send-email-rpeterso@redhat.com> References: <1365432074-17615-1-git-send-email-rpeterso@redhat.com> Message-ID: <1365432074-17615-24-git-send-email-rpeterso@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit From: Bob Peterson 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 file changed, 23 insertions(+), 21 deletions(-) diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c index e985dbc..d1b12f1 100644 --- a/gfs2/fsck/metawalk.c +++ b/gfs2/fsck/metawalk.c @@ -1331,6 +1331,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 @@ -1401,28 +1418,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) -- 1.7.11.7