summaryrefslogtreecommitdiff
path: root/fs/nfsd/nfs3xdr.c
Commit message (Collapse)AuthorAgeFilesLines
* SUNRPC: Change return value type of .pc_encodeChuck Lever2021-10-131-83/+83
| | | | | | | | | | | | | 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>
* SUNRPC: Replace the "__be32 *p" parameter to .pc_encodeChuck Lever2021-10-131-30/+16
| | | | | | | | | | | | 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>
* SUNRPC: Change return value type of .pc_decodeChuck Lever2021-10-131-59/+59
| | | | | | | | | | | | | 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>
* SUNRPC: Replace the "__be32 *p" parameter to .pc_decodeChuck Lever2021-10-131-30/+15
| | | | | | | | | | | | 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>
* NFSD: Have legacy NFSD WRITE decoders use xdr_stream_subsegment()Chuck Lever2021-10-021-10/+2
| | | | | | | | | | | | | | | | | | 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>
* NFSD: simplify struct nfsfhNeilBrown2021-10-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* NFSD: Clean up NFSDDBG_FACILITY macroChuck Lever2021-03-221-3/+0
| | | | | | | These are no longer needed because there are no dprintk() call sites in these files. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Clean up after updating NFSv3 ACL encodersChuck Lever2021-03-221-86/+0
| | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Update the NFSv3 GETACL result encoder to use struct xdr_streamChuck Lever2021-03-221-2/+21
| | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Remove unused NFSv3 directory entry encodersChuck Lever2021-03-221-190/+0
| | | | | | Clean up. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Update NFSv3 READDIR entry encoders to use struct xdr_streamChuck Lever2021-03-221-12/+154
| | | | | | | | | | | | | | | | | 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>
* NFSD: Update the NFSv3 READDIR3res encoder to use struct xdr_streamChuck Lever2021-03-221-19/+35
| | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Count bytes instead of pages in the NFSv3 READDIR encoderChuck Lever2021-03-221-0/+1
| | | | | | | | 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>
* NFSD: Add a helper that encodes NFSv3 directory offset cookiesChuck Lever2021-03-221-13/+23
| | | | | | | Refactor: De-duplicate identical code that handles encoding of directory offset cookies across page boundaries. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Update the NFSv3 COMMIT3res encoder to use struct xdr_streamChuck Lever2021-03-221-39/+15
| | | | | | | 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>
* NFSD: Update the NFSv3 PATHCONF3res encoder to use struct xdr_streamChuck Lever2021-03-221-11/+33
| | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Update the NFSv3 FSINFO3res encoder to use struct xdr_streamChuck Lever2021-03-221-16/+46
| | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Update the NFSv3 FSSTAT3res encoder to use struct xdr_streamChuck Lever2021-03-221-14/+44
| | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Update the NFSv3 LINK3res encoder to use struct xdr_streamChuck Lever2021-03-221-4/+4
| | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Update the NFSv3 RENAMEv3res encoder to use struct xdr_streamChuck Lever2021-03-221-4/+4
| | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Update the NFSv3 CREATE family of encoders to use struct xdr_streamChuck Lever2021-03-221-7/+28
| | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Update the NFSv3 WRITE3res encoder to use struct xdr_streamChuck Lever2021-03-221-8/+32
| | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Update the NFSv3 READ3res encode to use struct xdr_streamChuck Lever2021-03-221-20/+23
| | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Update the NFSv3 READLINK3res encoder to use struct xdr_streamChuck Lever2021-03-221-16/+18
| | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Update the NFSv3 wccstat result encoder to use struct xdr_streamChuck Lever2021-03-221-3/+65
| | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Update the NFSv3 LOOKUP3res encoder to use struct xdr_streamChuck Lever2021-03-221-8/+35
| | | | | | | | 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>
* NFSD: Update the NFSv3 ACCESS3res encoder to use struct xdr_streamChuck Lever2021-03-221-5/+45
| | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Update the GETATTR3res encoder to use struct xdr_streamChuck Lever2021-03-221-8/+87
| | | | | | | | 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>
* nfsd: skip some unnecessary stats in the v4 caseJ. Bruce Fields2021-01-301-17/+27
| | | | | | | | | | 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>
* NFSD: Clean up after updating NFSv3 ACL decodersChuck Lever2021-01-251-20/+0
| | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Update the NFSv3 GETACL argument decoder to use struct xdr_streamChuck Lever2021-01-251-1/+10
| | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Update the MKNOD3args decoder to use struct xdr_streamChuck Lever2021-01-251-72/+35
| | | | | | | 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>
* NFSD: Update the SYMLINK3args decoder to use struct xdr_streamChuck Lever2021-01-251-13/+16
| | | | | | | 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>
* NFSD: Update the MKDIR3args decoder to use struct xdr_streamChuck Lever2021-01-251-6/+4
| | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Update the CREATE3args decoder to use struct xdr_streamChuck Lever2021-01-251-10/+10
| | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Update the SETATTR3args decoder to use struct xdr_streamChuck Lever2021-01-251-17/+121
| | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Update the LINK3args decoder to use struct xdr_streamChuck Lever2021-01-251-6/+4
| | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Update the RENAME3args decoder to use struct xdr_streamChuck Lever2021-01-251-7/+5
| | | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Update the NFSv3 DIROPargs decoder to use struct xdr_streamChuck Lever2021-01-251-5/+35
| | | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Update COMMIT3arg decoder to use struct xdr_streamChuck Lever2021-01-251-5/+8
| | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Update READDIR3args decoders to use struct xdr_streamChuck Lever2021-01-251-14/+24
| | | | | | | | 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>
* NFSD: Add helper to set up the pages where the dirlist is encodedChuck Lever2021-01-251-20/+0
| | | | | | | | 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>
* NFSD: Update READLINK3arg decoder to use struct xdr_streamChuck Lever2021-01-251-13/+0
| | | | | | | 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>
* NFSD: Update WRITE3arg decoder to use struct xdr_streamChuck Lever2021-01-251-31/+20
| | | | | | | | 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>
* NFSD: Update READ3arg decoder to use struct xdr_streamChuck Lever2021-01-251-21/+7
| | | | | | | The code that sets up rq_vec is refactored so that it is now adjacent to the nfsd_read() call site where it is used. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Update ACCESS3arg decoder to use struct xdr_streamChuck Lever2021-01-251-4/+5
| | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* NFSD: Update GETATTR3args decoder to use struct xdr_streamChuck Lever2021-01-251-6/+25
| | | | | Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* nfsd4: readdirplus shouldn't return parent of exportJ. Bruce Fields2021-01-121-1/+6
| | | | | | | | | | | | | | | | | | | | | | If you export a subdirectory of a filesystem, a READDIRPLUS on the root of that export will return the filehandle of the parent with the ".." entry. The filehandle is optional, so let's just not return the filehandle for ".." if we're at the root of an export. Note that once the client learns one filehandle outside of the export, they can trivially access the rest of the export using further lookups. However, it is also not very difficult to guess filehandles outside of the export. So exporting a subdirectory of a filesystem should considered equivalent to providing access to the entire filesystem. To avoid confusion, we recommend only exporting entire filesystems. Reported-by: Youjipeng <wangzhibei1999@gmail.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com> Cc: stable@vger.kernel.org Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
* nfsd: add a new EXPORT_OP_NOWCC flag to struct export_operationsJeff Layton2020-12-091-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* nfsd4: don't query change attribute in v2/v3 caseJ. Bruce Fields2020-12-091-5/+9
| | | | | | | | | | | | 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>