public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
From: Bob Peterson <rpeterso@fedoraproject.org>
To: cluster-cvs-relay@redhat.com
Subject: cluster: STABLE3 - Allow gfs2_edit printsavedmeta to print destination size and type
Date: Mon, 31 Aug 2009 17:33:00 -0000	[thread overview]
Message-ID: <20090831173312.C7B051201D4@lists.fedorahosted.org> (raw)

Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=3a0256932f1f441fd95516b0dbabfa5666b36632
Commit:        3a0256932f1f441fd95516b0dbabfa5666b36632
Parent:        84e6a86ece412ab4ccf86541813c51961d23b9bf
Author:        Bob Peterson <bob@ganesha.peterson>
AuthorDate:    Mon Aug 31 10:08:31 2009 -0500
Committer:     Bob Peterson <bob@ganesha.peterson>
CommitterDate: Mon Aug 31 10:08:31 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 243ee49..bef9393 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -711,10 +711,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;
+}
+
 static 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 rdbuf[256];
@@ -794,9 +811,9 @@ static 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;
 				}
@@ -809,6 +826,9 @@ static 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;
 			}
@@ -816,6 +836,8 @@ static 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);
@@ -857,6 +879,11 @@ static 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;
 }
 


                 reply	other threads:[~2009-08-31 17:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090831173312.C7B051201D4@lists.fedorahosted.org \
    --to=rpeterso@fedoraproject.org \
    --cc=cluster-cvs-relay@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).