All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs_mdrestore: initialize sb prior to xfs_sb_from_disk()
@ 2014-06-05 23:09 Eric Sandeen
  2014-06-05 23:56 ` Dave Chinner
  2014-06-09 21:30 ` [PATCH V2] xfs: fix crc field handling in xfs_sb_to/from_disk Eric Sandeen
  0 siblings, 2 replies; 7+ messages in thread
From: Eric Sandeen @ 2014-06-05 23:09 UTC (permalink / raw)
  To: xfs-oss

If we xfs_mdrestore an image from a non-crc filesystem, lo
and behold the restored image has gained a CRC:

# db/xfs_metadump.sh -o /dev/sdc1 - | xfs_mdrestore - test.img
# xfs_db -c "sb 0" -c "p crc" /dev/sdc1
crc = 0 (correct)
# xfs_db -c "sb 0" -c "p crc" test.img
crc = 0xb6f8d6a0 (correct)

Obviously it can't really be correct :)

The problem is, xfs_sb_from_disk doesn't fill in the sb_crc
field.

An earlier commit:

  47de6e1 repair: ensure that unused superblock fields are zeroed

fixed this same sort of problem for xfs_repair.  Do the same
for mdrestore.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

But ... should we maybe just do this once and for all in
xfs_sb_from_disk?  I'm not sure leaving it up to every
caller is a good idea, unless somebody ahs a reason to
pre-populate some fields - I can't imagine why that would
be, though...

diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c
index e57bdb2..0453f17 100644
--- a/mdrestore/xfs_mdrestore.c
+++ b/mdrestore/xfs_mdrestore.c
@@ -104,6 +104,7 @@ perform_restore(
 			1, src_f) != 1)
 		fatal("error reading from file: %s\n", strerror(errno));
 
+	memset(&sb, 0, sizeof(struct xfs_sb));
 	libxfs_sb_from_disk(&sb, (xfs_dsb_t *)block_buffer);
 
 	if (sb.sb_magicnum != XFS_SB_MAGIC)

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-06-09 21:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-05 23:09 [PATCH] xfs_mdrestore: initialize sb prior to xfs_sb_from_disk() Eric Sandeen
2014-06-05 23:56 ` Dave Chinner
2014-06-06  0:00   ` Eric Sandeen
2014-06-06  1:42     ` Dave Chinner
2014-06-06  2:53       ` Eric Sandeen
2014-06-09 20:58         ` Eric Sandeen
2014-06-09 21:30 ` [PATCH V2] xfs: fix crc field handling in xfs_sb_to/from_disk Eric Sandeen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.