diff mbox series

[v2,2/2] generic/608: Add new regression test

Message ID 20210329092054.5278-2-yangx.jy@fujitsu.com (mailing list archive)
State New
Headers show
Series [v2,1/2] generic/608: Remove drop cache and umount & mount cycle | expand

Commit Message

Xiao Yang March 29, 2021, 9:20 a.m. UTC
Write data into a file and then enable DAX on the file immediately,
the written data which is still in the buffer will be lost when
the corresponding inode is evicted.

It's a regression test for commit 26b15a042b8a.

Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
---
 tests/generic/608 | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

Comments

Ira Weiny March 29, 2021, 6:23 p.m. UTC | #1
On Mon, Mar 29, 2021 at 05:20:54PM +0800, Xiao Yang wrote:
> Write data into a file and then enable DAX on the file immediately,
> the written data which is still in the buffer will be lost when
> the corresponding inode is evicted.

This and the comment below are confusing.  Doesn't the buffered data get
written?  Which means the data is not lost?

IOW the test is checking to make sure the data does not get lost, not that it
does.  What am I missing?

Ira

> 
> It's a regression test for commit 26b15a042b8a.
> 
> Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
> ---
>  tests/generic/608 | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/tests/generic/608 b/tests/generic/608
> index d81a2488..674bd2cf 100755
> --- a/tests/generic/608
> +++ b/tests/generic/608
> @@ -7,6 +7,12 @@
>  # file change immediately when all applications close the file.
>  # It's a regression test for:
>  # 'commit e7bed0b5bc4b ("fs: Kill DCACHE_DONTCACHE dentry even if DCACHE_REFERENCED is set")'
> +#
> +# Write data into a file and then enable DAX on the file immediately,
> +# the written data which is still in the buffer will be lost when the
> +# corresponding inode is evicted.
> +# It's a regression test for:
> +# 'commit 26b15a042b8a ("fs: Handle I_DONTCACHE in iput_final() instead of generic_drop_inode()"'
>  
>  seq=`basename $0`
>  seqres=$RESULT_DIR/$seq
> @@ -87,6 +93,26 @@ test_disable_dax()
>  	_check_s_dax $t_file 0
>  }
>  
> +test_buffered_data_lost()
> +{
> +	local t_file=$SCRATCH_MNT/datafile
> +
> +	# Write data into a file
> +	echo "Buffered data" > $t_file
> +
> +	# Then enable DAX on the file immediately
> +	$XFS_IO_PROG -c 'chattr +x' $t_file
> +
> +	# Without commit e7bed0b5bc4b, ensure inode can
> +	# be evicted by drop_caches
> +	echo 2 > /proc/sys/vm/drop_caches
> +
> +	# The written data which is still in the buffer will be lost
> +	grep -q "Buffered data" $t_file || echo "Buffered data is lost"
> +
> +	rm -f $t_file
> +}
> +
>  do_tests()
>  {
>  	local mount_option=$1
> @@ -100,6 +126,9 @@ do_tests()
>  	test_enable_dax
>  	test_disable_dax
>  
> +	# Do test for commit 26b15a042b8a
> +	test_buffered_data_lost
> +
>  	_scratch_unmount
>  }
>  
> -- 
> 2.21.0
> 
> 
>
Xiao Yang March 30, 2021, 1:27 a.m. UTC | #2
On 2021/3/30 2:23, Ira Weiny wrote:
> On Mon, Mar 29, 2021 at 05:20:54PM +0800, Xiao Yang wrote:
>> Write data into a file and then enable DAX on the file immediately,
>> the written data which is still in the buffer will be lost when
>> the corresponding inode is evicted.
> This and the comment below are confusing.  Doesn't the buffered data get
> written?  Which means the data is not lost?
Hi Ira,

Thanks for your quick comment.

How about the following commit message:
-------------------------------------------------------------------------

Write data into a file and then enable DAX on the file immediately,
the written data which is still in the buffer should be synchronized
to disk instead of discarded when the corresponding inode is evicted.

-------------------------------------------------------------------------
> IOW the test is checking to make sure the data does not get lost, not that it
> does.  What am I missing?

Right, the data should not get lost.

Best Regards,
Xiao Yang
> Ira
>
>> It's a regression test for commit 26b15a042b8a.
>>
>> Signed-off-by: Xiao Yang<yangx.jy@fujitsu.com>
>> ---
>>   tests/generic/608 | 29 +++++++++++++++++++++++++++++
>>   1 file changed, 29 insertions(+)
>>
>> diff --git a/tests/generic/608 b/tests/generic/608
>> index d81a2488..674bd2cf 100755
>> --- a/tests/generic/608
>> +++ b/tests/generic/608
>> @@ -7,6 +7,12 @@
>>   # file change immediately when all applications close the file.
>>   # It's a regression test for:
>>   # 'commit e7bed0b5bc4b ("fs: Kill DCACHE_DONTCACHE dentry even if DCACHE_REFERENCED is set")'
>> +#
>> +# Write data into a file and then enable DAX on the file immediately,
>> +# the written data which is still in the buffer will be lost when the
>> +# corresponding inode is evicted.
>> +# It's a regression test for:
>> +# 'commit 26b15a042b8a ("fs: Handle I_DONTCACHE in iput_final() instead of generic_drop_inode()"'
>>
>>   seq=`basename $0`
>>   seqres=$RESULT_DIR/$seq
>> @@ -87,6 +93,26 @@ test_disable_dax()
>>   	_check_s_dax $t_file 0
>>   }
>>
>> +test_buffered_data_lost()
>> +{
>> +	local t_file=$SCRATCH_MNT/datafile
>> +
>> +	# Write data into a file
>> +	echo "Buffered data">  $t_file
>> +
>> +	# Then enable DAX on the file immediately
>> +	$XFS_IO_PROG -c 'chattr +x' $t_file
>> +
>> +	# Without commit e7bed0b5bc4b, ensure inode can
>> +	# be evicted by drop_caches
>> +	echo 2>  /proc/sys/vm/drop_caches
>> +
>> +	# The written data which is still in the buffer will be lost
>> +	grep -q "Buffered data" $t_file || echo "Buffered data is lost"
>> +
>> +	rm -f $t_file
>> +}
>> +
>>   do_tests()
>>   {
>>   	local mount_option=$1
>> @@ -100,6 +126,9 @@ do_tests()
>>   	test_enable_dax
>>   	test_disable_dax
>>
>> +	# Do test for commit 26b15a042b8a
>> +	test_buffered_data_lost
>> +
>>   	_scratch_unmount
>>   }
>>
>> -- 
>> 2.21.0
>>
>>
>>
> .
>
diff mbox series

Patch

diff --git a/tests/generic/608 b/tests/generic/608
index d81a2488..674bd2cf 100755
--- a/tests/generic/608
+++ b/tests/generic/608
@@ -7,6 +7,12 @@ 
 # file change immediately when all applications close the file.
 # It's a regression test for:
 # 'commit e7bed0b5bc4b ("fs: Kill DCACHE_DONTCACHE dentry even if DCACHE_REFERENCED is set")'
+#
+# Write data into a file and then enable DAX on the file immediately,
+# the written data which is still in the buffer will be lost when the
+# corresponding inode is evicted.
+# It's a regression test for:
+# 'commit 26b15a042b8a ("fs: Handle I_DONTCACHE in iput_final() instead of generic_drop_inode()"'
 
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
@@ -87,6 +93,26 @@  test_disable_dax()
 	_check_s_dax $t_file 0
 }
 
+test_buffered_data_lost()
+{
+	local t_file=$SCRATCH_MNT/datafile
+
+	# Write data into a file
+	echo "Buffered data" > $t_file
+
+	# Then enable DAX on the file immediately
+	$XFS_IO_PROG -c 'chattr +x' $t_file
+
+	# Without commit e7bed0b5bc4b, ensure inode can
+	# be evicted by drop_caches
+	echo 2 > /proc/sys/vm/drop_caches
+
+	# The written data which is still in the buffer will be lost
+	grep -q "Buffered data" $t_file || echo "Buffered data is lost"
+
+	rm -f $t_file
+}
+
 do_tests()
 {
 	local mount_option=$1
@@ -100,6 +126,9 @@  do_tests()
 	test_enable_dax
 	test_disable_dax
 
+	# Do test for commit 26b15a042b8a
+	test_buffered_data_lost
+
 	_scratch_unmount
 }