public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfsprogs: xfs_copy: fix data corruption of target
@ 2014-05-28  3:28 Junxiao Bi
  2014-05-28  5:32 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Junxiao Bi @ 2014-05-28  3:28 UTC (permalink / raw)
  To: xfs; +Cc: hch, joe.jin, junxiao.bi

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>
---
 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@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-05-29  1:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-28  3:28 [PATCH] xfsprogs: xfs_copy: fix data corruption of target Junxiao Bi
2014-05-28  5:32 ` Christoph Hellwig
2014-05-29  1:46   ` Junxiao Bi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox