* [PATCH v2] generic/430: add copy in same file test
@ 2019-09-04 12:58 Jianhong.Yin
2019-09-15 5:58 ` Eryu Guan
0 siblings, 1 reply; 5+ messages in thread
From: Jianhong.Yin @ 2019-09-04 12:58 UTC (permalink / raw)
To: fstests; +Cc: jiyin, Jianhong.Yin
now xfstests has not cover the senario that copy in same file
related bug:
copy_file_range return "Invalid argument" when copy in the same file
https://bugzilla.kernel.org/show_bug.cgi?id=202935
step1:
copy whole file to itself, and compare with original file.
step2:
copy whole file to end of itself, and compare the two halves with the original file
step3:
recover from original file.
Signed-off-by: Jianhong Yin <yin-jianhong@163.com>
---
this is a base function test, I don't think we should add a new
test for it like 553 554, so add it in generic/430
what do you think?
tests/generic/430 | 12 ++++++++++++
tests/generic/430.out | 4 ++++
2 files changed, 16 insertions(+)
diff --git a/tests/generic/430 b/tests/generic/430
index 1b11f60d..4ce0ee26 100755
--- a/tests/generic/430
+++ b/tests/generic/430
@@ -6,6 +6,7 @@
#
# Tests vfs_copy_file_range():
# - Copy a file
+# - Copy in same file
# - Copy beginning of original to new file
# - Copy middle of original to a new file
# - Copy end of original to new file
@@ -52,6 +53,17 @@ cmp $testdir/file $testdir/copy
echo "Original md5sums:"
md5sum $testdir/{file,copy} | _filter_test_dir
+fsize=$(stat -c %s $testdir/copy)
+echo "Copy in same file"
+$XFS_IO_PROG -c "copy_range -l $fsize $testdir/copy" "$testdir/copy"
+cmp $testdir/file $testdir/copy
+$XFS_IO_PROG -c "copy_range -l $fsize -d $fsize $testdir/copy" "$testdir/copy"
+cmp -n $fsize $testdir/file $testdir/copy
+cmp -i $fsize:0 $testdir/file $testdir/copy
+$XFS_IO_PROG -f -c "copy_range $testdir/file" "$testdir/copy"
+echo "md5sums after copying in same file and recover:"
+md5sum $testdir/{file,copy} | _filter_test_dir
+
echo "Copy beginning of original file"
$XFS_IO_PROG -f -c "copy_range -l 1000 $testdir/file" "$testdir/beginning"
cmp -n 1000 $testdir/file $testdir/beginning
diff --git a/tests/generic/430.out b/tests/generic/430.out
index 4b4ca75d..57584957 100644
--- a/tests/generic/430.out
+++ b/tests/generic/430.out
@@ -3,6 +3,10 @@ Create the original file and then copy
Original md5sums:
e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/file
e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/copy
+Copy in same file
+md5sums after copying in same file and recover:
+e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/file
+e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/copy
Copy beginning of original file
md5sums after copying beginning:
e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/file
--
2.21.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] generic/430: add copy in same file test
2019-09-04 12:58 [PATCH v2] generic/430: add copy in same file test Jianhong.Yin
@ 2019-09-15 5:58 ` Eryu Guan
2019-09-16 5:12 ` Jianhong Yin
2019-09-16 6:14 ` Zorro Lang
0 siblings, 2 replies; 5+ messages in thread
From: Eryu Guan @ 2019-09-15 5:58 UTC (permalink / raw)
To: Jianhong.Yin; +Cc: fstests, jiyin
On Wed, Sep 04, 2019 at 08:58:21PM +0800, Jianhong.Yin wrote:
> now xfstests has not cover the senario that copy in same file
> related bug:
> copy_file_range return "Invalid argument" when copy in the same file
> https://bugzilla.kernel.org/show_bug.cgi?id=202935
>
> step1:
> copy whole file to itself, and compare with original file.
This is explicitly forbidden by commit 96e6e8f4a68d ("vfs: add missing
checks to copy_file_range").
> step2:
> copy whole file to end of itself, and compare the two halves with the original file
> step3:
> recover from original file.
>
> Signed-off-by: Jianhong Yin <yin-jianhong@163.com>
> ---
>
> this is a base function test, I don't think we should add a new
> test for it like 553 554, so add it in generic/430
> what do you think?
>
> tests/generic/430 | 12 ++++++++++++
> tests/generic/430.out | 4 ++++
> 2 files changed, 16 insertions(+)
>
> diff --git a/tests/generic/430 b/tests/generic/430
> index 1b11f60d..4ce0ee26 100755
> --- a/tests/generic/430
> +++ b/tests/generic/430
> @@ -6,6 +6,7 @@
> #
> # Tests vfs_copy_file_range():
> # - Copy a file
> +# - Copy in same file
> # - Copy beginning of original to new file
> # - Copy middle of original to a new file
> # - Copy end of original to new file
> @@ -52,6 +53,17 @@ cmp $testdir/file $testdir/copy
> echo "Original md5sums:"
> md5sum $testdir/{file,copy} | _filter_test_dir
>
> +fsize=$(stat -c %s $testdir/copy)
> +echo "Copy in same file"
> +$XFS_IO_PROG -c "copy_range -l $fsize $testdir/copy" "$testdir/copy"
> +cmp $testdir/file $testdir/copy
> +$XFS_IO_PROG -c "copy_range -l $fsize -d $fsize $testdir/copy" "$testdir/copy"
> +cmp -n $fsize $testdir/file $testdir/copy
> +cmp -i $fsize:0 $testdir/file $testdir/copy
We should skip '0' from original file and $fsize from the copy, i.e.
cmp -i 0:$fsize $testdir/file $testdir/copy
Thanks,
Eryu
> +$XFS_IO_PROG -f -c "copy_range $testdir/file" "$testdir/copy"
> +echo "md5sums after copying in same file and recover:"
> +md5sum $testdir/{file,copy} | _filter_test_dir
> +
> echo "Copy beginning of original file"
> $XFS_IO_PROG -f -c "copy_range -l 1000 $testdir/file" "$testdir/beginning"
> cmp -n 1000 $testdir/file $testdir/beginning
> diff --git a/tests/generic/430.out b/tests/generic/430.out
> index 4b4ca75d..57584957 100644
> --- a/tests/generic/430.out
> +++ b/tests/generic/430.out
> @@ -3,6 +3,10 @@ Create the original file and then copy
> Original md5sums:
> e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/file
> e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/copy
> +Copy in same file
> +md5sums after copying in same file and recover:
> +e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/file
> +e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/copy
> Copy beginning of original file
> md5sums after copying beginning:
> e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/file
> --
> 2.21.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] generic/430: add copy in same file test
2019-09-15 5:58 ` Eryu Guan
@ 2019-09-16 5:12 ` Jianhong Yin
2019-09-16 6:27 ` //Re: " Jianhong Yin
2019-09-16 6:14 ` Zorro Lang
1 sibling, 1 reply; 5+ messages in thread
From: Jianhong Yin @ 2019-09-16 5:12 UTC (permalink / raw)
To: Eryu Guan; +Cc: Jianhong.Yin, fstests
----- 原始邮件 -----
> 发件人: "Eryu Guan" <guaneryu@gmail.com>
> 收件人: "Jianhong.Yin" <yin-jianhong@163.com>
> 抄送: fstests@vger.kernel.org, jiyin@redhat.com
> 发送时间: 星期日, 2019年 9 月 15日 下午 1:58:01
> 主题: Re: [PATCH v2] generic/430: add copy in same file test
>
> On Wed, Sep 04, 2019 at 08:58:21PM +0800, Jianhong.Yin wrote:
> > now xfstests has not cover the senario that copy in same file
> > related bug:
> > copy_file_range return "Invalid argument" when copy in the same file
> > https://bugzilla.kernel.org/show_bug.cgi?id=202935
> >
> > step1:
> > copy whole file to itself, and compare with original file.
>
> This is explicitly forbidden by commit 96e6e8f4a68d ("vfs: add missing
> checks to copy_file_range").
Good to know.
so this test should be in generic/434 (error checking)
+ /* Don't allow overlapped copying within the same file. */
+ if (inode_in == inode_out &&
+ pos_out + count > pos_in &&
+ pos_out < pos_in + count)
+ return -EINVAL;
>
> > step2:
> > copy whole file to end of itself, and compare the two halves with the
> > original file
> > step3:
> > recover from original file.
> >
> > Signed-off-by: Jianhong Yin <yin-jianhong@163.com>
> > ---
> >
> > this is a base function test, I don't think we should add a new
> > test for it like 553 554, so add it in generic/430
> > what do you think?
> >
> > tests/generic/430 | 12 ++++++++++++
> > tests/generic/430.out | 4 ++++
> > 2 files changed, 16 insertions(+)
> >
> > diff --git a/tests/generic/430 b/tests/generic/430
> > index 1b11f60d..4ce0ee26 100755
> > --- a/tests/generic/430
> > +++ b/tests/generic/430
> > @@ -6,6 +6,7 @@
> > #
> > # Tests vfs_copy_file_range():
> > # - Copy a file
> > +# - Copy in same file
> > # - Copy beginning of original to new file
> > # - Copy middle of original to a new file
> > # - Copy end of original to new file
> > @@ -52,6 +53,17 @@ cmp $testdir/file $testdir/copy
> > echo "Original md5sums:"
> > md5sum $testdir/{file,copy} | _filter_test_dir
> >
> > +fsize=$(stat -c %s $testdir/copy)
> > +echo "Copy in same file"
> > +$XFS_IO_PROG -c "copy_range -l $fsize $testdir/copy" "$testdir/copy"
> > +cmp $testdir/file $testdir/copy
> > +$XFS_IO_PROG -c "copy_range -l $fsize -d $fsize $testdir/copy"
> > "$testdir/copy"
> > +cmp -n $fsize $testdir/file $testdir/copy
> > +cmp -i $fsize:0 $testdir/file $testdir/copy
>
> We should skip '0' from original file and $fsize from the copy, i.e.
>
> cmp -i 0:$fsize $testdir/file $testdir/copy
yes, had fixed in PATVH v3; will send PATCH v4(remove step 1)
Thanks
Jianhong
>
> Thanks,
> Eryu
>
> > +$XFS_IO_PROG -f -c "copy_range $testdir/file" "$testdir/copy"
> > +echo "md5sums after copying in same file and recover:"
> > +md5sum $testdir/{file,copy} | _filter_test_dir
> > +
> > echo "Copy beginning of original file"
> > $XFS_IO_PROG -f -c "copy_range -l 1000 $testdir/file" "$testdir/beginning"
> > cmp -n 1000 $testdir/file $testdir/beginning
> > diff --git a/tests/generic/430.out b/tests/generic/430.out
> > index 4b4ca75d..57584957 100644
> > --- a/tests/generic/430.out
> > +++ b/tests/generic/430.out
> > @@ -3,6 +3,10 @@ Create the original file and then copy
> > Original md5sums:
> > e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/file
> > e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/copy
> > +Copy in same file
> > +md5sums after copying in same file and recover:
> > +e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/file
> > +e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/copy
> > Copy beginning of original file
> > md5sums after copying beginning:
> > e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/file
> > --
> > 2.21.0
> >
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* //Re: [PATCH v2] generic/430: add copy in same file test
2019-09-16 5:12 ` Jianhong Yin
@ 2019-09-16 6:27 ` Jianhong Yin
0 siblings, 0 replies; 5+ messages in thread
From: Jianhong Yin @ 2019-09-16 6:27 UTC (permalink / raw)
To: Eryu Guan; +Cc: Jianhong.Yin, fstests
----- 原始邮件 -----
> 发件人: "Jianhong Yin" <jiyin@redhat.com>
> 收件人: "Eryu Guan" <guaneryu@gmail.com>
> 抄送: "Jianhong.Yin" <yin-jianhong@163.com>, fstests@vger.kernel.org
> 发送时间: 星期一, 2019年 9 月 16日 下午 1:12:38
> 主题: Re: [PATCH v2] generic/430: add copy in same file test
>
>
> ----- 原始邮件 -----
> > 发件人: "Eryu Guan" <guaneryu@gmail.com>
> > 收件人: "Jianhong.Yin" <yin-jianhong@163.com>
> > 抄送: fstests@vger.kernel.org, jiyin@redhat.com
> > 发送时间: 星期日, 2019年 9 月 15日 下午 1:58:01
> > 主题: Re: [PATCH v2] generic/430: add copy in same file test
> >
> > On Wed, Sep 04, 2019 at 08:58:21PM +0800, Jianhong.Yin wrote:
> > > now xfstests has not cover the senario that copy in same file
> > > related bug:
> > > copy_file_range return "Invalid argument" when copy in the same file
> > > https://bugzilla.kernel.org/show_bug.cgi?id=202935
> > >
> > > step1:
> > > copy whole file to itself, and compare with original file.
> >
> > This is explicitly forbidden by commit 96e6e8f4a68d ("vfs: add missing
> > checks to copy_file_range").
>
> Good to know.
> so this test should be in generic/434 (error checking)
update:
find that the overlaps test has done by generic/564.
Jianhong.
>
> + /* Don't allow overlapped copying within the same file. */
> + if (inode_in == inode_out &&
> + pos_out + count > pos_in &&
> + pos_out < pos_in + count)
> + return -EINVAL;
>
> >
> > > step2:
> > > copy whole file to end of itself, and compare the two halves with the
> > > original file
> > > step3:
> > > recover from original file.
> > >
> > > Signed-off-by: Jianhong Yin <yin-jianhong@163.com>
> > > ---
> > >
> > > this is a base function test, I don't think we should add a new
> > > test for it like 553 554, so add it in generic/430
> > > what do you think?
> > >
> > > tests/generic/430 | 12 ++++++++++++
> > > tests/generic/430.out | 4 ++++
> > > 2 files changed, 16 insertions(+)
> > >
> > > diff --git a/tests/generic/430 b/tests/generic/430
> > > index 1b11f60d..4ce0ee26 100755
> > > --- a/tests/generic/430
> > > +++ b/tests/generic/430
> > > @@ -6,6 +6,7 @@
> > > #
> > > # Tests vfs_copy_file_range():
> > > # - Copy a file
> > > +# - Copy in same file
> > > # - Copy beginning of original to new file
> > > # - Copy middle of original to a new file
> > > # - Copy end of original to new file
> > > @@ -52,6 +53,17 @@ cmp $testdir/file $testdir/copy
> > > echo "Original md5sums:"
> > > md5sum $testdir/{file,copy} | _filter_test_dir
> > >
> > > +fsize=$(stat -c %s $testdir/copy)
> > > +echo "Copy in same file"
> > > +$XFS_IO_PROG -c "copy_range -l $fsize $testdir/copy" "$testdir/copy"
> > > +cmp $testdir/file $testdir/copy
> > > +$XFS_IO_PROG -c "copy_range -l $fsize -d $fsize $testdir/copy"
> > > "$testdir/copy"
> > > +cmp -n $fsize $testdir/file $testdir/copy
> > > +cmp -i $fsize:0 $testdir/file $testdir/copy
> >
> > We should skip '0' from original file and $fsize from the copy, i.e.
> >
> > cmp -i 0:$fsize $testdir/file $testdir/copy
>
> yes, had fixed in PATVH v3; will send PATCH v4(remove step 1)
>
> Thanks
> Jianhong
>
> >
> > Thanks,
> > Eryu
> >
> > > +$XFS_IO_PROG -f -c "copy_range $testdir/file" "$testdir/copy"
> > > +echo "md5sums after copying in same file and recover:"
> > > +md5sum $testdir/{file,copy} | _filter_test_dir
> > > +
> > > echo "Copy beginning of original file"
> > > $XFS_IO_PROG -f -c "copy_range -l 1000 $testdir/file"
> > > "$testdir/beginning"
> > > cmp -n 1000 $testdir/file $testdir/beginning
> > > diff --git a/tests/generic/430.out b/tests/generic/430.out
> > > index 4b4ca75d..57584957 100644
> > > --- a/tests/generic/430.out
> > > +++ b/tests/generic/430.out
> > > @@ -3,6 +3,10 @@ Create the original file and then copy
> > > Original md5sums:
> > > e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/file
> > > e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/copy
> > > +Copy in same file
> > > +md5sums after copying in same file and recover:
> > > +e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/file
> > > +e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/copy
> > > Copy beginning of original file
> > > md5sums after copying beginning:
> > > e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/file
> > > --
> > > 2.21.0
> > >
> >
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] generic/430: add copy in same file test
2019-09-15 5:58 ` Eryu Guan
2019-09-16 5:12 ` Jianhong Yin
@ 2019-09-16 6:14 ` Zorro Lang
1 sibling, 0 replies; 5+ messages in thread
From: Zorro Lang @ 2019-09-16 6:14 UTC (permalink / raw)
To: Eryu Guan; +Cc: Jianhong.Yin, fstests, jiyin
On Sun, Sep 15, 2019 at 01:58:01PM +0800, Eryu Guan wrote:
> On Wed, Sep 04, 2019 at 08:58:21PM +0800, Jianhong.Yin wrote:
> > now xfstests has not cover the senario that copy in same file
> > related bug:
> > copy_file_range return "Invalid argument" when copy in the same file
> > https://bugzilla.kernel.org/show_bug.cgi?id=202935
> >
> > step1:
> > copy whole file to itself, and compare with original file.
>
> This is explicitly forbidden by commit 96e6e8f4a68d ("vfs: add missing
> checks to copy_file_range").
Yes, you're right. Tested on latest upstream kernel with XFS:
# xfs_io -f -t -c "pwrite -S 0xff 0 1m" -c "copy_range testfile" testfile
wrote 1048576/1048576 bytes at offset 0
1 MiB, 256 ops; 0.0051 sec (195.733 MiB/sec and 50107.6532 ops/sec)
copy_range: Invalid argument
So VFS doesn't allow overlapped copying within same file now. We need to
re-think about this test now.
Thanks,
Zorro
>
> > step2:
> > copy whole file to end of itself, and compare the two halves with the original file
> > step3:
> > recover from original file.
> >
> > Signed-off-by: Jianhong Yin <yin-jianhong@163.com>
> > ---
> >
> > this is a base function test, I don't think we should add a new
> > test for it like 553 554, so add it in generic/430
> > what do you think?
> >
> > tests/generic/430 | 12 ++++++++++++
> > tests/generic/430.out | 4 ++++
> > 2 files changed, 16 insertions(+)
> >
> > diff --git a/tests/generic/430 b/tests/generic/430
> > index 1b11f60d..4ce0ee26 100755
> > --- a/tests/generic/430
> > +++ b/tests/generic/430
> > @@ -6,6 +6,7 @@
> > #
> > # Tests vfs_copy_file_range():
> > # - Copy a file
> > +# - Copy in same file
> > # - Copy beginning of original to new file
> > # - Copy middle of original to a new file
> > # - Copy end of original to new file
> > @@ -52,6 +53,17 @@ cmp $testdir/file $testdir/copy
> > echo "Original md5sums:"
> > md5sum $testdir/{file,copy} | _filter_test_dir
> >
> > +fsize=$(stat -c %s $testdir/copy)
> > +echo "Copy in same file"
> > +$XFS_IO_PROG -c "copy_range -l $fsize $testdir/copy" "$testdir/copy"
> > +cmp $testdir/file $testdir/copy
> > +$XFS_IO_PROG -c "copy_range -l $fsize -d $fsize $testdir/copy" "$testdir/copy"
> > +cmp -n $fsize $testdir/file $testdir/copy
> > +cmp -i $fsize:0 $testdir/file $testdir/copy
>
> We should skip '0' from original file and $fsize from the copy, i.e.
>
> cmp -i 0:$fsize $testdir/file $testdir/copy
>
> Thanks,
> Eryu
>
> > +$XFS_IO_PROG -f -c "copy_range $testdir/file" "$testdir/copy"
> > +echo "md5sums after copying in same file and recover:"
> > +md5sum $testdir/{file,copy} | _filter_test_dir
> > +
> > echo "Copy beginning of original file"
> > $XFS_IO_PROG -f -c "copy_range -l 1000 $testdir/file" "$testdir/beginning"
> > cmp -n 1000 $testdir/file $testdir/beginning
> > diff --git a/tests/generic/430.out b/tests/generic/430.out
> > index 4b4ca75d..57584957 100644
> > --- a/tests/generic/430.out
> > +++ b/tests/generic/430.out
> > @@ -3,6 +3,10 @@ Create the original file and then copy
> > Original md5sums:
> > e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/file
> > e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/copy
> > +Copy in same file
> > +md5sums after copying in same file and recover:
> > +e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/file
> > +e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/copy
> > Copy beginning of original file
> > md5sums after copying beginning:
> > e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/file
> > --
> > 2.21.0
> >
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-09-16 6:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-04 12:58 [PATCH v2] generic/430: add copy in same file test Jianhong.Yin
2019-09-15 5:58 ` Eryu Guan
2019-09-16 5:12 ` Jianhong Yin
2019-09-16 6:27 ` //Re: " Jianhong Yin
2019-09-16 6:14 ` Zorro Lang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).