linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@poochiereds.net>
To: Christoph Hellwig <hch@lst.de>
Cc: bfields@redhat.com, linux-nfs@vger.kernel.org,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] nfsd: special case truncates some more
Date: Mon, 23 Jan 2017 11:14:05 -0500	[thread overview]
Message-ID: <1485188045.2786.13.camel@poochiereds.net> (raw)
In-Reply-To: <20170123160559.GA786@lst.de>

On Mon, 2017-01-23 at 17:05 +0100, Christoph Hellwig wrote:
> On Mon, Jan 23, 2017 at 10:52:09AM -0500, Jeff Layton wrote:
> > To be clear, the client is requesting to set the mtime to current server
> > time and not to a specific mtime, right?
> 
> Yes.  And I think it's mostly the Linux client being lazy - ATTR_MTIME
> is what it gets from the VFS for a truncate operation (but not ftrunate,
> so we probably won't see it on the wire in that case, but I need to verify
> that first).  Yet another reason for ->truncate :)
> 

Heh, ok. Makes sense.

> > I don't see where vfs_truncate will handle the times though. do_truncate
> > will, but you have to pass in a non-zero time_attrs and vfs_truncate
> > always sets that to 0.
> 
> This is the magic of the Linux VFS interface.  For a ATTR_SIZE operation
> the file system is expected to update mtime and ctime if the size changes
> even if ATTR_MTIME and ATTR_CTIME are not set.  See the comments
> in xfs_vn_setattr_size, which I wrote many years ago when I tripped
> over this interesting calling convention.
> 

Ick.

> > If we did want to do this, it seems like it might be better to just add
> > a new time_attrs arg to vfs_truncate that gets passed to do_truncate.
> > Most callers would set it to zero, but nfsd could set it to:
> > 
> >     iap->ia_valid & (ATTR_MTIME|ATTR_CTIME)
> > 
> > Would that work?
> 
> I'd hate it.  I'd rather spent my time on a real truncate operation
> which makes all the above magic explicit, and as a side effect would
> fix the Linux client sending spurious mtime update requests that
> the procotol already requires to be done implicitly.

Fair enough. In that case, I wouldn't try to optimize away the second
notify_change if the client sets ATTR_MTIME/ATTR_CTIME for now

 We might have to dip down into the fs twice for a truncate, but so be
it. If it becomes a problem then we can consider that more reason to add
a real ->truncate operation.

-- 
Jeff Layton <jlayton@poochiereds.net>

  reply	other threads:[~2017-01-23 16:14 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-22 16:54 setattr ATTR_SIZE vs the rest Christoph Hellwig
2017-01-22 16:54 ` [PATCH] nfsd: special case truncates some more Christoph Hellwig
2017-01-23 12:21   ` Jeff Layton
2017-01-23 12:33     ` Christoph Hellwig
2017-01-23 15:36       ` Christoph Hellwig
2017-01-23 15:52         ` Jeff Layton
2017-01-23 16:05           ` Christoph Hellwig
2017-01-23 16:14             ` Jeff Layton [this message]
2017-01-23 16:20             ` Trond Myklebust
2017-01-23 16:26               ` hch
2017-01-23 17:25                 ` Trond Myklebust
2017-01-23 17:38                   ` hch
2017-01-23 17:42                     ` Trond Myklebust
2017-01-24 16:25                 ` J. Bruce Fields
2017-01-24 22:02           ` J. Bruce Fields
2017-01-23 16:58 ` setattr ATTR_SIZE vs the rest J. Bruce Fields
2017-01-24  7:52   ` Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2017-02-20  6:21 split setattr operations take 2 Christoph Hellwig
2017-02-20  6:21 ` [PATCH] nfsd: special case truncates some more Christoph Hellwig
2017-02-20 22:23   ` J. Bruce Fields
2017-02-21 15:07   ` Chuck Lever
2017-02-21 15:14     ` 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=1485188045.2786.13.camel@poochiereds.net \
    --to=jlayton@poochiereds.net \
    --cc=bfields@redhat.com \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --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).