Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=c1310a43bb8... Commit: c1310a43bb88ff28c946c61eb1cceca83e18a2d0 Parent: b57c362a3eab9fb6225f098f1c33e4afec6ad0ce Author: Andrew Price anprice@redhat.com AuthorDate: Fri Mar 14 21:30:51 2014 +0000 Committer: Andrew Price anprice@redhat.com CommitterDate: Sat Mar 29 23:20:29 2014 +0000
libgfs2: Don't call gfs2_blk2rgrpd in gfs2_set_bitmap
gfs2_set_bitmap was calling gfs2_blk2rgrpd even when callers already have the resource group to hand. This changes that function to accept the resource group instead and calls to gfs2_blk2rgrpd have been moved outside.
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/edit/hexedit.c | 2 +- gfs2/fsck/metawalk.c | 2 +- gfs2/fsck/pass5.c | 6 ++++-- gfs2/libgfs2/fs_bits.c | 5 +---- gfs2/libgfs2/fs_ops.c | 12 +++++------- gfs2/libgfs2/libgfs2.h | 2 +- 6 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c index bc3ca35..53a816d 100644 --- a/gfs2/edit/hexedit.c +++ b/gfs2/edit/hexedit.c @@ -2045,7 +2045,7 @@ static void find_change_block_alloc(int *newval) if (rgd) { gfs2_rgrp_read(&sbd, rgd); if (newval) { - if (gfs2_set_bitmap(&sbd, ablock, *newval)) + if (gfs2_set_bitmap(rgd, ablock, *newval)) printf("-1 (block invalid or part of an rgrp).\n"); else printf("%d\n", *newval); diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c index 15cba56..594fbfa 100644 --- a/gfs2/fsck/metawalk.c +++ b/gfs2/fsck/metawalk.c @@ -73,7 +73,7 @@ int check_n_fix_bitmap(struct gfs2_sbd *sdp, uint64_t blk, int error_on_dinode, subtract to the free space. If the type changed from dinode to data or data to dinode, no change in free space. */ - gfs2_set_bitmap(sdp, blk, new_bitmap_state); + gfs2_set_bitmap(rgd, blk, new_bitmap_state); if (new_bitmap_state == GFS2_BLKST_FREE) { /* If we're freeing a dinode, get rid of the hash table entries for it. */ diff --git a/gfs2/fsck/pass5.c b/gfs2/fsck/pass5.c index 92861a1..49ab682 100644 --- a/gfs2/fsck/pass5.c +++ b/gfs2/fsck/pass5.c @@ -148,7 +148,8 @@ static int check_block_status(struct gfs2_sbd *sdp, char *buffer, (unsigned long long)block); if (query(_("Do you want to reclaim the block? " "(y/n) "))) { - if (gfs2_set_bitmap(sdp, block, block_status)) + lgfs2_rgrp_t rg = gfs2_blk2rgrpd(sdp, block); + if (gfs2_set_bitmap(rg, block, block_status)) log_err(_("Unlinked block %llu " "(0x%llx) bitmap not fixed." "\n"), @@ -182,7 +183,8 @@ static int check_block_status(struct gfs2_sbd *sdp, char *buffer, if (query(_("Fix bitmap for block %llu (0x%llx) ? (y/n) "), (unsigned long long)block, (unsigned long long)block)) { - if (gfs2_set_bitmap(sdp, block, block_status)) + lgfs2_rgrp_t rg = gfs2_blk2rgrpd(sdp, block); + if (gfs2_set_bitmap(rg, block, block_status)) log_err( _("Repair failed.\n")); else log_err( _("Fixed.\n")); diff --git a/gfs2/libgfs2/fs_bits.c b/gfs2/libgfs2/fs_bits.c index e4b5505..7194949 100644 --- a/gfs2/libgfs2/fs_bits.c +++ b/gfs2/libgfs2/fs_bits.c @@ -124,12 +124,11 @@ int gfs2_check_range(struct gfs2_sbd *sdp, uint64_t blkno) * * Returns: 0 on success, -1 on error */ -int gfs2_set_bitmap(struct gfs2_sbd *sdp, uint64_t blkno, int state) +int gfs2_set_bitmap(lgfs2_rgrp_t rgd, uint64_t blkno, int state) { int buf; uint32_t rgrp_block; struct gfs2_bitmap *bits = NULL; - struct rgrp_tree *rgd; unsigned char *byte, cur_state; unsigned int bit;
@@ -137,8 +136,6 @@ int gfs2_set_bitmap(struct gfs2_sbd *sdp, uint64_t blkno, int state) if ((state < GFS2_BLKST_FREE) || (state > GFS2_BLKST_DINODE)) return -1;
- rgd = gfs2_blk2rgrpd(sdp, blkno); - if(!rgd || blkno < rgd->ri.ri_data0) return -1;
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c index b95f2ed..fdd4438 100644 --- a/gfs2/libgfs2/fs_ops.c +++ b/gfs2/libgfs2/fs_ops.c @@ -141,7 +141,7 @@ static int blk_alloc_in_rg(struct gfs2_sbd *sdp, unsigned state, struct rgrp_tre if (blkno == 0) return -1;
- if (gfs2_set_bitmap(sdp, blkno, state)) + if (gfs2_set_bitmap(rgd, blkno, state)) return -1;
if (state == GFS2_BLKST_DINODE) @@ -1763,7 +1763,7 @@ void gfs2_free_block(struct gfs2_sbd *sdp, uint64_t block) /* Adjust the free space count for the freed block */ rgd = gfs2_blk2rgrpd(sdp, block); /* find the rg for indir block */ if (rgd) { - gfs2_set_bitmap(sdp, block, GFS2_BLKST_FREE); + gfs2_set_bitmap(rgd, block, GFS2_BLKST_FREE); rgd->rg.rg_free++; /* adjust the free count */ if (sdp->gfs1) gfs_rgrp_out((struct gfs_rgrp *)&rgd->rg, rgd->bh[0]); @@ -1826,16 +1826,14 @@ int gfs2_freedi(struct gfs2_sbd *sdp, uint64_t diblock) } } } - /* Set the bitmap type for inode to free space: */ - gfs2_set_bitmap(sdp, ip->i_di.di_num.no_addr, GFS2_BLKST_FREE); + rgd = gfs2_blk2rgrpd(sdp, diblock); + gfs2_set_bitmap(rgd, diblock, GFS2_BLKST_FREE); inode_put(&ip); /* inode_put deallocated the extra block used by the disk inode, */ /* so adjust it in the superblock struct */ sdp->blks_alloced--; - /* Now we have to adjust the rg freespace count and inode count: */ - rgd = gfs2_blk2rgrpd(sdp, diblock); rgd->rg.rg_free++; - rgd->rg.rg_dinodes--; /* one less inode in use */ + rgd->rg.rg_dinodes--; if (sdp->gfs1) gfs_rgrp_out((struct gfs_rgrp *)&rgd->rg, rgd->bh[0]); else diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h index 24947c2..b2f6bc3 100644 --- a/gfs2/libgfs2/libgfs2.h +++ b/gfs2/libgfs2/libgfs2.h @@ -418,7 +418,7 @@ extern int gfs2_check_range(struct gfs2_sbd *sdp, uint64_t blkno);
/* functions with blk #'s that are file system relative */ extern int lgfs2_get_bitmap(struct gfs2_sbd *sdp, uint64_t blkno, struct rgrp_tree *rgd); -extern int gfs2_set_bitmap(struct gfs2_sbd *sdp, uint64_t blkno, int state); +extern int gfs2_set_bitmap(lgfs2_rgrp_t rg, uint64_t blkno, int state);
/* fs_geometry.c */ extern uint32_t rgblocks2bitblocks(const unsigned int bsize, const uint32_t rgblocks,