mbox series

[0/8] Support btime and other NFSv4 specific attributes

Message ID 20211217204854.439578-1-trondmy@kernel.org (mailing list archive)
Headers show
Series Support btime and other NFSv4 specific attributes | expand

Message

Trond Myklebust Dec. 17, 2021, 8:48 p.m. UTC
From: Trond Myklebust <trond.myklebust@hammerspace.com>

NFSv4 has support for a number of extra attributes that are of interest
to Samba when it is used to re-export a filesystem to Windows clients.
Aside from the btime, which is of interest in statx(), Windows clients
have an interest in determining the status of the 'hidden', and 'system'
flags.
Backup programs want to read the 'archive' flags and the 'time backup'
attribute.
Finally, the 'offline' flag can tell whether or not a file needs to be
staged by an HSM system before it can be read or written to.

The patch series also adds an ioctl() to allow userspace retrieval and
setting of these attributes where appropriate. It also adds an ioctl()
to allow retrieval of the raw NFSv4 ACCESS information, to allow more
fine grained determination of the user's access rights to a file or
directory. All of this information is of use for Samba.

Anne Marie Merritt (3):
  nfs: Add timecreate to nfs inode
  nfs: Add 'archive', 'hidden' and 'system' fields to nfs inode
  nfs: Add 'time backup' to nfs inode

Richard Sharpe (1):
  NFS: Support statx_get and statx_set ioctls

Trond Myklebust (4):
  NFS: Expand the type of nfs_fattr->valid
  NFS: Return the file btime in the statx results when appropriate
  NFSv4: Support the offline bit
  NFSv4: Add an ioctl to allow retrieval of the NFS raw ACCESS mask

 fs/nfs/dir.c              |  71 ++---
 fs/nfs/getroot.c          |   3 +-
 fs/nfs/inode.c            | 147 +++++++++-
 fs/nfs/internal.h         |  10 +
 fs/nfs/nfs3proc.c         |   1 +
 fs/nfs/nfs4_fs.h          |  31 +++
 fs/nfs/nfs4file.c         | 550 ++++++++++++++++++++++++++++++++++++++
 fs/nfs/nfs4proc.c         | 175 +++++++++++-
 fs/nfs/nfs4trace.h        |   8 +-
 fs/nfs/nfs4xdr.c          | 240 +++++++++++++++--
 fs/nfs/nfstrace.c         |   5 +
 fs/nfs/nfstrace.h         |   9 +-
 fs/nfs/proc.c             |   1 +
 include/linux/nfs4.h      |   1 +
 include/linux/nfs_fs.h    |  15 ++
 include/linux/nfs_fs_sb.h |   2 +-
 include/linux/nfs_xdr.h   |  80 ++++--
 include/uapi/linux/nfs.h  | 101 +++++++
 18 files changed, 1356 insertions(+), 94 deletions(-)

Comments

J. Bruce Fields Jan. 3, 2022, 8:51 p.m. UTC | #1
On Fri, Dec 17, 2021 at 03:48:46PM -0500, trondmy@kernel.org wrote:
> From: Trond Myklebust <trond.myklebust@hammerspace.com>
> 
> NFSv4 has support for a number of extra attributes that are of interest
> to Samba when it is used to re-export a filesystem to Windows clients.
> Aside from the btime, which is of interest in statx(), Windows clients
> have an interest in determining the status of the 'hidden', and 'system'
> flags.
> Backup programs want to read the 'archive' flags and the 'time backup'
> attribute.
> Finally, the 'offline' flag can tell whether or not a file needs to be
> staged by an HSM system before it can be read or written to.
> 
> The patch series also adds an ioctl() to allow userspace retrieval and
> setting of these attributes where appropriate. It also adds an ioctl()
> to allow retrieval of the raw NFSv4 ACCESS information, to allow more
> fine grained determination of the user's access rights to a file or
> directory. All of this information is of use for Samba.

Same question, what filesystem and server are you testing against?

--b.

> 
> Anne Marie Merritt (3):
>   nfs: Add timecreate to nfs inode
>   nfs: Add 'archive', 'hidden' and 'system' fields to nfs inode
>   nfs: Add 'time backup' to nfs inode
> 
> Richard Sharpe (1):
>   NFS: Support statx_get and statx_set ioctls
> 
> Trond Myklebust (4):
>   NFS: Expand the type of nfs_fattr->valid
>   NFS: Return the file btime in the statx results when appropriate
>   NFSv4: Support the offline bit
>   NFSv4: Add an ioctl to allow retrieval of the NFS raw ACCESS mask
> 
>  fs/nfs/dir.c              |  71 ++---
>  fs/nfs/getroot.c          |   3 +-
>  fs/nfs/inode.c            | 147 +++++++++-
>  fs/nfs/internal.h         |  10 +
>  fs/nfs/nfs3proc.c         |   1 +
>  fs/nfs/nfs4_fs.h          |  31 +++
>  fs/nfs/nfs4file.c         | 550 ++++++++++++++++++++++++++++++++++++++
>  fs/nfs/nfs4proc.c         | 175 +++++++++++-
>  fs/nfs/nfs4trace.h        |   8 +-
>  fs/nfs/nfs4xdr.c          | 240 +++++++++++++++--
>  fs/nfs/nfstrace.c         |   5 +
>  fs/nfs/nfstrace.h         |   9 +-
>  fs/nfs/proc.c             |   1 +
>  include/linux/nfs4.h      |   1 +
>  include/linux/nfs_fs.h    |  15 ++
>  include/linux/nfs_fs_sb.h |   2 +-
>  include/linux/nfs_xdr.h   |  80 ++++--
>  include/uapi/linux/nfs.h  | 101 +++++++
>  18 files changed, 1356 insertions(+), 94 deletions(-)
> 
> -- 
> 2.33.1
Trond Myklebust Jan. 3, 2022, 8:51 p.m. UTC | #2
On Mon, 2022-01-03 at 15:51 -0500, J. Bruce Fields wrote:
> On Fri, Dec 17, 2021 at 03:48:46PM -0500, trondmy@kernel.org wrote:
> > From: Trond Myklebust <trond.myklebust@hammerspace.com>
> > 
> > NFSv4 has support for a number of extra attributes that are of
> > interest
> > to Samba when it is used to re-export a filesystem to Windows
> > clients.
> > Aside from the btime, which is of interest in statx(), Windows
> > clients
> > have an interest in determining the status of the 'hidden', and
> > 'system'
> > flags.
> > Backup programs want to read the 'archive' flags and the 'time
> > backup'
> > attribute.
> > Finally, the 'offline' flag can tell whether or not a file needs to
> > be
> > staged by an HSM system before it can be read or written to.
> > 
> > The patch series also adds an ioctl() to allow userspace retrieval
> > and
> > setting of these attributes where appropriate. It also adds an
> > ioctl()
> > to allow retrieval of the raw NFSv4 ACCESS information, to allow
> > more
> > fine grained determination of the user's access rights to a file or
> > directory. All of this information is of use for Samba.
> 
> Same question, what filesystem and server are you testing against?
> 

Same answer.

> --b.
> 
> > 
> > Anne Marie Merritt (3):
> >   nfs: Add timecreate to nfs inode
> >   nfs: Add 'archive', 'hidden' and 'system' fields to nfs inode
> >   nfs: Add 'time backup' to nfs inode
> > 
> > Richard Sharpe (1):
> >   NFS: Support statx_get and statx_set ioctls
> > 
> > Trond Myklebust (4):
> >   NFS: Expand the type of nfs_fattr->valid
> >   NFS: Return the file btime in the statx results when appropriate
> >   NFSv4: Support the offline bit
> >   NFSv4: Add an ioctl to allow retrieval of the NFS raw ACCESS mask
> > 
> >  fs/nfs/dir.c              |  71 ++---
> >  fs/nfs/getroot.c          |   3 +-
> >  fs/nfs/inode.c            | 147 +++++++++-
> >  fs/nfs/internal.h         |  10 +
> >  fs/nfs/nfs3proc.c         |   1 +
> >  fs/nfs/nfs4_fs.h          |  31 +++
> >  fs/nfs/nfs4file.c         | 550
> > ++++++++++++++++++++++++++++++++++++++
> >  fs/nfs/nfs4proc.c         | 175 +++++++++++-
> >  fs/nfs/nfs4trace.h        |   8 +-
> >  fs/nfs/nfs4xdr.c          | 240 +++++++++++++++--
> >  fs/nfs/nfstrace.c         |   5 +
> >  fs/nfs/nfstrace.h         |   9 +-
> >  fs/nfs/proc.c             |   1 +
> >  include/linux/nfs4.h      |   1 +
> >  include/linux/nfs_fs.h    |  15 ++
> >  include/linux/nfs_fs_sb.h |   2 +-
> >  include/linux/nfs_xdr.h   |  80 ++++--
> >  include/uapi/linux/nfs.h  | 101 +++++++
> >  18 files changed, 1356 insertions(+), 94 deletions(-)
> > 
> > -- 
> > 2.33.1
Ondrej Valousek Jan. 5, 2022, 3:05 p.m. UTC | #3
Hi all,
Sorry for confusion and maybe dumb questions:
- The aim is to transfer these attributes via RFC8276 (File System Extended attributes in NFSv4)?
- AFAIK support for RFC8276 in NFS (only version 4.2) server is since kernel 5.9, right? NFS client supports these as well?
- The patches below implements the feature in both, nfs client AND server, right?

I am bit confused as "btime" does not seem to be stored as extended attribute in most local filesystems (checked ext4) but is in standard inode structure.
Thanks,
Ondrej


-----Original Message-----
From: Trond Myklebust <trondmy@hammerspace.com>
Sent: pondělí 3. ledna 2022 21:52
To: bfields@fieldses.org; trondmy@kernel.org
Cc: linux-nfs@vger.kernel.org; anna.schumaker@netapp.com
Subject: Re: [PATCH 0/8] Support btime and other NFSv4 specific attributes

On Mon, 2022-01-03 at 15:51 -0500, J. Bruce Fields wrote:
> On Fri, Dec 17, 2021 at 03:48:46PM -0500, trondmy@kernel.org wrote:
> > From: Trond Myklebust <trond.myklebust@hammerspace.com>
> >
> > NFSv4 has support for a number of extra attributes that are of
> > interest to Samba when it is used to re-export a filesystem to
> > Windows clients.
> > Aside from the btime, which is of interest in statx(), Windows
> > clients have an interest in determining the status of the 'hidden',
> > and 'system'
> > flags.
> > Backup programs want to read the 'archive' flags and the 'time
> > backup'
> > attribute.
> > Finally, the 'offline' flag can tell whether or not a file needs to
> > be staged by an HSM system before it can be read or written to.
> >
> > The patch series also adds an ioctl() to allow userspace retrieval
> > and setting of these attributes where appropriate. It also adds an
> > ioctl()
> > to allow retrieval of the raw NFSv4 ACCESS information, to allow
> > more fine grained determination of the user's access rights to a
> > file or directory. All of this information is of use for Samba.
>
> Same question, what filesystem and server are you testing against?
>

Same answer.

> --b.
>
> >
> > Anne Marie Merritt (3):
> >   nfs: Add timecreate to nfs inode
> >   nfs: Add 'archive', 'hidden' and 'system' fields to nfs inode
> >   nfs: Add 'time backup' to nfs inode
> >
> > Richard Sharpe (1):
> >   NFS: Support statx_get and statx_set ioctls
> >
> > Trond Myklebust (4):
> >   NFS: Expand the type of nfs_fattr->valid
> >   NFS: Return the file btime in the statx results when appropriate
> >   NFSv4: Support the offline bit
> >   NFSv4: Add an ioctl to allow retrieval of the NFS raw ACCESS mask
> >
> >  fs/nfs/dir.c              |  71 ++---
> >  fs/nfs/getroot.c          |   3 +-
> >  fs/nfs/inode.c            | 147 +++++++++-
> >  fs/nfs/internal.h         |  10 +
> >  fs/nfs/nfs3proc.c         |   1 +
> >  fs/nfs/nfs4_fs.h          |  31 +++
> >  fs/nfs/nfs4file.c         | 550
> > ++++++++++++++++++++++++++++++++++++++
> >  fs/nfs/nfs4proc.c         | 175 +++++++++++-
> >  fs/nfs/nfs4trace.h        |   8 +-
> >  fs/nfs/nfs4xdr.c          | 240 +++++++++++++++--
> >  fs/nfs/nfstrace.c         |   5 +
> >  fs/nfs/nfstrace.h         |   9 +-
> >  fs/nfs/proc.c             |   1 +
> >  include/linux/nfs4.h      |   1 +
> >  include/linux/nfs_fs.h    |  15 ++
> >  include/linux/nfs_fs_sb.h |   2 +-
> >  include/linux/nfs_xdr.h   |  80 ++++--
> >  include/uapi/linux/nfs.h  | 101 +++++++
> >  18 files changed, 1356 insertions(+), 94 deletions(-)
> >
> > --
> > 2.33.1

--
Trond Myklebust
Linux NFS client maintainer, Hammerspace trond.myklebust@hammerspace.com


Legal Disclaimer: This e-mail communication (and any attachment/s) is confidential and contains proprietary information, some or all of which may be legally privileged. It is intended solely for the use of the individual or entity to which it is addressed. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful.
Trond Myklebust Jan. 5, 2022, 3:10 p.m. UTC | #4
On Wed, 2022-01-05 at 15:05 +0000, Ondrej Valousek wrote:
> Hi all,
> Sorry for confusion and maybe dumb questions:
> - The aim is to transfer these attributes via RFC8276 (File System
> Extended attributes in NFSv4)?

No.

> - AFAIK support for RFC8276 in NFS (only version 4.2) server is since
> kernel 5.9, right? NFS client supports these as well?
> - The patches below implements the feature in both, nfs client AND
> server, right?
> 
> I am bit confused as "btime" does not seem to be stored as extended
> attribute in most local filesystems (checked ext4) but is in standard
> inode structure.

All these attributes are defined as regular attributes in rfc7530. All
this code does is add the standard NFSv4 encoders/decoders for these
attributes and adds the ioctl() to set/retrieve them all.

There is no need to hack the NFS protocol to retrieve or set them using
the xattr stuff.

> Thanks,
> Ondrej
> 
> 
> -----Original Message-----
> From: Trond Myklebust <trondmy@hammerspace.com>
> Sent: pondělí 3. ledna 2022 21:52
> To: bfields@fieldses.org; trondmy@kernel.org
> Cc: linux-nfs@vger.kernel.org; anna.schumaker@netapp.com
> Subject: Re: [PATCH 0/8] Support btime and other NFSv4 specific
> attributes
> 
> On Mon, 2022-01-03 at 15:51 -0500, J. Bruce Fields wrote:
> > On Fri, Dec 17, 2021 at 03:48:46PM -0500, trondmy@kernel.org wrote:
> > > From: Trond Myklebust <trond.myklebust@hammerspace.com>
> > > 
> > > NFSv4 has support for a number of extra attributes that are of
> > > interest to Samba when it is used to re-export a filesystem to
> > > Windows clients.
> > > Aside from the btime, which is of interest in statx(), Windows
> > > clients have an interest in determining the status of the
> > > 'hidden',
> > > and 'system'
> > > flags.
> > > Backup programs want to read the 'archive' flags and the 'time
> > > backup'
> > > attribute.
> > > Finally, the 'offline' flag can tell whether or not a file needs
> > > to
> > > be staged by an HSM system before it can be read or written to.
> > > 
> > > The patch series also adds an ioctl() to allow userspace
> > > retrieval
> > > and setting of these attributes where appropriate. It also adds
> > > an
> > > ioctl()
> > > to allow retrieval of the raw NFSv4 ACCESS information, to allow
> > > more fine grained determination of the user's access rights to a
> > > file or directory. All of this information is of use for Samba.
> > 
> > Same question, what filesystem and server are you testing against?
> > 
> 
> Same answer.
> 
> > --b.
> > 
> > > 
> > > Anne Marie Merritt (3):
> > >   nfs: Add timecreate to nfs inode
> > >   nfs: Add 'archive', 'hidden' and 'system' fields to nfs inode
> > >   nfs: Add 'time backup' to nfs inode
> > > 
> > > Richard Sharpe (1):
> > >   NFS: Support statx_get and statx_set ioctls
> > > 
> > > Trond Myklebust (4):
> > >   NFS: Expand the type of nfs_fattr->valid
> > >   NFS: Return the file btime in the statx results when
> > > appropriate
> > >   NFSv4: Support the offline bit
> > >   NFSv4: Add an ioctl to allow retrieval of the NFS raw ACCESS
> > > mask
> > > 
> > >  fs/nfs/dir.c              |  71 ++---
> > >  fs/nfs/getroot.c          |   3 +-
> > >  fs/nfs/inode.c            | 147 +++++++++-
> > >  fs/nfs/internal.h         |  10 +
> > >  fs/nfs/nfs3proc.c         |   1 +
> > >  fs/nfs/nfs4_fs.h          |  31 +++
> > >  fs/nfs/nfs4file.c         | 550
> > > ++++++++++++++++++++++++++++++++++++++
> > >  fs/nfs/nfs4proc.c         | 175 +++++++++++-
> > >  fs/nfs/nfs4trace.h        |   8 +-
> > >  fs/nfs/nfs4xdr.c          | 240 +++++++++++++++--
> > >  fs/nfs/nfstrace.c         |   5 +
> > >  fs/nfs/nfstrace.h         |   9 +-
> > >  fs/nfs/proc.c             |   1 +
> > >  include/linux/nfs4.h      |   1 +
> > >  include/linux/nfs_fs.h    |  15 ++
> > >  include/linux/nfs_fs_sb.h |   2 +-
> > >  include/linux/nfs_xdr.h   |  80 ++++--
> > >  include/uapi/linux/nfs.h  | 101 +++++++
> > >  18 files changed, 1356 insertions(+), 94 deletions(-)
> > > 
> > > --
> > > 2.33.1
> 
> --
> Trond Myklebust
> Linux NFS client maintainer, Hammerspace
> trond.myklebust@hammerspace.com
> 
> 
> Legal Disclaimer: This e-mail communication (and any attachment/s) is
> confidential and contains proprietary information, some or all of
> which may be legally privileged. It is intended solely for the use of
> the individual or entity to which it is addressed. Access to this
> email by anyone else is unauthorized. If you are not the intended
> recipient, any disclosure, copying, distribution or any action taken
> or omitted to be taken in reliance on it, is prohibited and may be
> unlawful.
J. Bruce Fields Jan. 5, 2022, 3:10 p.m. UTC | #5
On Wed, Jan 05, 2022 at 03:05:17PM +0000, Ondrej Valousek wrote:
> Sorry for confusion and maybe dumb questions:
> - The aim is to transfer these attributes via RFC8276 (File System Extended attributes in NFSv4)?

No, NFSv4 defines attributes for all of these.

RFC8276 attributes are purely for user-defined attribues, not for
anything that the server or filesystem gives specific meaning.

> - AFAIK support for RFC8276 in NFS (only version 4.2) server is since kernel 5.9, right? NFS client supports these as well?
> - The patches below implements the feature in both, nfs client AND server, right?

Client only.

These would probably be quite easy to support on the server side when
the filesystem supports them, but nobody's volunteered to implement
that yet; patches welcome.

--b.
Ondrej Valousek Jan. 5, 2022, 3:40 p.m. UTC | #6
>> - AFAIK support for RFC8276 in NFS (only version 4.2) server is since kernel 5.9, right? NFS client supports these as well?
>> - The patches below implements the feature in both, nfs client AND server, right?

> Client only.

Right, but then it will be only useful if we use non-linux based NFS server right?

I mean simply:
1. $ stat /tmp/foo.txt   --> shows birth date
2. # exportfs \*/tmp
3. # mount 127.0.0.1:/tmp /mnt
4. $ stat /mnt/foo.txt   --> no birth date shown
Legal Disclaimer: This e-mail communication (and any attachment/s) is confidential and contains proprietary information, some or all of which may be legally privileged. It is intended solely for the use of the individual or entity to which it is addressed. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful.
J. Bruce Fields Jan. 5, 2022, 3:54 p.m. UTC | #7
On Wed, Jan 05, 2022 at 03:40:19PM +0000, Ondrej Valousek wrote:
> 
> >> - AFAIK support for RFC8276 in NFS (only version 4.2) server is since kernel 5.9, right? NFS client supports these as well?
> >> - The patches below implements the feature in both, nfs client AND server, right?
> 
> > Client only.
> 
> Right, but then it will be only useful if we use non-linux based NFS server right?
> 
> I mean simply:
> 1. $ stat /tmp/foo.txt   --> shows birth date
> 2. # exportfs \*/tmp
> 3. # mount 127.0.0.1:/tmp /mnt
> 4. $ stat /mnt/foo.txt   --> no birth date shown

Right.

Fixing that's likely just a few lines of code added to
fs/nfsd/nfs4xdr.c:nfsd4_encode_fattr().  Patches welcome.

--b.
Ondrej Valousek Jan. 6, 2022, 9:31 a.m. UTC | #8
Looks like this should do I guess...

diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 5a93a5db4fb0..be47e1dd6da5 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -3265,6 +3265,14 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
                p = xdr_encode_hyper(p, (s64)stat.mtime.tv_sec);
                *p++ = cpu_to_be32(stat.mtime.tv_nsec);
        }
+       /* support for btime here */
+        if (bmval1 & FATTR4_WORD1_TIME_CREATE) {
+                p = xdr_reserve_space(xdr, 12);
+                if (!p)
+                        goto out_resource;
+                p = xdr_encode_hyper(p, (s64)stat.btime.tv_sec);
+                *p++ = cpu_to_be32(stat.btime.tv_nsec);
+        }
        if (bmval1 & FATTR4_WORD1_MOUNTED_ON_FILEID) {
                struct kstat parent_stat;
                u64 ino = stat.ino;



-----Original Message-----
From: bfields@fieldses.org <bfields@fieldses.org>
Sent: středa 5. ledna 2022 16:55
To: Ondrej Valousek <ondrej.valousek.xm@renesas.com>
Cc: Trond Myklebust <trondmy@hammerspace.com>; trondmy@kernel.org; linux-nfs@vger.kernel.org; anna.schumaker@netapp.com
Subject: Re: [PATCH 0/8] Support btime and other NFSv4 specific attributes

On Wed, Jan 05, 2022 at 03:40:19PM +0000, Ondrej Valousek wrote:
>
> >> - AFAIK support for RFC8276 in NFS (only version 4.2) server is since kernel 5.9, right? NFS client supports these as well?
> >> - The patches below implements the feature in both, nfs client AND server, right?
>
> > Client only.
>
> Right, but then it will be only useful if we use non-linux based NFS server right?
>
> I mean simply:
> 1. $ stat /tmp/foo.txt   --> shows birth date
> 2. # exportfs \*/tmp
> 3. # mount 127.0.0.1:/tmp /mnt
> 4. $ stat /mnt/foo.txt   --> no birth date shown

Right.

Fixing that's likely just a few lines of code added to fs/nfsd/nfs4xdr.c:nfsd4_encode_fattr().  Patches welcome.

--b.
Legal Disclaimer: This e-mail communication (and any attachment/s) is confidential and contains proprietary information, some or all of which may be legally privileged. It is intended solely for the use of the individual or entity to which it is addressed. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful.
Trond Myklebust Jan. 6, 2022, 2:15 p.m. UTC | #9
On Thu, 2022-01-06 at 09:31 +0000, Ondrej Valousek wrote:
> Looks like this should do I guess...
> 
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index 5a93a5db4fb0..be47e1dd6da5 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -3265,6 +3265,14 @@ nfsd4_encode_fattr(struct xdr_stream *xdr,
> struct svc_fh *fhp,
>                 p = xdr_encode_hyper(p, (s64)stat.mtime.tv_sec);
>                 *p++ = cpu_to_be32(stat.mtime.tv_nsec);
>         }
> +       /* support for btime here */
> +        if (bmval1 & FATTR4_WORD1_TIME_CREATE) {
> +                p = xdr_reserve_space(xdr, 12);
> +                if (!p)
> +                        goto out_resource;
> +                p = xdr_encode_hyper(p, (s64)stat.btime.tv_sec);
> +                *p++ = cpu_to_be32(stat.btime.tv_nsec);
> +        }
>         if (bmval1 & FATTR4_WORD1_MOUNTED_ON_FILEID) {
>                 struct kstat parent_stat;
>                 u64 ino = stat.ino;
> 

You also need to update the value of NFSD4_SUPPORTED_ATTRS_WORD1 to
reflect the new support for FATTR4_WORD1_TIME_CREATE.
Ondrej Valousek Jan. 6, 2022, 2:19 p.m. UTC | #10
> You also need to update the value of NFSD4_SUPPORTED_ATTRS_WORD1 to reflect the new support for FATTR4_WORD1_TIME_CREATE.

Yes, I realized that one shortly after I sent the mail.
Just going to try this patch:

[ondrejv@skynet19 /opt/kernel/linux-git/fs/nfsd]$ git diff
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 5a93a5db4fb0..be47e1dd6da5 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -3265,6 +3265,14 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
                p = xdr_encode_hyper(p, (s64)stat.mtime.tv_sec);
                *p++ = cpu_to_be32(stat.mtime.tv_nsec);
        }
+       /* support for btime here */
+        if (bmval1 & FATTR4_WORD1_TIME_CREATE) {
+                p = xdr_reserve_space(xdr, 12);
+                if (!p)
+                        goto out_resource;
+                p = xdr_encode_hyper(p, (s64)stat.btime.tv_sec);
+                *p++ = cpu_to_be32(stat.btime.tv_nsec);
+        }
        if (bmval1 & FATTR4_WORD1_MOUNTED_ON_FILEID) {
                struct kstat parent_stat;
                u64 ino = stat.ino;
diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
index 498e5a489826..5ef056ce7591 100644
--- a/fs/nfsd/nfsd.h
+++ b/fs/nfsd/nfsd.h
@@ -364,7 +364,7 @@ void                nfsd_lockd_shutdown(void);
  | FATTR4_WORD1_OWNER          | FATTR4_WORD1_OWNER_GROUP  | FATTR4_WORD1_RAWDEV           \
  | FATTR4_WORD1_SPACE_AVAIL     | FATTR4_WORD1_SPACE_FREE   | FATTR4_WORD1_SPACE_TOTAL      \
  | FATTR4_WORD1_SPACE_USED      | FATTR4_WORD1_TIME_ACCESS  | FATTR4_WORD1_TIME_ACCESS_SET  \
- | FATTR4_WORD1_TIME_DELTA   | FATTR4_WORD1_TIME_METADATA    \
+ | FATTR4_WORD1_TIME_DELTA   | FATTR4_WORD1_TIME_METADATA   | FATTR4_WORD1_TIME_CREATE      \
  | FATTR4_WORD1_TIME_MODIFY     | FATTR4_WORD1_TIME_MODIFY_SET | FATTR4_WORD1_MOUNTED_ON_FILEID)

 #define NFSD4_SUPPORTED_ATTRS_WORD2 0


... will see

Legal Disclaimer: This e-mail communication (and any attachment/s) is confidential and contains proprietary information, some or all of which may be legally privileged. It is intended solely for the use of the individual or entity to which it is addressed. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful.
J. Bruce Fields Jan. 6, 2022, 2:28 p.m. UTC | #11
On Thu, Jan 06, 2022 at 02:19:22PM +0000, Ondrej Valousek wrote:
> > You also need to update the value of NFSD4_SUPPORTED_ATTRS_WORD1 to reflect the new support for FATTR4_WORD1_TIME_CREATE.
> 
> Yes, I realized that one shortly after I sent the mail.
> Just going to try this patch:

Thanks!

Don't we want to vary support depending on the filesystem, though?  Is
there a way to query that?

--b.

> 
> [ondrejv@skynet19 /opt/kernel/linux-git/fs/nfsd]$ git diff
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index 5a93a5db4fb0..be47e1dd6da5 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -3265,6 +3265,14 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
>                 p = xdr_encode_hyper(p, (s64)stat.mtime.tv_sec);
>                 *p++ = cpu_to_be32(stat.mtime.tv_nsec);
>         }
> +       /* support for btime here */
> +        if (bmval1 & FATTR4_WORD1_TIME_CREATE) {
> +                p = xdr_reserve_space(xdr, 12);
> +                if (!p)
> +                        goto out_resource;
> +                p = xdr_encode_hyper(p, (s64)stat.btime.tv_sec);
> +                *p++ = cpu_to_be32(stat.btime.tv_nsec);
> +        }
>         if (bmval1 & FATTR4_WORD1_MOUNTED_ON_FILEID) {
>                 struct kstat parent_stat;
>                 u64 ino = stat.ino;
> diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
> index 498e5a489826..5ef056ce7591 100644
> --- a/fs/nfsd/nfsd.h
> +++ b/fs/nfsd/nfsd.h
> @@ -364,7 +364,7 @@ void                nfsd_lockd_shutdown(void);
>   | FATTR4_WORD1_OWNER          | FATTR4_WORD1_OWNER_GROUP  | FATTR4_WORD1_RAWDEV           \
>   | FATTR4_WORD1_SPACE_AVAIL     | FATTR4_WORD1_SPACE_FREE   | FATTR4_WORD1_SPACE_TOTAL      \
>   | FATTR4_WORD1_SPACE_USED      | FATTR4_WORD1_TIME_ACCESS  | FATTR4_WORD1_TIME_ACCESS_SET  \
> - | FATTR4_WORD1_TIME_DELTA   | FATTR4_WORD1_TIME_METADATA    \
> + | FATTR4_WORD1_TIME_DELTA   | FATTR4_WORD1_TIME_METADATA   | FATTR4_WORD1_TIME_CREATE      \
>   | FATTR4_WORD1_TIME_MODIFY     | FATTR4_WORD1_TIME_MODIFY_SET | FATTR4_WORD1_MOUNTED_ON_FILEID)
> 
>  #define NFSD4_SUPPORTED_ATTRS_WORD2 0
> 
> 
> ... will see
> 
> Legal Disclaimer: This e-mail communication (and any attachment/s) is confidential and contains proprietary information, some or all of which may be legally privileged. It is intended solely for the use of the individual or entity to which it is addressed. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful.
J. Bruce Fields Jan. 6, 2022, 2:36 p.m. UTC | #12
On Thu, Jan 06, 2022 at 09:28:12AM -0500, bfields@fieldses.org wrote:
> On Thu, Jan 06, 2022 at 02:19:22PM +0000, Ondrej Valousek wrote:
> > > You also need to update the value of NFSD4_SUPPORTED_ATTRS_WORD1 to reflect the new support for FATTR4_WORD1_TIME_CREATE.
> > 
> > Yes, I realized that one shortly after I sent the mail.
> > Just going to try this patch:
> 
> Thanks!
> 
> Don't we want to vary support depending on the filesystem, though?  Is
> there a way to query that?

Poking around a bit...  looks like we need to check stat->result_mask &
STATX_BTIME.  And use that to adjust the value of bmval0 at the top of
encode_fattr, and make the below encoding conditional on it.

?

--b.

> 
> --b.
> 
> > 
> > [ondrejv@skynet19 /opt/kernel/linux-git/fs/nfsd]$ git diff
> > diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> > index 5a93a5db4fb0..be47e1dd6da5 100644
> > --- a/fs/nfsd/nfs4xdr.c
> > +++ b/fs/nfsd/nfs4xdr.c
> > @@ -3265,6 +3265,14 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
> >                 p = xdr_encode_hyper(p, (s64)stat.mtime.tv_sec);
> >                 *p++ = cpu_to_be32(stat.mtime.tv_nsec);
> >         }
> > +       /* support for btime here */
> > +        if (bmval1 & FATTR4_WORD1_TIME_CREATE) {
> > +                p = xdr_reserve_space(xdr, 12);
> > +                if (!p)
> > +                        goto out_resource;
> > +                p = xdr_encode_hyper(p, (s64)stat.btime.tv_sec);
> > +                *p++ = cpu_to_be32(stat.btime.tv_nsec);
> > +        }
> >         if (bmval1 & FATTR4_WORD1_MOUNTED_ON_FILEID) {
> >                 struct kstat parent_stat;
> >                 u64 ino = stat.ino;
> > diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
> > index 498e5a489826..5ef056ce7591 100644
> > --- a/fs/nfsd/nfsd.h
> > +++ b/fs/nfsd/nfsd.h
> > @@ -364,7 +364,7 @@ void                nfsd_lockd_shutdown(void);
> >   | FATTR4_WORD1_OWNER          | FATTR4_WORD1_OWNER_GROUP  | FATTR4_WORD1_RAWDEV           \
> >   | FATTR4_WORD1_SPACE_AVAIL     | FATTR4_WORD1_SPACE_FREE   | FATTR4_WORD1_SPACE_TOTAL      \
> >   | FATTR4_WORD1_SPACE_USED      | FATTR4_WORD1_TIME_ACCESS  | FATTR4_WORD1_TIME_ACCESS_SET  \
> > - | FATTR4_WORD1_TIME_DELTA   | FATTR4_WORD1_TIME_METADATA    \
> > + | FATTR4_WORD1_TIME_DELTA   | FATTR4_WORD1_TIME_METADATA   | FATTR4_WORD1_TIME_CREATE      \
> >   | FATTR4_WORD1_TIME_MODIFY     | FATTR4_WORD1_TIME_MODIFY_SET | FATTR4_WORD1_MOUNTED_ON_FILEID)
> > 
> >  #define NFSD4_SUPPORTED_ATTRS_WORD2 0
> > 
> > 
> > ... will see
> > 
> > Legal Disclaimer: This e-mail communication (and any attachment/s) is confidential and contains proprietary information, some or all of which may be legally privileged. It is intended solely for the use of the individual or entity to which it is addressed. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful.
Ondrej Valousek Jan. 6, 2022, 2:52 p.m. UTC | #13
You rather mean bmval1 not bmval0, right?

-----Original Message-----
From: bfields@fieldses.org <bfields@fieldses.org>
Sent: čtvrtek 6. ledna 2022 15:36
To: Ondrej Valousek <ondrej.valousek.xm@renesas.com>
Cc: Trond Myklebust <trondmy@hammerspace.com>; linux-nfs@vger.kernel.org; anna.schumaker@netapp.com; trondmy@kernel.org
Subject: Re: [PATCH 0/8] Support btime and other NFSv4 specific attributes

On Thu, Jan 06, 2022 at 09:28:12AM -0500, bfields@fieldses.org wrote:
> On Thu, Jan 06, 2022 at 02:19:22PM +0000, Ondrej Valousek wrote:
> > > You also need to update the value of NFSD4_SUPPORTED_ATTRS_WORD1 to reflect the new support for FATTR4_WORD1_TIME_CREATE.
> >
> > Yes, I realized that one shortly after I sent the mail.
> > Just going to try this patch:
>
> Thanks!
>
> Don't we want to vary support depending on the filesystem, though?  Is
> there a way to query that?

Poking around a bit...  looks like we need to check stat->result_mask & STATX_BTIME.  And use that to adjust the value of bmval0 at the top of encode_fattr, and make the below encoding conditional on it.

?

--b.

>
> --b.
>
> >
> > [ondrejv@skynet19 /opt/kernel/linux-git/fs/nfsd]$ git diff diff
> > --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index
> > 5a93a5db4fb0..be47e1dd6da5 100644
> > --- a/fs/nfsd/nfs4xdr.c
> > +++ b/fs/nfsd/nfs4xdr.c
> > @@ -3265,6 +3265,14 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
> >                 p = xdr_encode_hyper(p, (s64)stat.mtime.tv_sec);
> >                 *p++ = cpu_to_be32(stat.mtime.tv_nsec);
> >         }
> > +       /* support for btime here */
> > +        if (bmval1 & FATTR4_WORD1_TIME_CREATE) {
> > +                p = xdr_reserve_space(xdr, 12);
> > +                if (!p)
> > +                        goto out_resource;
> > +                p = xdr_encode_hyper(p, (s64)stat.btime.tv_sec);
> > +                *p++ = cpu_to_be32(stat.btime.tv_nsec);
> > +        }
> >         if (bmval1 & FATTR4_WORD1_MOUNTED_ON_FILEID) {
> >                 struct kstat parent_stat;
> >                 u64 ino = stat.ino;
> > diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h index
> > 498e5a489826..5ef056ce7591 100644
> > --- a/fs/nfsd/nfsd.h
> > +++ b/fs/nfsd/nfsd.h
> > @@ -364,7 +364,7 @@ void                nfsd_lockd_shutdown(void);
> >   | FATTR4_WORD1_OWNER          | FATTR4_WORD1_OWNER_GROUP  | FATTR4_WORD1_RAWDEV           \
> >   | FATTR4_WORD1_SPACE_AVAIL     | FATTR4_WORD1_SPACE_FREE   | FATTR4_WORD1_SPACE_TOTAL      \
> >   | FATTR4_WORD1_SPACE_USED      | FATTR4_WORD1_TIME_ACCESS  | FATTR4_WORD1_TIME_ACCESS_SET  \
> > - | FATTR4_WORD1_TIME_DELTA   | FATTR4_WORD1_TIME_METADATA    \
> > + | FATTR4_WORD1_TIME_DELTA   | FATTR4_WORD1_TIME_METADATA   | FATTR4_WORD1_TIME_CREATE      \
> >   | FATTR4_WORD1_TIME_MODIFY     | FATTR4_WORD1_TIME_MODIFY_SET | FATTR4_WORD1_MOUNTED_ON_FILEID)
> >
> >  #define NFSD4_SUPPORTED_ATTRS_WORD2 0
> >
> >
> > ... will see
> >
> > Legal Disclaimer: This e-mail communication (and any attachment/s) is confidential and contains proprietary information, some or all of which may be legally privileged. It is intended solely for the use of the individual or entity to which it is addressed. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful.
Legal Disclaimer: This e-mail communication (and any attachment/s) is confidential and contains proprietary information, some or all of which may be legally privileged. It is intended solely for the use of the individual or entity to which it is addressed. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful.
J. Bruce Fields Jan. 6, 2022, 2:55 p.m. UTC | #14
On Thu, Jan 06, 2022 at 02:52:36PM +0000, Ondrej Valousek wrote:
> You rather mean bmval1 not bmval0, right?

Oops, right.--b.

> 
> -----Original Message-----
> From: bfields@fieldses.org <bfields@fieldses.org>
> Sent: čtvrtek 6. ledna 2022 15:36
> To: Ondrej Valousek <ondrej.valousek.xm@renesas.com>
> Cc: Trond Myklebust <trondmy@hammerspace.com>; linux-nfs@vger.kernel.org; anna.schumaker@netapp.com; trondmy@kernel.org
> Subject: Re: [PATCH 0/8] Support btime and other NFSv4 specific attributes
> 
> On Thu, Jan 06, 2022 at 09:28:12AM -0500, bfields@fieldses.org wrote:
> > On Thu, Jan 06, 2022 at 02:19:22PM +0000, Ondrej Valousek wrote:
> > > > You also need to update the value of NFSD4_SUPPORTED_ATTRS_WORD1 to reflect the new support for FATTR4_WORD1_TIME_CREATE.
> > >
> > > Yes, I realized that one shortly after I sent the mail.
> > > Just going to try this patch:
> >
> > Thanks!
> >
> > Don't we want to vary support depending on the filesystem, though?  Is
> > there a way to query that?
> 
> Poking around a bit...  looks like we need to check stat->result_mask & STATX_BTIME.  And use that to adjust the value of bmval0 at the top of encode_fattr, and make the below encoding conditional on it.
> 
> ?
> 
> --b.
> 
> >
> > --b.
> >
> > >
> > > [ondrejv@skynet19 /opt/kernel/linux-git/fs/nfsd]$ git diff diff
> > > --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index
> > > 5a93a5db4fb0..be47e1dd6da5 100644
> > > --- a/fs/nfsd/nfs4xdr.c
> > > +++ b/fs/nfsd/nfs4xdr.c
> > > @@ -3265,6 +3265,14 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
> > >                 p = xdr_encode_hyper(p, (s64)stat.mtime.tv_sec);
> > >                 *p++ = cpu_to_be32(stat.mtime.tv_nsec);
> > >         }
> > > +       /* support for btime here */
> > > +        if (bmval1 & FATTR4_WORD1_TIME_CREATE) {
> > > +                p = xdr_reserve_space(xdr, 12);
> > > +                if (!p)
> > > +                        goto out_resource;
> > > +                p = xdr_encode_hyper(p, (s64)stat.btime.tv_sec);
> > > +                *p++ = cpu_to_be32(stat.btime.tv_nsec);
> > > +        }
> > >         if (bmval1 & FATTR4_WORD1_MOUNTED_ON_FILEID) {
> > >                 struct kstat parent_stat;
> > >                 u64 ino = stat.ino;
> > > diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h index
> > > 498e5a489826..5ef056ce7591 100644
> > > --- a/fs/nfsd/nfsd.h
> > > +++ b/fs/nfsd/nfsd.h
> > > @@ -364,7 +364,7 @@ void                nfsd_lockd_shutdown(void);
> > >   | FATTR4_WORD1_OWNER          | FATTR4_WORD1_OWNER_GROUP  | FATTR4_WORD1_RAWDEV           \
> > >   | FATTR4_WORD1_SPACE_AVAIL     | FATTR4_WORD1_SPACE_FREE   | FATTR4_WORD1_SPACE_TOTAL      \
> > >   | FATTR4_WORD1_SPACE_USED      | FATTR4_WORD1_TIME_ACCESS  | FATTR4_WORD1_TIME_ACCESS_SET  \
> > > - | FATTR4_WORD1_TIME_DELTA   | FATTR4_WORD1_TIME_METADATA    \
> > > + | FATTR4_WORD1_TIME_DELTA   | FATTR4_WORD1_TIME_METADATA   | FATTR4_WORD1_TIME_CREATE      \
> > >   | FATTR4_WORD1_TIME_MODIFY     | FATTR4_WORD1_TIME_MODIFY_SET | FATTR4_WORD1_MOUNTED_ON_FILEID)
> > >
> > >  #define NFSD4_SUPPORTED_ATTRS_WORD2 0
> > >
> > >
> > > ... will see
> > >
> > > Legal Disclaimer: This e-mail communication (and any attachment/s) is confidential and contains proprietary information, some or all of which may be legally privileged. It is intended solely for the use of the individual or entity to which it is addressed. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful.
> Legal Disclaimer: This e-mail communication (and any attachment/s) is confidential and contains proprietary information, some or all of which may be legally privileged. It is intended solely for the use of the individual or entity to which it is addressed. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful.
Ondrej Valousek Jan. 6, 2022, 4:13 p.m. UTC | #15
So I think this is what we eventually need (thanks for the pointers you gave me!):

diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 5a93a5db4fb0..e88ae4ce5263 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -2865,6 +2865,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
        err = vfs_getattr(&path, &stat, STATX_BASIC_STATS, AT_STATX_SYNC_AS_STAT);
        if (err)
                goto out_nfserr;
+       if (! stat.result_mask & STATX_BTIME)
+               /* underlying FS does not offer btime so we can't share it */
+               bmval1 &= ~FATTR4_WORD1_TIME_CREATE;
        if ((bmval0 & (FATTR4_WORD0_FILES_AVAIL | FATTR4_WORD0_FILES_FREE |
                        FATTR4_WORD0_FILES_TOTAL | FATTR4_WORD0_MAXNAME)) ||
            (bmval1 & (FATTR4_WORD1_SPACE_AVAIL | FATTR4_WORD1_SPACE_FREE |
@@ -3265,6 +3268,14 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
                p = xdr_encode_hyper(p, (s64)stat.mtime.tv_sec);
                *p++ = cpu_to_be32(stat.mtime.tv_nsec);
        }
+       /* support for btime here */
+        if (bmval1 & FATTR4_WORD1_TIME_CREATE) {
+                p = xdr_reserve_space(xdr, 12);
+                if (!p)
+                        goto out_resource;
+                p = xdr_encode_hyper(p, (s64)stat.btime.tv_sec);
+                *p++ = cpu_to_be32(stat.btime.tv_nsec);
+        }
        if (bmval1 & FATTR4_WORD1_MOUNTED_ON_FILEID) {
                struct kstat parent_stat;
                u64 ino = stat.ino;

diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
index 498e5a489826..5ef056ce7591 100644
--- a/fs/nfsd/nfsd.h
+++ b/fs/nfsd/nfsd.h
@@ -364,7 +364,7 @@ void                nfsd_lockd_shutdown(void);
  | FATTR4_WORD1_OWNER          | FATTR4_WORD1_OWNER_GROUP  | FATTR4_WORD1_RAWDEV           \
  | FATTR4_WORD1_SPACE_AVAIL     | FATTR4_WORD1_SPACE_FREE   | FATTR4_WORD1_SPACE_TOTAL      \
  | FATTR4_WORD1_SPACE_USED      | FATTR4_WORD1_TIME_ACCESS  | FATTR4_WORD1_TIME_ACCESS_SET  \
- | FATTR4_WORD1_TIME_DELTA   | FATTR4_WORD1_TIME_METADATA    \
+ | FATTR4_WORD1_TIME_DELTA   | FATTR4_WORD1_TIME_METADATA   | FATTR4_WORD1_TIME_CREATE      \
  | FATTR4_WORD1_TIME_MODIFY     | FATTR4_WORD1_TIME_MODIFY_SET | FATTR4_WORD1_MOUNTED_ON_FILEID)

 #define NFSD4_SUPPORTED_ATTRS_WORD2 0

Legal Disclaimer: This e-mail communication (and any attachment/s) is confidential and contains proprietary information, some or all of which may be legally privileged. It is intended solely for the use of the individual or entity to which it is addressed. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful.
Chuck Lever III Jan. 6, 2022, 4:59 p.m. UTC | #16
> On Jan 6, 2022, at 11:13 AM, Ondrej Valousek <ondrej.valousek.xm@renesas.com> wrote:
> 
> So I think this is what we eventually need (thanks for the pointers you gave me!):
> 
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index 5a93a5db4fb0..e88ae4ce5263 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -2865,6 +2865,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
>        err = vfs_getattr(&path, &stat, STATX_BASIC_STATS, AT_STATX_SYNC_AS_STAT);
>        if (err)
>                goto out_nfserr;
> +       if (! stat.result_mask & STATX_BTIME)
> +               /* underlying FS does not offer btime so we can't share it */
> +               bmval1 &= ~FATTR4_WORD1_TIME_CREATE;
>        if ((bmval0 & (FATTR4_WORD0_FILES_AVAIL | FATTR4_WORD0_FILES_FREE |
>                        FATTR4_WORD0_FILES_TOTAL | FATTR4_WORD0_MAXNAME)) ||
>            (bmval1 & (FATTR4_WORD1_SPACE_AVAIL | FATTR4_WORD1_SPACE_FREE |
> @@ -3265,6 +3268,14 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
>                p = xdr_encode_hyper(p, (s64)stat.mtime.tv_sec);
>                *p++ = cpu_to_be32(stat.mtime.tv_nsec);
>        }
> +       /* support for btime here */
> +        if (bmval1 & FATTR4_WORD1_TIME_CREATE) {
> +                p = xdr_reserve_space(xdr, 12);
> +                if (!p)
> +                        goto out_resource;
> +                p = xdr_encode_hyper(p, (s64)stat.btime.tv_sec);
> +                *p++ = cpu_to_be32(stat.btime.tv_nsec);
> +        }
>        if (bmval1 & FATTR4_WORD1_MOUNTED_ON_FILEID) {
>                struct kstat parent_stat;
>                u64 ino = stat.ino;
> 
> diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
> index 498e5a489826..5ef056ce7591 100644
> --- a/fs/nfsd/nfsd.h
> +++ b/fs/nfsd/nfsd.h
> @@ -364,7 +364,7 @@ void                nfsd_lockd_shutdown(void);
>  | FATTR4_WORD1_OWNER          | FATTR4_WORD1_OWNER_GROUP  | FATTR4_WORD1_RAWDEV           \
>  | FATTR4_WORD1_SPACE_AVAIL     | FATTR4_WORD1_SPACE_FREE   | FATTR4_WORD1_SPACE_TOTAL      \
>  | FATTR4_WORD1_SPACE_USED      | FATTR4_WORD1_TIME_ACCESS  | FATTR4_WORD1_TIME_ACCESS_SET  \
> - | FATTR4_WORD1_TIME_DELTA   | FATTR4_WORD1_TIME_METADATA    \
> + | FATTR4_WORD1_TIME_DELTA   | FATTR4_WORD1_TIME_METADATA   | FATTR4_WORD1_TIME_CREATE      \
>  | FATTR4_WORD1_TIME_MODIFY     | FATTR4_WORD1_TIME_MODIFY_SET | FATTR4_WORD1_MOUNTED_ON_FILEID)
> 
> #define NFSD4_SUPPORTED_ATTRS_WORD2 0
> 
> Legal Disclaimer: This e-mail communication (and any attachment/s) is confidential and contains proprietary information, some or all of which may be legally privileged. It is intended solely for the use of the individual or entity to which it is addressed. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful.

Thanks, Ondrej.

This looks like an interesting new feature, however it's a little
late for the v5.17 merge window, IMO. (On the plus side, that gives
us a month or two for further review and deeper testing).

Also, the change needs to be submitted as a real patch. See the

   Documentation/process/submitting-patches.rst 

file in the Linux kernel tree for information on the p's and q's.
In particular:

 -- you need a short and full patch description. The "Describe
    your changes" section explains the details.

 -- you need to ensure your employer permits you to contribute
    to the Linux kernel under GPLv2. The "Sign your work - the
    Developer's Certificate of Origin" section explains this.

I'm a little concerned about your Legal Disclaimer which suggests
that anything you have sent in e-mail is already owned by Renesas
and is therefore constrained for submission to the kernel. Before
submitting again, can you ask your legal team for clarification?

--
Chuck Lever
Olga Kornievskaia Jan. 6, 2022, 6:47 p.m. UTC | #17
On Mon, Jan 3, 2022 at 4:34 PM J. Bruce Fields <bfields@fieldses.org> wrote:
>
> On Fri, Dec 17, 2021 at 03:48:46PM -0500, trondmy@kernel.org wrote:
> > From: Trond Myklebust <trond.myklebust@hammerspace.com>
> >
> > NFSv4 has support for a number of extra attributes that are of interest
> > to Samba when it is used to re-export a filesystem to Windows clients.
> > Aside from the btime, which is of interest in statx(), Windows clients
> > have an interest in determining the status of the 'hidden', and 'system'
> > flags.
> > Backup programs want to read the 'archive' flags and the 'time backup'
> > attribute.
> > Finally, the 'offline' flag can tell whether or not a file needs to be
> > staged by an HSM system before it can be read or written to.
> >
> > The patch series also adds an ioctl() to allow userspace retrieval and
> > setting of these attributes where appropriate. It also adds an ioctl()
> > to allow retrieval of the raw NFSv4 ACCESS information, to allow more
> > fine grained determination of the user's access rights to a file or
> > directory. All of this information is of use for Samba.
>
> Same question, what filesystem and server are you testing against?

I have tested the patch set against the Netapp filer. generic/528
tests the btime attribute. I'm not sure if xfstests has any other
tests for archive, offline, hidden attributes.

>
> --b.
>
> >
> > Anne Marie Merritt (3):
> >   nfs: Add timecreate to nfs inode
> >   nfs: Add 'archive', 'hidden' and 'system' fields to nfs inode
> >   nfs: Add 'time backup' to nfs inode
> >
> > Richard Sharpe (1):
> >   NFS: Support statx_get and statx_set ioctls
> >
> > Trond Myklebust (4):
> >   NFS: Expand the type of nfs_fattr->valid
> >   NFS: Return the file btime in the statx results when appropriate
> >   NFSv4: Support the offline bit
> >   NFSv4: Add an ioctl to allow retrieval of the NFS raw ACCESS mask
> >
> >  fs/nfs/dir.c              |  71 ++---
> >  fs/nfs/getroot.c          |   3 +-
> >  fs/nfs/inode.c            | 147 +++++++++-
> >  fs/nfs/internal.h         |  10 +
> >  fs/nfs/nfs3proc.c         |   1 +
> >  fs/nfs/nfs4_fs.h          |  31 +++
> >  fs/nfs/nfs4file.c         | 550 ++++++++++++++++++++++++++++++++++++++
> >  fs/nfs/nfs4proc.c         | 175 +++++++++++-
> >  fs/nfs/nfs4trace.h        |   8 +-
> >  fs/nfs/nfs4xdr.c          | 240 +++++++++++++++--
> >  fs/nfs/nfstrace.c         |   5 +
> >  fs/nfs/nfstrace.h         |   9 +-
> >  fs/nfs/proc.c             |   1 +
> >  include/linux/nfs4.h      |   1 +
> >  include/linux/nfs_fs.h    |  15 ++
> >  include/linux/nfs_fs_sb.h |   2 +-
> >  include/linux/nfs_xdr.h   |  80 ++++--
> >  include/uapi/linux/nfs.h  | 101 +++++++
> >  18 files changed, 1356 insertions(+), 94 deletions(-)
> >
> > --
> > 2.33.1