This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 53ea0225019770fc86971f2b49a68d7fc9d93e8e
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Mon Jan 20 17:04:57 2020 +0000
restoremeta: Remove find_highest_block()
Doing a first pass through the metadata file just to find the highest
saved block and report it is a bit excessive, so remove
find_highest_block() and simply use the value from the metadata file
header if present. For ancient files that don't have the header, we just
don't report the size, which is a reasonable tradeoff as old files are
really only encountered during testing.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/savemeta.c | 41 ++++++-----------------------------------
1 file changed, 6 insertions(+), 35 deletions(-)
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index f73cb0e..dd20397 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -1066,37 +1066,6 @@ err:
return -1;
}
-static int find_highest_block(struct metafd *mfd, off_t pos, uint64_t fssize)
-{
- int err = 0;
- uint64_t highest = 0;
- struct saved_metablock svb = {0};
-
- while (1) {
- mfd->seek(mfd, pos, SEEK_SET);
- err = restore_block(mfd, &svb, NULL, 0);
- if (err == 1)
- break;
- if (err != 0)
- return -1;
-
- if (svb.blk > highest)
- highest = svb.blk;
- pos += sizeof(svb) + svb.siglen;
- }
-
- if (fssize > 0) {
- printf("Saved file system size is %"PRIu64" blocks, %.2fGB\n",
- fssize, (fssize * sbd.bsize) / ((float)(1 << 30)));
- sbd.fssize = fssize;
- } else {
- sbd.fssize = highest + 1;
- }
-
- printf("Highest saved block is %"PRIu64" (0x%"PRIx64")\n",
highest, highest);
- return 0;
-}
-
static int restore_data(int fd, struct metafd *mfd, off_t pos, int printonly)
{
struct saved_metablock savedata = {0};
@@ -1248,6 +1217,12 @@ void restoremeta(const char *in_fn, const char *out_device,
uint64_t printonly)
if (error)
exit(1);
+ if (smh.sh_fs_bytes > 0) {
+ sbd.fssize = smh.sh_fs_bytes / sbd.bsize;
+ printf("Saved file system size is %"PRIu64" blocks, %.2fGB\n",
+ sbd.fssize, smh.sh_fs_bytes / ((float)(1 << 30)));
+ }
+
printf("This is gfs%c metadata.\n", sbd.gfs1 ? '1': '2');
if (!printonly) {
@@ -1255,10 +1230,6 @@ void restoremeta(const char *in_fn, const char *out_device,
uint64_t printonly)
printf("There are %"PRIu64" free blocks on the destination
device.\n", space);
}
- error = find_highest_block(&mfd, pos, sbd.fssize);
- if (error)
- exit(1);
-
error = restore_data(sbd.device_fd, &mfd, pos, printonly);
printf("File %s %s %s.\n", in_fn,
(printonly ? "print" : "restore"),
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
Show replies by date