xfs
[Top] [All Lists]

[PATCH] xfsprogs: xfs_copy: fix data corruption of target

To: xfs@xxxxxxxxxxx
Subject: [PATCH] xfsprogs: xfs_copy: fix data corruption of target
From: Junxiao Bi <junxiao.bi@xxxxxxxxxx>
Date: Wed, 28 May 2014 11:28:07 +0800
Cc: hch@xxxxxxxxxxxxx, david@xxxxxxxxxxxxx, joe.jin@xxxxxxxxxx, junxiao.bi@xxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
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@xxxxxxxxxx>
---
 copy/xfs_copy.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/copy/xfs_copy.c b/copy/xfs_copy.c
index 39bb9d7..6b3396d 100644
--- a/copy/xfs_copy.c
+++ b/copy/xfs_copy.c
@@ -687,7 +687,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;
@@ -700,10 +700,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 */
-- 
1.7.1

<Prev in Thread] Current Thread [Next in Thread>