diff mbox series

generic/670: allow _mread_range() races with reflink_range()

Message ID 20220112092846.1467088-1-ruansy.fnst@fujitsu.com (mailing list archive)
State New, archived
Headers show
Series generic/670: allow _mread_range() races with reflink_range() | expand

Commit Message

Shiyang Ruan Jan. 12, 2022, 9:28 a.m. UTC
mread copies data one-byte-at-a-time, so it may races with
reflink_range() who invalidates page cache of the dest file.
Allow this race by adjusting the egrep regexp.

Reported-by: Darrick J. Wong <djwong@kernel.org>
Suggested-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
---
 tests/generic/670 | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Darrick J. Wong Jan. 13, 2022, 9:09 p.m. UTC | #1
On Wed, Jan 12, 2022 at 05:28:46PM +0800, Shiyang Ruan wrote:
> mread copies data one-byte-at-a-time, so it may races with
> reflink_range() who invalidates page cache of the dest file.
> Allow this race by adjusting the egrep regexp.
> 
> Reported-by: Darrick J. Wong <djwong@kernel.org>
> Suggested-by: Darrick J. Wong <djwong@kernel.org>
> Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>

Looks reasonable; I'll put this in the test system for tonight and
report back if I see anything strange.  I didn't see anything obvious
after a dozen or so rounds.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  tests/generic/670 | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/generic/670 b/tests/generic/670
> index 83fbd0b9..4a895d90 100755
> --- a/tests/generic/670
> +++ b/tests/generic/670
> @@ -40,7 +40,10 @@ _cp_reflink $testdir/file1 $testdir/file3
>  _scratch_cycle_mount
>  
>  fbytes() {
> -	egrep -v '(61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61|62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62)'
> +	# Different with generic/164,165, mread copies data from mmapped area
> +	# one-byte-at-a-time, which may cause races during reflink_range().
> +	# So the result of _mread_range() may be a mix of 61 and 62.
> +	egrep -v '((61|62) ){15}(61|62)'
>  }
>  
>  reader() {
> -- 
> 2.34.1
> 
> 
>
diff mbox series

Patch

diff --git a/tests/generic/670 b/tests/generic/670
index 83fbd0b9..4a895d90 100755
--- a/tests/generic/670
+++ b/tests/generic/670
@@ -40,7 +40,10 @@  _cp_reflink $testdir/file1 $testdir/file3
 _scratch_cycle_mount
 
 fbytes() {
-	egrep -v '(61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61|62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62)'
+	# Different with generic/164,165, mread copies data from mmapped area
+	# one-byte-at-a-time, which may cause races during reflink_range().
+	# So the result of _mread_range() may be a mix of 61 and 62.
+	egrep -v '((61|62) ){15}(61|62)'
 }
 
 reader() {