cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Andrew Price <anprice@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 13/13] restoremeta: Skip the right number of bytes for the superblock
Date: Thu, 23 Jan 2020 15:55:52 +0000	[thread overview]
Message-ID: <20200123155552.1080247-14-anprice@redhat.com> (raw)
In-Reply-To: <20200123155552.1080247-1-anprice@redhat.com>

Fix a bug where the second saved block was reached by skipping over the
size of a gfs2 superblock, which is not always the correct offset.
Instead, skip over the length specified by the saved superblock's
descriptor.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/edit/savemeta.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index e20b405d..63cb91af 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -1198,6 +1198,7 @@ static void complain(const char *complaint)
 static int restore_init(const char *path, struct metafd *mfd, struct savemeta_header *smh, int printonly)
 {
 	struct gfs2_meta_header *sbmh;
+	uint16_t sb_siglen;
 	char *end;
 	char *bp;
 	int ret;
@@ -1229,6 +1230,7 @@ static int restore_init(const char *path, struct metafd *mfd, struct savemeta_he
 	/* Scan for the position of the superblock. Required to support old formats(?). */
 	end = &restore_buf[256 + sizeof(struct saved_metablock) + sizeof(*sbmh)];
 	while (bp <= end) {
+		sb_siglen = be16_to_cpu(((struct saved_metablock *)bp)->siglen);
 		sbmh = (struct gfs2_meta_header *)(bp + sizeof(struct saved_metablock));
 		if (sbmh->mh_magic == cpu_to_be32(GFS2_MAGIC) &&
 		    sbmh->mh_type == cpu_to_be32(GFS2_METATYPE_SB))
@@ -1243,7 +1245,7 @@ static int restore_init(const char *path, struct metafd *mfd, struct savemeta_he
 	if (ret != 0)
 		return ret;
 
-	bp += sizeof(struct saved_metablock) + sizeof(sbd.sd_sb);
+	bp += sizeof(struct saved_metablock) + sb_siglen;
 	restore_off = bp - restore_buf;
 	restore_left -= restore_off;
 	return 0;
-- 
2.24.1



      parent reply	other threads:[~2020-01-23 15:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-23 15:55 [Cluster-devel] [PATCH 00/13] gfs2_edit restoremeta: Add bzip2 support Andrew Price
2020-01-23 15:55 ` [Cluster-devel] [PATCH 01/13] restoremeta: Use zlib by file descriptor Andrew Price
2020-01-23 15:55 ` [Cluster-devel] [PATCH 02/13] restoremeta: Abstract out metadata file opening Andrew Price
2020-01-23 15:55 ` [Cluster-devel] [PATCH 03/13] restoremeta: Use metafd instead of gzFile for parameters Andrew Price
2020-01-23 15:55 ` [Cluster-devel] [PATCH 04/13] restoremeta: Abstract out decompression operations Andrew Price
2020-01-23 15:55 ` [Cluster-devel] [PATCH 05/13] restoremeta: Combine restore_init() and open_metadata() Andrew Price
2020-01-23 15:55 ` [Cluster-devel] [PATCH 06/13] restoremeta: Don't seek in restore_header() Andrew Price
2020-01-23 15:55 ` [Cluster-devel] [PATCH 07/13] savemeta: Remove anthropomorphize() Andrew Price
2020-01-23 15:55 ` [Cluster-devel] [PATCH 08/13] restoremeta: Remove find_highest_block() Andrew Price
2020-01-23 15:55 ` [Cluster-devel] [PATCH 09/13] restoremeta: Metadata file reading overhaul Andrew Price
2020-01-23 15:55 ` [Cluster-devel] [PATCH 10/13] restoremeta: Convert iseof function to a flag Andrew Price
2020-01-23 15:55 ` [Cluster-devel] [PATCH 11/13] restoremeta: Combine parse_header() and check_header() Andrew Price
2020-01-23 15:55 ` [Cluster-devel] [PATCH 12/13] restoremeta: Add bzip2 support Andrew Price
2020-01-23 15:55 ` Andrew Price [this message]

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=20200123155552.1080247-14-anprice@redhat.com \
    --to=anprice@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 NNTP newsgroup(s).