linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: Jeff Layton <jlayton@redhat.com>,
	"J. Bruce Fields" <bfields@redhat.com>,
	linux-nfs@vger.kernel.org
Subject: Re: [PATCH] nfs: open-associated setattr shouldn't invalidate own cache
Date: Thu, 3 Nov 2011 17:20:36 -0400	[thread overview]
Message-ID: <20111103212036.GB27393@fieldses.org> (raw)
In-Reply-To: <1320354185.18396.124.camel@lade.trondhjem.org>

On Thu, Nov 03, 2011 at 05:03:05PM -0400, Trond Myklebust wrote:
> On Thu, 2011-11-03 at 16:44 -0400, J. Bruce Fields wrote: 
> > I'm feeling dense.
> > 
> > On Wed, Nov 02, 2011 at 11:54:53AM -0400, Jeff Layton wrote:
> > > Yes, I think it is different. When we truncate the file to 0 then we
> > > don't care if another write races in.
> > 
> > 	Client 1		Client 2
> > 	--------		--------
> > 
> > 	setattr size to 0
> > 				write to file
> > 	get change attribute
> > 
> > If we decide not to invalidate the cache here, then we miss Client 2's
> > write.  The same is true if we set the size to something other than 0.
> 
> ?????????
> How can we "decide not to invalidate the cache here"? the call to
> nfs_vmtruncate() will _always_ call truncate_pagecache().
> The only case where we don't call nfs_vmtruncate() is if the client has
> already determined that the file size was zero, and optimised away the
> setattr call altogether.

Sorry, I'm probably using the wrong language.

I'm using the word "cache" to refer not to the page cache, but more
generally to the client's idea of the file state.  Thus if the client,
after the above operation, is left believing the file has size 0, I
wouldn't say it has invalidated its cache, I'd say it's cached the fact
that the file has size zero....

Does what I said make sense, given that?

> > There's a second possible race when Client 2's write comes before the
> > setattr, and it's true that that race doesn't matter in the size-0 case
> > and does in the other.
> > 
> > But if we were doing a write instead of a setattr, we'd ignore that
> > second race.
> > 
> > And I don't understand why something like ftruncate should be treated
> > differently from write.  In either case we're modifying a file while
> > holding a write open, and I'd expect us to assume in both cases that
> > nobody else is doing the same.
> 
> When did we move to the topic of multiple clients, and why do you think
> it is relevant?

We're seeing the client decide that it can no longer trust its idea of
the file, presumably because it no longer believes it safe to assume
that nobody else has modified it.

--b.

  reply	other threads:[~2011-11-03 21:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-19  0:09 [PATCH] nfs: open-associated setattr shouldn't invalidate own cache Myklebust, Trond
2011-11-01 20:27 ` J. Bruce Fields
2011-11-01 23:07   ` Myklebust, Trond
2011-11-02  0:43     ` Jeff Layton
2011-11-02  1:23       ` J. Bruce Fields
2011-11-02  1:36         ` Myklebust, Trond
2011-11-02 11:07         ` Jeff Layton
2011-11-02 14:46           ` J. Bruce Fields
2011-11-02 15:54             ` Jeff Layton
2011-11-03 20:44               ` J. Bruce Fields
2011-11-03 21:03                 ` Trond Myklebust
2011-11-03 21:20                   ` J. Bruce Fields [this message]
2011-11-03 21:39                     ` Trond Myklebust
  -- strict thread matches above, loose matches on Subject: below --
2011-07-18 22:23 J. Bruce Fields

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=20111103212036.GB27393@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=Trond.Myklebust@netapp.com \
    --cc=bfields@redhat.com \
    --cc=jlayton@redhat.com \
    --cc=linux-nfs@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).