From: Jeff Layton <jlayton@kernel.org>
To: Eryu Guan <guaneryu@gmail.com>
Cc: fstests@vger.kernel.org, aweits@rit.edu, dhowells@redhat.com,
willy@infradead.org
Subject: [PATCH v3] generic: add a test to ensure that page is properly filled before write
Date: Fri, 2 Jul 2021 09:40:24 -0400 [thread overview]
Message-ID: <20210702134024.24233-1-jlayton@kernel.org> (raw)
We had a broken optimization in cephfs and netfs lib that could cause
part of a page to be improperly zeroed-out when writing to an offset
that was beyond the EOF but in an existing page.
Add a simple test that would have caught this.
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
tests/generic/639 | 39 +++++++++++++++++++++++++++++++++++++++
tests/generic/639.out | 5 +++++
2 files changed, 44 insertions(+)
create mode 100755 tests/generic/639
create mode 100644 tests/generic/639.out
v3: adapt to new test template
diff --git a/tests/generic/639 b/tests/generic/639
new file mode 100755
index 000000000000..c30f7644a2fc
--- /dev/null
+++ b/tests/generic/639
@@ -0,0 +1,39 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2021, Jeff Layton <jlayton@redhat.com>
+#
+# FS QA Test No. 639
+#
+# Open a file and write a little data to it. Unmount (to clean out the cache)
+# and then mount again. Then write some data to it beyond the EOF and ensure
+# the result is correct.
+#
+# Prompted by a bug in ceph_write_begin that was fixed by commit 827a746f405d.
+#
+. ./common/preamble
+_begin_fstest auto quick rw
+
+# Import common functions.
+. ./common/filter
+
+# real QA test starts here
+_supported_fs generic
+_require_test
+
+testfile="$TEST_DIR/test_write_begin.$$"
+
+# write some data to file and fsync it out
+$XFS_IO_PROG -f -c "pwrite -q 0 32" $testfile
+
+# cycle the mount to clean out the pagecache
+_test_cycle_mount
+
+# now, write to the file (near the end)
+$XFS_IO_PROG -c "pwrite -q 32 32" $testfile
+
+# dump what we think is in there
+echo "The result should be 64 bytes filled with 0xcd:"
+hexdump -C $testfile
+
+status=0
+exit
diff --git a/tests/generic/639.out b/tests/generic/639.out
new file mode 100644
index 000000000000..9bf0bac96864
--- /dev/null
+++ b/tests/generic/639.out
@@ -0,0 +1,5 @@
+QA output created by 639
+The result should be 64 bytes filled with 0xcd:
+00000000 cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd |................|
+*
+00000040
--
2.31.1
next reply other threads:[~2021-07-02 13:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-02 13:40 Jeff Layton [this message]
2021-07-05 11:04 ` [PATCH v3] generic: add a test to ensure that page is properly filled before write Zorro Lang
2021-07-05 11:10 ` Zorro Lang
2021-07-06 10:56 ` Jeff Layton
2021-07-07 5:27 ` Eryu Guan
2021-07-07 10:46 ` Jeff Layton
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=20210702134024.24233-1-jlayton@kernel.org \
--to=jlayton@kernel.org \
--cc=aweits@rit.edu \
--cc=dhowells@redhat.com \
--cc=fstests@vger.kernel.org \
--cc=guaneryu@gmail.com \
--cc=willy@infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox