summaryrefslogtreecommitdiffstats
path: root/fs/nfsd
Commit message (Collapse)AuthorAgeFilesLines
...
| * | NFSD: simplify error paths in nfsd_svc()NeilBrown2023-10-161-10/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Clean up nfsd4_encode_seek()Chuck Lever2023-10-161-6/+7
| | | | | | | | | | | | | | | | | | | | | Use modern XDR encoder utilities. Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * | NFSD: Clean up nfsd4_encode_offset_status()Chuck Lever2023-10-161-6/+7
| | | | | | | | | | | | | | | | | | | | | Use modern XDR encoder utilities. Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * | NFSD: Clean up nfsd4_encode_copy_notify()Chuck Lever2023-10-163-69/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Clean up nfsd4_encode_copy()Chuck Lever2023-10-161-39/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Clean up nfsd4_encode_test_stateid()Chuck Lever2023-10-161-10/+8
| | | | | | | | | | | | | | | | | | | | | Use conventional XDR utilities. Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * | NFSD: Clean up nfsd4_encode_exchange_id()Chuck Lever2023-10-161-55/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Clean up nfsd4_do_encode_secinfo()Chuck Lever2023-10-162-17/+40
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Clean up nfsd4_encode_access()Chuck Lever2023-10-161-7/+7
| | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Clean up nfsd4_encode_readdir()Chuck Lever2023-10-161-57/+55
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Clean up nfsd4_encode_entry4()Chuck Lever2023-10-162-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Add an nfsd4_encode_nfs_cookie4() helperChuck Lever2023-10-161-12/+20
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Clean up nfsd4_encode_rdattr_error()Chuck Lever2023-10-161-15/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Rename nfsd4_encode_dirent()Chuck Lever2023-10-161-8/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Clean up nfsd4_encode_sequence()Chuck Lever2023-10-162-12/+26
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Restructure nfsd4_encode_create_session()Chuck Lever2023-10-162-9/+13
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Add nfsd4_encode_channel_attr4()Chuck Lever2023-10-161-36/+44
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Add a utility function for encoding sessionid4 objectsChuck Lever2023-10-161-9/+16
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Clean up nfsd4_encode_open()Chuck Lever2023-10-161-7/+10
| | | | | | | | | | | | | | | | | | | | | Finish cleaning up nfsd4_encode_open(). Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
| * | NFSD: Add nfsd4_encode_open_delegation4()Chuck Lever2023-10-161-23/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Add nfsd4_encode_open_none_delegation4()Chuck Lever2023-10-161-18/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Add nfsd4_encode_open_write_delegation4()Chuck Lever2023-10-161-26/+33
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Add nfsd4_encode_open_read_delegation4()Chuck Lever2023-10-163-20/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Refactor nfsd4_encode_lock_denied()Chuck Lever2023-10-161-25/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Add nfsd4_encode_lock_owner4()Chuck Lever2023-10-161-10/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Remove a layering violation when encoding lock_deniedChuck Lever2023-10-164-26/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Clean up nfsd4_encode_getdeviceinfo()Chuck Lever2023-10-161-37/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Make @gdev parameter of ->encode_getdeviceinfo a const pointerChuck Lever2023-10-165-5/+5
| | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Clean up nfsd4_encode_layoutreturn()Chuck Lever2023-10-163-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Clean up nfsd4_encode_layoutcommit()Chuck Lever2023-10-163-16/+11
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Clean up nfsd4_encode_layoutget()Chuck Lever2023-10-162-18/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Make @lgp parameter of ->encode_layoutget a const pointerChuck Lever2023-10-165-8/+8
| | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Clean up nfsd4_encode_stateid()Chuck Lever2023-10-161-16/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Add nfsd4_encode_count4()Chuck Lever2023-10-162-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Rename nfsd4_encode_fattr()Chuck Lever2023-10-161-10/+13
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Use a bitmask loop to encode FATTR4 resultsChuck Lever2023-10-161-287/+146
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Add nfsd4_encode_fattr4_xattr_support()Chuck Lever2023-10-161-7/+12
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Add nfsd4_encode_fattr4_sec_label()Chuck Lever2023-10-161-9/+18
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Add nfsd4_encode_fattr4_suppattr_exclcreat()Chuck Lever2023-10-161-8/+15
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Add nfsd4_encode_fattr4_layout_blksize()Chuck Lever2023-10-161-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Add nfsd4_encode_fattr4_layout_types()Chuck Lever2023-10-161-20/+19
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Add nfsd4_encode_fattr4_fs_layout_types()Chuck Lever2023-10-161-1/+23
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Add nfsd4_encode_fattr4_mounted_on_fileid()Chuck Lever2023-10-161-17/+22
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Add nfsd4_encode_fattr4_time_modify()Chuck Lever2023-10-161-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Add nfsd4_encode_fattr4_time_metadata()Chuck Lever2023-10-161-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Add nfsd4_encode_fattr4_time_delta()Chuck Lever2023-10-161-29/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Add nfsd4_encode_fattr4_time_create()Chuck Lever2023-10-161-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Add nfsd4_encode_fattr4_time_access()Chuck Lever2023-10-161-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Add nfsd4_encode_fattr4_space_used()Chuck Lever2023-10-161-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | NFSD: Add nfsd4_encode_fattr4_space_total()Chuck Lever2023-10-161-5/+11
| | | | | | | | | | | | | | | | | | | | | | | | 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>