From: Jeff Layton <jlayton@kernel.org>
To: Eryu Guan <guan@eryu.me>
Cc: Eryu Guan <guaneryu@gmail.com>,
fstests@vger.kernel.org, aweits@rit.edu, dhowells@redhat.com,
willy@infradead.org
Subject: Re: [PATCH] generic: add a test to ensure that page is properly filled before write
Date: Sun, 13 Jun 2021 13:31:40 -0400 [thread overview]
Message-ID: <705733a48274f5235a76a60fe9b229493e9772de.camel@kernel.org> (raw)
In-Reply-To: <YMYbkDgYdkLkA0BW@desktop>
On Sun, 2021-06-13 at 22:52 +0800, Eryu Guan wrote:
> On Sat, Jun 12, 2021 at 08:31:54AM -0400, Jeff Layton wrote:
> > 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/XXX | 53 +++++++++++++++++++++++++++++++++++++++++++
> > tests/generic/XXX.out | 5 ++++
>
> Ah, all the 'XXX' in this test should be replaced with proper seq
> number.
>
I can do that and resend.
> > tests/generic/group | 1 +
> > 3 files changed, 59 insertions(+)
> > create mode 100755 tests/generic/XXX
> > create mode 100644 tests/generic/XXX.out
> >
> > diff --git a/tests/generic/XXX b/tests/generic/XXX
> > new file mode 100755
> > index 000000000000..0ddaaa544609
> > --- /dev/null
> > +++ b/tests/generic/XXX
> > @@ -0,0 +1,53 @@
> > +#! /bin/bash
> > +# SPDX-License-Identifier: GPL-2.0
> > +# Copyright (c) 2021, Jeff Layton <jlayton@redhat.com>
> > +#
> > +# FS QA Test No. XXX
> > +#
> > +# 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. See:
> > +#
> > +# https://lore.kernel.org/ceph-devel/97002.1623448034@warthog.procyon.org.uk/T/#m9f34b328623b493c529505e12f64f4dfdbddfb27
>
> This looks like a thread 9 months ago. Was the fix merged? If so, it'd
> be better to reference the kernel commit here.
>
> Otherwise test looks fine to me.
>
Not yet. v5.13 will require a fix in the netfs lib, whereas ceph will
need a one-off fix in v5.10.z - v5.12.z. We're sorting out both fixes
now.
Thanks!
>
> > +#
> > +seq=`basename $0`
> > +seqres=$RESULT_DIR/$seq
> > +echo "QA output created by $seq"
> > +
> > +here=`pwd`
> > +status=1 # failure is the default!
> > +trap "_cleanup; exit \$status" 0 1 2 3 15
> > +
> > +
> > +_cleanup()
> > +{
> > + cd /
> > + rm -f $testfile
> > +}
> > +
> > +# get standard environment, filters and checks
> > +. ./common/rc
> > +. ./common/filter
> > +
> > +_supported_fs generic
> > +_require_test
> > +
> > +rm -f $seqres.full
> > +
> > +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/XXX.out b/tests/generic/XXX.out
> > new file mode 100644
> > index 000000000000..4e7653858e51
> > --- /dev/null
> > +++ b/tests/generic/XXX.out
> > @@ -0,0 +1,5 @@
> > +QA output created by XXX
> > +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
> > diff --git a/tests/generic/group b/tests/generic/group
> > index 9a636b23f243..204a9b548f78 100644
> > --- a/tests/generic/group
> > +++ b/tests/generic/group
> > @@ -641,3 +641,4 @@
> > 636 auto quick swap
> > 637 auto quick dir
> > 638 auto quick rw
> > +XXX auto quick rw
> > --
> > 2.31.1
> >
--
Jeff Layton <jlayton@kernel.org>
next prev parent reply other threads:[~2021-06-13 17:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-12 12:31 [PATCH] generic: add a test to ensure that page is properly filled before write Jeff Layton
2021-06-13 14:52 ` Eryu Guan
2021-06-13 17:31 ` Jeff Layton [this message]
2021-06-25 18:06 ` [PATCH v2] " 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=705733a48274f5235a76a60fe9b229493e9772de.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=aweits@rit.edu \
--cc=dhowells@redhat.com \
--cc=fstests@vger.kernel.org \
--cc=guan@eryu.me \
--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