]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
xfs_copy: Fix meta UUID handling on multiple copies
authorEric Sandeen <sandeen@redhat.com>
Thu, 22 Sep 2016 23:16:52 +0000 (09:16 +1000)
committerDave Chinner <david@fromorbit.com>
Thu, 22 Sep 2016 23:16:52 +0000 (09:16 +1000)
commitcbca895541facb3a1a00fd0fe6614301a64c0e3a
tree6395993ab71176746b3f30c97ef620bcb9d3d314
parente5c4ab5e1ff0145e1a071ce76b12c57c723c63e6
xfs_copy: Fix meta UUID handling on multiple copies

Zorro reported that when making multiple copies of a V5
filesystem with xfs_copy while generating new UUIDs, all
but the first copy were corrupt.

Upon inspection, the corruption was related to incorrect UUIDs;
the original UUID, as stamped into every metadata structure,
was not preserved in the sb_meta_uuid field of the superblock
on any but the first copy.

This happened because sb_update_uuid was using the UUID present in
the ag_hdr structure as the unchanging meta-uuid which is to match
existing structures, but it also /updates/ that UUID with the
new identifying UUID present in tcarg.  So the newly-generated
UUIDs moved transitively from tcarg->uuid to ag_hdr->xfs_sb->sb_uuid
to ag_hdr->xfs_sb->sb_meta_uuid each time the function got called.

Fix this by looking instead to the unchanging, original UUID
present in the xfs_sb_t we are given, which reflects the original
filesystem's metadata UUID, and copy /that/ UUID into each target
filesystem's meta_uuid field.

Most of this patch is changing comments and re-ordering tests
to match; the functional change is to simply use the *sb rather
than the *ag_hdr to identify the proper metadata UUID.

Reported-and-tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
copy/xfs_copy.c