From: Nick Piggin <npiggin@suse.de>
To: Jeff Layton <jlayton@redhat.com>
Cc: Steve French <smfrench@gmail.com>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
pbadari@us.ibm.com,
"linux-cifs-client@lists.samba.org"
<linux-cifs-client@lists.samba.org>
Subject: Re: [linux-cifs-client] Re: fsx-linux failing with latest cifs-2.6 git tree
Date: Thu, 27 Nov 2008 09:33:30 +0100 [thread overview]
Message-ID: <20081127083330.GB28285@wotan.suse.de> (raw)
In-Reply-To: <20081126113758.66d27c67@tleilax.poochiereds.net>
On Wed, Nov 26, 2008 at 11:37:58AM -0500, Jeff Layton wrote:
> On Wed, 26 Nov 2008 16:23:32 +0100
> Nick Piggin <npiggin@suse.de> wrote:
> >
> > > > That seems pretty reasonable, although keep in mind that
> > > > AOP_FLAG_UNINTERRUPTIBLE is not going to be the common case (unless
> > > > you're running loop or nfsd or something on the filesystem).
> > > >
> > > > It would be really nice to figure out a way to avoid the reads in
> > > > the interruptible case as well.
> > >
> >
> > > > I can't remember the CIFS code very well, but in several of the new
> > > > aops conversions I did, I added something like a BUG_ON(!PageUptodate())
> > > > in the write_end methods to ensure I wasn't missing some key part of
> > > > the logic. It's entirely possible that cifs is almost ready to handle
> > > > a !uptodate page in write_end...
> > >
> > > Well, CIFS is "special". Rather than just updating the pagecache, we
> > > can fall back to doing a sync write instead. So I don't think we want
> > > to BUG if the page isn't up to date. It's not ideal, but I think it's a
> > > situation we can deal with if necessary.
> >
> > Yes, that would be better. That sync write fallback is quite clever I
> > think...
> >
>
> Since we're able to do the sync write fallback here, I think we can
> probably not bother with checking for AOP_FLAG_UNINTERRUPTIBLE at all.
> As long as we only set the page uptodate in write_end in the case that
> the write isn't short, then we'll be ok I think even when it's
> interruptible.
Yes, that would make sense. The AOP_FLAG_UNINTERRUPTIBLE is really just
a hint in case the filesystem can avoid some really expensive operation.
In reality, ~AOP_FLAG_UNINTERRUPTIBLE is going to be the most common
case for 99% of users, so having any tricky optimisations for it is
probably not worth the hassle.
> This does make the assumption that the interrupted case is somewhat
> rare...
It should be somewhat rare. The kernel prefaults the user memory before
it attempts to copy. For regular write(2), this means a short write is
almost never going to happen. For writev(2), we only fault in the first
iovec, so short writes could be much more common -- if this ever becomes
a problem then we could easily look at prefetching more than one iov.
> Thoughts on this patch?
Looks pretty good.
> ------------------[snip]-------------------
>
> From a8e5ea4d9859f590b5c04954e8e2a13023f690f5 Mon Sep 17 00:00:00 2001
> From: Jeff Layton <jlayton@redhat.com>
> Date: Wed, 26 Nov 2008 11:32:09 -0500
> Subject: [PATCH] cifs: fix regression in cifs_write_begin/cifs_write_end
>
> The conversion to write_begin/write_end interfaces had a bug where we
> were passing a bad parameter to cifs_readpage_worker. Rather than
> passing the page offset of the start of the write, we needed to pass the
> offset of the beginning of the page. This was reliably showing up as
> data corruption in the fsx-linux test from LTP.
>
> It also became evident that this code was occasionally doing unnecessary
> read calls. Optimize those away by using the PG_checked flag to indicate
> that the unwritten part of the page has been initialized.
>
> Signed-off-by: Jeff Layton <jlayton@redhat.com>
> ---
> fs/cifs/file.c | 79 +++++++++++++++++++++++++++++++++++++++++---------------
> 1 files changed, 58 insertions(+), 21 deletions(-)
>
> diff --git a/fs/cifs/file.c b/fs/cifs/file.c
> index b691b89..49d4a97 100644
> --- a/fs/cifs/file.c
> +++ b/fs/cifs/file.c
> @@ -1475,7 +1475,11 @@ static int cifs_write_end(struct file *file, struct address_space *mapping,
> cFYI(1, ("write_end for page %p from pos %lld with %d bytes",
> page, pos, copied));
>
> - if (!PageUptodate(page) && copied == PAGE_CACHE_SIZE)
> + if (PageChecked(page)) {
> + if (copied == len)
> + SetPageUptodate(page);
> + ClearPageChecked(page);
> + } else if (!PageUptodate(page) && copied == PAGE_CACHE_SIZE)
> SetPageUptodate(page);
One minor thing -- you could do the !PageUptodate check first? If the
page is already uptodate, then everything is much simpler I think? (and
PageChecked should not be set).
if (!PageUptodate(page)) {
if (PageChecked(page)) {
if (copied == len)
SetPageUptodate(page);
ClearPageChecked(page);
} else if (copied == PAGE_CACHE_SIZE)
SetPageUptodate(page);
}
I don't know if you think that's better or not, but I really like to
make it clear that this is the !PageUptodate logic, and we never try
to SetPageUptodate on an already uptodate page.
But I guess it is just a matter of style. So go with whatever you like
best.
Thanks,
Nick
next prev parent reply other threads:[~2008-11-27 8:33 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20081121105613.09a8cb8e@tleilax.poochiereds.net>
[not found] ` <524f69650811210820s549de2bah3181cbc0c5633091@mail.gmail.com>
[not found] ` <20081121112249.0b408b55@tleilax.poochiereds.net>
[not found] ` <524f69650811210846q7502fd99m6f4d335bb6ac1b65@mail.gmail.com>
[not found] ` <524f69650811211109w659e5decoa34a8e0f907772a3@mail.gmail.com>
[not found] ` <524f69650811211113q4fffcc70of88cb85db531c358@mail.gmail.com>
[not found] ` <1227296476.20845.8.camel@norville.austin.ibm.com>
[not found] ` <524f69650811211218v78295682lcf6dce842327b097@mail.gmail.com>
2008-11-21 20:38 ` Fwd: fsx-linux failing with latest cifs-2.6 git tree Steve French
2008-11-21 20:41 ` Dave Kleikamp
2008-11-21 21:02 ` Steve French
2008-11-21 23:44 ` Nick Piggin
2008-11-21 20:50 ` Jeff Layton
2008-11-21 22:50 ` Jeff Layton
2008-11-21 23:02 ` Dave Kleikamp
2008-11-21 23:25 ` Jeff Layton
2008-11-22 1:04 ` Steve French
2008-11-22 1:50 ` Jeff Layton
2008-11-21 23:53 ` Nick Piggin
2008-11-22 1:51 ` Jeff Layton
2008-11-22 2:02 ` Steve French
2008-11-22 4:47 ` Dave Kleikamp
2008-11-22 15:39 ` [linux-cifs-client] " Jeff Layton
2008-11-22 20:27 ` Dave Kleikamp
2008-11-23 11:57 ` Jeff Layton
2008-11-24 2:32 ` Steve French
2008-11-24 11:19 ` [linux-cifs-client] " Jeff Layton
2008-11-26 4:04 ` Steve French
2008-11-26 11:54 ` Jeff Layton
2008-11-26 12:11 ` Jeff Layton
2008-11-26 13:09 ` [linux-cifs-client] " Nick Piggin
2008-11-26 15:08 ` Jeff Layton
2008-11-26 15:23 ` Nick Piggin
2008-11-26 16:37 ` Jeff Layton
2008-11-27 8:33 ` Nick Piggin [this message]
2008-11-28 12:18 ` Jeff Layton
2008-11-30 21:44 ` Steve French
2008-11-30 22:17 ` Jeff Layton
2008-12-01 8:44 ` Nick Piggin
2008-12-01 11:28 ` Jeff Layton
2008-12-01 11:32 ` Nick Piggin
2008-12-01 11:55 ` Jeff Layton
2008-12-01 17:43 ` Steve French
2008-11-26 19:46 ` Steve French
2008-11-24 20:00 ` Dave Kleikamp
2008-11-26 13:02 ` Nick Piggin
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=20081127083330.GB28285@wotan.suse.de \
--to=npiggin@suse.de \
--cc=jlayton@redhat.com \
--cc=linux-cifs-client@lists.samba.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=pbadari@us.ibm.com \
--cc=smfrench@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).