public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@redhat.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	Trond Myklebust <trondmy@hammerspace.com>,
	Anna Schumaker <schumakeranna@gmail.com>,
	Chuck Lever <chuck.lever@oracle.com>
Subject: Re: [PATCH 2/3] nfsd: move change attribute generation to filesystem
Date: Fri, 22 Jan 2021 13:46:48 -0500	[thread overview]
Message-ID: <20210122184648.GD52753@pick.fieldses.org> (raw)
In-Reply-To: <20210122173248.GB241302@infradead.org>

On Fri, Jan 22, 2021 at 05:32:48PM +0000, Christoph Hellwig wrote:
> On Fri, Jan 22, 2021 at 09:47:53AM -0500, J. Bruce Fields wrote:
> > > > I also have a vague idea that some filesystem-specific improvements
> > > > might be possible.  (E.g., if a filesystem had some kind of boot count
> > > > in the superblock, maybe that would be a better way to prevent the
> > > > change attribute from going backwards on reboot than the thing
> > > > generic_fetch_iversion is currently doing with ctime.  But I have no
> > > > concrete plan there, maybe I'm dreaming.)
> > > 
> > > Even without the ctime i_version never goes backward, what is the
> > > problem here?
> > 
> > Suppose a modification bumps the change attribute, a client reads
> > the new value of the change attribute before it's committed to disk,
> > then the server crashes.  After the server comes back up, the client
> > requests the change attribute again and sees an older value.
> 
> So all metadata operations kicked off by nfsd are synchronous due
> to ->commit_metadata/sync_inode_metadata, so this could only happen
> for operations not kicked off by nfsd.

Plain old nfs write also bumps the change attribute.

> More importanly ctime will
> also be lost as i_version and the ctime are commited together.

That's not the reason for using ctime.

The ctime is so that change attributes due to new changes that happen
after the boot will not collide with change attributes used before.

So:

	0. file has change attribute i.
	1. write bumps change attribute to i+1.
	2. client fetches new data and change attribute i+1.
	3. server crashes and comes back up.
	4. a new write with different data bumps change attribute to i+1.
	5. client fetches change attribute again, incorrectly concludes
	   its data cache is still correct.

Including the ctime ensures the change attributes at step 2 and 4 are no
longer the same.

> > That's actually not too bad.  What I'd mainly like to avoid is
> > incrementing the change attribute further and risking reuse of an old
> > value for a different new state of the file.
> 
> Ok but that is an issue if we need to deal with changes that did not
> come in through NFSD.

Those matter too, of course.

--b.


  reply	other threads:[~2021-01-22 19:38 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-19 19:24 [PATCH 0/3] NFS change attribute patches J. Bruce Fields
2021-01-19 19:24 ` [PATCH 1/3] nfs: use change attribute for NFS re-exports J. Bruce Fields
2021-01-19 19:24 ` [PATCH 2/3] nfsd: move change attribute generation to filesystem J. Bruce Fields
2021-01-20  8:46   ` Christoph Hellwig
2021-01-21 20:27     ` J. Bruce Fields
2021-01-22  8:20       ` Christoph Hellwig
2021-01-22 14:47         ` J. Bruce Fields
2021-01-22 17:32           ` Christoph Hellwig
2021-01-22 18:46             ` J. Bruce Fields [this message]
2021-01-29 19:25         ` J. Bruce Fields
2021-01-29 19:26         ` [PATCH 1/2 v2] nfs: use change attribute for NFS re-exports J. Bruce Fields
2021-01-29 19:27           ` [PATCH 2/2 v2] nfsd: skip some unnecessary stats in the v4 case J. Bruce Fields
2021-01-30  6:02             ` Christoph Hellwig
2021-01-29 20:43           ` [PATCH 1/2 v2] nfs: use change attribute for NFS re-exports Chuck Lever
2021-01-30  6:02           ` Christoph Hellwig
2021-01-19 19:24 ` [PATCH 3/3] nfsd: skip some unnecessary stats in the v4 case J. Bruce Fields
2021-01-22 17:34 ` [PATCH 0/3] NFS change attribute patches Christoph Hellwig

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=20210122184648.GD52753@pick.fieldses.org \
    --to=bfields@redhat.com \
    --cc=chuck.lever@oracle.com \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=schumakeranna@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox