cluster: RHEL55 - gfs2_convert: gfs2_convert should fix statfs file

Abhijith Das adas at fedoraproject.org
Tue Feb 2 20:36:01 UTC 2010


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=af9b2042ec0f0ca80229051bc158f18c241347ed
Commit:        af9b2042ec0f0ca80229051bc158f18c241347ed
Parent:        112a4979a64dc0e8cc74e5e63ae55b5788cf334e
Author:        Abhijith Das <adas at redhat.com>
AuthorDate:    Tue Feb 2 14:34:23 2010 -0600
Committer:     Abhijith Das <adas at redhat.com>
CommitterDate: Tue Feb 2 14:34:23 2010 -0600

gfs2_convert: gfs2_convert should fix statfs file

This patch modifies the freedi() code path in libgfs2
to update the blks_alloced and dinodes_alloced counts
in the superblock struct. It also moves some code
around in gfs2_convert so that all the block changes
are correctly recorded into the statfs file.

rhbz#556961
---
 gfs2/convert/gfs2_convert.c |    9 +++++----
 gfs2/libgfs2/fs_ops.c       |    5 +++++
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index cea8496..aa039ef 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -1367,10 +1367,10 @@ int journ_space_to_rg(struct gfs2_sbd *sdp)
 
 		rgd->ri.ri_data0 = jndx->ji_addr + rgd->ri.ri_length;
 		rgd->ri.ri_data = size - rgd->ri.ri_length;
-		sdp->blks_total += rgd->ri.ri_data; /* For statfs file update */
 		/* Round down to nearest multiple of GFS2_NBBY */
 		while (rgd->ri.ri_data & 0x03)
 			rgd->ri.ri_data--;
+		sdp->blks_total += rgd->ri.ri_data; /* For statfs file update */
 		rgd->rg.rg_free = rgd->ri.ri_data;
 		rgd->ri.ri_bitbytes = rgd->ri.ri_data / GFS2_NBBY;
 		convert_bitmaps(sdp, rgd, FALSE); /* allocates rgd->bh */
@@ -1414,7 +1414,7 @@ void write_statfs_file(struct gfs2_sbd *sdp)
 	struct gfs2_statfs_change sc;
 	char buf[sizeof(struct gfs2_statfs_change)];
 	int count;
-	
+
 	sc.sc_total = sdp->blks_total;
 	sc.sc_free = sdp->blks_total - sdp->blks_alloced;
 	sc.sc_dinodes = sdp->dinodes_alloced;
@@ -1581,6 +1581,9 @@ int main(int argc, char **argv)
 		build_quota(&sb2);
 
 		update_inode_file(&sb2);
+		/* Now delete the now-obsolete gfs1 files: */
+		remove_obsolete_gfs1(&sb2);
+
 		write_statfs_file(&sb2);
 
 		inode_put(sb2.master_dir, updated);
@@ -1590,8 +1593,6 @@ int main(int argc, char **argv)
 		bcommit(&sb2.buf_list); /* write the buffers to disk */
 		bcommit(&sb2.nvbuf_list); /* write the buffers to disk */
 
-		/* Now delete the now-obsolete gfs1 files: */
-		remove_obsolete_gfs1(&sb2);
 		/* Now free all the in memory */
 		gfs2_rgrp_free(&sb2.rglist, updated);
 		log_notice("Committing changes to disk.\n");
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 9cc6dea..675dcd6 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -1576,6 +1576,7 @@ void gfs2_free_block(struct gfs2_sbd *sdp, uint64_t block)
 	rgd->rg.rg_free++; /* adjust the free count */
 	gfs2_rgrp_out(&rgd->rg, bh->b_data); /* back to the buffer */
 	brelse(bh, updated); /* release the buffer */
+	sdp->blks_alloced--;
 }
 
 /**
@@ -1633,6 +1634,9 @@ 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);
 	inode_put(ip, updated);
+	/* 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);
 	/* The rg itself is in memory as rgd->rg, but there's most likely a  */
@@ -1643,5 +1647,6 @@ int gfs2_freedi(struct gfs2_sbd *sdp, uint64_t diblock)
 	rgd->rg.rg_dinodes--; /* one less inode in use */
 	gfs2_rgrp_out(&rgd->rg, bh->b_data);
 	brelse(bh, updated); /* release the buffer */
+	sdp->dinodes_alloced--;
 	return 0;
 }


More information about the cluster-commits mailing list