From: Junxiao Bi Date: Thu, 19 Jun 2014 02:11:48 +0000 (+1000) Subject: xfs_copy: fix data corruption of target X-Git-Tag: v3.2.1~19 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c667d79c2149a5a678cbde7090766b1be155b033;p=thirdparty%2Fxfsprogs-dev.git xfs_copy: fix data corruption of target The unit of XFS_AGFL_DADDR(mp) is "basic block" whose size is "BBSIZE" (512 bytes), so when "source_sectorsize" is not 512, it will cause the target a corrupted filesystem. Signed-off-by: Junxiao Bi Reviewed-by: Christoph Hellwig Signed-off-by: Dave Chinner --- diff --git a/copy/xfs_copy.c b/copy/xfs_copy.c index f4c84e30d..7ce5ec954 100644 --- a/copy/xfs_copy.c +++ b/copy/xfs_copy.c @@ -700,7 +700,7 @@ main(int argc, char **argv) if (source_blocksize > source_sectorsize) { /* get number of leftover sectors in last block of ag header */ - tmp_residue = ((XFS_AGFL_DADDR(mp) + 1) * source_sectorsize) + tmp_residue = ((XFS_AGFL_DADDR(mp) + 1) * BBSIZE) % source_blocksize; first_residue = (tmp_residue == 0) ? 0 : source_blocksize - tmp_residue; @@ -713,10 +713,10 @@ main(int argc, char **argv) exit(1); } - first_agbno = (((XFS_AGFL_DADDR(mp) + 1) * source_sectorsize) + first_agbno = (((XFS_AGFL_DADDR(mp) + 1) * BBSIZE) + first_residue) / source_blocksize; ASSERT(first_agbno != 0); - ASSERT( ((((XFS_AGFL_DADDR(mp) + 1) * source_sectorsize) + ASSERT(((((XFS_AGFL_DADDR(mp) + 1) * BBSIZE) + first_residue) % source_blocksize) == 0); /* now open targets */