All of lore.kernel.org
 help / color / mirror / Atom feed
From: "inoguchi.yuki@fujitsu.com" <inoguchi.yuki@fujitsu.com>
To: "'bfields@fieldses.org'" <bfields@fieldses.org>,
	'NeilBrown' <neilb@suse.de>
Cc: 'Matt Benjamin' <mbenjami@redhat.com>,
	'Trond Myklebust' <trondmy@hammerspace.com>,
	"'linux-nfs@vger.kernel.org'" <linux-nfs@vger.kernel.org>
Subject: RE: client caching and locks
Date: Tue, 4 Jan 2022 09:24:56 +0000	[thread overview]
Message-ID: <OSZPR01MB7050F9737016E8E3F0FD5255EF4A9@OSZPR01MB7050.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <20220103162041.GC21514@fieldses.org>

Hi Neil and Bruce,

Thank you for your comments.
Now I have understood that this behavior is by design.

> > With NFSv4 there is no atomicity guarantees relating to writes and
> > changeid.
> > There is provision for atomicity around directory operations, but not
> > around data operations.

So I feel like clients cannot always trust changeid in NFSv4. 
Should it be described in the spec?

For example, the following section refers about the usage of changeid:
https://datatracker.ietf.org/doc/html/draft-dnoveck-nfsv4-rfc5661bis#section-14.3.1

It says clients use change attribute " to ensure that the data for the OPENed file is still 
correctly reflected in the client's cache." But in fact, it could be wrong.

Yuki Inoguchi

> -----Original Message-----
> From: 'bfields@fieldses.org' <bfields@fieldses.org>
> Sent: Tuesday, January 4, 2022 1:21 AM
> To: NeilBrown <neilb@suse.de>
> Cc: Inoguchi, Yuki/井ノ口 雄生 <inoguchi.yuki@fujitsu.com>; 'Matt Benjamin'
> <mbenjami@redhat.com>; 'Trond Myklebust' <trondmy@hammerspace.com>;
> 'linux-nfs@vger.kernel.org' <linux-nfs@vger.kernel.org>
> Subject: Re: client caching and locks
> 
> On Tue, Dec 28, 2021 at 04:11:51PM +1100, NeilBrown wrote:
> > This is due to an (arguable) weakness in the NFSv4 protocol.
> > In NFSv3 the reply to the WRITE request had "wcc" data which would
> > report change information before and after the write and, if present, it
> > was required to be atomic.  So, providing timestamps had a high
> > resolution, the client0 would see change information from *before* the
> > write from client1 completed.  So it would know it needed to refresh
> > after that write became visible.
> >
> > With NFSv4 there is no atomicity guarantees relating to writes and
> > changeid.
> > There is provision for atomicity around directory operations, but not
> > around data operations.
> >
> > This means that if different clients access a file concurrently, then
> > their cache can become incorrect.  The only way to ensure uncorrupted
> > data is to use locking for ALL reads and writes.  The above 'od -i' does
> > not perform a locked read, so can give incorrect data.
> > If you got a whole-file lock before reading, then you should get correct
> > data.
> 
> You'd also have to get a whole-file write lock on every write, wouldn't
> you, to prevent your own write from obscuring the change-attribute
> update caused by a concurrent writer?
> 
> > You could argue that this requirement (always lock if there is any risk)
> > is by design, and so this aspect of the protocl is not a weakness.
> 
> The spec discussion of byte-range locking and caching is here:
> https://datatracker.ietf.org/doc/html/rfc7530#section-10.3.2
> 
> The nfs man page, under ac/noac, says "Using the noac option provides
> greater  cache  coherence among  NFS  clients accessing the same files,
> but it extracts a significant performance penalty.  As such,  judicious
> use of file locking is encouraged instead.  The DATA AND METADATA
> COHERENCE section contains a detailed discussion of these trade-offs."
> 
> That section does have a "Using file locks with NFS" subsection, but
> that subsection doesn't actually discuss the interaction of file locks
> with client caching.
> 
> It's a confusing and under-documented area.
> 
> --b.

  reply	other threads:[~2022-01-04  9:33 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-08 21:19 client caching and locks J. Bruce Fields
2020-06-18  9:54 ` inoguchi.yuki
2020-06-18 14:29   ` Trond Myklebust
2020-06-18 20:09     ` bfields
2020-06-22 13:52       ` bfields
2020-10-01 21:47         ` bfields
2020-10-01 22:26           ` Matt Benjamin
2020-10-06 17:26             ` bfields
2021-12-28  2:39               ` inoguchi.yuki
2021-12-28  5:11               ` NeilBrown
2022-01-03 16:20                 ` 'bfields@fieldses.org'
2022-01-04  9:24                   ` inoguchi.yuki [this message]
2022-01-04 12:36                     ` Trond Myklebust
2022-01-04 15:32                       ` bfields
2022-01-04 15:54                         ` Trond Myklebust
2022-01-05  9:31                           ` inoguchi.yuki
2022-01-05 22:03                             ` 'bfields@fieldses.org'
2022-01-06  7:23                               ` inoguchi.yuki
2022-01-06 14:16                                 ` 'bfields@fieldses.org'
2022-01-07  8:33                                   ` inoguchi.yuki
2022-01-09 22:16                                   ` NeilBrown
2022-01-09 22:38                                     ` 'bfields@fieldses.org'
2022-01-09 21:58                               ` NeilBrown
2022-01-09 22:41                                 ` 'bfields@fieldses.org'
2022-01-17  9:09                                 ` inoguchi.yuki
2022-01-17 22:27                                 ` NeilBrown
2022-02-02  4:09                                   ` inoguchi.yuki
2022-02-02  4:25                                     ` Trond Myklebust
2022-02-02  4:44                                   ` NeilBrown
2022-02-03  7:31                                     ` inoguchi.yuki
2022-02-07  4:16                                     ` NeilBrown

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=OSZPR01MB7050F9737016E8E3F0FD5255EF4A9@OSZPR01MB7050.jpnprd01.prod.outlook.com \
    --to=inoguchi.yuki@fujitsu.com \
    --cc=bfields@fieldses.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=mbenjami@redhat.com \
    --cc=neilb@suse.de \
    --cc=trondmy@hammerspace.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.