mbox series

[00/13] client side user xattr (RFC8276) support

Message ID 20200311195613.26108-1-fllinden@amazon.com (mailing list archive)
Headers show
Series client side user xattr (RFC8276) support | expand

Message

Frank van der Linden March 11, 2020, 7:56 p.m. UTC
This patchset implements the client side for NFS user extended attributes,
as defined in RFC8726.

This was originally posted as an RFC in:

https://patchwork.kernel.org/cover/11143565/

Patch 1 is shared with the server side patch, posted
separately.

Most comments in there still apply, except that:

1. Client side caching is now included in this patch set.
2. As per the discussion, user extended attributes are enabled if
   the client and server support them (e.g. they support 4.2 and
   advertise the user extended attribute FATTR). There are no longer
   options to switch them off on either the client or the server.
3. The code is no longer conditioned on a config option.
4. The number of patches has been reduced somewhat by merging
   smaller, related ones.

The client side caching is implemented through a per-inode hash table,
which is allocated on demand. See fs/nfs/nfs42xattr.c for details.

This has been tested as follows:

* Linux client and server:
	* Test all corner cases (XATTR_SIZE_*)
	* Test all failure cases (no xattr, setxattr with different or
	  invalid flags, etc).
	* Verify the content of xattrs across several operations.
	* Use KASAN and KMEMLEAK for a longer mix of testruns to verify
	  that there were no leaks (after unmounting the filesystem).
	* Stress tested caching, trying to run the client out of memory.

* Tested against the FreeBSD-current implementation as well, which works
  (after I fixed 2 bugs in that implementation, which I'm sending out to
  them too).

* Not tested: RDMA (I couldn't get a setup going).

Frank van der Linden (13):
  nfs,nfsd:  NFSv4.2 extended attribute protocol definitions
  nfs: add client side only definitions for user xattrs
  NFSv4.2: query the server for extended attribute support
  NFSv4.2: define limits and sizes for user xattr handling
  NFSv4.2: add client side XDR handling for extended attributes
  nfs: define nfs_access_get_cached function
  NFSv4.2: query the extended attribute access bits
  nfs: modify update_changeattr to deal with regular files
  nfs: define and use the NFS_INO_INVALID_XATTR flag
  nfs: make the buf_to_pages_noslab function available to the nfs code
  NFSv4.2: add the extended attribute proc functions.
  NFSv4.2: hook in the user extended attribute handlers
  NFSv4.2: add client side xattr caching.

 fs/nfs/Makefile             |    1 +
 fs/nfs/client.c             |   19 +-
 fs/nfs/dir.c                |   24 +-
 fs/nfs/inode.c              |   16 +-
 fs/nfs/internal.h           |   28 ++
 fs/nfs/nfs42.h              |   24 +
 fs/nfs/nfs42proc.c          |  248 ++++++++++
 fs/nfs/nfs42xattr.c         | 1083 +++++++++++++++++++++++++++++++++++++++++++
 fs/nfs/nfs42xdr.c           |  442 ++++++++++++++++++
 fs/nfs/nfs4_fs.h            |    5 +
 fs/nfs/nfs4client.c         |   31 ++
 fs/nfs/nfs4proc.c           |  248 ++++++++--
 fs/nfs/nfs4super.c          |   10 +
 fs/nfs/nfs4xdr.c            |   29 ++
 fs/nfs/nfstrace.h           |    3 +-
 include/linux/nfs4.h        |   25 +
 include/linux/nfs_fs.h      |   12 +
 include/linux/nfs_fs_sb.h   |    6 +
 include/linux/nfs_xdr.h     |   60 ++-
 include/uapi/linux/nfs4.h   |    3 +
 include/uapi/linux/nfs_fs.h |    1 +
 21 files changed, 2276 insertions(+), 42 deletions(-)
 create mode 100644 fs/nfs/nfs42xattr.c

Comments

Mkrtchyan, Tigran March 12, 2020, 7:06 p.m. UTC | #1
I have applied the patchset and run simple test against dCache nfs server:

root@anahit xattr-test]# df -h .
Filesystem      Size  Used Avail Use% Mounted on
ani:/           213G  179G   35G  84% /mnt
[root@anahit xattr-test]#
[root@anahit xattr-test]# touch file.txt
[root@anahit xattr-test]# attr -l file.txt
[root@anahit xattr-test]# attr -s key1 -V value1 file.txt
Attribute "key1" set to a 6 byte value for file.txt:
value1
[root@anahit xattr-test]# attr -s key2 -V value2 file.txt
Attribute "key2" set to a 6 byte value for file.txt:
value2
[root@anahit xattr-test]# attr -l file.txt
Attribute "user.key1" has a 6 byte value for file.txt
Attribute "user.key2" has a 6 byte value for file.txt
[root@anahit xattr-test]# attr -g key1 file.txt
Attribute "key1" had a 6 byte value for file.txt:
value1
[root@anahit xattr-test]# attr -g key2 file.txt
Attribute "key2" had a 6 byte value for file.txt:
value2
[root@anahit xattr-test]# getfattr -n user.key1 file.txt
# file: file.txt
user.key1="value1"

[root@anahit xattr-test]# getfattr -n user.key2 file.txt
# file: file.txt
user.key2="value2"

[root@anahit xattr-test]# attr -r key1 file.txt
[root@anahit xattr-test]# attr -r key2 file.txt
[root@anahit xattr-test]# attr -l file.txt
[root@anahit xattr-test]#


At lease a dirrerent implementation in addition to linux server works as expected.

Tested-by:  "Tigran Mkrtchyan" <tigran.mkrtchyan@desy.de>


Tigran.

----- Original Message -----
> From: "Frank van der Linden" <fllinden@amazon.com>
> To: "Trond Myklebust" <trond.myklebust@hammerspace.com>, "Anna Schumaker" <anna.schumaker@netapp.com>, "linux-nfs"
> <linux-nfs@vger.kernel.org>
> Cc: "Frank van der Linden" <fllinden@amazon.com>
> Sent: Wednesday, March 11, 2020 8:56:00 PM
> Subject: [PATCH 00/13] client side user xattr (RFC8276) support

> This patchset implements the client side for NFS user extended attributes,
> as defined in RFC8726.
> 
> This was originally posted as an RFC in:
> 
> https://patchwork.kernel.org/cover/11143565/
> 
> Patch 1 is shared with the server side patch, posted
> separately.
> 
> Most comments in there still apply, except that:
> 
> 1. Client side caching is now included in this patch set.
> 2. As per the discussion, user extended attributes are enabled if
>   the client and server support them (e.g. they support 4.2 and
>   advertise the user extended attribute FATTR). There are no longer
>   options to switch them off on either the client or the server.
> 3. The code is no longer conditioned on a config option.
> 4. The number of patches has been reduced somewhat by merging
>   smaller, related ones.
> 
> The client side caching is implemented through a per-inode hash table,
> which is allocated on demand. See fs/nfs/nfs42xattr.c for details.
> 
> This has been tested as follows:
> 
> * Linux client and server:
>	* Test all corner cases (XATTR_SIZE_*)
>	* Test all failure cases (no xattr, setxattr with different or
>	  invalid flags, etc).
>	* Verify the content of xattrs across several operations.
>	* Use KASAN and KMEMLEAK for a longer mix of testruns to verify
>	  that there were no leaks (after unmounting the filesystem).
>	* Stress tested caching, trying to run the client out of memory.
> 
> * Tested against the FreeBSD-current implementation as well, which works
>  (after I fixed 2 bugs in that implementation, which I'm sending out to
>  them too).
> 
> * Not tested: RDMA (I couldn't get a setup going).
> 
> Frank van der Linden (13):
>  nfs,nfsd:  NFSv4.2 extended attribute protocol definitions
>  nfs: add client side only definitions for user xattrs
>  NFSv4.2: query the server for extended attribute support
>  NFSv4.2: define limits and sizes for user xattr handling
>  NFSv4.2: add client side XDR handling for extended attributes
>  nfs: define nfs_access_get_cached function
>  NFSv4.2: query the extended attribute access bits
>  nfs: modify update_changeattr to deal with regular files
>  nfs: define and use the NFS_INO_INVALID_XATTR flag
>  nfs: make the buf_to_pages_noslab function available to the nfs code
>  NFSv4.2: add the extended attribute proc functions.
>  NFSv4.2: hook in the user extended attribute handlers
>  NFSv4.2: add client side xattr caching.
> 
> fs/nfs/Makefile             |    1 +
> fs/nfs/client.c             |   19 +-
> fs/nfs/dir.c                |   24 +-
> fs/nfs/inode.c              |   16 +-
> fs/nfs/internal.h           |   28 ++
> fs/nfs/nfs42.h              |   24 +
> fs/nfs/nfs42proc.c          |  248 ++++++++++
> fs/nfs/nfs42xattr.c         | 1083 +++++++++++++++++++++++++++++++++++++++++++
> fs/nfs/nfs42xdr.c           |  442 ++++++++++++++++++
> fs/nfs/nfs4_fs.h            |    5 +
> fs/nfs/nfs4client.c         |   31 ++
> fs/nfs/nfs4proc.c           |  248 ++++++++--
> fs/nfs/nfs4super.c          |   10 +
> fs/nfs/nfs4xdr.c            |   29 ++
> fs/nfs/nfstrace.h           |    3 +-
> include/linux/nfs4.h        |   25 +
> include/linux/nfs_fs.h      |   12 +
> include/linux/nfs_fs_sb.h   |    6 +
> include/linux/nfs_xdr.h     |   60 ++-
> include/uapi/linux/nfs4.h   |    3 +
> include/uapi/linux/nfs_fs.h |    1 +
> 21 files changed, 2276 insertions(+), 42 deletions(-)
> create mode 100644 fs/nfs/nfs42xattr.c
> 
> --
> 2.16.6
Schumaker, Anna March 12, 2020, 8:09 p.m. UTC | #2
Hi Frank,

On Wed, Mar 11, 2020 at 3:57 PM Frank van der Linden
<fllinden@amazon.com> wrote:
>
> This patchset implements the client side for NFS user extended attributes,
> as defined in RFC8726.
>
> This was originally posted as an RFC in:
>
> https://patchwork.kernel.org/cover/11143565/
>
> Patch 1 is shared with the server side patch, posted
> separately.
>
> Most comments in there still apply, except that:
>
> 1. Client side caching is now included in this patch set.
> 2. As per the discussion, user extended attributes are enabled if
>    the client and server support them (e.g. they support 4.2 and
>    advertise the user extended attribute FATTR). There are no longer
>    options to switch them off on either the client or the server.
> 3. The code is no longer conditioned on a config option.
> 4. The number of patches has been reduced somewhat by merging
>    smaller, related ones.
>
> The client side caching is implemented through a per-inode hash table,
> which is allocated on demand. See fs/nfs/nfs42xattr.c for details.
>
> This has been tested as follows:
>
> * Linux client and server:
>         * Test all corner cases (XATTR_SIZE_*)
>         * Test all failure cases (no xattr, setxattr with different or
>           invalid flags, etc).
>         * Verify the content of xattrs across several operations.
>         * Use KASAN and KMEMLEAK for a longer mix of testruns to verify
>           that there were no leaks (after unmounting the filesystem).
>         * Stress tested caching, trying to run the client out of memory.

I'm curious if you've tried xfstests with your patches? There are a
handful of tests using xattrs that might be good to check with, too:

anna@gouda % grep xattr -l tests/generic/[0-9][0-9][0-9]
tests/generic/037
tests/generic/062
tests/generic/066
tests/generic/093
tests/generic/117
tests/generic/337
tests/generic/377
tests/generic/403
tests/generic/425
tests/generic/454
tests/generic/489
tests/generic/523
tests/generic/529
tests/generic/556

Thanks,
Anna


>
> * Tested against the FreeBSD-current implementation as well, which works
>   (after I fixed 2 bugs in that implementation, which I'm sending out to
>   them too).
>
> * Not tested: RDMA (I couldn't get a setup going).
>
> Frank van der Linden (13):
>   nfs,nfsd:  NFSv4.2 extended attribute protocol definitions
>   nfs: add client side only definitions for user xattrs
>   NFSv4.2: query the server for extended attribute support
>   NFSv4.2: define limits and sizes for user xattr handling
>   NFSv4.2: add client side XDR handling for extended attributes
>   nfs: define nfs_access_get_cached function
>   NFSv4.2: query the extended attribute access bits
>   nfs: modify update_changeattr to deal with regular files
>   nfs: define and use the NFS_INO_INVALID_XATTR flag
>   nfs: make the buf_to_pages_noslab function available to the nfs code
>   NFSv4.2: add the extended attribute proc functions.
>   NFSv4.2: hook in the user extended attribute handlers
>   NFSv4.2: add client side xattr caching.
>
>  fs/nfs/Makefile             |    1 +
>  fs/nfs/client.c             |   19 +-
>  fs/nfs/dir.c                |   24 +-
>  fs/nfs/inode.c              |   16 +-
>  fs/nfs/internal.h           |   28 ++
>  fs/nfs/nfs42.h              |   24 +
>  fs/nfs/nfs42proc.c          |  248 ++++++++++
>  fs/nfs/nfs42xattr.c         | 1083 +++++++++++++++++++++++++++++++++++++++++++
>  fs/nfs/nfs42xdr.c           |  442 ++++++++++++++++++
>  fs/nfs/nfs4_fs.h            |    5 +
>  fs/nfs/nfs4client.c         |   31 ++
>  fs/nfs/nfs4proc.c           |  248 ++++++++--
>  fs/nfs/nfs4super.c          |   10 +
>  fs/nfs/nfs4xdr.c            |   29 ++
>  fs/nfs/nfstrace.h           |    3 +-
>  include/linux/nfs4.h        |   25 +
>  include/linux/nfs_fs.h      |   12 +
>  include/linux/nfs_fs_sb.h   |    6 +
>  include/linux/nfs_xdr.h     |   60 ++-
>  include/uapi/linux/nfs4.h   |    3 +
>  include/uapi/linux/nfs_fs.h |    1 +
>  21 files changed, 2276 insertions(+), 42 deletions(-)
>  create mode 100644 fs/nfs/nfs42xattr.c
>
> --
> 2.16.6
>
Frank van der Linden March 16, 2020, 3:50 p.m. UTC | #3
Hi Anna,

On Thu, Mar 12, 2020 at 04:09:51PM -0400, Anna Schumaker wrote:
> I'm curious if you've tried xfstests with your patches? There are a
> handful of tests using xattrs that might be good to check with, too:
> 
> anna@gouda % grep xattr -l tests/generic/[0-9][0-9][0-9]
> tests/generic/037
> tests/generic/062
> tests/generic/066
> tests/generic/093
> tests/generic/117
> tests/generic/337
> tests/generic/377
> tests/generic/403
> tests/generic/425
> tests/generic/454
> tests/generic/489
> tests/generic/523
> tests/generic/529
> tests/generic/556
> 
> Thanks,
> Anna

I did run xfstests, and it looks fine, meaning that the differences between
actual and expected output are expected. I can rerun the xattr
specific ones and post the report. Will do that with v2.

- Frank
Frank van der Linden March 17, 2020, 11:03 p.m. UTC | #4
On Thu, Mar 12, 2020 at 04:09:51PM -0400, Anna Schumaker wrote:
> I'm curious if you've tried xfstests with your patches? There are a
> handful of tests using xattrs that might be good to check with, too:
> 
> anna@gouda % grep xattr -l tests/generic/[0-9][0-9][0-9]
> tests/generic/037
> tests/generic/062
> tests/generic/066
> tests/generic/093
> tests/generic/117
> tests/generic/337
> tests/generic/377
> tests/generic/403
> tests/generic/425
> tests/generic/454
> tests/generic/489
> tests/generic/523
> tests/generic/529
> tests/generic/556
> 
> Thanks,
> Anna

I ran did a "check -nfs -g quick" run of xfstests-dev. The following tests
were applicable to extended attributes:

generic/020     fail   Doesn't compute MAX_ATTR right for NFS, passes
                       after fixing that.
generic/037     pass
generic/062     fail   It unconditionally expects the "system" and
                       "trusted" namespaces to be there too, not
                       easily fixed.
generic/066     pass
generic/093     fail   Capabilities use the "security" namespace, can't
                       work on NFS.
generic/097     fail   "trusted" namespace explicitly used, can't work
                       on NFS.
generic/103     fail   fallocate fails on NFS, not xattr related
generic/117     pass
generic/377     fail   Doesn't expect the "system.nfs4acl" attribute to
                       show up in listxattr.  Can be fixed by filtering
                       out only "user" namespace xattrs.
generic/403     fail   Uses the "trusted" namespace, but does not really
                       need it. Works if converted to the "user" namespace.
generic/454     pass
generic/523     pass


In other words, there were no problems with the patches themselves, but
xfstests will need some work to work properly.

I can send a few simple fixes in for xfstests, but a few need a bit more
work, specifically the ones that expected certain xattr namespaces to be
there. Right now there is a "_require_attr" check function, that probably
needs to be split up in to "_require_attr_user, _require_attr_system", etc
functions, which is a bit more work.

- Frank
J. Bruce Fields March 19, 2020, 2:39 p.m. UTC | #5
On Tue, Mar 17, 2020 at 11:03:39PM +0000, Frank van der Linden wrote:
> On Thu, Mar 12, 2020 at 04:09:51PM -0400, Anna Schumaker wrote:
> > I'm curious if you've tried xfstests with your patches? There are a
> > handful of tests using xattrs that might be good to check with, too:
> > 
> > anna@gouda % grep xattr -l tests/generic/[0-9][0-9][0-9]
> > tests/generic/037
> > tests/generic/062
> > tests/generic/066
> > tests/generic/093
> > tests/generic/117
> > tests/generic/337
> > tests/generic/377
> > tests/generic/403
> > tests/generic/425
> > tests/generic/454
> > tests/generic/489
> > tests/generic/523
> > tests/generic/529
> > tests/generic/556
> > 
> > Thanks,
> > Anna
> 
> I ran did a "check -nfs -g quick" run of xfstests-dev. The following tests
> were applicable to extended attributes:
> 
> generic/020     fail   Doesn't compute MAX_ATTR right for NFS, passes
>                        after fixing that.
> generic/037     pass
> generic/062     fail   It unconditionally expects the "system" and
>                        "trusted" namespaces to be there too, not
>                        easily fixed.
> generic/066     pass
> generic/093     fail   Capabilities use the "security" namespace, can't
>                        work on NFS.
> generic/097     fail   "trusted" namespace explicitly used, can't work
>                        on NFS.
> generic/103     fail   fallocate fails on NFS, not xattr related
> generic/117     pass
> generic/377     fail   Doesn't expect the "system.nfs4acl" attribute to
>                        show up in listxattr.  Can be fixed by filtering
>                        out only "user" namespace xattrs.
> generic/403     fail   Uses the "trusted" namespace, but does not really
>                        need it. Works if converted to the "user" namespace.
> generic/454     pass
> generic/523     pass
> 
> 
> In other words, there were no problems with the patches themselves, but
> xfstests will need some work to work properly.
> 
> I can send a few simple fixes in for xfstests, but a few need a bit more
> work, specifically the ones that expected certain xattr namespaces to be
> there. Right now there is a "_require_attr" check function, that probably
> needs to be split up in to "_require_attr_user, _require_attr_system", etc
> functions, which is a bit more work.

I just took a quick look at common/attr and all I see in _require_attrs
is:

	attr -s "user.xfstests" -V "attr" $TEST_DIR/syscalltest

What am I missing?

--b.