generic/608: Add new regression test

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.

It's a regression test for commit 88149082bb8e ("fs: Handle
I_DONTCACHE in iput_final() instead of generic_drop_inode()")

Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
This commit is contained in:
Xiao Yang
2021-03-30 10:06:55 +08:00
committed by Eryu Guan
parent 72ba8811b0
commit 70b22758a8
+29
View File
@@ -7,6 +7,12 @@
# file change immediately when all applications close the file. # file change immediately when all applications close the file.
# It's a regression test for: # It's a regression test for:
# 'commit 77573fa310d9 ("fs: Kill DCACHE_DONTCACHE dentry even if DCACHE_REFERENCED is set")' # 'commit 77573fa310d9 ("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 should be synchronized
# to disk instead of discarded when the corresponding inode is evicted.
# It's a regression test for:
# 'commit 88149082bb8e ("fs: Handle I_DONTCACHE in iput_final() instead of generic_drop_inode()"'
seq=`basename $0` seq=`basename $0`
seqres=$RESULT_DIR/$seq seqres=$RESULT_DIR/$seq
@@ -87,6 +93,26 @@ test_disable_dax()
_check_s_dax $t_file 0 _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 77573fa310d9, ensure inode can
# be evicted by drop_caches
echo 2 > /proc/sys/vm/drop_caches
# The written data which is still in the buffer should not be lost
grep -q "Buffered data" $t_file || echo "Buffered data is lost"
rm -f $t_file
}
do_tests() do_tests()
{ {
local mount_option=$1 local mount_option=$1
@@ -100,6 +126,9 @@ do_tests()
test_enable_dax test_enable_dax
test_disable_dax test_disable_dax
# Do test for commit 88149082bb8e
test_buffered_data_lost
_scratch_unmount _scratch_unmount
} }