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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

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




[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux