From: Andreas Dilger <adilger@dilger.ca>
To: Trond Myklebust <trondmy@hammerspace.com>
Cc: "miklos@szeredi.hu" <miklos@szeredi.hu>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"amir73il@gmail.com" <amir73il@gmail.com>,
"mszeredi@redhat.com" <mszeredi@redhat.com>,
"linux-api@vger.kernel.org" <linux-api@vger.kernel.org>,
"dhowells@redhat.com" <dhowells@redhat.com>,
"fw@deneb.enyo.de" <fw@deneb.enyo.de>,
"mtk.manpages@gmail.com" <mtk.manpages@gmail.com>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH v2 5/5] nfs: don't clear STATX_ATIME from result_mask
Date: Mon, 5 Nov 2018 15:29:02 -0700 [thread overview]
Message-ID: <6E9E333D-CD57-4EDB-A55F-CD79DF9E2811@dilger.ca> (raw)
In-Reply-To: <fbc3501c07fd48e65c0ffc8634870bf57a6f7fe1.camel@hammerspace.com>
[-- Attachment #1: Type: text/plain, Size: 3444 bytes --]
On Oct 20, 2018, at 11:46 AM, Trond Myklebust <trondmy@hammerspace.com> wrote:
>
> On Fri, 2018-10-19 at 22:48 +0200, Miklos Szeredi wrote:
>> On Fri, Oct 19, 2018 at 8:14 PM, Trond Myklebust
>> <trondmy@hammerspace.com> wrote:
>>> On Fri, 2018-10-19 at 19:46 +0200, Miklos Szeredi wrote:
>>>> How is it then that only STATX_ATIME is cleared and not the other
>>>> fields?
>>>
>>> It isn't just the atime. We can also fail to revalidate the ctime
>>> and mtime if they are not being requested by the user.
>>>
>>>> Note: junk != stale. The statx definition doesn't talk about the
>>>> fields being up-to-date, except for AT_STATX_FORCE_SYNC, so stale
>>>> attributes are okay, and do not warrant clearing the result_mask.
>>>
>>> I disagree. stale == junk here, because the default of
>>> AT_STATX_SYNC_AS_STAT is described by the manpage as "Do whatever
>>> stat(2) does." which this is not.
>>
>> Ah, you are talking about this:
>>
>> /* Is the user requesting attributes that might need revalidation? */
>> if (!(request_mask & (STATX_MODE|STATX_NLINK|STATX_ATIME|STATX_CTIME|
>> STATX_MTIME|STATX_UID|STATX_GID|
>> STATX_SIZE|STATX_BLOCKS)))
>> goto out_no_update;
>>
>> Well, if this is triggered for statx(..., STATX_ATIME,
>> AT_STATX_SYNC_AS_STAT) and MNT_NOATIME, then yes, result will be
>> junk. Which means that the code is wrong, it shouldn't do that.
>
> The problem is that vfs_getattr_nosec() populates stat->result_mask
> with a default of STATX_BASIC_STATS, which makes no sense unless you
> assume that the user will always ask for a superset of
> STATX_BASIC_STATS (or you assume that those attributes never need
> revalidation, which is obviously braindead).
I guess the assumption in the VFS code is that statx is mostly called
by local filesystems, for which STATX_BASIC_STATS is usually right,
so the basic VFS helper is OK to set those stats. It should also be
possible for the filesystem to clear flags out of result_mask for
attributes that it doesn't want to return.
For filesystems that know what they are doing, it might just be best
to always clear stat->result_mask and fill in what they want, based
on the available attributes and request_mask rather than assuming
something is set by the caller.
Cheers, Andreas
>> Otherwise (if something other than STATX_ATIME or STATX_INO or
>> STATX_TYPE is given as well) it *will* do the same thing as what
>> stat(2) does, so in that case STATX_ATIME should not be cleared (yet
>> it is cleared).
>
> As far as I'm concerned, we can definitely get rid of the
>
> /*
> * We may force a getattr if the user cares about atime.
> *
> * Note that we only have to check the vfsmount flags here:
> * - NFS always sets S_NOATIME by so checking it would give a
> * bogus result
> * - NFS never sets SB_NOATIME or SB_NODIRATIME so there is
> * no point in checking those.
> */
> if ((path->mnt->mnt_flags & MNT_NOATIME) ||
> ((path->mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode)))
> request_mask &= ~STATX_ATIME;
>
>
> however the rest needs to stay, or there is no way we can use statx()
> to allow optimised retrieval of only those attributes that your
> application cares about.
Cheers, Andreas
[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 873 bytes --]
next prev parent reply other threads:[~2018-11-05 22:29 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-19 12:20 [PATCH v2 1/5] orangefs: fix request_mask misuse Miklos Szeredi
2018-10-19 12:20 ` [PATCH v2 2/5] uapi: deprecate STATX_ALL Miklos Szeredi
2018-10-19 12:20 ` [PATCH v2 3/5] statx: add STATX_ATTRIBUTES flag Miklos Szeredi
2018-10-19 12:20 ` [PATCH v2 4/5] statx: don't clear STATX_ATIME on SB_RDONLY Miklos Szeredi
2018-10-19 12:20 ` [PATCH v2 5/5] nfs: don't clear STATX_ATIME from result_mask Miklos Szeredi
2018-10-19 15:52 ` Trond Myklebust
2018-10-19 17:46 ` Miklos Szeredi
2018-10-19 18:14 ` Trond Myklebust
2018-10-19 20:48 ` Miklos Szeredi
2018-10-20 17:46 ` Trond Myklebust
2018-11-05 22:29 ` Andreas Dilger [this message]
2018-10-19 14:27 ` [PATCH v2 1/5] orangefs: fix request_mask misuse Andreas Dilger
2018-10-19 15:35 ` [PATCH v2 2/5] uapi: deprecate STATX_ALL David Howells
2018-10-19 15:40 ` Miklos Szeredi
2018-10-19 15:47 ` David Howells
2018-10-19 17:30 ` Miklos Szeredi
2018-10-19 15:36 ` [PATCH v2 3/5] statx: add STATX_ATTRIBUTES flag David Howells
2018-10-19 15:40 ` [PATCH v2 4/5] statx: don't clear STATX_ATIME on SB_RDONLY David Howells
2018-10-19 15:44 ` [PATCH v2 5/5] nfs: don't clear STATX_ATIME from result_mask David Howells
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=6E9E333D-CD57-4EDB-A55F-CD79DF9E2811@dilger.ca \
--to=adilger@dilger.ca \
--cc=amir73il@gmail.com \
--cc=dhowells@redhat.com \
--cc=fw@deneb.enyo.de \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=mszeredi@redhat.com \
--cc=mtk.manpages@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;
as well as URLs for NNTP newsgroup(s).