]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_copy: fix data corruption of target
authorJunxiao Bi <junxiao.bi@oracle.com>
Thu, 19 Jun 2014 02:11:48 +0000 (12:11 +1000)
committerDave Chinner <david@fromorbit.com>
Thu, 19 Jun 2014 02:11:48 +0000 (12:11 +1000)
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 <junxiao.bi@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
copy/xfs_copy.c

index f4c84e30ddbd0eda6b53cd156ad6be41994d7c20..7ce5ec95496aad074a351ba8466509233105bdd8 100644 (file)
@@ -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 */