public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* cluster: RHEL55 - Allow gfs2_edit printsavedmeta to print destination size and type
@ 2009-08-31 17:56 Bob Peterson
  0 siblings, 0 replies; only message in thread
From: Bob Peterson @ 2009-08-31 17:56 UTC (permalink / raw)
  To: cluster-cvs-relay

Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=1b9110194688b6b982067f99952cf3418bc93d42
Commit:        1b9110194688b6b982067f99952cf3418bc93d42
Parent:        28f3bf4cff08f5d714e9d7b134ebbce12264746e
Author:        Bob Peterson <bob@ganesha.peterson>
AuthorDate:    Mon Aug 31 10:07:12 2009 -0500
Committer:     Bob Peterson <rpeterso@redhat.com>
CommitterDate: Mon Aug 31 12:58:08 2009 -0500

Allow gfs2_edit printsavedmeta to print destination size and type

When doing gfs2_edit printsavedmeta, the code will now print
whether the metadata is gfs2 or gfs at the top of the output.
At the end of the output, it will print the device size
required to restore it.

rhbz#503529
---
 gfs2/edit/savemeta.c |   35 +++++++++++++++++++++++++++++++----
 1 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 4559f6d..064eaef 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -653,10 +653,27 @@ void savemeta(char *out_fn, int saveoption)
 	exit(0);
 }
 
+/**
+ * anthropomorphize - make a uint64_t number more human
+ */
+static const char *anthropomorphize(unsigned long long inhuman_value)
+{
+	const char *symbols = " KMGTPE";
+	int i;
+	unsigned long long val = inhuman_value;
+	static char out_val[32];
+
+	memset(out_val, 0, sizeof(out_val));
+	for (i = 0; i < 6 && val > 1024; i++)
+		val /= 1024;
+	sprintf(out_val, "%llu%c", val, symbols[i]);
+	return out_val;
+}
+
 int restore_data(int fd, int in_fd, int printblocksonly)
 {
 	size_t rs;
-	uint64_t buf64, writes = 0;
+	uint64_t buf64, writes = 0, highest_valid_block = 0;
 	uint16_t buf16;
 	int first = 1, pos;
 	char buf[256];
@@ -722,9 +739,9 @@ int restore_data(int fd, int in_fd, int printblocksonly)
 				    sbd1->sb_header.mh_format ==
 				    GFS_FORMAT_SB &&
 				    sbd1->sb_multihost_format ==
-				    GFS_FORMAT_MULTI)
-					;
-				else if (check_sb(&sbd.sd_sb)) {
+				    GFS_FORMAT_MULTI) {
+					gfs1 = TRUE;
+				} else if (check_sb(&sbd.sd_sb)) {
 					fprintf(stderr,"Error: Invalid superblock data.\n");
 					return -1;
 				}
@@ -737,6 +754,9 @@ int restore_data(int fd, int in_fd, int printblocksonly)
 					       "%u bytes in the destination" \
 					       " file system.\n\n",
 					       last_fs_block, sbd.bsize);
+				} else {
+					printf("This is %s metadata\n", gfs1 ?
+					       "gfs (not gfs2)" : "gfs2");
 				}
 				first = 0;
 			}
@@ -744,6 +764,8 @@ int restore_data(int fd, int in_fd, int printblocksonly)
 				print_gfs2("%d (l=0x%x): ", blks_saved,
 					   savedata->siglen);
 				block = savedata->blk;
+				if (block > highest_valid_block)
+					highest_valid_block = block;
 				display_block_type(savedata->buf, TRUE);
 			} else {
 				warm_fuzzy_stuff(savedata->blk, FALSE, FALSE);
@@ -766,6 +788,11 @@ int restore_data(int fd, int in_fd, int printblocksonly)
 	}
 	if (!printblocksonly)
 		warm_fuzzy_stuff(savedata->blk, TRUE, FALSE);
+	else
+		printf("File system size: %lld (0x%llx) blocks, aka %sB\n",
+		       (unsigned long long)highest_valid_block,
+		       (unsigned long long)highest_valid_block,
+		       anthropomorphize(highest_valid_block * sbd.bsize));
 	return 0;
 }
 


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-08-31 17:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-31 17:56 cluster: RHEL55 - Allow gfs2_edit printsavedmeta to print destination size and type Bob Peterson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).