cluster: STABLE3 - gfs2_convert: gfs2_convert should fix statfs file

Abhijith Das adas at fedoraproject.org
Tue Feb 2 20:34:00 UTC 2010


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=b55c086de3d0eba532f8ced97da92d1117718b22
Commit:        b55c086de3d0eba532f8ced97da92d1117718b22
Parent:        4c4127b776eec26d09b09322cea7240a707ce152
Author:        Abhijith Das <adas at redhat.com>
AuthorDate:    Tue Feb 2 14:29:15 2010 -0600
Committer:     Abhijith Das <adas at redhat.com>
CommitterDate: Tue Feb 2 14:29:15 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 a9e42cb..819399c 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -1351,10 +1351,10 @@ static 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;
 
@@ -1415,7 +1415,7 @@ static 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;
@@ -1586,6 +1586,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);
@@ -1594,8 +1597,6 @@ int main(int argc, char **argv)
 
 		fsync(sb2.device_fd); /* 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);
 		log_notice("Committing changes to disk.\n");
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 8573dac..254c705 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -1673,6 +1673,7 @@ void gfs2_free_block(struct gfs2_sbd *sdp, uint64_t block)
 		gfs2_set_bitmap(sdp, block, GFS2_BLKST_FREE);
 		rgd->rg.rg_free++; /* adjust the free count */
 		gfs2_rgrp_out(&rgd->rg, rgd->bh[0]); /* back to the buffer */
+		sdp->blks_alloced--;
 	}
 }
 
@@ -1728,10 +1729,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);
 	inode_put(&ip);
+	/* inode_put deallocated the extra block used by the dist 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 */
 	gfs2_rgrp_out(&rgd->rg, rgd->bh[0]);
+	sdp->dinodes_alloced--;
 	return 0;
 }


More information about the cluster-commits mailing list