summaryrefslogtreecommitdiff
path: root/fs/nfsd/nfs3xdr.c
AgeCommit message (Collapse)Author
2022-09-26NFSD: Clean up WRITE arg decodersChuck Lever
xdr_stream_subsegment() already returns a boolean value. Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2022-09-26NFSD: Use xdr_inline_decode() to decode NFSv3 symlinksChuck Lever
Replace the check for buffer over/underflow with a helper that is commonly used for this purpose. The helper also sets xdr->nwords correctly after successfully linearizing the symlink argument into the stream's scratch buffer. Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2022-02-09NFSD: Deprecate NFS_OFFSET_MAXChuck Lever
NFS_OFFSET_MAX was introduced way back in Linux v2.3.y before there was a kernel-wide OFFSET_MAX value. As a clean up, replace the last few uses of it with its generic equivalent, and get rid of it. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2022-02-09NFSD: Fix NFSv3 SETATTR/CREATE's handling of large file sizesChuck Lever
iattr::ia_size is a loff_t, so these NFSv3 procedures must be careful to deal with incoming client size values that are larger than s64_max without corrupting the value. Silently capping the value results in storing a different value than the client passed in which is unexpected behavior, so remove the min_t() check in decode_sattr3(). Note that RFC 1813 permits only the WRITE procedure to return NFS3ERR_FBIG. We believe that NFSv3 reference implementations also return NFS3ERR_FBIG when ia_size is too large. Cc: stable@vger.kernel.org Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2022-01-08NFSD: Move fill_pre_wcc() and fill_post_wcc()Chuck Lever
These functions are related to file handle processing and have nothing to do with XDR encoding or decoding. Also they are no longer NFSv3-specific. As a clean-up, move their definitions to a more appropriate location. WCC is also an NFSv3-specific term, so rename them as general-purpose helpers. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2022-01-08Revert "nfsd: skip some unnecessary stats in the v4 case"Chuck Lever
On the wire, I observed NFSv4 OPEN(CREATE) operations sometimes returning a reasonable-looking value in the cinfo.before field and zero in the cinfo.after field. RFC 8881 Section 10.8.1 says: > When a client is making changes to a given directory, it needs to > determine whether there have been changes made to the directory by > other clients. It does this by using the change attribute as > reported before and after the directory operation in the associated > change_info4 value returned for the operation. and > ... The post-operation change > value needs to be saved as the basis for future change_info4 > comparisons. A good quality client implementation therefore saves the zero cinfo.after value. During a subsequent OPEN operation, it will receive a different non-zero value in the cinfo.before field for that directory, and it will incorrectly believe the directory has changed, triggering an undesirable directory cache invalidation. There are filesystem types where fs_supports_change_attribute() returns false, tmpfs being one. On NFSv4 mounts, this means the fh_getattr() call site in fill_pre_wcc() and fill_post_wcc() is never invoked. Subsequently, nfsd4_change_attribute() is invoked with an uninitialized @stat argument. In fill_pre_wcc(), @stat contains stale stack garbage, which is then placed on the wire. In fill_post_wcc(), ->fh_post_wc is all zeroes, so zero is placed on the wire. Both of these values are meaningless. This fix can be applied immediately to stable kernels. Once there are more regression tests in this area, this optimization can be attempted again. Fixes: 428a23d2bf0c ("nfsd: skip some unnecessary stats in the v4 case") Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-10-13SUNRPC: Change return value type of .pc_encodeChuck Lever
Returning an undecorated integer is an age-old trope, but it's not clear (even to previous experts in this code) that the only valid return values are 1 and 0. These functions do not return a negative errno, rpc_stat value, or a positive length. Document there are only two valid return values by having .pc_encode return only true or false. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
2021-10-13SUNRPC: Replace the "__be32 *p" parameter to .pc_encodeChuck Lever
The passed-in value of the "__be32 *p" parameter is now unused in every server-side XDR encoder, and can be removed. Note also that there is a line in each encoder that sets up a local pointer to a struct xdr_stream. Passing that pointer from the dispatcher instead saves one line per encoder function. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
2021-10-13SUNRPC: Change return value type of .pc_decodeChuck Lever
Returning an undecorated integer is an age-old trope, but it's not clear (even to previous experts in this code) that the only valid return values are 1 and 0. These functions do not return a negative errno, rpc_stat value, or a positive length. Document there are only two valid return values by having .pc_decode return only true or false. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
2021-10-13SUNRPC: Replace the "__be32 *p" parameter to .pc_decodeChuck Lever
The passed-in value of the "__be32 *p" parameter is now unused in every server-side XDR decoder, and can be removed. Note also that there is a line in each decoder that sets up a local pointer to a struct xdr_stream. Passing that pointer from the dispatcher instead saves one line per decoder function. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
2021-10-02NFSD: Have legacy NFSD WRITE decoders use xdr_stream_subsegment()Chuck Lever
Refactor. Now that the NFSv2 and NFSv3 XDR decoders have been converted to use xdr_streams, the WRITE decoder functions can use xdr_stream_subsegment() to extract the WRITE payload into its own xdr_buf, just as the NFSv4 WRITE XDR decoder currently does. That makes it possible to pass the first kvec, pages array + length, page_base, and total payload length via a single function parameter. The payload's page_base is not yet assigned or used, but will be in subsequent patches. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
2021-10-02NFSD: simplify struct nfsfhNeilBrown
Most of the fields in 'struct knfsd_fh' are 2 levels deep (a union and a struct) and are accessed using macros like: #define fh_FOO fh_base.fh_new.fb_FOO This patch makes the union and struct anonymous, so that "fh_FOO" can be a name directly within 'struct knfsd_fh' and the #defines aren't needed. The file handle as a whole is sometimes accessed as "fh_base" or "fh_base.fh_pad", neither of which are particularly helpful names. As the struct holding the filehandle is now anonymous, we cannot use the name of that, so we union it with 'fh_raw' and use that where the raw filehandle is needed. fh_raw also ensure the structure is large enough for the largest possible filehandle. fh_raw is a 'char' array, removing any need to cast it for memcpy etc. SVCFH_fmt() is simplified using the "%ph" printk format. This changes the appearance of filehandles in dprintk() debugging, making them a little more precise. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
2021-03-22NFSD: Clean up NFSDDBG_FACILITY macroChuck Lever
These are no longer needed because there are no dprintk() call sites in these files. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-03-22NFSD: Clean up after updating NFSv3 ACL encodersChuck Lever
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-03-22NFSD: Update the NFSv3 GETACL result encoder to use struct xdr_streamChuck Lever
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-03-22NFSD: Remove unused NFSv3 directory entry encodersChuck Lever
Clean up. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-03-22NFSD: Update NFSv3 READDIR entry encoders to use struct xdr_streamChuck Lever
The benefit of the xdr_stream helpers is that they transparently handle encoding an XDR data item that crosses page boundaries. Most of the open-coded logic to do that here can be eliminated. A sub-buffer and sub-stream are set up as a sink buffer for the directory entry encoder. As an entry is encoded, it is added to the end of the content in this buffer/stream. The total length of the directory list is tracked in the buffer's @len field. When it comes time to encode the Reply, the sub-buffer is merged into rq_res's page array at the correct place using xdr_write_pages(). Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-03-22NFSD: Update the NFSv3 READDIR3res encoder to use struct xdr_streamChuck Lever
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-03-22NFSD: Count bytes instead of pages in the NFSv3 READDIR encoderChuck Lever
Clean up: Counting the bytes used by each returned directory entry seems less brittle to me than trying to measure consumed pages after the fact. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-03-22NFSD: Add a helper that encodes NFSv3 directory offset cookiesChuck Lever
Refactor: De-duplicate identical code that handles encoding of directory offset cookies across page boundaries. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-03-22NFSD: Update the NFSv3 COMMIT3res encoder to use struct xdr_streamChuck Lever
As an additional clean up, encode_wcc_data() is removed because it is now no longer used. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-03-22NFSD: Update the NFSv3 PATHCONF3res encoder to use struct xdr_streamChuck Lever
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-03-22NFSD: Update the NFSv3 FSINFO3res encoder to use struct xdr_streamChuck Lever
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-03-22NFSD: Update the NFSv3 FSSTAT3res encoder to use struct xdr_streamChuck Lever
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-03-22NFSD: Update the NFSv3 LINK3res encoder to use struct xdr_streamChuck Lever
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-03-22NFSD: Update the NFSv3 RENAMEv3res encoder to use struct xdr_streamChuck Lever
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-03-22NFSD: Update the NFSv3 CREATE family of encoders to use struct xdr_streamChuck Lever
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-03-22NFSD: Update the NFSv3 WRITE3res encoder to use struct xdr_streamChuck Lever
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-03-22NFSD: Update the NFSv3 READ3res encode to use struct xdr_streamChuck Lever
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-03-22NFSD: Update the NFSv3 READLINK3res encoder to use struct xdr_streamChuck Lever
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-03-22NFSD: Update the NFSv3 wccstat result encoder to use struct xdr_streamChuck Lever
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-03-22NFSD: Update the NFSv3 LOOKUP3res encoder to use struct xdr_streamChuck Lever
Also, clean up: Rename the encoder function to match the name of the result structure in RFC 1813, consistent with other encoder function names in nfs3xdr.c. "diropres" is an NFSv2 thingie. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-03-22NFSD: Update the NFSv3 ACCESS3res encoder to use struct xdr_streamChuck Lever
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-03-22NFSD: Update the GETATTR3res encoder to use struct xdr_streamChuck Lever
As an additional clean up, some renaming is done to more closely reflect the data type and variable names used in the NFSv3 XDR definition provided in RFC 1813. "attrstat" is an NFSv2 thingie. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-01-30nfsd: skip some unnecessary stats in the v4 caseJ. Bruce Fields
In the typical case of v4 and an i_version-supporting filesystem, we can skip a stat which is only required to fake up a change attribute from ctime. Signed-off-by: J. Bruce Fields <bfields@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-01-25NFSD: Clean up after updating NFSv3 ACL decodersChuck Lever
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-01-25NFSD: Update the NFSv3 GETACL argument decoder to use struct xdr_streamChuck Lever
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-01-25NFSD: Update the MKNOD3args decoder to use struct xdr_streamChuck Lever
This commit removes the last usage of the original decode_sattr3(), so it is removed as a clean-up. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-01-25NFSD: Update the SYMLINK3args decoder to use struct xdr_streamChuck Lever
Similar to the WRITE decoder, code that checks the sanity of the payload size is re-wired to work with xdr_stream infrastructure. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-01-25NFSD: Update the MKDIR3args decoder to use struct xdr_streamChuck Lever
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-01-25NFSD: Update the CREATE3args decoder to use struct xdr_streamChuck Lever
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-01-25NFSD: Update the SETATTR3args decoder to use struct xdr_streamChuck Lever
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-01-25NFSD: Update the LINK3args decoder to use struct xdr_streamChuck Lever
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-01-25NFSD: Update the RENAME3args decoder to use struct xdr_streamChuck Lever
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-01-25NFSD: Update the NFSv3 DIROPargs decoder to use struct xdr_streamChuck Lever
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-01-25NFSD: Update COMMIT3arg decoder to use struct xdr_streamChuck Lever
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-01-25NFSD: Update READDIR3args decoders to use struct xdr_streamChuck Lever
As an additional clean up, neither nfsd3_proc_readdir() nor nfsd3_proc_readdirplus() make use of the dircount argument, so remove it from struct nfsd3_readdirargs. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-01-25NFSD: Add helper to set up the pages where the dirlist is encodedChuck Lever
De-duplicate some code that is used by both READDIR and READDIRPLUS to build the dirlist in the Reply. Because this code is not related to decoding READ arguments, it is moved to a more appropriate spot. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-01-25NFSD: Update READLINK3arg decoder to use struct xdr_streamChuck Lever
The NFSv3 READLINK request takes a single filehandle, so it can re-use GETATTR's decoder. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2021-01-25NFSD: Update WRITE3arg decoder to use struct xdr_streamChuck Lever
As part of the update, open code that sanity-checks the size of the data payload against the length of the RPC Call message has to be re-implemented to use xdr_stream infrastructure. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>