Cluster Project branch, STABLE2, updated. cluster-2.03.03-7-gf21cbeb

rpeterso@sourceware.org rpeterso@sourceware.org
Wed Jun 4 19:58:00 GMT 2008


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Cluster Project".

http://sources.redhat.com/git/gitweb.cgi?p=cluster.git;a=commitdiff;h=f21cbeb482fad5eab16e2f14dc65dcd07d1afcaf

The branch, STABLE2 has been updated
       via  f21cbeb482fad5eab16e2f14dc65dcd07d1afcaf (commit)
       via  d0fa71839be16af2f82b3bc8129f1ec0639fb6e5 (commit)
       via  77bf8a9c23b46f93b9a1bf8b80146002694c6750 (commit)
      from  ab51857c0232d079ddbd8ec0a3b9c4c8a7faa645 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f21cbeb482fad5eab16e2f14dc65dcd07d1afcaf
Author: Bob Peterson <bob@ganesha.peterson>
Date:   Wed Jun 4 14:33:30 2008 -0500

    Updates to gfs2_edit man page for new option.

commit d0fa71839be16af2f82b3bc8129f1ec0639fb6e5
Author: Bob Peterson <bob@ganesha.peterson>
Date:   Wed Jun 4 14:26:48 2008 -0500

    Make gfs2_edit more friendly to automated testing.

commit 77bf8a9c23b46f93b9a1bf8b80146002694c6750
Author: Bob Peterson <bob@ganesha.peterson>
Date:   Wed Jun 4 14:24:05 2008 -0500

    Fix gfs2_edit bugs with non-4K block sizes

-----------------------------------------------------------------------

Summary of changes:
 gfs2/edit/gfs2hex.c  |   13 ++---
 gfs2/edit/hexedit.c  |  141 +++++++++++++++++++++++++++++++------------------
 gfs2/edit/hexedit.h  |    1 -
 gfs2/edit/savemeta.c |   58 ++++++++++----------
 gfs2/man/gfs2_edit.8 |    4 ++
 5 files changed, 128 insertions(+), 89 deletions(-)

diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index 7262d78..082f5b6 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -38,7 +38,6 @@
 extern struct gfs2_sb sb;
 extern char *buf;
 extern struct gfs2_dinode di;
-extern uint64_t bufsize;
 extern int line, termlines;
 extern char edit_fmt[80];
 extern char estring[1024];
@@ -226,7 +225,7 @@ void do_dinode_extended(struct gfs2_dinode *di, char *buf)
 	memset(indirect, 0, sizeof(indirect));
 	if (di->di_height > 0) {
 		/* Indirect pointers */
-		for (x = sizeof(struct gfs2_dinode); x < bufsize;
+		for (x = sizeof(struct gfs2_dinode); x < sbd.bsize;
 			 x += sizeof(uint64_t)) {
 			p = be64_to_cpu(*(uint64_t *)(buf + x));
 			if (p) {
@@ -243,7 +242,7 @@ void do_dinode_extended(struct gfs2_dinode *di, char *buf)
 		indirect->ii[0].dirents = 0;
 		indirect->ii[0].block = block;
 		indirect->ii[0].is_dir = TRUE;
-		for (x = sizeof(struct gfs2_dinode); x < bufsize; x += skip) {
+		for (x = sizeof(struct gfs2_dinode); x < sbd.bsize; x += skip) {
 			skip = indirect_dirent(indirect->ii,
 					       buf + x,
 					       indirect->ii[0].dirents);
@@ -275,7 +274,7 @@ void do_dinode_extended(struct gfs2_dinode *di, char *buf)
 				gfs2_leaf_in(&leaf, tmp_bh->b_data);
 				indirect->ii[indirect_blocks].dirents = 0;
 				for (direntcount = 0, bufoffset = sizeof(struct gfs2_leaf);
-					 bufoffset < bufsize;
+					 bufoffset < sbd.bsize;
 					 direntcount++, bufoffset += skip) {
 					skip = indirect_dirent(&indirect->ii[indirect_blocks],
 										   tmp_bh->b_data + bufoffset,
@@ -317,7 +316,7 @@ int do_indirect_extended(char *buf, struct iinfo *iinf)
 	memset(iinf, 0, sizeof(struct iinfo));
 	for (x = (gfs1 ? sizeof(struct gfs_indirect):
 			  sizeof(struct gfs2_meta_header)), y = 0;
-		 x < bufsize;
+		 x < sbd.bsize;
 		 x += sizeof(uint64_t), y++) {
 		p = be64_to_cpu(*(uint64_t *)(buf + x));
 		if (p) {
@@ -352,7 +351,7 @@ void do_leaf_extended(char *buf, struct iinfo *indir)
 	x = 0;
 	memset(indir, 0, sizeof(indir));
 	/* Directory Entries: */
-	for (i = sizeof(struct gfs2_leaf); i < bufsize;
+	for (i = sizeof(struct gfs2_leaf); i < sbd.bsize;
 	     i += de.de_rec_len) {
 		gfs2_dirent_in(&de, buf + i);
 		if (de.de_inum.no_addr) {
@@ -399,7 +398,7 @@ void do_eattr_extended(char *buf)
 	print_gfs2("Eattr Entries:");
 	eol(0);
 
-	for (x = sizeof(struct gfs2_meta_header); x < bufsize; x += ea.ea_rec_len)
+	for (x = sizeof(struct gfs2_meta_header); x < sbd.bsize; x += ea.ea_rec_len)
 	{
 		eol(0);
 		gfs2_ea_header_in(&ea, buf + x);
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 07edf81..9189979 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -469,8 +469,8 @@ int display_block_type(const char *lpBuffer, int from_restore)
 		if (!screen_chunk_size)
 			screen_chunk_size = 256;
 		print_gfs2("(p.%d of %d)", (offset / screen_chunk_size) + 1,
-				   (bufsize % screen_chunk_size) > 0 ? 
-				   bufsize / screen_chunk_size + 1 : bufsize / 
+				   (sbd.bsize % screen_chunk_size) > 0 ?
+				   sbd.bsize / screen_chunk_size + 1 : sbd.bsize /
 				   screen_chunk_size);
 		/*eol(9);*/
 	}
@@ -534,7 +534,7 @@ int hexdump(uint64_t startaddr, const char *lpBuffer, int len)
 			line < termlines &&
 			line <= ((screen_chunk_size / 16) + 2)) ||
 			(!termlines && l < len)) &&
-		   l < bufsize) {
+		   l < sbd.bsize) {
 		if (termlines) {
 			move(line, 0);
 			COLORS_OFFSETS; /* cyan for offsets */
@@ -942,8 +942,15 @@ int print_jindex(struct gfs2_inode *di)
 int print_inum(struct gfs2_inode *di)
 {
 	uint64_t buf, inodenum;
+	int rc;
 	
-	if (gfs2_readi(di, (void *)&buf, 0, sizeof(buf)) != sizeof(buf)) {
+	rc = gfs2_readi(di, (void *)&buf, 0, sizeof(buf));
+	if (!rc) {
+		print_gfs2("The inum file is empty.");
+		eol(0);
+		return 0;
+	}
+	if (rc != sizeof(buf)) {
 		print_gfs2("Error reading inum file.");
 		eol(0);
 		return -1;
@@ -960,8 +967,15 @@ int print_inum(struct gfs2_inode *di)
 int print_statfs(struct gfs2_inode *di)
 {
 	struct gfs2_statfs_change buf, sfc;
+	int rc;
 	
-	if (gfs2_readi(di, (void *)&buf, 0, sizeof(buf)) !=	sizeof(buf)) {
+	rc = gfs2_readi(di, (void *)&buf, 0, sizeof(buf));
+	if (!rc) {
+		print_gfs2("The statfs file is empty.");
+		eol(0);
+		return 0;
+	}
+	if (rc != sizeof(buf)) {
 		print_gfs2("Error reading statfs file.");
 		eol(0);
 		return -1;
@@ -1160,8 +1174,8 @@ int display_indirect(struct iinfo *ind, int indblocks, int level, uint64_t start
 				diptrs = 483;
 				inptrs = 501;
 			} else {
-				diptrs = (bufsize - sizeof(sizeof(struct gfs2_dinode))) / sizeof(uint64_t);
-				inptrs = (bufsize - sizeof(sizeof(struct gfs2_meta_header))) /
+				diptrs = (sbd.bsize - sizeof(sizeof(struct gfs2_dinode))) / sizeof(uint64_t);
+				inptrs = (sbd.bsize - sizeof(sizeof(struct gfs2_meta_header))) /
 					sizeof(uint64_t);
 			}
 			/* Multiply out the max factor based on inode height.*/
@@ -1228,7 +1242,7 @@ int display_indirect(struct iinfo *ind, int indblocks, int level, uint64_t start
 			offsets[0] = pndx;
 			for (hgt = cur_height; hgt >= 0; hgt--)
 				file_offset += offsets[cur_height - hgt] *
-					factor[di.di_height - hgt - 1] * bufsize;
+					factor[di.di_height - hgt - 1] * sbd.bsize;
 			print_gfs2("     ");
 			h = 'K';
 			human_off = (file_offset / 1024.0);
@@ -1250,12 +1264,12 @@ int display_indirect(struct iinfo *ind, int indblocks, int level, uint64_t start
 			char *tmpbuf;
 			
 			more_indir = malloc(sizeof(struct iinfo));
-			tmpbuf = malloc(bufsize);
+			tmpbuf = malloc(sbd.bsize);
 			if (tmpbuf) {
 				do_lseek(sbd.device_fd,
-					 ind->ii[pndx].block * bufsize);
+					 ind->ii[pndx].block * sbd.bsize);
 				do_read(sbd.device_fd, tmpbuf,
-					bufsize); /* read in the desired block */
+					sbd.bsize); /* read in the desired block */
 				memset(more_indir, 0, sizeof(struct iinfo));
 				if (S_ISDIR(di.di_mode)) {
 					do_leaf_extended(tmpbuf, more_indir);
@@ -1332,6 +1346,8 @@ int block_is_inum_file(void)
 /* ------------------------------------------------------------------------ */
 int block_is_statfs_file(void)
 {
+	if (gfs1 && block == gfs1_license_di.no_addr)
+		return TRUE;
 	if (!gfs1 && block == masterblock("statfs"))
 		return TRUE;
 	return FALSE;
@@ -1342,8 +1358,9 @@ int block_is_statfs_file(void)
 /* ------------------------------------------------------------------------ */
 int block_is_quota_file(void)
 {
-	if ((gfs1 && block == gfs1_quota_di.no_addr) ||
-	    (block == masterblock("quota")))
+	if (gfs1 && block == gfs1_quota_di.no_addr)
+		return TRUE;
+	if (!gfs1 && block == masterblock("quota"))
 		return TRUE;
 	return FALSE;
 }
@@ -1430,7 +1447,7 @@ void read_superblock(int fd)
 	sbd1 = (struct gfs_sb *)&sbd.sd_sb;
 	ioctl(fd, BLKFLSBUF, 0);
 	do_lseek(fd, 0x10 * 4096);
-	do_read(fd, buf, bufsize); /* read in the desired block */
+	do_read(fd, buf, sbd.bsize); /* read in the desired block */
 	memset(&sbd, 0, sizeof(struct gfs2_sbd));
 	sbd.device_fd = fd;
 	sbd.bsize = GFS2_DEFAULT_BSIZE;
@@ -1459,10 +1476,11 @@ void read_superblock(int fd)
 	}
 	else
 		gfs1 = FALSE;
-	bufsize = sbd.sd_sb.sb_bsize;
-	if (!bufsize)
-		bufsize = GFS2_DEFAULT_BSIZE;
-	block = 0x10 * (GFS2_DEFAULT_BSIZE / bufsize);
+	sbd.bsize = sbd.sd_sb.sb_bsize;
+	if (!sbd.bsize)
+		sbd.bsize = GFS2_DEFAULT_BSIZE;
+	compute_constants(&sbd);
+	block = 0x10 * (GFS2_DEFAULT_BSIZE / sbd.bsize);
 }
 
 /* ------------------------------------------------------------------------ */
@@ -1471,8 +1489,8 @@ void read_superblock(int fd)
 void read_master_dir(void)
 {
 	ioctl(sbd.device_fd, BLKFLSBUF, 0);
-	do_lseek(sbd.device_fd, sbd.sd_sb.sb_master_dir.no_addr * bufsize);
-	do_read(sbd.device_fd, buf, bufsize); /* read in the desired block */
+	do_lseek(sbd.device_fd, sbd.sd_sb.sb_master_dir.no_addr * sbd.bsize);
+	do_read(sbd.device_fd, buf, sbd.bsize); /* read in the desired block */
 	gfs2_dinode_in(&di, buf); /* parse disk inode into structure */
 	do_dinode_extended(&di, buf); /* get extended data, if any */
 	memcpy(&masterdir, &indirect[0], sizeof(struct indirect_info));
@@ -1497,10 +1515,10 @@ int display(int identify_only)
 		move(2,0);
 	}
 	if (block_in_mem != blk) { /* If we changed blocks from the last read */
-		dev_offset = blk * bufsize;
+		dev_offset = blk * sbd.bsize;
 		ioctl(sbd.device_fd, BLKFLSBUF, 0);
 		do_lseek(sbd.device_fd, dev_offset);
-		do_read(sbd.device_fd, buf, bufsize); /* read desired block */
+		do_read(sbd.device_fd, buf, sbd.bsize); /* read desired block */
 		block_in_mem = blk; /* remember which block is in memory */
 	}
 	line = 1;
@@ -1509,7 +1527,7 @@ int display(int identify_only)
 		return 0;
 	indirect_blocks = 0;
 	lines_per_row[dmode] = 1;
-	if (gfs2_struct_type == GFS2_METATYPE_SB || blk == 0x10 * (4096 / bufsize)) {
+	if (gfs2_struct_type == GFS2_METATYPE_SB || blk == 0x10 * (4096 / sbd.bsize)) {
 		gfs2_sb_in(&sbd.sd_sb, buf); /* parse it out into the sb structure */
 		memset(indirect, 0, sizeof(indirect));
 		indirect->ii[0].block = sbd.sd_sb.sb_master_dir.no_addr;
@@ -1558,7 +1576,7 @@ int display(int identify_only)
 	if (dmode == HEX_MODE)          /* if hex display mode           */
 		hexdump(dev_offset, buf,
 			(gfs2_struct_type == GFS2_METATYPE_DI)?
-			struct_len + di.di_size:bufsize);
+			struct_len + di.di_size:sbd.bsize);
 	else if (dmode == GFS2_MODE)    /* if structure display          */
 		display_gfs2();            /* display the gfs2 structure    */
 	else
@@ -1714,7 +1732,7 @@ void hex_edit(int *exitch)
 	int left_off;
 	int ch;
 
-	left_off = ((block * bufsize) < 0xffffffff) ? 9 : 17;
+	left_off = ((block * sbd.bsize) < 0xffffffff) ? 9 : 17;
 	/* 8 and 16 char addresses on screen */
 	
 	if (bobgets(estring, edit_row[dmode] + 3,
@@ -1747,7 +1765,7 @@ void hex_edit(int *exitch)
 				buf[offset + hexoffset] = ch;
 			}
 			do_lseek(sbd.device_fd, dev_offset);
-			do_write(sbd.device_fd, buf, bufsize);
+			do_write(sbd.device_fd, buf, sbd.bsize);
 			fsync(sbd.device_fd);
 		}
 	}
@@ -1775,10 +1793,10 @@ void pageup(void)
 		if (dmode == GFS2_MODE || offset==0) {
 			block--;
 			if (dmode == HEX_MODE)
-				offset = (bufsize % screen_chunk_size) > 0 ? 
+				offset = (sbd.bsize % screen_chunk_size) > 0 ?
 					screen_chunk_size *
-					(bufsize / screen_chunk_size) :
-					bufsize - screen_chunk_size;
+					(sbd.bsize / screen_chunk_size) :
+					sbd.bsize - screen_chunk_size;
 			else
 				offset = 0;
 		}
@@ -1806,7 +1824,7 @@ void pagedn(void)
 	else {
 		start_row[dmode] = edit_row[dmode] = 0;
 		if (dmode == GFS2_MODE ||
-		    offset + screen_chunk_size >= bufsize) {
+		    offset + screen_chunk_size >= sbd.bsize) {
 			block++;
 			offset = 0;
 		}
@@ -1912,7 +1930,7 @@ void interactive_mode(void)
 				edit_row[dmode] = 0;
 			}
 			else {
-				block = 0x10 * (4096 / bufsize);
+				block = 0x10 * (4096 / sbd.bsize);
 				push_block(block);
 				offset = 0;
 			}
@@ -2143,7 +2161,7 @@ void dump_journal(const char *journal)
 	uint64_t jindex_block, jblock, j_size, jb;
 	int error, start_line, journal_num;
 	struct gfs2_dinode jdi;
-	char jbuf[bufsize];
+	char jbuf[sbd.bsize];
 	struct gfs2_inode *j_inode = NULL;
 
 	start_line = line;
@@ -2187,16 +2205,16 @@ void dump_journal(const char *journal)
 		j_size = jdi.di_size;
 	}
 
-	for (jb = 0; jb < j_size; jb += (gfs1 ? 1:bufsize)) {
+	for (jb = 0; jb < j_size; jb += (gfs1 ? 1:sbd.bsize)) {
 		if (gfs1) {
 			if (j_bh)
 				brelse(j_bh, not_updated);
 			j_bh = bread(&sbd, jblock + jb);
-			memcpy(jbuf, j_bh->b_data, bufsize);
+			memcpy(jbuf, j_bh->b_data, sbd.bsize);
 		}
 		else
 			error = gfs2_readi(j_inode, (void *)&jbuf, jb,
-					   bufsize);
+					   sbd.bsize);
 		if (!error) /* end of file */
 			break;
 		if (get_block_type(jbuf) == GFS2_METATYPE_LD) {
@@ -2221,7 +2239,7 @@ void dump_journal(const char *journal)
 				 "Quota", "Final Entry", "Unknown"}};
 
 			print_gfs2("Block #%4llx: Log descriptor, ",
-				   jb / (gfs1 ? 1 : bufsize));
+				   jb / (gfs1 ? 1 : sbd.bsize));
 			gfs2_log_descriptor_in(&ld, jbuf);
 			print_gfs2("type %d ", ld.ld_type);
 
@@ -2241,7 +2259,7 @@ void dump_journal(const char *journal)
 			else
 				b = (uint64_t *)(jbuf +
 					sizeof(struct gfs2_log_descriptor));
-			while (*b && (char *)b < (jbuf + bufsize)) {
+			while (*b && (char *)b < (jbuf + sbd.bsize)) {
 				if (!termlines ||
 				    (print_entry_ndx >= start_row[dmode] &&
 				     ((print_entry_ndx - start_row[dmode])+1) *
@@ -2271,7 +2289,7 @@ void dump_journal(const char *journal)
 				gfs2_log_header_in(&lh, jbuf);
 				print_gfs2("Block #%4llx: Log header: Seq"
 					   "= 0x%x, tail = 0x%x, blk = 0x%x",
-					   jb / bufsize, lh.lh_sequence,
+					   jb / sbd.bsize, lh.lh_sequence,
 					   lh.lh_tail, lh.lh_blkno);
 			}
 			eol(0);
@@ -2401,15 +2419,17 @@ void process_parameters(int argc, char *argv[], int pass)
 						   max_block, max_block);
 				else if (!strcmp(argv[i], "sb") ||
 						 !strcmp(argv[i], "superblock"))
-					push_block(0x10 * (4096 / bufsize)); /* superblock */
+					push_block(0x10 * (4096 / sbd.bsize)); /* superblock */
 				else if (!strcmp(argv[i], "root") ||
 						 !strcmp(argv[i], "rootdir"))
 					push_block(sbd.sd_sb.sb_root_dir.no_addr);
 				else if (!strcmp(argv[i], "master")) {
-					if (!gfs1)
-						push_block(sbd.sd_sb.sb_master_dir.no_addr);
-					else
-						fprintf(stderr, "This is GFS1; there's no master directory.\n");
+					if (gfs1) {
+						fprintf(stderr, "Error: 'master' is invalid "
+							"for GFS (1) file systems.\n");
+						exit(-1);
+					}
+					push_block(sbd.sd_sb.sb_master_dir.no_addr);
 				}
 				else if (!strcmp(argv[i], "jindex")) {
 					if (gfs1)
@@ -2417,12 +2437,28 @@ void process_parameters(int argc, char *argv[], int pass)
 					else
 						push_block(masterblock("jindex"));/* journal index */
 				}
-				else if (!gfs1 && !strcmp(argv[i], "per_node"))
+				else if (!strcmp(argv[i], "per_node")) {
+					if (gfs1) {
+						fprintf(stderr, "Error: 'per_node' is invalid "
+							"for GFS (1) file systems.\n");
+						exit(-1);
+					}
 					push_block(masterblock("per_node"));
-				else if (!gfs1 && !strcmp(argv[i], "inum"))
+				}
+				else if (!strcmp(argv[i], "inum")) {
+					if (gfs1) {
+						fprintf(stderr, "Error: 'inum' is invalid "
+							"for GFS (1) file systems.\n");
+						exit(-1);
+					}
 					push_block(masterblock("inum"));
-				else if (!gfs1 && !strcmp(argv[i], "statfs"))
-					push_block(masterblock("statfs"));
+				}
+				else if (!strcmp(argv[i], "statfs")) {
+					if (gfs1)
+						push_block(gfs1_license_di.no_addr);
+					else
+						push_block(masterblock("statfs"));
+				}
 				else if (!strcmp(argv[i], "rindex") ||
 						 !strcmp(argv[i], "rgindex")) {
 					if (gfs1)
@@ -2510,7 +2546,7 @@ void process_parameters(int argc, char *argv[], int pass)
 				else {
 					fprintf(stderr,"I don't know what '%s' means.\n", argv[i]);
 					usage();
-					exit(0);
+					exit(-1);
 				}
 			}
 		}
@@ -2545,7 +2581,8 @@ int main(int argc, char *argv[])
 	memset(edit_size, 0, sizeof(edit_size));
 	memset(last_entry_onscreen, 0, sizeof(last_entry_onscreen));
 	dmode = HEX_MODE;
-	type_alloc(buf, char, bufsize); /* allocate/malloc a new 4K buffer */
+	sbd.bsize = 4096;
+	type_alloc(buf, char, sbd.bsize); /* allocate/malloc a new 4K buffer */
 	block = 0x10;
 	for (i = 0; i < BLOCK_STACK_SIZE; i++) {
 		blockstack[i].dmode = dmode;
@@ -2568,11 +2605,11 @@ int main(int argc, char *argv[])
 	fd = open(device, O_RDWR);
 	if (fd < 0)
 		die("can't open %s: %s\n", device, strerror(errno));
-	max_block = lseek(fd, 0, SEEK_END) / bufsize;
+	max_block = lseek(fd, 0, SEEK_END) / sbd.bsize;
 
 	read_superblock(fd);
-	max_block = lseek(fd, 0, SEEK_END) / bufsize;
-	blockstack[0].block = 0x10 * (4096 / bufsize);
+	max_block = lseek(fd, 0, SEEK_END) / sbd.bsize;
+	blockstack[0].block = 0x10 * (4096 / sbd.bsize);
 	strcpy(sbd.device_name, device);
 	if (!gfs1)
 		read_master_dir();
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index 40cf47c..1ff2775 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -74,7 +74,6 @@ EXTERN char estring[1024]; /* edit string */
 EXTERN uint64_t dev_offset INIT(0);
 EXTERN uint64_t max_block INIT(0);
 EXTERN char *buf INIT(NULL);
-EXTERN uint64_t bufsize INIT(4096);
 EXTERN int termlines INIT(30);
 EXTERN int termcols INIT(80);
 EXTERN int insert INIT(0);
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index d582304..e27d9df 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -383,7 +383,7 @@ int get_gfs_struct_info(char *buf, int *block_type, int *struct_len)
 	struct gfs2_meta_header mh;
 
 	*block_type = 0;
-	*struct_len = bufsize;
+	*struct_len = sbd.bsize;
 
 	gfs2_meta_header_in(&mh, buf);
 	if (mh.mh_magic != GFS2_MAGIC)
@@ -396,19 +396,19 @@ int get_gfs_struct_info(char *buf, int *block_type, int *struct_len)
 		*struct_len = sizeof(struct gfs_sb);
 		break;
 	case GFS2_METATYPE_RG:   /* 2 (rsrc grp hdr) */
-		*struct_len = bufsize; /*sizeof(struct gfs_rgrp);*/
+		*struct_len = sbd.bsize; /*sizeof(struct gfs_rgrp);*/
 		break;
 	case GFS2_METATYPE_RB:   /* 3 (rsrc grp bitblk) */
-		*struct_len = bufsize;
+		*struct_len = sbd.bsize;
 		break;
 	case GFS2_METATYPE_DI:   /* 4 (disk inode) */
-		*struct_len = bufsize; /*sizeof(struct gfs_dinode);*/
+		*struct_len = sbd.bsize; /*sizeof(struct gfs_dinode);*/
 		break;
 	case GFS2_METATYPE_IN:   /* 5 (indir inode blklst) */
-		*struct_len = bufsize; /*sizeof(struct gfs_indirect);*/
+		*struct_len = sbd.bsize; /*sizeof(struct gfs_indirect);*/
 		break;
 	case GFS2_METATYPE_LF:   /* 6 (leaf dinode blklst) */
-		*struct_len = bufsize; /*sizeof(struct gfs_leaf);*/
+		*struct_len = sbd.bsize; /*sizeof(struct gfs_leaf);*/
 		break;
 	case GFS2_METATYPE_JD:   /* 7 (journal data) */
 		*struct_len = sizeof(struct gfs2_meta_header);
@@ -417,16 +417,16 @@ int get_gfs_struct_info(char *buf, int *block_type, int *struct_len)
 		*struct_len = sizeof(struct gfs2_log_header);
 		break;
 	case GFS2_METATYPE_LD:   /* 9 (log descriptor) */
-		*struct_len = bufsize;
+		*struct_len = sbd.bsize;
 		break;
 	case GFS2_METATYPE_EA:   /* 10 (extended attr hdr) */
-		*struct_len = bufsize;
+		*struct_len = sbd.bsize;
 		break;
 	case GFS2_METATYPE_ED:   /* 11 (extended attr data) */
-		*struct_len = bufsize;
+		*struct_len = sbd.bsize;
 		break;
 	default:
-		*struct_len = bufsize;
+		*struct_len = sbd.bsize;
 		break;
 	}
 	return 0;
@@ -509,8 +509,8 @@ int save_block(int fd, int out_fd, uint64_t blk)
 		return 0;
 	}
 	memset(savedata, 0, sizeof(struct saved_metablock));
-	do_lseek(fd, blk * bufsize);
-	do_read(fd, savedata->buf, bufsize); /* read in the block */
+	do_lseek(fd, blk * sbd.bsize);
+	do_read(fd, savedata->buf, sbd.bsize); /* read in the block */
 
 	/* If this isn't metadata and isn't a system file, we don't want it.
 	   Note that we're checking "block" here rather than blk.  That's
@@ -522,7 +522,7 @@ int save_block(int fd, int out_fd, uint64_t blk)
 		return 0; /* Not metadata, and not system file, so skip it */
 	trailing0 = 0;
 	p = &savedata->buf[blklen - 1];
-	while (*p=='\0' && trailing0 < bufsize) {
+	while (*p=='\0' && trailing0 < sbd.bsize) {
 		trailing0++;
 		p--;
 	}
@@ -597,7 +597,7 @@ void save_inode_data(int out_fd)
 
 	for (i = 0; i < GFS2_MAX_META_HEIGHT; i++)
 		osi_list_init(&metalist[i]);
-	buf = malloc(bufsize);
+	buf = malloc(sbd.bsize);
 	metabh = bread(&sbd, block);
 	inode = inode_get(&sbd, metabh);
 	height = inode->i_di.di_height;
@@ -645,7 +645,7 @@ void save_inode_data(int out_fd)
 		gfs2_meta_header_in(&mh, metabh->b_data);
 		if (mh.mh_magic == GFS2_MAGIC) {
 			for (e = sizeof(struct gfs2_meta_header);
-			     e < bufsize; e += ea.ea_rec_len) {
+			     e < sbd.bsize; e += ea.ea_rec_len) {
 				uint64_t blk, *b;
 				int charoff;
 
@@ -751,7 +751,7 @@ void savemeta(const char *out_fn, int saveoption)
 
 	do_lseek(sbd.device_fd, 0);
 	blks_saved = total_out = last_reported_block = 0;
-	bufsize = BUFSIZE;
+	sbd.bsize = BUFSIZE;
 	if (!slow) {
 		int i;
 
@@ -766,11 +766,11 @@ void savemeta(const char *out_fn, int saveoption)
 		if(!gfs1 && read_sb(&sbd) < 0)
 			slow = TRUE;
 		else
-			bufsize = sbd.bsize = sbd.sd_sb.sb_bsize;
+			sbd.bsize = sbd.bsize = sbd.sd_sb.sb_bsize;
 	}
-	last_fs_block = lseek(sbd.device_fd, 0, SEEK_END) / bufsize;
-	printf("There are %" PRIu64 " blocks of %" PRIu64 " bytes.\n",
-	       last_fs_block, bufsize);
+	last_fs_block = lseek(sbd.device_fd, 0, SEEK_END) / sbd.bsize;
+	printf("There are %" PRIu64 " blocks of %u bytes.\n",
+	       last_fs_block, sbd.bsize);
 	if (!slow) {
 		if (gfs1) {
 			sbd.md.riinode =
@@ -810,7 +810,7 @@ void savemeta(const char *out_fn, int saveoption)
 	get_journal_inode_blocks();
 	if (!slow) {
 		/* Save off the superblock */
-		save_block(sbd.device_fd, out_fd, 0x10 * (4096 / bufsize));
+		save_block(sbd.device_fd, out_fd, 0x10 * (4096 / sbd.bsize));
 		/* If this is gfs1, save off the rindex because it's not
 		   part of the file system as it is in gfs2. */
 		if (gfs1) {
@@ -898,7 +898,7 @@ int restore_data(int fd, int in_fd, int printblocksonly)
 			fprintf(stderr, "Error reading from file.\n");
 			return -1;
 		}
-		total_out += bufsize;
+		total_out += sbd.bsize;
 		savedata->blk = be64_to_cpu(buf64);
 		if (!printblocksonly &&
 		    last_fs_block && savedata->blk >= last_fs_block) {
@@ -930,15 +930,15 @@ int restore_data(int fd, int in_fd, int printblocksonly)
 					fprintf(stderr,"Error: Invalid superblock data.\n");
 					return -1;
 				}
-				bufsize = sbd.sd_sb.sb_bsize;
+				sbd.bsize = sbd.sd_sb.sb_bsize;
 				if (!printblocksonly) {
 					last_fs_block =
 						lseek(fd, 0, SEEK_END) /
-						bufsize;
-					printf("There are %" PRIu64 " blocks of %" \
-					       PRIu64 " bytes in the destination" \
+						sbd.bsize;
+					printf("There are %" PRIu64 " blocks of " \
+					       "%u bytes in the destination" \
 					       " file system.\n\n",
-					       last_fs_block, bufsize);
+					       last_fs_block, sbd.bsize);
 				}
 				first = 0;
 			}
@@ -954,8 +954,8 @@ int restore_data(int fd, int in_fd, int printblocksonly)
 					       "device; quitting.\n");
 					break;
 				}
-				do_lseek(fd, savedata->blk * bufsize);
-				do_write(fd, savedata->buf, bufsize);
+				do_lseek(fd, savedata->blk * sbd.bsize);
+				do_write(fd, savedata->buf, sbd.bsize);
 				writes++;
 			}
 			blks_saved++;
diff --git a/gfs2/man/gfs2_edit.8 b/gfs2/man/gfs2_edit.8
index 022382f..5cd3e16 100644
--- a/gfs2/man/gfs2_edit.8
+++ b/gfs2/man/gfs2_edit.8
@@ -126,6 +126,10 @@ block in the file system for metadata.  This option is less prone to failure
 due to file system corruption than the savemeta option, but it is 
 extremely slow.
 .TP
+\fBsavergs\fP \fI<device>\fR \fI<filename>\fR
+Save off only the GFS2 resource group metadata for the file system on the
+specified device to a file given by <filename>.
+.TP
 \fBrestoremeta\fP \fI<filename>\fR \fI<dest device>\fR
 Take a file created with the savemeta option and restores its
 contents on top of the specified destination device.  \fBWARNING\fP:


hooks/post-receive
--
Cluster Project



More information about the Cluster-cvs mailing list