From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17148 invoked by alias); 31 Aug 2009 17:53:37 -0000 Received: (qmail 17142 invoked by alias); 31 Aug 2009 17:53:37 -0000 X-SWARE-Spam-Status: No, hits=-1.2 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_84,SPF_HELO_PASS X-Spam-Status: No, hits=-1.2 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_84,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bastion2.fedora.phx.redhat.com Subject: cluster: STABLE2 - Allow gfs2_edit printsavedmeta to print destination size and type To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/STABLE2 X-Git-Reftype: branch X-Git-Oldrev: 1028257becdaca26b9b14fa5abfb78280804d627 X-Git-Newrev: 7b4aca7ea898cd4f63311a6195f5d2e28883539c From: Bob Peterson Message-Id: <20090831175314.A2DFE1201D4@lists.fedorahosted.org> Date: Mon, 31 Aug 2009 17:53:00 -0000 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2009-q3/txt/msg00268.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=7b4aca7ea898cd4f63311a6195f5d2e28883539c Commit: 7b4aca7ea898cd4f63311a6195f5d2e28883539c Parent: 1028257becdaca26b9b14fa5abfb78280804d627 Author: Bob Peterson AuthorDate: Mon Aug 31 10:07:12 2009 -0500 Committer: Bob Peterson CommitterDate: Mon Aug 31 12:54:21 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 76f37ab..687dbc2 100644 --- a/gfs2/edit/savemeta.c +++ b/gfs2/edit/savemeta.c @@ -666,10 +666,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]; @@ -735,9 +752,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; } @@ -750,6 +767,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; } @@ -757,6 +777,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); @@ -779,6 +801,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; }