This is the mail archive of the cluster-cvs@sourceware.org mailing list for the cluster.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

cluster: STABLE3 - Make gfs2_edit -p <block> blockalloc work for gfs1file systems


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=d0d61c12bc72ae7d15cd71f1e9cfbe4c9e6c2691
Commit:        d0d61c12bc72ae7d15cd71f1e9cfbe4c9e6c2691
Parent:        3a0256932f1f441fd95516b0dbabfa5666b36632
Author:        Bob Peterson <bob@ganesha.peterson>
AuthorDate:    Mon Aug 31 11:00:06 2009 -0500
Committer:     Bob Peterson <bob@ganesha.peterson>
CommitterDate: Mon Aug 31 11:00:06 2009 -0500

Make gfs2_edit -p <block> blockalloc work for gfs1 file systems

Several gfs2_edit options, like blockalloc, are designed to
read in the resource group information to determine the block
status according to the bitmap on disk.  That was working fine
for GFS2 file systems but not for GFS file systems.  This patch
allows gfs2_edit to read in the gfs1 rindex and parse the
bitmaps by using libgfs2's gfs1 functions.

rhbz#503529
---
 gfs2/convert/gfs2_convert.c |    2 +-
 gfs2/edit/hexedit.c         |   20 ++++++++++----------
 gfs2/edit/savemeta.c        |    2 +-
 gfs2/libgfs2/gfs1.c         |    4 ++--
 gfs2/libgfs2/libgfs2.h      |    2 +-
 5 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index cf6e7b4..bc6312d 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -1165,7 +1165,7 @@ static int init(struct gfs2_sbd *sbp)
 	sbp->md.riinode->i_di.di_mode &= ~S_IFMT;
 	sbp->md.riinode->i_di.di_mode |= S_IFDIR;
 	printf("Examining file system");
-	if (gfs1_ri_update(sbp, 0, &rgcount)){
+	if (gfs1_ri_update(sbp, 0, &rgcount, 0)){
 		log_crit("Unable to fill in resource group information.\n");
 		return -1;
 	}
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index ff449e9..2092d9a 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -30,7 +30,9 @@
 
 const char *mtypes[] = {"none", "sb", "rg", "rb", "di", "in", "lf", "jd",
 			"lh", "ld", "ea", "ed", "lb", "13", "qc"};
-const char *allocdesc[] = {"Free ", "Data ", "Unlnk", "Meta ", "Resrv"};
+const char *allocdesc[2][5] = {
+	{"Free ", "Data ", "Unlnk", "Meta ", "Resrv"},
+	{"Free ", "Data ", "FreeM", "Meta ", "Resrv"},};
 
 #define RGLIST_DUMMY_BLOCK -2
 
@@ -580,7 +582,7 @@ int display_block_type(const char *lpBuffer, int from_restore)
 		print_gfs2("(p.%d of %d--%s)", pgnum + 1,
 			   (sbd.bsize % screen_chunk_size) > 0 ?
 			   sbd.bsize / screen_chunk_size + 1 : sbd.bsize /
-			   screen_chunk_size, allocdesc[type]);
+			   screen_chunk_size, allocdesc[gfs1][type]);
 		/*eol(9);*/
 		if ((*(lpBuffer+7) == GFS2_METATYPE_IN) ||
 		    (*(lpBuffer+7) == GFS2_METATYPE_DI &&
@@ -1663,10 +1665,6 @@ static void read_superblock(int fd)
 	osi_list_init(&sbd.rglist);
 	init_buf_list(&sbd, &sbd.buf_list, 128 << 20);
 	init_buf_list(&sbd, &sbd.nvbuf_list, 0xffffffff);
-	if (compute_constants(&sbd)) {
-		fprintf(stderr, "Bad constants (1)\n");
-		exit(-1);
-	}
 	gfs2_sb_in(&sbd.sd_sb, buf); /* parse it out into the sb structure */
 	/* Check to see if this is really gfs1 */
 	if (sbd1->sb_fs_format == GFS_FORMAT_FS &&
@@ -1703,6 +1701,8 @@ static void read_superblock(int fd)
 			sizeof(uint64_t);
 		sbd.md.riinode = gfs2_load_inode(&sbd,
 						 sbd1->sb_rindex_di.no_addr);
+		sbd.fssize = sbd.device.length;
+		gfs1_ri_update(&sbd, 0, &count, 1);
 	} else {
 		sbd.sd_inptrs = (sbd.bsize - sizeof(struct gfs2_meta_header)) /
 			sizeof(uint64_t);
@@ -1711,10 +1711,10 @@ static void read_superblock(int fd)
 		sbd.master_dir = gfs2_load_inode(&sbd,
 					    sbd.sd_sb.sb_master_dir.no_addr);
 		gfs2_lookupi(sbd.master_dir, "rindex", 6, &sbd.md.riinode);
+		sbd.fssize = sbd.device.length;
+		ri_update(&sbd, 0, &count);
 	}
 
-	sbd.fssize = sbd.device.length;
-	ri_update(&sbd, 0, &count);
 }
 
 /* ------------------------------------------------------------------------ */
@@ -2443,7 +2443,7 @@ static void find_change_block_alloc(int *newval)
 		printf("Error: value %d is not valid.\nValid values are:\n",
 		       *newval);
 		for (i = GFS2_BLKST_FREE; i <= GFS2_BLKST_DINODE; i++)
-			printf("%d - %s\n", i, allocdesc[i]);
+			printf("%d - %s\n", i, allocdesc[gfs1][i]);
 		gfs2_rgrp_free(&sbd.rglist, not_updated);
 		exit(-1);
 	}
@@ -2460,7 +2460,7 @@ static void find_change_block_alloc(int *newval)
 			rgd = gfs2_blk2rgrpd(&sbd, ablock);
 			if (rgd) {
 				type = gfs2_get_bitmap(&sbd, ablock, rgd);
-				printf("%d (%s)\n", type, allocdesc[type]);
+				printf("%d (%s)\n", type, allocdesc[gfs1][type]);
 				gfs2_rgrp_relse(rgd, not_updated);
 			} else {
 				gfs2_rgrp_free(&sbd.rglist, not_updated);
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index bef9393..cfe8f82 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -607,7 +607,7 @@ void savemeta(char *out_fn, int saveoption)
 		printf("Reading resource groups...");
 		fflush(stdout);
 		if (gfs1)
-			slow = gfs1_ri_update(&sbd, 0, &rgcount);
+			slow = gfs1_ri_update(&sbd, 0, &rgcount, 0);
 		else
 			slow = ri_update(&sbd, 0, &rgcount);
 		printf("Done.\n\n");
diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index 6fdabd9..59c4f8f 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -291,7 +291,7 @@ int gfs1_rindex_read(struct gfs2_sbd *sdp, int fd, int *count1)
  *
  * Returns: 0 on success, -1 on failure.
  */
-int gfs1_ri_update(struct gfs2_sbd *sdp, int fd, int *rgcount)
+int gfs1_ri_update(struct gfs2_sbd *sdp, int fd, int *rgcount, int quiet)
 {
 	struct rgrp_list *rgd;
 	osi_list_t *tmp;
@@ -306,7 +306,7 @@ int gfs1_ri_update(struct gfs2_sbd *sdp, int fd, int *rgcount)
 		if (errblock)
 			return errblock;
 		count2++;
-		if (count2 % 100 == 0) {
+		if (!quiet && count2 % 100 == 0) {
 			printf(".");
 			fflush(stdout);
 		}
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index b3c9483..3d7b28a 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -565,7 +565,7 @@ extern void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
 extern int gfs1_readi(struct gfs2_inode *ip, void *buf, uint64_t offset,
 		      unsigned int size);
 extern int gfs1_rindex_read(struct gfs2_sbd *sdp, int fd, int *count1);
-extern int gfs1_ri_update(struct gfs2_sbd *sdp, int fd, int *rgcount);
+extern int gfs1_ri_update(struct gfs2_sbd *sdp, int fd, int *rgcount, int quiet);
 extern struct gfs2_inode *gfs_inode_get(struct gfs2_sbd *sdp,
 					struct gfs2_buffer_head *bh);
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]