All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xiao Yang <yangx.jy@fujitsu.com>
To: <fstests@vger.kernel.org>
Cc: <darrick.wong@oracle.com>, <lihao2018.fnst@fujitsu.com>,
	<david@fromorbit.com>, <xifeng@redhat.com>, <ira.weiny@intel.com>,
	Xiao Yang <yangx.jy@fujitsu.com>
Subject: [PATCH v2 2/2] generic/608: Add new regression test
Date: Mon, 29 Mar 2021 17:20:54 +0800	[thread overview]
Message-ID: <20210329092054.5278-2-yangx.jy@fujitsu.com> (raw)
In-Reply-To: <20210329092054.5278-1-yangx.jy@fujitsu.com>

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(+)

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




  reply	other threads:[~2021-03-29  9:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-29  9:20 [PATCH v2 1/2] generic/608: Remove drop cache and umount & mount cycle Xiao Yang
2021-03-29  9:20 ` Xiao Yang [this message]
2021-03-29 18:23   ` [PATCH v2 2/2] generic/608: Add new regression test Ira Weiny
2021-03-30  1:27     ` yangx.jy
2021-03-29 18:20 ` [PATCH v2 1/2] generic/608: Remove drop cache and umount & mount cycle Ira Weiny
2021-03-30  1:55 ` yangx.jy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210329092054.5278-2-yangx.jy@fujitsu.com \
    --to=yangx.jy@fujitsu.com \
    --cc=darrick.wong@oracle.com \
    --cc=david@fromorbit.com \
    --cc=fstests@vger.kernel.org \
    --cc=ira.weiny@intel.com \
    --cc=lihao2018.fnst@fujitsu.com \
    --cc=xifeng@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.