linux-2.6-microblaze.git
3 years agonfsd: close cached files prior to a REMOVE or RENAME that would replace target
Jeff Layton [Mon, 30 Nov 2020 22:03:16 +0000 (17:03 -0500)]
nfsd: close cached files prior to a REMOVE or RENAME that would replace target

It's not uncommon for some workloads to do a bunch of I/O to a file and
delete it just afterward. If knfsd has a cached open file however, then
the file may still be open when the dentry is unlinked. If the
underlying filesystem is nfs, then that could trigger it to do a
sillyrename.

On a REMOVE or RENAME scan the nfsd_file cache for open files that
correspond to the inode, and proactively unhash and put their
references. This should prevent any delete-on-last-close activity from
occurring, solely due to knfsd's open file cache.

This must be done synchronously though so we use the variants that call
flush_delayed_fput. There are deadlock possibilities if you call
flush_delayed_fput while holding locks, however. In the case of
nfsd_rename, we don't even do the lookups of the dentries to be renamed
until we've locked for rename.

Once we've figured out what the target dentry is for a rename, check to
see whether there are cached open files associated with it. If there
are, then unwind all of the locking, close them all, and then reattempt
the rename.

None of this is really necessary for "typical" filesystems though. It's
mostly of use for NFS, so declare a new export op flag and use that to
determine whether to close the files beforehand.

Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
Signed-off-by: Lance Shelton <lance.shelton@hammerspace.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agonfsd: allow filesystems to opt out of subtree checking
Jeff Layton [Mon, 30 Nov 2020 22:03:15 +0000 (17:03 -0500)]
nfsd: allow filesystems to opt out of subtree checking

When we start allowing NFS to be reexported, then we have some problems
when it comes to subtree checking. In principle, we could allow it, but
it would mean encoding parent info in the filehandles and there may not
be enough space for that in a NFSv3 filehandle.

To enforce this at export upcall time, we add a new export_ops flag
that declares the filesystem ineligible for subtree checking.

Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
Signed-off-by: Lance Shelton <lance.shelton@hammerspace.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agonfsd: add a new EXPORT_OP_NOWCC flag to struct export_operations
Jeff Layton [Mon, 30 Nov 2020 22:03:14 +0000 (17:03 -0500)]
nfsd: add a new EXPORT_OP_NOWCC flag to struct export_operations

With NFSv3 nfsd will always attempt to send along WCC data to the
client. This generally involves saving off the in-core inode information
prior to doing the operation on the given filehandle, and then issuing a
vfs_getattr to it after the op.

Some filesystems (particularly clustered or networked ones) have an
expensive ->getattr inode operation. Atomicity is also often difficult
or impossible to guarantee on such filesystems. For those, we're best
off not trying to provide WCC information to the client at all, and to
simply allow it to poll for that information as needed with a GETATTR
RPC.

This patch adds a new flags field to struct export_operations, and
defines a new EXPORT_OP_NOWCC flag that filesystems can use to indicate
that nfsd should not attempt to provide WCC info in NFSv3 replies. It
also adds a blurb about the new flags field and flag to the exporting
documentation.

The server will also now skip collecting this information for NFSv2 as
well, since that info is never used there anyway.

Note that this patch does not add this flag to any filesystem
export_operations structures. This was originally developed to allow
reexporting nfs via nfsd.

Other filesystems may want to consider enabling this flag too. It's hard
to tell however which ones have export operations to enable export via
knfsd and which ones mostly rely on them for open-by-filehandle support,
so I'm leaving that up to the individual maintainers to decide. I am
cc'ing the relevant lists for those filesystems that I think may want to
consider adding this though.

Cc: HPDD-discuss@lists.01.org
Cc: ceph-devel@vger.kernel.org
Cc: cluster-devel@redhat.com
Cc: fuse-devel@lists.sourceforge.net
Cc: ocfs2-devel@oss.oracle.com
Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
Signed-off-by: Lance Shelton <lance.shelton@hammerspace.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoRevert "nfsd4: support change_attr_type attribute"
J. Bruce Fields [Mon, 30 Nov 2020 22:46:18 +0000 (17:46 -0500)]
Revert "nfsd4: support change_attr_type attribute"

This reverts commit a85857633b04d57f4524cca0a2bfaf87b2543f9f.

We're still factoring ctime into our change attribute even in the
IS_I_VERSION case.  If someone sets the system time backwards, a client
could see the change attribute go backwards.  Maybe we can just say
"well, don't do that", but there's some question whether that's good
enough, or whether we need a better guarantee.

Also, the client still isn't actually using the attribute.

While we're still figuring this out, let's just stop returning this
attribute.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agonfsd4: don't query change attribute in v2/v3 case
J. Bruce Fields [Mon, 30 Nov 2020 22:46:17 +0000 (17:46 -0500)]
nfsd4: don't query change attribute in v2/v3 case

inode_query_iversion() has side effects, and there's no point calling it
when we're not even going to use it.

We check whether we're currently processing a v4 request by checking
fh_maxsize, which is arguably a little hacky; we could add a flag to
svc_fh instead.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agonfsd: minor nfsd4_change_attribute cleanup
J. Bruce Fields [Mon, 30 Nov 2020 22:46:16 +0000 (17:46 -0500)]
nfsd: minor nfsd4_change_attribute cleanup

Minor cleanup, no change in behavior.

Also pull out a common helper that'll be useful elsewhere.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agonfsd: simplify nfsd4_change_info
J. Bruce Fields [Mon, 30 Nov 2020 22:46:15 +0000 (17:46 -0500)]
nfsd: simplify nfsd4_change_info

It doesn't make sense to carry all these extra fields around.  Just
make everything into change attribute from the start.

This is just cleanup, there should be no change in behavior.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agonfsd: only call inode_query_iversion in the I_VERSION case
J. Bruce Fields [Mon, 30 Nov 2020 22:46:14 +0000 (17:46 -0500)]
nfsd: only call inode_query_iversion in the I_VERSION case

inode_query_iversion() can modify i_version.  Depending on the exported
filesystem, that may not be safe.  For example, if you're re-exporting
NFS, NFS stores the server's change attribute in i_version and does not
expect it to be modified locally.  This has been observed causing
unnecessary cache invalidations.

The way a filesystem indicates that it's OK to call
inode_query_iverson() is by setting SB_I_VERSION.

So, move the I_VERSION check out of encode_change(), where it's used
only in GETATTR responses, to nfsd4_change_attribute(), which is
also called for pre- and post- operation attributes.

(Note we could also pull the NFSEXP_V4ROOT case into
nfsd4_change_attribute() as well.  That would actually be a no-op,
since pre/post attrs are only used for metadata-modifying operations,
and V4ROOT exports are read-only.  But we might make the change in
the future just for simplicity.)

Reported-by: Daire Byrne <daire@dneg.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agonfs_common: need lock during iterate through the list
Cheng Lin [Tue, 1 Dec 2020 12:06:35 +0000 (07:06 -0500)]
nfs_common: need lock during iterate through the list

If the elem is deleted during be iterated on it, the iteration
process will fall into an endless loop.

kernel: NMI watchdog: BUG: soft lockup - CPU#4 stuck for 22s! [nfsd:17137]

PID: 17137  TASK: ffff8818d93c0000  CPU: 4   COMMAND: "nfsd"
    [exception RIP: __state_in_grace+76]
    RIP: ffffffffc00e817c  RSP: ffff8818d3aefc98  RFLAGS: 00000246
    RAX: ffff881dc0c38298  RBX: ffffffff81b03580  RCX: ffff881dc02c9f50
    RDX: ffff881e3fce8500  RSI: 0000000000000001  RDI: ffffffff81b03580
    RBP: ffff8818d3aefca0   R8: 0000000000000020   R9: ffff8818d3aefd40
    R10: ffff88017fc03800  R11: ffff8818e83933c0  R12: ffff8818d3aefd40
    R13: 0000000000000000  R14: ffff8818e8391068  R15: ffff8818fa6e4000
    CS: 0010  SS: 0018
 #0 [ffff8818d3aefc98] opens_in_grace at ffffffffc00e81e3 [grace]
 #1 [ffff8818d3aefca8] nfs4_preprocess_stateid_op at ffffffffc02a3e6c [nfsd]
 #2 [ffff8818d3aefd18] nfsd4_write at ffffffffc028ed5b [nfsd]
 #3 [ffff8818d3aefd80] nfsd4_proc_compound at ffffffffc0290a0d [nfsd]
 #4 [ffff8818d3aefdd0] nfsd_dispatch at ffffffffc027b800 [nfsd]
 #5 [ffff8818d3aefe08] svc_process_common at ffffffffc02017f3 [sunrpc]
 #6 [ffff8818d3aefe70] svc_process at ffffffffc0201ce3 [sunrpc]
 #7 [ffff8818d3aefe98] nfsd at ffffffffc027b117 [nfsd]
 #8 [ffff8818d3aefec8] kthread at ffffffff810b88c1
 #9 [ffff8818d3aeff50] ret_from_fork at ffffffff816d1607

The troublemake elem:
crash> lock_manager ffff881dc0c38298
struct lock_manager {
  list = {
    next = 0xffff881dc0c38298,
    prev = 0xffff881dc0c38298
  },
  block_opens = false
}

Fixes: c87fb4a378f9 ("lockd: NLM grace period shouldn't block NFSv4 opens")
Signed-off-by: Cheng Lin <cheng.lin130@zte.com.cn>
Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Fix 5 seconds delay when doing inter server copy
Dai Ngo [Mon, 30 Nov 2020 21:24:49 +0000 (16:24 -0500)]
NFSD: Fix 5 seconds delay when doing inter server copy

Since commit b4868b44c5628 ("NFSv4: Wait for stateid updates after
CLOSE/OPEN_DOWNGRADE"), every inter server copy operation suffers 5
seconds delay regardless of the size of the copy. The delay is from
nfs_set_open_stateid_locked when the check by nfs_stateid_is_sequential
fails because the seqid in both nfs4_state and nfs4_stateid are 0.

Fix by modifying nfs4_init_cp_state to return the stateid with seqid 1
instead of 0. This is also to conform with section 4.8 of RFC 7862.

Here is the relevant paragraph from section 4.8 of RFC 7862:

   A copy offload stateid's seqid MUST NOT be zero.  In the context of a
   copy offload operation, it is inappropriate to indicate "the most
   recent copy offload operation" using a stateid with a seqid of zero
   (see Section 8.2.2 of [RFC5661]).  It is inappropriate because the
   stateid refers to internal state in the server and there may be
   several asynchronous COPY operations being performed in parallel on
   the same file by the server.  Therefore, a copy offload stateid with
   a seqid of zero MUST be considered invalid.

Fixes: ce0887ac96d3 ("NFSD add nfs4 inter ssc to nfsd4_copy")
Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Fix sparse warning in nfs4proc.c
Chuck Lever [Mon, 30 Nov 2020 21:17:40 +0000 (16:17 -0500)]
NFSD: Fix sparse warning in nfs4proc.c

linux/fs/nfsd/nfs4proc.c:1542:24: warning: incorrect type in assignment (different base types)
linux/fs/nfsd/nfs4proc.c:1542:24:    expected restricted __be32 [assigned] [usertype] status
linux/fs/nfsd/nfs4proc.c:1542:24:    got int

Clean-up: The dup_copy_fields() function returns only zero, so make
it return void for now, and get rid of the return code check.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoSUNRPC: Remove XDRBUF_SPARSE_PAGES flag in gss_proxy upcall
Chuck Lever [Tue, 24 Nov 2020 20:48:01 +0000 (15:48 -0500)]
SUNRPC: Remove XDRBUF_SPARSE_PAGES flag in gss_proxy upcall

There's no need to defer allocation of pages for the receive buffer.

- This upcall is quite infrequent
- gssp_alloc_receive_pages() can allocate the pages with GFP_KERNEL,
  unlike the transport
- gssp_alloc_receive_pages() knows exactly how many pages are needed

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Reviewed-by: Olga Kornievskaia <kolga@netapp.com>
3 years agosunrpc: clean-up cache downcall
Roberto Bergantinos Corpas [Fri, 27 Nov 2020 18:38:31 +0000 (19:38 +0100)]
sunrpc: clean-up cache downcall

We can simplify code around cache_downcall unifying memory
allocations using kvmalloc. This has the benefit of getting rid of
cache_slow_downcall (and queue_io_mutex), and also matches userland
allocation size and limits.

Signed-off-by: Roberto Bergantinos Corpas <rbergant@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agonfsd: Fix message level for normal termination
kazuo ito [Fri, 27 Nov 2020 06:26:59 +0000 (15:26 +0900)]
nfsd: Fix message level for normal termination

The warning message from nfsd terminating normally
can confuse system adminstrators or monitoring software.

Though it's not exactly fair to pin-point a commit where it
originated, the current form in the current place started
to appear in:

Fixes: e096bbc6488d ("knfsd: remove special handling for SIGHUP")
Signed-off-by: kazuo ito <kzpn200@gmail.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Remove macros that are no longer used
Chuck Lever [Wed, 4 Nov 2020 16:12:18 +0000 (11:12 -0500)]
NFSD: Remove macros that are no longer used

Now that all the NFSv4 decoder functions have been converted to
make direct calls to the xdr helpers, remove the unused C macros.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_compound()
Chuck Lever [Wed, 4 Nov 2020 16:07:06 +0000 (11:07 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_compound()

And clean-up: Now that we have removed the DECODE_TAIL macro from
nfsd4_decode_compound(), we observe that there's no benefit for
nfsd4_decode_compound() to return nfs_ok or nfserr_bad_xdr only to
have its sole caller convert those values to one or zero,
respectively. Have nfsd4_decode_compound() return 1/0 instead.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Make nfsd4_ops::opnum a u32
Chuck Lever [Sun, 22 Nov 2020 17:49:52 +0000 (12:49 -0500)]
NFSD: Make nfsd4_ops::opnum a u32

Avoid passing a "pointer to int" argument to xdr_stream_decode_u32.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_listxattrs()
Chuck Lever [Wed, 4 Nov 2020 16:04:02 +0000 (11:04 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_listxattrs()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_setxattr()
Chuck Lever [Wed, 4 Nov 2020 15:59:57 +0000 (10:59 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_setxattr()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_xattr_name()
Chuck Lever [Wed, 4 Nov 2020 15:56:52 +0000 (10:56 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_xattr_name()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_clone()
Chuck Lever [Wed, 4 Nov 2020 15:46:46 +0000 (10:46 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_clone()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_seek()
Chuck Lever [Wed, 4 Nov 2020 15:54:47 +0000 (10:54 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_seek()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_offload_status()
Chuck Lever [Sat, 21 Nov 2020 19:21:25 +0000 (14:21 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_offload_status()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_copy_notify()
Chuck Lever [Sat, 21 Nov 2020 19:19:24 +0000 (14:19 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_copy_notify()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_copy()
Chuck Lever [Wed, 4 Nov 2020 15:49:37 +0000 (10:49 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_copy()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_nl4_server()
Chuck Lever [Mon, 16 Nov 2020 23:05:06 +0000 (18:05 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_nl4_server()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_fallocate()
Chuck Lever [Wed, 4 Nov 2020 15:44:05 +0000 (10:44 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_fallocate()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_reclaim_complete()
Chuck Lever [Tue, 3 Nov 2020 20:02:11 +0000 (15:02 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_reclaim_complete()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_destroy_clientid()
Chuck Lever [Wed, 4 Nov 2020 20:15:09 +0000 (15:15 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_destroy_clientid()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_test_stateid()
Chuck Lever [Tue, 3 Nov 2020 19:57:44 +0000 (14:57 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_test_stateid()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_sequence()
Chuck Lever [Tue, 3 Nov 2020 19:55:19 +0000 (14:55 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_sequence()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_secinfo_no_name()
Chuck Lever [Tue, 3 Nov 2020 19:33:12 +0000 (14:33 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_secinfo_no_name()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_layoutreturn()
Chuck Lever [Wed, 4 Nov 2020 15:42:25 +0000 (10:42 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_layoutreturn()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_layoutget()
Chuck Lever [Tue, 3 Nov 2020 20:06:04 +0000 (15:06 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_layoutget()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_layoutcommit()
Chuck Lever [Wed, 4 Nov 2020 15:40:07 +0000 (10:40 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_layoutcommit()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_getdeviceinfo()
Chuck Lever [Tue, 3 Nov 2020 20:03:50 +0000 (15:03 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_getdeviceinfo()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_free_stateid()
Chuck Lever [Sun, 1 Nov 2020 18:38:27 +0000 (13:38 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_free_stateid()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_destroy_session()
Chuck Lever [Wed, 4 Nov 2020 18:50:55 +0000 (13:50 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_destroy_session()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_create_session()
Chuck Lever [Tue, 3 Nov 2020 19:52:44 +0000 (14:52 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_create_session()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Add a helper to decode channel_attrs4
Chuck Lever [Mon, 16 Nov 2020 20:35:05 +0000 (15:35 -0500)]
NFSD: Add a helper to decode channel_attrs4

De-duplicate some code.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Add a helper to decode nfs_impl_id4
Chuck Lever [Mon, 16 Nov 2020 20:21:55 +0000 (15:21 -0500)]
NFSD: Add a helper to decode nfs_impl_id4

Refactor for clarity.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Add a helper to decode state_protect4_a
Chuck Lever [Mon, 2 Nov 2020 20:19:12 +0000 (15:19 -0500)]
NFSD: Add a helper to decode state_protect4_a

Refactor for clarity.

Also, remove a stale comment. Commit ed94164398c9 ("nfsd: implement
machine credential support for some operations") added support for
SP4_MACH_CRED, so state_protect_a is no longer completely ignored.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Add a separate decoder for ssv_sp_parms
Chuck Lever [Tue, 3 Nov 2020 16:17:50 +0000 (11:17 -0500)]
NFSD: Add a separate decoder for ssv_sp_parms

Refactor for clarity.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Add a separate decoder to handle state_protect_ops
Chuck Lever [Tue, 3 Nov 2020 16:13:00 +0000 (11:13 -0500)]
NFSD: Add a separate decoder to handle state_protect_ops

Refactor for clarity and de-duplication of code.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_bind_conn_to_session()
Chuck Lever [Tue, 3 Nov 2020 18:16:23 +0000 (13:16 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_bind_conn_to_session()

A dedicated sessionid4 decoder is introduced that will be used by
other operation decoders in subsequent patches.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_backchannel_ctl()
Chuck Lever [Tue, 3 Nov 2020 18:14:35 +0000 (13:14 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_backchannel_ctl()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_cb_sec()
Chuck Lever [Tue, 3 Nov 2020 18:09:34 +0000 (13:09 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_cb_sec()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_release_lockowner()
Chuck Lever [Wed, 4 Nov 2020 18:42:25 +0000 (13:42 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_release_lockowner()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_write()
Chuck Lever [Tue, 3 Nov 2020 19:44:28 +0000 (14:44 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_write()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_verify()
Chuck Lever [Tue, 3 Nov 2020 19:40:32 +0000 (14:40 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_verify()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_setclientid_confirm()
Chuck Lever [Wed, 4 Nov 2020 20:12:33 +0000 (15:12 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_setclientid_confirm()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_setclientid()
Chuck Lever [Tue, 3 Nov 2020 19:35:02 +0000 (14:35 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_setclientid()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_setattr()
Chuck Lever [Sat, 21 Nov 2020 19:14:59 +0000 (14:14 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_setattr()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_secinfo()
Chuck Lever [Wed, 4 Nov 2020 20:09:42 +0000 (15:09 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_secinfo()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_renew()
Chuck Lever [Wed, 4 Nov 2020 20:08:50 +0000 (15:08 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_renew()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_rename()
Chuck Lever [Wed, 4 Nov 2020 20:05:58 +0000 (15:05 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_rename()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_remove()
Chuck Lever [Wed, 4 Nov 2020 20:04:36 +0000 (15:04 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_remove()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_readdir()
Chuck Lever [Tue, 3 Nov 2020 19:30:59 +0000 (14:30 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_readdir()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_read()
Chuck Lever [Tue, 3 Nov 2020 19:28:24 +0000 (14:28 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_read()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_putfh()
Chuck Lever [Tue, 3 Nov 2020 19:23:02 +0000 (14:23 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_putfh()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_open_downgrade()
Chuck Lever [Tue, 3 Nov 2020 19:21:01 +0000 (14:21 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_open_downgrade()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_open_confirm()
Chuck Lever [Tue, 3 Nov 2020 19:18:57 +0000 (14:18 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_open_confirm()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_open()
Chuck Lever [Sun, 1 Nov 2020 17:04:06 +0000 (12:04 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_open()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Add helper to decode OPEN's open_claim4 argument
Chuck Lever [Mon, 16 Nov 2020 22:45:04 +0000 (17:45 -0500)]
NFSD: Add helper to decode OPEN's open_claim4 argument

Refactor for clarity.

Note that op_fname is the only instance of an NFSv4 filename stored
in a struct xdr_netobj. Convert it to a u32/char * pair so that the
new nfsd4_decode_filename() helper can be used.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_share_deny()
Chuck Lever [Mon, 16 Nov 2020 22:56:17 +0000 (17:56 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_share_deny()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_share_access()
Chuck Lever [Mon, 16 Nov 2020 22:54:48 +0000 (17:54 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_share_access()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Add helper to decode OPEN's openflag4 argument
Chuck Lever [Mon, 16 Nov 2020 22:41:21 +0000 (17:41 -0500)]
NFSD: Add helper to decode OPEN's openflag4 argument

Refactor for clarity.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Add helper to decode OPEN's createhow4 argument
Chuck Lever [Mon, 16 Nov 2020 22:37:42 +0000 (17:37 -0500)]
NFSD: Add helper to decode OPEN's createhow4 argument

Refactor for clarity.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Add helper to decode NFSv4 verifiers
Chuck Lever [Mon, 16 Nov 2020 22:34:01 +0000 (17:34 -0500)]
NFSD: Add helper to decode NFSv4 verifiers

This helper will be used to simplify decoders in subsequent
patches.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_lookup()
Chuck Lever [Wed, 4 Nov 2020 20:02:40 +0000 (15:02 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_lookup()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_locku()
Chuck Lever [Tue, 3 Nov 2020 18:33:28 +0000 (13:33 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_locku()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_lockt()
Chuck Lever [Tue, 3 Nov 2020 18:31:44 +0000 (13:31 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_lockt()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_lock()
Chuck Lever [Tue, 3 Nov 2020 18:29:27 +0000 (13:29 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_lock()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Add helper for decoding locker4
Chuck Lever [Mon, 16 Nov 2020 22:16:52 +0000 (17:16 -0500)]
NFSD: Add helper for decoding locker4

Refactor for clarity.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Add helpers to decode a clientid4 and an NFSv4 state owner
Chuck Lever [Mon, 16 Nov 2020 22:25:02 +0000 (17:25 -0500)]
NFSD: Add helpers to decode a clientid4 and an NFSv4 state owner

These helpers will also be used to simplify decoders in subsequent
patches.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Relocate nfsd4_decode_opaque()
Chuck Lever [Wed, 4 Nov 2020 16:41:55 +0000 (11:41 -0500)]
NFSD: Relocate nfsd4_decode_opaque()

Enable nfsd4_decode_opaque() to be used in more decoders, and
replace the READ* macros in nfsd4_decode_opaque().

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years ago NFSD: Replace READ* macros in nfsd4_decode_link()
Chuck Lever [Wed, 4 Nov 2020 20:01:24 +0000 (15:01 -0500)]
 NFSD: Replace READ* macros in nfsd4_decode_link()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_getattr()
Chuck Lever [Thu, 19 Nov 2020 19:40:20 +0000 (14:40 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_getattr()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_delegreturn()
Chuck Lever [Sat, 21 Nov 2020 19:11:58 +0000 (14:11 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_delegreturn()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_create()
Chuck Lever [Tue, 3 Nov 2020 18:24:10 +0000 (13:24 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_create()

A dedicated decoder for component4 is introduced here, which will be
used by other operation decoders in subsequent patches.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_fattr()
Chuck Lever [Tue, 3 Nov 2020 17:56:05 +0000 (12:56 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_fattr()

Let's be more careful to avoid overrunning the memory that backs
the bitmap array. This requires updating the synopsis of
nfsd4_decode_fattr().

Bruce points out that a server needs to be careful to return nfs_ok
when a client presents bitmap bits the server doesn't support. This
includes bits in bitmap words the server might not yet support.

The current READ* based implementation is good about that, but that
requirement hasn't been documented.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros that decode the fattr4 umask attribute
Chuck Lever [Thu, 19 Nov 2020 19:07:43 +0000 (14:07 -0500)]
NFSD: Replace READ* macros that decode the fattr4 umask attribute

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros that decode the fattr4 security label attribute
Chuck Lever [Thu, 19 Nov 2020 19:05:51 +0000 (14:05 -0500)]
NFSD: Replace READ* macros that decode the fattr4 security label attribute

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros that decode the fattr4 time_set attributes
Chuck Lever [Thu, 19 Nov 2020 19:01:08 +0000 (14:01 -0500)]
NFSD: Replace READ* macros that decode the fattr4 time_set attributes

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros that decode the fattr4 owner_group attribute
Chuck Lever [Thu, 19 Nov 2020 18:58:18 +0000 (13:58 -0500)]
NFSD: Replace READ* macros that decode the fattr4 owner_group attribute

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros that decode the fattr4 owner attribute
Chuck Lever [Thu, 19 Nov 2020 18:56:42 +0000 (13:56 -0500)]
NFSD: Replace READ* macros that decode the fattr4 owner attribute

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros that decode the fattr4 mode attribute
Chuck Lever [Thu, 19 Nov 2020 18:54:26 +0000 (13:54 -0500)]
NFSD: Replace READ* macros that decode the fattr4 mode attribute

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros that decode the fattr4 acl attribute
Chuck Lever [Thu, 19 Nov 2020 18:02:54 +0000 (13:02 -0500)]
NFSD: Replace READ* macros that decode the fattr4 acl attribute

Refactor for clarity and to move infrequently-used code out of line.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros that decode the fattr4 size attribute
Chuck Lever [Thu, 19 Nov 2020 18:47:16 +0000 (13:47 -0500)]
NFSD: Replace READ* macros that decode the fattr4 size attribute

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Change the way the expected length of a fattr4 is checked
Chuck Lever [Thu, 19 Nov 2020 18:09:13 +0000 (13:09 -0500)]
NFSD: Change the way the expected length of a fattr4 is checked

Because the fattr4 is now managed in an xdr_stream, all that is
needed is to store the initial position of the stream before
decoding the attribute list. Then the actual length of the list
is computed using the final stream position, after decoding is
complete.

No behavior change is expected.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_commit()
Chuck Lever [Tue, 3 Nov 2020 18:19:51 +0000 (13:19 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_commit()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_close()
Chuck Lever [Tue, 3 Nov 2020 18:18:23 +0000 (13:18 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_close()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace READ* macros in nfsd4_decode_access()
Chuck Lever [Tue, 3 Nov 2020 18:12:27 +0000 (13:12 -0500)]
NFSD: Replace READ* macros in nfsd4_decode_access()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Replace the internals of the READ_BUF() macro
Chuck Lever [Tue, 3 Nov 2020 16:54:23 +0000 (11:54 -0500)]
NFSD: Replace the internals of the READ_BUF() macro

Convert the READ_BUF macro in nfs4xdr.c from open code to instead
use the new xdr_stream-style decoders already in use by the encode
side (and by the in-kernel NFS client implementation). Once this
conversion is done, each individual NFSv4 argument decoder can be
independently cleaned up to replace these macros with C code.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Add tracepoints in nfsd4_decode/encode_compound()
Chuck Lever [Sat, 21 Nov 2020 16:36:42 +0000 (11:36 -0500)]
NFSD: Add tracepoints in nfsd4_decode/encode_compound()

For troubleshooting purposes, record failures to decode NFSv4
operation arguments and encode operation results.

trace_nfsd_compound_decode_err() replaces the dprintk() call sites
that are embedded in READ_* macros that are about to be removed.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Add tracepoints in nfsd_dispatch()
Chuck Lever [Mon, 19 Oct 2020 17:00:29 +0000 (13:00 -0400)]
NFSD: Add tracepoints in nfsd_dispatch()

For troubleshooting purposes, record GARBAGE_ARGS and CANT_ENCODE
failures.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoNFSD: Add common helpers to decode void args and encode void results
Chuck Lever [Thu, 5 Nov 2020 19:48:29 +0000 (14:48 -0500)]
NFSD: Add common helpers to decode void args and encode void results

Start off the conversion to xdr_stream by de-duplicating the functions
that decode void arguments and encode void results.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoSUNRPC: Prepare for xdr_stream-style decoding on the server-side
Chuck Lever [Thu, 5 Nov 2020 16:19:42 +0000 (11:19 -0500)]
SUNRPC: Prepare for xdr_stream-style decoding on the server-side

A "permanent" struct xdr_stream is allocated in struct svc_rqst so
that it is usable by all server-side decoders. A per-rqst scratch
buffer is also allocated to handle decoding XDR data items that
cross page boundaries.

To demonstrate how it will be used, add the first call site for the
new svcxdr_init_decode() API.

As an additional part of the overall conversion, add symbolic
constants for successful and failed XDR operations. Returning "0" is
overloaded. Sometimes it means something failed, but sometimes it
means success. To make it more clear when XDR decoding functions
succeed or fail, introduce symbolic constants.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agoSUNRPC: Add xdr_set_scratch_page() and xdr_reset_scratch_buffer()
Chuck Lever [Wed, 11 Nov 2020 20:52:47 +0000 (15:52 -0500)]
SUNRPC: Add xdr_set_scratch_page() and xdr_reset_scratch_buffer()

Clean up: De-duplicate some frequently-used code.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
3 years agonfsd: Fix error return code in nfsd_file_cache_init()
Huang Guobin [Wed, 25 Nov 2020 08:39:33 +0000 (03:39 -0500)]
nfsd: Fix error return code in nfsd_file_cache_init()

Fix to return PTR_ERR() error code from the error handling case instead of
0 in function nfsd_file_cache_init(), as done elsewhere in this function.

Fixes: 65294c1f2c5e7("nfsd: add a new struct file caching facility to nfsd")
Signed-off-by: Huang Guobin <huangguobin4@huawei.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>