Chuck Lever [Fri, 10 Nov 2023 16:28:33 +0000 (11:28 -0500)]
NFSD: Fix "start of NFS reply" pointer passed to nfsd_cache_update()
The "statp + 1" pointer that is passed to nfsd_cache_update() is
supposed to point to the start of the egress NFS Reply header. In
fact, it does point there for AUTH_SYS and RPCSEC_GSS_KRB5 requests.
But both krb5i and krb5p add fields between the RPC header's
accept_stat field and the start of the NFS Reply header. In those
cases, "statp + 1" points at the extra fields instead of the Reply.
The result is that nfsd_cache_update() caches what looks to the
client like garbage.
A connection break can occur for a number of reasons, but the most
common reason when using krb5i/p is a GSS sequence number window
underrun. When an underrun is detected, the server is obliged to
drop the RPC and the connection to force a retransmit with a fresh
GSS sequence number. The client presents the same XID, it hits in
the server's DRC, and the server returns the garbage cache entry.
The "statp + 1" argument has been used since the oldest changeset
in the kernel history repo, so it has been in nfsd_dispatch()
literally since before history began. The problem arose only when
the server-side GSS implementation was added twenty years ago.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Tested-by: Jeff Layton <jlayton@kernel.org
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Fri, 10 Nov 2023 16:28:39 +0000 (11:28 -0500)]
NFSD: Update nfsd_cache_append() to use xdr_stream
When inserting a DRC-cached response into the reply buffer, ensure
that the reply buffer's xdr_stream is updated properly. Otherwise
the server will send a garbage response.
Cc: stable@vger.kernel.org # v6.3+
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Tested-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Mahmoud Adam [Fri, 10 Nov 2023 18:21:04 +0000 (19:21 +0100)]
nfsd: fix file memleak on client_opens_release
seq_release should be called to free the allocated seq_file
Cc: stable@vger.kernel.org # v5.3+
Signed-off-by: Mahmoud Adam <mngyadam@amazon.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Fixes:
78599c42ae3c ("nfsd4: add file to display list of client's opens")
Reviewed-by: NeilBrown <neilb@suse.de>
Tested-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Fri, 13 Oct 2023 12:22:24 +0000 (08:22 -0400)]
svcrdma: Fix tracepoint printk format
Other tracepoints use "cq.id=" rather than "cq_id=". Let's make it
more reliable to grep for the CQ restracker ID.
Reviewed-by: Benjamin Coddington <bcodding@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Tue, 10 Oct 2023 17:23:41 +0000 (13:23 -0400)]
svcrdma: Drop connection after an RDMA Read error
When an RPC Call message cannot be pulled from the client, that
is a message loss, by definition. Close the connection to trigger
the client to resend.
Cc: <stable@vger.kernel.org>
Reviewed-by: Tom Talpey <tom@talpey.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Sicong Huang [Thu, 12 Oct 2023 08:34:58 +0000 (16:34 +0800)]
NFSD: clean up alloc_init_deleg()
Modify the conditional statement for null pointer check in the function
'alloc_init_deleg' to make this function more robust and clear. Otherwise,
this function may have potential pointer dereference problem in the future,
when modifying or expanding the nfs4_delegation structure.
Signed-off-by: Sicong Huang <huangsicong@iie.ac.cn>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Sun, 1 Oct 2023 17:25:16 +0000 (13:25 -0400)]
NFSD: Fix frame size warning in svc_export_parse()
fs/nfsd/export.c: In function 'svc_export_parse':
fs/nfsd/export.c:737:1: warning: the frame size of 1040 bytes is larger than 1024 bytes [-Wframe-larger-than=]
737 | }
On my systems, svc_export_parse() has a stack frame of over 800
bytes, not 1040, but nonetheless, it could do with some reduction.
When a struct svc_export is on the stack, it's a temporary structure
used as an argument, and not visible as an actual exported FS. No
need to reserve space for export_stats in such cases.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/
202310012359.YEw5IrK6-lkp@intel.com/
Cc: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Sun, 1 Oct 2023 17:25:09 +0000 (13:25 -0400)]
NFSD: Rewrite synopsis of nfsd_percpu_counters_init()
In function ‘export_stats_init’,
inlined from ‘svc_export_alloc’ at fs/nfsd/export.c:866:6:
fs/nfsd/export.c:337:16: warning: ‘nfsd_percpu_counters_init’ accessing 40 bytes in a region of size 0 [-Wstringop-overflow=]
337 | return nfsd_percpu_counters_init(&stats->counter, EXP_STATS_COUNTERS_NUM);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/nfsd/export.c:337:16: note: referencing argument 1 of type ‘struct percpu_counter[0]’
fs/nfsd/stats.h: In function ‘svc_export_alloc’:
fs/nfsd/stats.h:40:5: note: in a call to function ‘nfsd_percpu_counters_init’
40 | int nfsd_percpu_counters_init(struct percpu_counter counters[], int num);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
Cc: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
KaiLong Wang [Thu, 28 Sep 2023 02:51:55 +0000 (10:51 +0800)]
nfsd: Clean up errors in nfs3proc.c
Fix the following errors reported by checkpatch:
ERROR: need consistent spacing around '+' (ctx:WxV)
ERROR: spaces required around that '?' (ctx:VxW)
Signed-off-by: KaiLong Wang <wangkailong@jari.cn>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
KaiLong Wang [Thu, 28 Sep 2023 02:43:04 +0000 (10:43 +0800)]
nfsd: Clean up errors in nfs4state.c
Fix the following errors reported by checkpatch:
ERROR: spaces required around that '=' (ctx:VxW)
ERROR: space required after that ',' (ctx:VxO)
ERROR: space required before that '~' (ctx:OxV)
Signed-off-by: KaiLong Wang <wangkailong@jari.cn>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
KaiLong Wang [Thu, 28 Sep 2023 02:35:16 +0000 (10:35 +0800)]
NFSD: Clean up errors in stats.c
Fix the following errors reported by checkpatch:
ERROR: space required after that ',' (ctx:VxV)
Signed-off-by: KaiLong Wang <wangkailong@jari.cn>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
NeilBrown [Mon, 25 Sep 2023 02:06:44 +0000 (12:06 +1000)]
NFSD: simplify error paths in nfsd_svc()
The error paths in nfsd_svc() are needlessly complex and can result in a
final call to svc_put() without nfsd_last_thread() being called. This
results in the listening sockets not being closed properly.
The per-netns setup provided by nfsd_startup_new() and removed by
nfsd_shutdown_net() is needed precisely when there are running threads.
So we don't need nfsd_up_before. We don't need to know if it *was* up.
We only need to know if any threads are left. If none are, then we must
call nfsd_shutdown_net(). But we don't need to do that explicitly as
nfsd_last_thread() does that for us.
So simply call nfsd_last_thread() before the last svc_put() if there are
no running threads. That will always do the right thing.
Also discard:
pr_info("nfsd: last server has exited, flushing export cache\n");
It may not be true if an attempt to start the first server failed, and
it isn't particularly helpful and it simply reports normal behaviour.
Signed-off-by: NeilBrown <neilb@suse.de>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 9 Oct 2023 18:30:29 +0000 (14:30 -0400)]
NFSD: Clean up nfsd4_encode_seek()
Use modern XDR encoder utilities.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 9 Oct 2023 18:30:23 +0000 (14:30 -0400)]
NFSD: Clean up nfsd4_encode_offset_status()
Use modern XDR encoder utilities.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 9 Oct 2023 18:30:16 +0000 (14:30 -0400)]
NFSD: Clean up nfsd4_encode_copy_notify()
Replace open-coded encoding logic with the use of conventional XDR
utility functions.
Note that if we replace the cpn_sec and cpn_nsec fields with a
single struct timespec64 field, the encoder can use
nfsd4_encode_nfstime4(), as that is the data type specified by the
XDR spec.
NFS4ERR_INVAL seems inappropriate if the encoder doesn't support
encoding the response. Instead use NFS4ERR_SERVERFAULT, since this
condition is a software bug on the server.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 9 Oct 2023 18:30:09 +0000 (14:30 -0400)]
NFSD: Clean up nfsd4_encode_copy()
Restructure this function using conventional XDR utility functions
and so it aligns better with the XDR in the specification.
I've also moved nfsd4_encode_copy() closer to the data type encoders
that only it uses.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 9 Oct 2023 18:30:03 +0000 (14:30 -0400)]
NFSD: Clean up nfsd4_encode_test_stateid()
Use conventional XDR utilities.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 9 Oct 2023 18:29:56 +0000 (14:29 -0400)]
NFSD: Clean up nfsd4_encode_exchange_id()
Restructure nfsd4_encode_exchange_id() so that it will be more
straightforward to add support for SSV one day. Also, adopt the use
of the conventional XDR utility functions.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 9 Oct 2023 18:29:49 +0000 (14:29 -0400)]
NFSD: Clean up nfsd4_do_encode_secinfo()
Refactor nfsd4_encode_secinfo() so it is more clear what XDR data
item is being encoded by which piece of code.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 9 Oct 2023 18:29:43 +0000 (14:29 -0400)]
NFSD: Clean up nfsd4_encode_access()
Convert nfsd4_encode_access() to use modern XDR utility functions.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Wed, 4 Oct 2023 13:42:10 +0000 (09:42 -0400)]
NFSD: Clean up nfsd4_encode_readdir()
Untangle nfsd4_encode_readdir() so it is more clear what XDR data
item is being encoded by which piece of code.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Wed, 4 Oct 2023 13:42:03 +0000 (09:42 -0400)]
NFSD: Clean up nfsd4_encode_entry4()
Reshape nfsd4_encode_entry4() to be more like the legacy dirent
encoders, which were recently rewritten to use xdr_stream.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Wed, 4 Oct 2023 13:41:57 +0000 (09:41 -0400)]
NFSD: Add an nfsd4_encode_nfs_cookie4() helper
De-duplicate the entry4 cookie encoder, similar to the arrangement
for the NFSv2 and NFSv3 directory entry encoders.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Wed, 4 Oct 2023 13:41:51 +0000 (09:41 -0400)]
NFSD: Clean up nfsd4_encode_rdattr_error()
No need for specialized code here, as this function is invoked only
rarely. Convert it to encode to xdr_stream using conventional XDR
helpers.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Wed, 4 Oct 2023 13:41:44 +0000 (09:41 -0400)]
NFSD: Rename nfsd4_encode_dirent()
Rename nfsd4_encode_dirent() to match the naming convention already
used in the NFSv2 and NFSv3 readdir paths. The new name reflects the
name of the spec-defined XDR data type for an NFSv4 directory entry.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 2 Oct 2023 14:51:37 +0000 (10:51 -0400)]
NFSD: Clean up nfsd4_encode_sequence()
De-duplicate open-coded encoding of the sessionid, and convert the
rest of the function to use conventional XDR utility functions.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 2 Oct 2023 14:51:30 +0000 (10:51 -0400)]
NFSD: Restructure nfsd4_encode_create_session()
Convert nfsd4_encode_create_session() to use the conventional XDR
encoding utilities.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 2 Oct 2023 14:51:24 +0000 (10:51 -0400)]
NFSD: Add nfsd4_encode_channel_attr4()
De-duplicate the encoding of the fore channel and backchannel
attributes.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 2 Oct 2023 14:51:17 +0000 (10:51 -0400)]
NFSD: Add a utility function for encoding sessionid4 objects
There is more than one NFSv4 operation that needs to encode a
sessionid4, so extract that data type into a separate helper.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Fri, 29 Sep 2023 13:59:31 +0000 (09:59 -0400)]
NFSD: Clean up nfsd4_encode_open()
Finish cleaning up nfsd4_encode_open().
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Fri, 29 Sep 2023 13:59:24 +0000 (09:59 -0400)]
NFSD: Add nfsd4_encode_open_delegation4()
To better align our implementation with the XDR specification,
refactor the part of nfsd4_encode_open() that encodes delegation
metadata.
As part of that refactor, remove an unnecessary BUG() call site and
a comment that appears to be stale.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Fri, 29 Sep 2023 13:59:18 +0000 (09:59 -0400)]
NFSD: Add nfsd4_encode_open_none_delegation4()
To better align our implementation with the XDR specification,
refactor the part of nfsd4_encode_open() that encodes the
open_none_delegation4 type.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Fri, 29 Sep 2023 13:59:12 +0000 (09:59 -0400)]
NFSD: Add nfsd4_encode_open_write_delegation4()
Make it easier to adjust the XDR encoder to handle new features
related to write delegations.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Fri, 29 Sep 2023 13:59:05 +0000 (09:59 -0400)]
NFSD: Add nfsd4_encode_open_read_delegation4()
Refactor nfsd4_encode_open() so the open_read_delegation4 type is
encoded in a separate function. This makes it more straightforward
to later add support for returning an nfsace4 in OPEN responses that
offer a delegation.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Fri, 29 Sep 2023 13:58:59 +0000 (09:58 -0400)]
NFSD: Refactor nfsd4_encode_lock_denied()
Use the modern XDR utility functions.
The LOCK and LOCKT encoder functions need to return nfserr_denied
when a lock is denied, but nfsd4_encode_lock4denied() should return
a status code that is consistent with other XDR encoders.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Fri, 29 Sep 2023 13:58:53 +0000 (09:58 -0400)]
NFSD: Add nfsd4_encode_lock_owner4()
To improve readability and better align the LOCK encoders with the
XDR specification, add an explicit encoder named for the lock_owner4
type.
In particular, to avoid code duplication, use
nfsd4_encode_clientid4() to encode the clientid in the lock owner
rather than open-coding it.
It looks to me like nfs4_set_lock_denied() already clears the
clientid if it won't return an owner (cf: the nevermind: label). The
code in the XDR encoder appears to be redundant and can safely be
removed.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Thu, 12 Oct 2023 17:46:39 +0000 (13:46 -0400)]
NFSD: Remove a layering violation when encoding lock_denied
An XDR encoder is responsible for marshaling results, not releasing
memory that was allocated by the upper layer. We have .op_release
for that purpose.
Move the release of the ld_owner.data string to op_release functions
for LOCK and LOCKT.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 25 Sep 2023 13:28:23 +0000 (09:28 -0400)]
NFSD: Clean up nfsd4_encode_getdeviceinfo()
Adopt the conventional XDR utility functions. Also, restructure to
make the function align more closely with the spec -- there doesn't
seem to be a performance need for speciality code, so prioritize
readability.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 25 Sep 2023 13:28:17 +0000 (09:28 -0400)]
NFSD: Make @gdev parameter of ->encode_getdeviceinfo a const pointer
This enables callers to be passed const pointer parameters.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 25 Sep 2023 13:28:10 +0000 (09:28 -0400)]
NFSD: Clean up nfsd4_encode_layoutreturn()
Adopt the use of conventional XDR utility functions. Restructure
the encoder to better align with the XDR definition of the result.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 25 Sep 2023 13:28:04 +0000 (09:28 -0400)]
NFSD: Clean up nfsd4_encode_layoutcommit()
Adopt the use of conventional XDR utility functions. Restructure
the encoder to better align with the XDR definition of the result.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 25 Sep 2023 13:27:58 +0000 (09:27 -0400)]
NFSD: Clean up nfsd4_encode_layoutget()
De-duplicate the open-coded stateid4 encoder. Adopt the use of the
conventional current XDR encoding helpers. Refactor the encoder to
align with the XDR specification.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 25 Sep 2023 13:27:51 +0000 (09:27 -0400)]
NFSD: Make @lgp parameter of ->encode_layoutget a const pointer
This enables callers to be passed const pointer parameters.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 25 Sep 2023 13:27:45 +0000 (09:27 -0400)]
NFSD: Clean up nfsd4_encode_stateid()
Update the encoder function name to match the type name, as is the
convention with other such encoder utility functions, and with
nfsd4_decode_stateid4().
Make the @stateid argument a const so that callers of
nfsd4_encode_stateid4() in the future can be passed const pointers
to structures.
Since the compiler is allowed to add padding to structs, use the
wire (spec-defined) size when reserving buffer space.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 25 Sep 2023 13:27:38 +0000 (09:27 -0400)]
NFSD: Add nfsd4_encode_count4()
This is a synonym for nfsd4_encode_uint32_t() that matches the
name of the XDR type. It will get at least one more use in a
subsequent patch.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 14:02:18 +0000 (10:02 -0400)]
NFSD: Rename nfsd4_encode_fattr()
For better alignment with the specification, NFSD's encoder function
name should match the name of the XDR data type.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 14:02:12 +0000 (10:02 -0400)]
NFSD: Use a bitmask loop to encode FATTR4 results
The fattr4 encoder is now structured like the COMPOUND op encoder:
one function for each individual attribute, called by bit number.
Benefits include:
- The individual attributes are now guaranteed to be encoded in
bitmask order into the send buffer
- There can be no unwanted side effects between attribute encoders
- The code now clearly documents which attributes are /not/
implemented on this server
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 14:02:06 +0000 (10:02 -0400)]
NFSD: Copy FATTR4 bit number definitions from RFCs
I'd like to convert nfsd4_encode_fattr() to rotate through the
attrmask using for_each_bit() instead of explicitly testing the
bitmask for each bit value. This means I need the bit numbers, as
defined in the specs, instead of our internal bitmask constants.
As a clean up, use the new spec-derived values to define the WORD#
bitmask constants.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 14:01:59 +0000 (10:01 -0400)]
NFSD: Add nfsd4_encode_fattr4_xattr_support()
Refactor the encoder for FATTR4_XATTR_SUPPORT into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 14:01:53 +0000 (10:01 -0400)]
NFSD: Add nfsd4_encode_fattr4_sec_label()
Refactor the encoder for FATTR4_SEC_LABEL into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 14:01:47 +0000 (10:01 -0400)]
NFSD: Add nfsd4_encode_fattr4_suppattr_exclcreat()
Refactor the encoder for FATTR4_SUPPATTR_EXCLCREAT into a helper. In
a subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 14:01:40 +0000 (10:01 -0400)]
NFSD: Add nfsd4_encode_fattr4_layout_blksize()
Refactor the encoder for FATTR4_LAYOUT_BLKSIZE into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 14:01:34 +0000 (10:01 -0400)]
NFSD: Add nfsd4_encode_fattr4_layout_types()
Refactor the encoder for FATTR4_LAYOUT_TYPES into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 14:01:28 +0000 (10:01 -0400)]
NFSD: Add nfsd4_encode_fattr4_fs_layout_types()
Refactor the encoder for FATTR4_FS_LAYOUT_TYPES into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 14:01:21 +0000 (10:01 -0400)]
NFSD: Add nfsd4_encode_fattr4_mounted_on_fileid()
Refactor the encoder for FATTR4_MOUNTED_ON_FILEID into a helper. In
a subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 14:01:15 +0000 (10:01 -0400)]
NFSD: Add nfsd4_encode_fattr4_time_modify()
Refactor the encoder for FATTR4_TIME_MODIFY into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 14:01:09 +0000 (10:01 -0400)]
NFSD: Add nfsd4_encode_fattr4_time_metadata()
Refactor the encoder for FATTR4_TIME_METADATA into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 14:01:02 +0000 (10:01 -0400)]
NFSD: Add nfsd4_encode_fattr4_time_delta()
Refactor the encoder for FATTR4_TIME_DELTA into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
fattr4_time_delta is specified as an nfstime4, so de-duplicate this
encoder.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 14:00:56 +0000 (10:00 -0400)]
NFSD: Add nfsd4_encode_fattr4_time_create()
Refactor the encoder for FATTR4_TIME_CREATE into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 14:00:50 +0000 (10:00 -0400)]
NFSD: Add nfsd4_encode_fattr4_time_access()
Refactor the encoder for FATTR4_TIME_ACCESS into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 14:00:43 +0000 (10:00 -0400)]
NFSD: Add nfsd4_encode_fattr4_space_used()
Refactor the encoder for FATTR4_SPACE_USED into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 14:00:37 +0000 (10:00 -0400)]
NFSD: Add nfsd4_encode_fattr4_space_total()
Refactor the encoder for FATTR4_SPACE_TOTAL into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 14:00:30 +0000 (10:00 -0400)]
NFSD: Add nfsd4_encode_fattr4_space_free()
Refactor the encoder for FATTR4_SPACE_FREE into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 14:00:24 +0000 (10:00 -0400)]
NFSD: Add nfsd4_encode_fattr4_space_avail()
Refactor the encoder for FATTR4_SPACE_AVAIL into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 14:00:18 +0000 (10:00 -0400)]
NFSD: Add nfsd4_encode_fattr4_rawdev()
Refactor the encoder for FATTR4_RAWDEV into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 14:00:11 +0000 (10:00 -0400)]
NFSD: Add nfsd4_encode_fattr4_owner_group()
Refactor the encoder for FATTR4_OWNER_GROUP into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 14:00:05 +0000 (10:00 -0400)]
NFSD: Add nfsd4_encode_fattr4_owner()
Refactor the encoder for FATTR4_OWNER into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:59:59 +0000 (09:59 -0400)]
NFSD: Add nfsd4_encode_fattr4_numlinks()
Refactor the encoder for FATTR4_NUMLINKS into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:59:52 +0000 (09:59 -0400)]
NFSD: Add nfsd4_encode_fattr4_mode()
Refactor the encoder for FATTR4_MODE into a helper. In a subsequent
patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:59:46 +0000 (09:59 -0400)]
NFSD: Add nfsd4_encode_fattr4_maxwrite()
Refactor the encoder for FATTR4_MAXWRITE into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:59:39 +0000 (09:59 -0400)]
NFSD: Add nfsd4_encode_fattr4_maxread()
Refactor the encoder for FATTR4_MAXREAD into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:59:33 +0000 (09:59 -0400)]
NFSD: Add nfsd4_encode_fattr4_maxname()
Refactor the encoder for FATTR4_MAXNAME into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:59:27 +0000 (09:59 -0400)]
NFSD: Add nfsd4_encode_fattr4_maxlink()
Refactor the encoder for FATTR4_MAXLINK into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:59:20 +0000 (09:59 -0400)]
NFSD: Add nfsd4_encode_fattr4_maxfilesize()
Refactor the encoder for FATTR4_MAXFILESIZE into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:59:14 +0000 (09:59 -0400)]
NFSD: Add nfsd4_encode_fattr4_fs_locations()
Refactor the encoder for FATTR4_FS_LOCATIONS into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:59:08 +0000 (09:59 -0400)]
NFSD: Add nfsd4_encode_fattr4_files_total()
Refactor the encoder for FATTR4_FILES_TOTAL into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:59:01 +0000 (09:59 -0400)]
NFSD: Add nfsd4_encode_fattr4_files_free()
Refactor the encoder for FATTR4_FILES_FREE into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:58:55 +0000 (09:58 -0400)]
NFSD: Add nfsd4_encode_fattr4_files_avail()
Refactor the encoder for FATTR4_FILES_AVAIL into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:58:49 +0000 (09:58 -0400)]
NFSD: Add nfsd4_encode_fattr4_fileid()
Refactor the encoder for FATTR4_FILEID into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:58:42 +0000 (09:58 -0400)]
NFSD: Add nfsd4_encode_fattr4_filehandle()
Refactor the encoder for FATTR4_FILEHANDLE into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
We can de-duplicate the other filehandle encoder (in GETFH) using
our new helper.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:58:36 +0000 (09:58 -0400)]
NFSD: Add nfsd4_encode_fattr4_acl()
Refactor the encoder for FATTR4_ACL into a helper. In a subsequent
patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:58:30 +0000 (09:58 -0400)]
NFSD: Add nfsd4_encode_nfsace4()
Refactor the ACE encoding helper so that it can eventually be reused
for encoding OPEN results that contain delegation ACEs.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:58:23 +0000 (09:58 -0400)]
NFSD: Add nfsd4_encode_fattr4_aclsupport()
Refactor the encoder for FATTR4_ACLSUPPORT into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:58:17 +0000 (09:58 -0400)]
NFSD: Add nfsd4_encode_fattr4_rdattr_error()
Refactor the encoder for FATTR4_RDATTR_ERROR into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:58:10 +0000 (09:58 -0400)]
NFSD: Add nfsd4_encode_fattr4_lease_time()
Refactor the encoder for FATTR4_LEASE_TIME into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:58:04 +0000 (09:58 -0400)]
NFSD: Add nfsd4_encode_fattr4_fsid()
Refactor the encoder for FATTR4_FSID into a helper. In a subsequent
patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:57:58 +0000 (09:57 -0400)]
NFSD: Add nfsd4_encode_fattr4_size()
Refactor the encoder for FATTR4_SIZE into a helper. In a subsequent
patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:57:51 +0000 (09:57 -0400)]
NFSD: Add nfsd4_encode_fattr4_change()
Refactor the encoder for FATTR4_CHANGE into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
The code is restructured a bit to use the modern xdr_stream flow,
and the encoded cinfo value is made const so that callers of the
encoders can be passed a const cinfo.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:57:45 +0000 (09:57 -0400)]
NFSD: Add nfsd4_encode_fattr4_fh_expire_type()
Refactor the encoder for FATTR4_FH_EXPIRE_TYPE into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:57:39 +0000 (09:57 -0400)]
NFSD: Add nfsd4_encode_fattr4_type()
Refactor the encoder for FATTR4_TYPE into a helper. In a subsequent
patch, this helper will be called from a bitmask loop.
In addition, restructure the code so that byte-swapping is done on
constant values rather than at run time. Run-time swapping can be
costly on some platforms, and "type" is a frequently-requested
attribute.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:57:32 +0000 (09:57 -0400)]
NFSD: Add nfsd4_encode_fattr4_supported_attrs()
Refactor the encoder for FATTR4_SUPPORTED_ATTRS into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:57:26 +0000 (09:57 -0400)]
NFSD: Add nfsd4_encode_fattr4__false()
Add an encoding helper that encodes a single boolean "false" value.
Attributes that always return "false" can use this helper.
In a subsequent patch, this helper will be called from a bitmask
loop, so it is given a standardized synopsis.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:57:19 +0000 (09:57 -0400)]
NFSD: Add nfsd4_encode_fattr4__true()
Add an encoding helper that encodes a single boolean "true" value.
Attributes that always return "true" can use this helper.
In a subsequent patch, this helper will be called from a bitmask
loop, so it is given a standardized synopsis.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:57:13 +0000 (09:57 -0400)]
NFSD: Add struct nfsd4_fattr_args
I'm about to split nfsd4_encode_fattr() into a number of smaller
functions. Instead of passing a large number of arguments to each of
the smaller functions, create a struct that can gather the common
argument variables into something with a convenient handle on it.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:57:07 +0000 (09:57 -0400)]
NFSD: Clean up nfsd4_encode_setattr()
De-duplicate the encoding of bitmap4 results in
nfsd4_encode_setattr().
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:57:00 +0000 (09:57 -0400)]
NFSD: Rename nfsd4_encode_bitmap()
For alignment with the specification, the name of NFSD's encoder
function should match the name of the XDR type.
I've also replaced a few "naked integers" with symbolic constants
that better reflect the usage of these values.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Mon, 18 Sep 2023 13:56:54 +0000 (09:56 -0400)]
NFSD: Add simple u32, u64, and bool encoders
The generic XDR encoders return a length or a negative errno. NFSv4
encoders want to know simply whether the encode ran out of stream
buffer space. The return values for server-side encoding are either
nfs_ok or nfserr_resource.
So far I've found it adds a lot of duplicate code to try to use the
generic XDR encoder utilities when encoding the simple data types in
the NFSv4 operation encoders.
Add a set of NFSv4-specific utilities that handle the basic XDR data
types. These are added in xdr4.h so they might eventually be used by
the callback server and pNFS driver encoders too.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Tue, 19 Sep 2023 15:35:15 +0000 (11:35 -0400)]
SUNRPC: Remove BUG_ON call sites
There is no need to take down the whole system for these assertions.
I'd rather not attempt a heroic save here, as some bug has occurred
that has left the transport data structures in an unknown state.
Just warn and then leak the left-over resources.
Acked-by: Christian Brauner <brauner@kernel.org>
Reviewed-by: NeilBrown <neilb@suse.de>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Kinglong Mee [Mon, 18 Sep 2023 06:59:06 +0000 (14:59 +0800)]
nfs: fix the typo of rfc number about xattr in NFSv4
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Chuck Lever [Thu, 5 Oct 2023 12:41:20 +0000 (08:41 -0400)]
tools: ynl: Add source files for nfsd netlink protocol
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>