Commit graph

600 commits

Author SHA1 Message Date
Chuck Lever
09208e9832 NFSD: Update the NFSv2 ACL ACCESS result encoder to use struct xdr_stream
[ Upstream commit 07f5c2963c04b11603e9667f89bb430c132e9cc1 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:35 +01:00
Chuck Lever
2409a1fbd9 NFSD: Update the NFSv2 ACL GETATTR result encoder to use struct xdr_stream
[ Upstream commit 8d2009a10b3abaa12a39deb4876b215714993fe8 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:35 +01:00
Chuck Lever
506998455c NFSD: Update the NFSv2 SETACL result encoder to use struct xdr_stream
[ Upstream commit 778f068fa0c0846b650ebdb8795fd51b5badc332 ]

The SETACL result encoder is exactly the same as the NFSv2
attrstatres decoder.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:35 +01:00
Chuck Lever
1f70d81dcf NFSD: Update the NFSv2 GETACL result encoder to use struct xdr_stream
[ Upstream commit f8cba47344f794b54373189bec23195b51020faf ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:35 +01:00
Chuck Lever
b6b773d33f NFSD: Remove unused NFSv2 directory entry encoders
[ Upstream commit 8a2cf9f5709cc20a1114a7d22655928314fc86f8 ]

Clean up.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:35 +01:00
Chuck Lever
c750724716 NFSD: Update the NFSv2 READDIR entry encoder to use struct xdr_stream
[ Upstream commit f5dcccd647da513a89f3b6ca392b0c1eb050b9fc ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:35 +01:00
Chuck Lever
6c4d316ef4 NFSD: Update the NFSv2 READDIR result encoder to use struct xdr_stream
[ Upstream commit 94c8f8c682a6497af7ea71351b18f637c6337d42 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:35 +01:00
Chuck Lever
adec3bc3b2 NFSD: Count bytes instead of pages in the NFSv2 READDIR encoder
[ Upstream commit 8141d6a2bb6c655ff0c0b81ced80d9025f03e926 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:35 +01:00
Chuck Lever
027123af6d NFSD: Add a helper that encodes NFSv3 directory offset cookies
[ Upstream commit d52532002ffa217ad3fa4c3ba86c95203d21dd21 ]

Refactor: Add helper function similar to nfs3svc_encode_cookie3().

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:35 +01:00
Chuck Lever
0379d2419a NFSD: Update the NFSv2 STATFS result encoder to use struct xdr_stream
[ Upstream commit bf15229f2ced4f14946eef958336f764e30f8efb ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:34 +01:00
Chuck Lever
9b4dc4f022 NFSD: Update the NFSv2 READ result encoder to use struct xdr_stream
[ Upstream commit a6f8d9dc9e44b51303d9abde4643460137d19b28 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:34 +01:00
Chuck Lever
12000cd126 NFSD: Update the NFSv2 READLINK result encoder to use struct xdr_stream
[ Upstream commit d9014b0f8fae11f22a3d356553844e06ddcdce4a ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:34 +01:00
Chuck Lever
6b2ab70994 NFSD: Update the NFSv2 diropres encoder to use struct xdr_stream
[ Upstream commit e3b4ef221ac57c08341c97a10c8a81c041f76716 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:34 +01:00
Chuck Lever
991b778b3a NFSD: Update the NFSv2 attrstat encoder to use struct xdr_stream
[ Upstream commit 92b54a4fa4224e6116eb0d87a39dd05af23fcdfa ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:34 +01:00
Chuck Lever
9e9a3adf4a NFSD: Update the NFSv2 stat encoder to use struct xdr_stream
[ Upstream commit a887eaed2a964754334cd3f8c5fe87e413e68fef ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:34 +01:00
Chuck Lever
bf746ce977 NFSD: Reduce svc_rqst::rq_pages churn during READDIR operations
[ Upstream commit 76ed0dd96eeb2771b21bf5dcbd88326ef89ee0ed ]

During NFSv2 and NFSv3 READDIR/PLUS operations, NFSD advances
rq_next_page to the full size of the client-requested buffer, then
releases all those pages at the end of the request. The next request
to use that nfsd thread has to refill the pages.

NFSD does this even when the dirlist in the reply is small. With
NFSv3 clients that send READDIR operations with large buffer sizes,
that can be 256 put_page/alloc_page pairs per READDIR request, even
though those pages often remain unused.

We can save some work by not releasing dirlist buffer pages that
were not used to form the READDIR Reply. I've left the NFSv2 code
alone since there are never more than three pages involved in an
NFSv2 READDIR Reply.

Eventually we should nail down why these pages need to be released
at all in order to avoid allocating and releasing pages
unnecessarily.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:34 +01:00
Chuck Lever
2415336d32 NFSD: Remove unused NFSv3 directory entry encoders
[ Upstream commit 1411934627f9fe31a36ac8c43179ce9b63edce5c ]

Clean up.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:34 +01:00
Chuck Lever
c6fa35a441 NFSD: Update NFSv3 READDIR entry encoders to use struct xdr_stream
[ Upstream commit 7f87fc2d34d475225e78b7f5c4eabb121f4282b2 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:34 +01:00
Chuck Lever
ebd915cf85 NFSD: Update the NFSv3 READDIR3res encoder to use struct xdr_stream
[ Upstream commit e4ccfe3014de435984939a3d84b7f241d3b57b0d ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:34 +01:00
Chuck Lever
1cf0ab7219 NFSD: Count bytes instead of pages in the NFSv3 READDIR encoder
[ Upstream commit a1409e2de4f11034c8eb30775cc3e37039a4ef13 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:34 +01:00
Chuck Lever
74e82961ae NFSD: Add a helper that encodes NFSv3 directory offset cookies
[ Upstream commit a161e6c76aeba835e475a2f27dbbe5c37e565e94 ]

Refactor: De-duplicate identical code that handles encoding of
directory offset cookies across page boundaries.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:34 +01:00
Chuck Lever
70b33c5fdb NFSD: Update the NFSv3 COMMIT3res encoder to use struct xdr_stream
[ Upstream commit 5ef2826c761079e27904c85034df34e601b82d94 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:34 +01:00
Chuck Lever
5d797a7434 NFSD: Update the NFSv3 PATHCONF3res encoder to use struct xdr_stream
[ Upstream commit ded04a587f6ceaaba3caefad4021f2212b46c9ff ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:34 +01:00
Chuck Lever
c730c58c76 NFSD: Update the NFSv3 FSINFO3res encoder to use struct xdr_stream
[ Upstream commit 0a139d1b7f327010acc36e8162936d3108c7addb ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:34 +01:00
Chuck Lever
791921849b NFSD: Update the NFSv3 FSSTAT3res encoder to use struct xdr_stream
[ Upstream commit 8b7044984fd6eeadf72285e3617116bd15e9e676 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:34 +01:00
Chuck Lever
f73ea84fca NFSD: Update the NFSv3 LINK3res encoder to use struct xdr_stream
[ Upstream commit 4d74380a446f75eebb2171687d9b8baf0025bdf1 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:34 +01:00
Chuck Lever
5cd3abdfee NFSD: Update the NFSv3 RENAMEv3res encoder to use struct xdr_stream
[ Upstream commit 89d79e9672dfa6d0cc416699c16f2d312da58ff2 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:33 +01:00
Chuck Lever
2f31aa3e49 NFSD: Update the NFSv3 CREATE family of encoders to use struct xdr_stream
[ Upstream commit 78315b36781d259dcbdc102ff22c3f2f25712223 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:33 +01:00
Chuck Lever
071f3e7c61 NFSD: Update the NFSv3 WRITE3res encoder to use struct xdr_stream
[ Upstream commit ecb7a085ac15a8844ebf12fca6ae51ce71ac9b3b ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:33 +01:00
Chuck Lever
5a2a508148 NFSD: Update the NFSv3 READ3res encode to use struct xdr_stream
[ Upstream commit cc9bcdad7773c295375e66c892c7ac00524706f2 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:33 +01:00
Chuck Lever
73f907895f NFSD: Update the NFSv3 READLINK3res encoder to use struct xdr_stream
[ Upstream commit 9a9c8923b3efd593d0e6a405efef9d58c6e6804b ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:33 +01:00
Chuck Lever
5b10023828 NFSD: Update the NFSv3 wccstat result encoder to use struct xdr_stream
[ Upstream commit 70f8e839859a994e324e1d18889f8319bbd5bff9 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:33 +01:00
Chuck Lever
68eefaa8dd NFSD: Update the NFSv3 LOOKUP3res encoder to use struct xdr_stream
[ Upstream commit 5cf353354af1a385f29dec4609a1532d32c83a25 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:33 +01:00
Chuck Lever
ed2796887b NFSD: Update the NFSv3 ACCESS3res encoder to use struct xdr_stream
[ Upstream commit 907c38227fb57f5c537491ca76dd0b9636029393 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:33 +01:00
Chuck Lever
36318a0ed9 NFSD: Update the GETATTR3res encoder to use struct xdr_stream
[ Upstream commit 2c42f804d30f6a8d86665eca84071b316821ea08 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:33 +01:00
Chuck Lever
3db89fe0db NFSD: Extract the svcxdr_init_encode() helper
[ Upstream commit bddfdbcddbe267519cd36aeb115fdf8620980111 ]

NFSD initializes an encode xdr_stream only after the RPC layer has
already inserted the RPC Reply header. Thus it behaves differently
than xdr_init_encode does, which assumes the passed-in xdr_buf is
entirely devoid of content.

nfs4proc.c has this server-side stream initialization helper, but
it is visible only to the NFSv4 code. Move this helper to a place
that can be accessed by NFSv2 and NFSv3 server XDR functions.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:33 +01:00
Christian Brauner
01eed6c908 namei: introduce struct renamedata
[ Upstream commit 9fe61450972d3900bffb1dc26a17ebb9cdd92db2 ]

In order to handle idmapped mounts we will extend the vfs rename helper
to take two new arguments in follow up patches. Since this operations
already takes a bunch of arguments add a simple struct renamedata and
make the current helper use it before we extend it.

Link: https://lore.kernel.org/r/20210121131959.646623-14-christian.brauner@ubuntu.com
Cc: Christoph Hellwig <hch@lst.de>
Cc: David Howells <dhowells@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
[ cel: backported to 5.10.y, prior to idmapped mounts ]
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:33 +01:00
J. Bruce Fields
3ecb34ecc2 nfsd: skip some unnecessary stats in the v4 case
[ Upstream commit 428a23d2bf0ca8fd4d364a464c3e468f0e81671e ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:32 +01:00
J. Bruce Fields
5666661a7e nfs: use change attribute for NFS re-exports
[ Upstream commit 3cc55f4434b421d37300aa9a167ace7d60b45ccf ]

When exporting NFS, we may as well use the real change attribute
returned by the original server instead of faking up a change attribute
from the ctime.

Note we can't do that by setting I_VERSION--that would also turn on the
logic in iversion.h which treats the lower bit specially, and that
doesn't make sense for NFS.

So instead we define a new export operation for filesystems like NFS
that want to manage the change attribute themselves.

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:32 +01:00
Dai Ngo
d2004ab4e4 NFSv4_2: SSC helper should use its own config.
[ Upstream commit 02591f9febd5f69bb4c266a4abf899c4cf21964f ]

Currently NFSv4_2 SSC helper, nfs_ssc, incorrectly uses GRACE_PERIOD
as its config. Fix by adding new config NFS_V4_2_SSC_HELPER which
depends on NFS_V4_2 and is automatically selected when NFSD_V4 is
enabled. Also removed the file name from a comment in nfs_ssc.c.

Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:32 +01:00
J. Bruce Fields
15b557992b nfsd: cstate->session->se_client -> cstate->clp
[ Upstream commit ec59659b4972ec25851aa03b4b5baba6764a62e4 ]

I'm not sure why we're writing this out the hard way in so many places.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:32 +01:00
J. Bruce Fields
14808d5e8d nfsd: simplify nfsd4_check_open_reclaim
[ Upstream commit 1722b04624806ced51693f546edb83e8b2297a77 ]

The set_client() was already taken care of by process_open1().

The comments here are mostly redundant with the code.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:32 +01:00
J. Bruce Fields
9a25007674 nfsd: remove unused set_client argument
[ Upstream commit f71475ba8c2a77fff8051903cf4b7d826c3d1693 ]

Every caller is setting this argument to false, so we don't need it.

Also cut this comment a bit and remove an unnecessary warning.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:32 +01:00
J. Bruce Fields
30a20ecc1b nfsd: find_cpntf_state cleanup
[ Upstream commit 47fdb22dacae78f37701d82a94c16a014186d34e ]

I think this unusual use of struct compound_state could cause confusion.

It's not that much more complicated just to open-code this stateid
lookup.

The only change in behavior should be a different error return in the
case the copy is using a source stateid that is a revoked delegation,
but I doubt that matters.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
[ cel: squashed in fix reported by Coverity ]
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:31 +01:00
J. Bruce Fields
794841da84 nfsd: refactor set_client
[ Upstream commit 7950b5316e40d99dcb85ab81a2d1dbb913d7c1c8 ]

This'll be useful elsewhere.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:31 +01:00
J. Bruce Fields
5204719478 nfsd: rename lookup_clientid->set_client
[ Upstream commit 460d27091ae2c23e7ac959a61cd481c58832db58 ]

I think this is a better name, and I'm going to reuse elsewhere the code
that does the lookup itself.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:31 +01:00
J. Bruce Fields
01b03fcec1 nfsd: simplify nfsd_renew
[ Upstream commit b4587eb2cf4b6271f67fb93b75f7de2a2026e853 ]

You can take the single-exit thing too far, I think.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:31 +01:00
J. Bruce Fields
238fe9021e nfsd: simplify process_lock
[ Upstream commit a9d53a75cf574d6aa41f3cb4968fffe4f64e0fad ]

Similarly, this STALE_CLIENTID check is already handled by:

nfs4_preprocess_confirmed_seqid_op()->
        nfs4_preprocess_seqid_op()->
                nfsd4_lookup_stateid()->
                        set_client()->
                                STALE_CLIENTID()

(This may cause it to return a different error in some cases where
there are multiple things wrong; pynfs test SEQ10 regressed on this
commit because of that, but I think that's the test's fault, and I've
fixed it separately.)

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:31 +01:00
J. Bruce Fields
6820e79873 nfsd4: simplify process_lookup1
[ Upstream commit 33311873adb0d55c287b164117b5b4bb7b1bdc40 ]

This STALE_CLIENTID check is redundant with the one in
lookup_clientid().

There's a difference in behavior is in case of memory allocation
failure, which I think isn't a big deal.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:31 +01:00
Amir Goldstein
7a838bc26d nfsd: report per-export stats
[ Upstream commit 20ad856e47323e208ae8d6a9ecfe5bf0be6f505e ]

Collect some nfsd stats per export in addition to the global stats.

A new nfsdfs export_stats file is created.  It uses the same ops as the
exports file to iterate the export entries and we use the file's name to
determine the reported info per export.  For example:

 $ cat /proc/fs/nfsd/export_stats
 # Version 1.1
 # Path Client Start-time
 #	Stats
 /test	localhost	92
	fh_stale: 0
	io_read: 9
	io_write: 1

Every export entry reports the start time when stats collection
started, so stats collecting scripts can know if stats where reset
between samples.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:31 +01:00
Amir Goldstein
5cc928db9c nfsd: protect concurrent access to nfsd stats counters
[ Upstream commit e567b98ce9a4b35b63c364d24828a9e5cd7a8179 ]

nfsd stats counters can be updated by concurrent nfsd threads without any
protection.

Convert some nfsd_stats and nfsd_net struct members to use percpu counters.

The longest_chain* members of struct nfsd_net remain unprotected.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:31 +01:00
Amir Goldstein
a5d723972f nfsd: remove unused stats counters
[ Upstream commit 1b76d1df1a3683b6b23cd1c813d13c5e6a9d35e5 ]

Commit 501cb1849f86 ("nfsd: rip out the raparms cache") removed the
code that updates read-ahead cache stats counters,
commit 8bbfa9f3889b ("knfsd: remove the nfsd thread busy histogram")
removed code that updates the thread busy stats counters back in 2009
and code that updated filehandle cache stats was removed back in 2002.

Remove the unused stats counters from nfsd_stats struct and print
hardcoded zeros in /proc/net/rpc/nfsd.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:31 +01:00
Chuck Lever
3d34960ddb NFSD: Clean up after updating NFSv3 ACL decoders
[ Upstream commit 9cee763ee654ce8622d673b8e32687d738e24ace ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:31 +01:00
Chuck Lever
d7e39a626f NFSD: Update the NFSv2 SETACL argument decoder to use struct xdr_stream
[ Upstream commit 68519ff2a1c72c67fcdc4b81671acda59f420af9 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:31 +01:00
Chuck Lever
367a75f550 NFSD: Update the NFSv3 GETACL argument decoder to use struct xdr_stream
[ Upstream commit 05027eafc266487c6e056d10ab352861df95b5d4 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:31 +01:00
Chuck Lever
2da089d28a NFSD: Clean up after updating NFSv2 ACL decoders
[ Upstream commit baadce65d6ee3032b921d9c043ba808bc69d6b13 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:31 +01:00
Chuck Lever
e95b18bb88 NFSD: Update the NFSv2 ACL ACCESS argument decoder to use struct xdr_stream
[ Upstream commit 64063892efc1daa3a48882673811ff327ba75ed5 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:31 +01:00
Chuck Lever
76807230a1 NFSD: Update the NFSv2 ACL GETATTR argument decoder to use struct xdr_stream
[ Upstream commit 571d31f37a57729c9d3463b5a692a84e619b408a ]

Since the ACL GETATTR procedure is the same as the normal GETATTR
procedure, simply re-use nfssvc_decode_fhandleargs.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:31 +01:00
Chuck Lever
48125c9dfe NFSD: Update the NFSv2 SETACL argument decoder to use struct xdr_stream
[ Upstream commit 427eab3ba22891845265f9a3846de6ac152ec836 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:31 +01:00
Chuck Lever
67e87fecaa NFSD: Update the NFSv2 GETACL argument decoder to use struct xdr_stream
[ Upstream commit 635a45d34706400c59c3b18ca9fccba195147bda ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:30 +01:00
Chuck Lever
54fc934afd NFSD: Remove argument length checking in nfsd_dispatch()
[ Upstream commit 5650682e16f41722f735b7beeb2dbc3411dfbeb6 ]

Now that the argument decoders for NFSv2 and NFSv3 use the
xdr_stream mechanism, the version-specific length checking logic in
nfsd_dispatch() is no longer necessary.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:30 +01:00
Chuck Lever
fa60fdae82 NFSD: Update the NFSv2 SYMLINK argument decoder to use struct xdr_stream
[ Upstream commit 09f75a5375ac61f4adb94da0accc1cfc60eb4f2b ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:30 +01:00
Chuck Lever
6a9bde4e9f NFSD: Update the NFSv2 CREATE argument decoder to use struct xdr_stream
[ Upstream commit 7dcf65b91ecaf60ce593e7859ae2b29b7c46ccbd ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:30 +01:00
Chuck Lever
846c00e1da NFSD: Update the NFSv2 SETATTR argument decoder to use struct xdr_stream
[ Upstream commit 2fdd6bd293b9e7dda61220538b2759fbf06f5af0 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:30 +01:00
Chuck Lever
42f9734887 NFSD: Update the NFSv2 LINK argument decoder to use struct xdr_stream
[ Upstream commit 77edcdf91f6245a9881b84e4e101738148bd039a ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:30 +01:00
Chuck Lever
600cb5c632 NFSD: Update the NFSv2 RENAME argument decoder to use struct xdr_stream
[ Upstream commit 62aa557efb81ea3339fabe7f5b1a343e742bbbdf ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:30 +01:00
Chuck Lever
3973346f7b NFSD: Update NFSv2 diropargs decoding to use struct xdr_stream
[ Upstream commit 6d742c1864c18f143ea2031f1ed66bcd8f4812de ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:30 +01:00
Chuck Lever
a157e4f21a NFSD: Update the NFSv2 READDIR argument decoder to use struct xdr_stream
[ Upstream commit 8688361ae2edb8f7e61d926dc5000c9a44f29370 ]

As an additional clean up, move code not related to XDR decoding
into readdir's .pc_func call out.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:30 +01:00
Chuck Lever
30d0fb860f NFSD: Add helper to set up the pages where the dirlist is encoded
[ Upstream commit 788cd46ecf83ee2d561cb4e754e276dc8089b787 ]

Add a helper similar to nfsd3_init_dirlist_pages().

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:30 +01:00
Chuck Lever
a6f42c646f NFSD: Update the NFSv2 READLINK argument decoder to use struct xdr_stream
[ Upstream commit 1fcbd1c9456ba129d38420e345e91c4b6363db47 ]

If the code that sets up the sink buffer for nfsd_readlink() is
moved adjacent to the nfsd_readlink() call site that uses it, then
the only argument is a file handle, and the fhandle decoder can be
used instead.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:30 +01:00
Chuck Lever
1aa33901b0 NFSD: Update the NFSv2 WRITE argument decoder to use struct xdr_stream
[ Upstream commit a51b5b737a0be93fae6ea2a18df03ab2359a3f4b ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:30 +01:00
Chuck Lever
a0c53cf707 NFSD: Update the NFSv2 READ argument decoder to use struct xdr_stream
[ Upstream commit 8c293ef993c8df0b1bea9ecb0de6eb96dec3ac9d ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:30 +01:00
Chuck Lever
25fd2ba100 NFSD: Update the NFSv2 GETATTR argument decoder to use struct xdr_stream
[ Upstream commit ebcd8e8b28535b643a4c06685bd363b3b73a96af ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:30 +01:00
Chuck Lever
49dee133c8 NFSD: Update the MKNOD3args decoder to use struct xdr_stream
[ Upstream commit f8a38e2d6c885f9d7cd03febc515d36293de4a5b ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:30 +01:00
Chuck Lever
0bc673e32a NFSD: Update the SYMLINK3args decoder to use struct xdr_stream
[ Upstream commit da39201637297460c13134c29286a00f3a1c92fe ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:29 +01:00
Chuck Lever
08ac11cca2 NFSD: Update the MKDIR3args decoder to use struct xdr_stream
[ Upstream commit 83374c278db193f3e8b2608b45da1132b867a760 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:29 +01:00
Chuck Lever
0112701439 NFSD: Update the CREATE3args decoder to use struct xdr_stream
[ Upstream commit 6b3a11960d898b25a30103cc6a2ff0b24b90a83b ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:29 +01:00
Chuck Lever
c591d746bf NFSD: Update the SETATTR3args decoder to use struct xdr_stream
[ Upstream commit 9cde9360d18d8b352b737d10f90f2aecccf93dbe ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:29 +01:00
Chuck Lever
b4501304c1 NFSD: Update the LINK3args decoder to use struct xdr_stream
[ Upstream commit efaa1e7c2c7475f0a9bbeb904d9aba09b73dd52a ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:29 +01:00
Chuck Lever
a22aea1a3f NFSD: Update the RENAME3args decoder to use struct xdr_stream
[ Upstream commit d181e0a4bef36ee74d1338e5b5c2561d7463a5d0 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:29 +01:00
Chuck Lever
a921f47270 NFSD: Update the NFSv3 DIROPargs decoder to use struct xdr_stream
[ Upstream commit 54d1d43dc709f58be38d278bfc38e9bfb38d35fc ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:29 +01:00
Chuck Lever
0047ce3f85 NFSD: Update COMMIT3arg decoder to use struct xdr_stream
[ Upstream commit c8d26a0acfe77f0880e0acfe77e4209cf8f3a38b ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:29 +01:00
Chuck Lever
3860dc70e0 NFSD: Update READDIR3args decoders to use struct xdr_stream
[ Upstream commit 9cedc2e64c296efb3bebe93a0ceeb5e71e8d722d ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:29 +01:00
Chuck Lever
9f3797bb38 NFSD: Add helper to set up the pages where the dirlist is encoded
[ Upstream commit 40116ebd0934cca7e46423bdb3397d3d27eb9fb9 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:29 +01:00
Chuck Lever
5eec1c89e7 NFSD: Fix returned READDIR offset cookie
[ Upstream commit 0a8f37fb34a96267c656f7254e69bb9a2fc89fe4 ]

Code inspection shows that the server's NFSv3 READDIR implementation
handles offset cookies slightly differently than the NFSv2 READDIR,
NFSv3 READDIRPLUS, and NFSv4 READDIR implementations,
and there doesn't seem to be any need for this difference.

As a clean up, I copied the logic from nfsd3_proc_readdirplus().

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:29 +01:00
Chuck Lever
a63bb88fb1 NFSD: Update READLINK3arg decoder to use struct xdr_stream
[ Upstream commit 224c1c894e48cd72e4dd9fb6311be80cbe1369b0 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:29 +01:00
Chuck Lever
61407ff817 NFSD: Update WRITE3arg decoder to use struct xdr_stream
[ Upstream commit c43b2f229a01969a7ccf94b033c5085e0ec2040c ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:29 +01:00
Chuck Lever
0be6ef7cf7 NFSD: Update READ3arg decoder to use struct xdr_stream
[ Upstream commit be63bd2ac6bbf8c065a0ef6dfbea76934326c352 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:29 +01:00
Chuck Lever
31b738b2d4 NFSD: Update ACCESS3arg decoder to use struct xdr_stream
[ Upstream commit 3b921a2b14251e9e203f1e8af76e8ade79f50e50 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:29 +01:00
Chuck Lever
cfdfe5a7de NFSD: Update GETATTR3args decoder to use struct xdr_stream
[ Upstream commit 9575363a9e4c8d7e2f9ba5e79884d623fff0be6f ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:29 +01:00
Chuck Lever
dcba979967 SUNRPC: Make trace_svc_process() display the RPC procedure symbolically
[ Upstream commit 2289e87b5951f97783f07fc895e6c5e804b53668 ]

The next few patches will employ these strings to help make server-
side trace logs more human-readable. A similar technique is already
in use in kernel RPC client code.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:28 +01:00
Chuck Lever
d36f5984df NFSD: Restore NFSv4 decoding's SAVEMEM functionality
[ Upstream commit 7b723008f9c95624c848fad661c01b06e47b20da ]

While converting the NFSv4 decoder to use xdr_stream-based XDR
processing, I removed the old SAVEMEM() macro. This macro wrapped
a bit of logic that avoided a memory allocation by recognizing when
the decoded item resides in a linear section of the Receive buffer.
In that case, it returned a pointer into that buffer instead of
allocating a bounce buffer.

The bounce buffer is necessary only when xdr_inline_decode() has
placed the decoded item in the xdr_stream's scratch buffer, which
disappears the next time xdr_inline_decode() is called with that
xdr_stream. That happens only if the data item crosses a page
boundary in the receive buffer, an exceedingly rare occurrence.

Allocating a bounce buffer every time results in a minor performance
regression that was introduced by the recent NFSv4 decoder overhaul.
Let's restore the previous behavior. On average, it saves about 1.5
kmalloc() calls per COMPOUND.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:28 +01:00
Chuck Lever
b2b588f411 NFSD: Fix sparse warning in nfssvc.c
[ Upstream commit d6c9e4368cc6a61bf25c9c72437ced509c854563 ]

fs/nfsd/nfssvc.c:36:6: warning: symbol 'inter_copy_offload_enable' was not declared. Should it be static?

The parameter was added by commit ce0887ac96d3 ("NFSD add nfs4 inter
ssc to nfsd4_copy"). Relocate it into the source file that uses it,
and make it static. This approach is similar to the
nfs4_disable_idmapping, cltrack_prog, and cltrack_legacy_disable
module parameters.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:28 +01:00
Trond Myklebust
2decf8283a nfsd: Record NFSv4 pre/post-op attributes as non-atomic
[ Upstream commit 716a8bc7f706eeef80ab42c99d9f210eda845c81 ]

For the case of NFSv4, specify to the client that the pre/post-op
attributes were not recorded atomically with the main operation.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:26 +01:00
Trond Myklebust
dc3a7dfef0 nfsd: Set PF_LOCAL_THROTTLE on local filesystems only
[ Upstream commit 01cbf3853959feec40ec9b9a399e12a021cd4d81 ]

Don't set PF_LOCAL_THROTTLE on remote filesystems like NFS, since they
aren't expected to ever be subject to double buffering.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:26 +01:00
Trond Myklebust
eb6ff86773 nfsd: Fix up nfsd to ensure that timeout errors don't result in ESTALE
[ Upstream commit 2e19d10c1438241de32467637a2a411971547991 ]

If the underlying filesystem times out, then we want knfsd to return
NFSERR_JUKEBOX/DELAY rather than NFSERR_STALE.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:26 +01:00
Jeff Layton
23581c9ef1 nfsd: close cached files prior to a REMOVE or RENAME that would replace target
[ Upstream commit 7f84b488f9add1d5cca3e6197c95914c7bd3c1cf ]

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>
[ cel: adjusted to apply to 5.10.y ]
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:26 +01:00
Jeff Layton
31e5e2f41c nfsd: allow filesystems to opt out of subtree checking
[ Upstream commit ba5e8187c55555519ae0b63c0fb681391bc42af9 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:26 +01:00
Jeff Layton
04188462fa nfsd: add a new EXPORT_OP_NOWCC flag to struct export_operations
[ Upstream commit daab110e47f8d7aa6da66923e3ac1a8dbd2b2a72 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:26 +01:00
J. Bruce Fields
704a97237e 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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:26 +01:00
J. Bruce Fields
eb19ec9b35 nfsd4: don't query change attribute in v2/v3 case
[ Upstream commit 942b20dc245590327ee0187c15c78174cd96dd52 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:26 +01:00
J. Bruce Fields
37458c7a7f nfsd: minor nfsd4_change_attribute cleanup
[ Upstream commit 4b03d99794eeed27650597a886247c6427ce1055 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:26 +01:00
J. Bruce Fields
312155cfb1 nfsd: simplify nfsd4_change_info
[ Upstream commit b2140338d8dca827ad9e83f3e026e9d51748b265 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:26 +01:00
J. Bruce Fields
f64589727b nfsd: only call inode_query_iversion in the I_VERSION case
[ Upstream commit 70b87f77294d16d3e567056ba4c9ee2b091a5b50 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:26 +01:00
Chuck Lever
ec57c3cb20 NFSD: Remove macros that are no longer used
[ Upstream commit 5cfc822f3e77b0477e6602d399116130317f537a ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:26 +01:00
Chuck Lever
20457336e9 NFSD: Replace READ* macros in nfsd4_decode_compound()
[ Upstream commit d9b74bdac6f24afc3101b6a5b6f59842610c9c94 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:25 +01:00
Chuck Lever
039c7707dc NFSD: Make nfsd4_ops::opnum a u32
[ Upstream commit 3a237b4af5b7b0e77588e120554077cab3341943 ]

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

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:25 +01:00
Chuck Lever
f01af13f07 NFSD: Replace READ* macros in nfsd4_decode_listxattrs()
[ Upstream commit 2212036cadf4da3c4b0e4bd2a9a8c3d78617ab4f ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:25 +01:00
Chuck Lever
da7cebf4e0 NFSD: Replace READ* macros in nfsd4_decode_setxattr()
[ Upstream commit 403366a7e8e2930002157525cd44add7fa01bca9 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:25 +01:00
Chuck Lever
737e6ad646 NFSD: Replace READ* macros in nfsd4_decode_xattr_name()
[ Upstream commit 830c71502ae0ae1677ac6c08ffbcf85a6e7b2937 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:25 +01:00
Chuck Lever
913cc7fffd NFSD: Replace READ* macros in nfsd4_decode_clone()
[ Upstream commit 3dfd0b0e15671e2b4047ccb9222432f0b2d930be ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:25 +01:00
Chuck Lever
64d6f85ff2 NFSD: Replace READ* macros in nfsd4_decode_seek()
[ Upstream commit 9d32b412fe0a6186cc57789d218e8f8299454ae2 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:25 +01:00
Chuck Lever
a63486680c NFSD: Replace READ* macros in nfsd4_decode_offload_status()
[ Upstream commit 2846bb0525a73e00b3566fda535ea6a5879e2971 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:25 +01:00
Chuck Lever
2253934928 NFSD: Replace READ* macros in nfsd4_decode_copy_notify()
[ Upstream commit f9a953fb369bbd2135ccead3393ec1ef66544471 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:25 +01:00
Chuck Lever
6561031e79 NFSD: Replace READ* macros in nfsd4_decode_copy()
[ Upstream commit e8febea7190bcbd1e608093acb67f2a5009556aa ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:25 +01:00
Chuck Lever
8315f841ec NFSD: Replace READ* macros in nfsd4_decode_nl4_server()
[ Upstream commit f49e4b4d58cc835d8bd0cc9663f7b9c5497e0e7e ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:25 +01:00
Chuck Lever
c9f85bc6fc NFSD: Replace READ* macros in nfsd4_decode_fallocate()
[ Upstream commit 6aef27aaeae7611f98af08205acc79f5a8f3aa59 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:25 +01:00
Chuck Lever
01d7b4526e NFSD: Replace READ* macros in nfsd4_decode_reclaim_complete()
[ Upstream commit 0d6467844d437e07db1e76d96176b1a55401018c ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:25 +01:00
Chuck Lever
109a0d206a NFSD: Replace READ* macros in nfsd4_decode_destroy_clientid()
[ Upstream commit c95f2ec3490586cbb33badc8f4c82d6aa4955078 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:25 +01:00
Chuck Lever
0518215d27 NFSD: Replace READ* macros in nfsd4_decode_test_stateid()
[ Upstream commit b7a0c8f6e741bf9dee0d24e69d3ce51fa4ccce78 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:25 +01:00
Chuck Lever
61b880dbaf NFSD: Replace READ* macros in nfsd4_decode_sequence()
[ Upstream commit cf907b11326d9360877d6c6ea8f75e1b29f39f2f ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:25 +01:00
Chuck Lever
ea65b904b6 NFSD: Replace READ* macros in nfsd4_decode_secinfo_no_name()
[ Upstream commit 53d70873e37c09a582167ed73d1858e3a2af0157 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:25 +01:00
Chuck Lever
d84965af03 NFSD: Replace READ* macros in nfsd4_decode_layoutreturn()
[ Upstream commit 645fcad371420913c30e9aca80fc0a38f3acf432 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:24 +01:00
Chuck Lever
9aae15ca48 NFSD: Replace READ* macros in nfsd4_decode_layoutget()
[ Upstream commit c8e88e3aa73889421461f878cd569ef84f231ceb ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:24 +01:00
Chuck Lever
b4ae5eebd4 NFSD: Replace READ* macros in nfsd4_decode_layoutcommit()
[ Upstream commit 5185980d8a23001c2317c290129ab7ab20067e20 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:24 +01:00
Chuck Lever
8f773fb898 NFSD: Replace READ* macros in nfsd4_decode_getdeviceinfo()
[ Upstream commit 044959715f370b24870c95df3940add8710c5a29 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:24 +01:00
Chuck Lever
7a3ff0295c NFSD: Replace READ* macros in nfsd4_decode_free_stateid()
[ Upstream commit aec387d5909304810d899f7d90ae57df33f3a75c ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:24 +01:00
Chuck Lever
ae0730e8d9 NFSD: Replace READ* macros in nfsd4_decode_destroy_session()
[ Upstream commit 94e254af1f873b4b551db4c4549294f2c4d385ef ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:24 +01:00
Chuck Lever
155c964221 NFSD: Replace READ* macros in nfsd4_decode_create_session()
[ Upstream commit 81243e3fe37ed547fc4ed8aab1cec2865540bb18 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:24 +01:00
Chuck Lever
a445bf2a33 NFSD: Add a helper to decode channel_attrs4
[ Upstream commit 3a3f1fbacb0960b628e5a9f07c78287312f7a99d ]

De-duplicate some code.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:24 +01:00
Chuck Lever
bda2edd08b NFSD: Add a helper to decode nfs_impl_id4
[ Upstream commit 10ff84228197f47401833495ba19a50131323b4a ]

Refactor for clarity.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:24 +01:00
Chuck Lever
c26952337e NFSD: Add a helper to decode state_protect4_a
[ Upstream commit 523ec6ed6fb80fd1537d748a06bffd060a8b3235 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:24 +01:00
Chuck Lever
39814dfd55 NFSD: Add a separate decoder for ssv_sp_parms
[ Upstream commit 547bfeb4cd8d491aabbd656d5a6f410cb4249b4e ]

Refactor for clarity.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:24 +01:00
Chuck Lever
0316890507 NFSD: Add a separate decoder to handle state_protect_ops
[ Upstream commit 2548aa784d760567c2a77cbd8b7c55b211167c37 ]

Refactor for clarity and de-duplication of code.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:24 +01:00
Chuck Lever
75e7eb55d1 NFSD: Replace READ* macros in nfsd4_decode_bind_conn_to_session()
[ Upstream commit 571e0451c4de0a545960ffaea16d969931afc563 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:24 +01:00
Chuck Lever
2f29d0b531 NFSD: Replace READ* macros in nfsd4_decode_backchannel_ctl()
[ Upstream commit 0f81d96098f8eb707afe2f8d5c3fe0f9316ef5ce ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:24 +01:00
Chuck Lever
ae3ea82492 NFSD: Replace READ* macros in nfsd4_decode_cb_sec()
[ Upstream commit 1a99440807bfc66597aaa2e0f0213c319b023e34 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:24 +01:00
Chuck Lever
783093b206 NFSD: Replace READ* macros in nfsd4_decode_release_lockowner()
[ Upstream commit a4a80c15ca4dd998ab5cbe87bd856c626a318a80 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:24 +01:00
Chuck Lever
844e52898c NFSD: Replace READ* macros in nfsd4_decode_write()
[ Upstream commit 244e2befcba80f42c65293b6c56282bb78f9f417 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:23 +01:00
Chuck Lever
2e01ced2a4 NFSD: Replace READ* macros in nfsd4_decode_verify()
[ Upstream commit 67cd453eeda86be90f83a0f4798f33832cf2d98c ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:23 +01:00
Chuck Lever
b2b8186a6c NFSD: Replace READ* macros in nfsd4_decode_setclientid_confirm()
[ Upstream commit d1ca55149d67e5896f89a30053f5d83c002ac10e ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:23 +01:00
Chuck Lever
34132fb635 NFSD: Replace READ* macros in nfsd4_decode_setclientid()
[ Upstream commit 92fa6c08c251d52d0d7b46066ecf87b96a0c4b8f ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:23 +01:00
Chuck Lever
24f75d3d2a NFSD: Replace READ* macros in nfsd4_decode_setattr()
[ Upstream commit 44592fe9479d8d4b88594365ab825f7b07afdf7c ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:23 +01:00
Chuck Lever
a9fde57f85 NFSD: Replace READ* macros in nfsd4_decode_secinfo()
[ Upstream commit d0abdae5191a916d767164f6fc6c0e2e814a20a7 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:23 +01:00
Chuck Lever
4e3cc691f3 NFSD: Replace READ* macros in nfsd4_decode_renew()
[ Upstream commit d12f90458dc8c11734ba44ec88f109bf8de86ff0 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:23 +01:00
Chuck Lever
b240d33402 NFSD: Replace READ* macros in nfsd4_decode_rename()
[ Upstream commit ba881a0a5342b3aaf83958901ebe3fe752eaab46 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:23 +01:00
Chuck Lever
28de5567a6 NFSD: Replace READ* macros in nfsd4_decode_remove()
[ Upstream commit b7f5fbf219aecda98e32de305551e445f9438899 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:23 +01:00
Chuck Lever
d13a153e28 NFSD: Replace READ* macros in nfsd4_decode_readdir()
[ Upstream commit 0dfaf2a371436860ace6af889e6cd8410ee63164 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:23 +01:00
Chuck Lever
3de83d8c6c NFSD: Replace READ* macros in nfsd4_decode_read()
[ Upstream commit 3909c3bc604688503e31ddceb429dc156c4720c1 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:23 +01:00
Chuck Lever
e1de828f20 NFSD: Replace READ* macros in nfsd4_decode_putfh()
[ Upstream commit a73bed98413b1d9eb4466f776a56d2fde8b3b2c9 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:23 +01:00
Chuck Lever
0ff3b1afe5 NFSD: Replace READ* macros in nfsd4_decode_open_downgrade()
[ Upstream commit dca71651f097ea608945d7a66bf62761a630de9a ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:23 +01:00
Chuck Lever
43e2862be3 NFSD: Replace READ* macros in nfsd4_decode_open_confirm()
[ Upstream commit 06bee693a1f1cb774b91000f05a6e183c257d8e9 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:23 +01:00
Chuck Lever
b53ba0c2da NFSD: Replace READ* macros in nfsd4_decode_open()
[ Upstream commit 61e5e0b3ec713d1365008c8af3fe5fdd262e2a60 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:23 +01:00
Chuck Lever
e14618a197 NFSD: Add helper to decode OPEN's open_claim4 argument
[ Upstream commit 1708e50b0145f393acbec9e319bdf0e33f765d25 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:22 +01:00
Chuck Lever
1485000120 NFSD: Replace READ* macros in nfsd4_decode_share_deny()
[ Upstream commit b07bebd9eb9842e2d0dea87efeb92884556e55b0 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:22 +01:00
Chuck Lever
53534bedf3 NFSD: Replace READ* macros in nfsd4_decode_share_access()
[ Upstream commit 9aa62f5199749b274454b6d7d914c9b2a5e77031 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:22 +01:00
Chuck Lever
e96a9ec762 NFSD: Add helper to decode OPEN's openflag4 argument
[ Upstream commit e6ec04b27bfb4869c0e35fbcf24333d379f101d5 ]

Refactor for clarity.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:22 +01:00
Chuck Lever
c6511e947e NFSD: Add helper to decode OPEN's createhow4 argument
[ Upstream commit bf33bab3c4182cdd795983f14de5606e82fab377 ]

Refactor for clarity.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:22 +01:00
Chuck Lever
4cb9382c5f NFSD: Add helper to decode NFSv4 verifiers
[ Upstream commit 796dd1c6b680959ac968b52aa507911b288b1749 ]

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

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:22 +01:00
Chuck Lever
49c5f4f27e NFSD: Replace READ* macros in nfsd4_decode_lookup()
[ Upstream commit 3d5877e8e03f60d7cc804d7b230ff9c00c9c07bd ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:22 +01:00
Chuck Lever
ab2c8c85dc NFSD: Replace READ* macros in nfsd4_decode_locku()
[ Upstream commit ca9cf9fc27f8f722e9eb2763173ba01f6ac3dad1 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:22 +01:00
Chuck Lever
72c0941906 NFSD: Replace READ* macros in nfsd4_decode_lockt()
[ Upstream commit 0a146f04aa0fa7a57aaed3913d1c2732b3853f31 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:22 +01:00
Chuck Lever
9618fd094a NFSD: Replace READ* macros in nfsd4_decode_lock()
[ Upstream commit 7c59deed5cd2e1cfc6cbecf06f4584ac53755f53 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:22 +01:00
Chuck Lever
4f0ad736dc NFSD: Add helper for decoding locker4
[ Upstream commit 8918cc0d2b72db9997390626010b182c4500d749 ]

Refactor for clarity.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:22 +01:00
Chuck Lever
42ea08442d NFSD: Add helpers to decode a clientid4 and an NFSv4 state owner
[ Upstream commit 144e82694092ff80b5e64749d6822cd8947587f2 ]

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

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:22 +01:00
Chuck Lever
3cffafb466 NFSD: Relocate nfsd4_decode_opaque()
[ Upstream commit 5dcbfabb676b2b6d97767209cf707eb463ca232a ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:22 +01:00
Chuck Lever
5e006a8128 NFSD: Replace READ* macros in nfsd4_decode_link()
[ Upstream commit 5c505d128691c70991b766dd6a3faf49fa59ecfb ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:22 +01:00
Chuck Lever
77de29c527 NFSD: Replace READ* macros in nfsd4_decode_getattr()
[ Upstream commit f759eff260f1f0b0f56531517762f27ee3233506 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:22 +01:00
Chuck Lever
6da527378e NFSD: Replace READ* macros in nfsd4_decode_delegreturn()
[ Upstream commit 95e6482cedfc0785b85db49b72a05323bbf41750 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:21 +01:00
Chuck Lever
bf141817e8 NFSD: Replace READ* macros in nfsd4_decode_create()
[ Upstream commit 000dfa18b3df9c62df5f768f9187cf1a94ded71d ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:21 +01:00
Chuck Lever
9b989a3f4d NFSD: Replace READ* macros in nfsd4_decode_fattr()
[ Upstream commit d1c263a031e876ac3ca5223c728e4d98ed50b3c0 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:21 +01:00
Chuck Lever
5fab553a7f NFSD: Replace READ* macros that decode the fattr4 umask attribute
[ Upstream commit 66f0476c704c86d44aa9da19d4753df66f2dbc96 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:21 +01:00
Chuck Lever
17c4197f1e NFSD: Replace READ* macros that decode the fattr4 security label attribute
[ Upstream commit dabe91828f92cd493e9e75efbc10f9878d2a73fe ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:21 +01:00
Chuck Lever
701ce73f1b NFSD: Replace READ* macros that decode the fattr4 time_set attributes
[ Upstream commit 1c3eff7ea4a98c642134ee493001ae13b79ff38c ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:21 +01:00
Chuck Lever
a98e2e0e51 NFSD: Replace READ* macros that decode the fattr4 owner_group attribute
[ Upstream commit 393c31dd27f83adb06b07a1b5f0a5b8966a0f01e ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:21 +01:00
Chuck Lever
4d043b60f5 NFSD: Replace READ* macros that decode the fattr4 owner attribute
[ Upstream commit 9853a5ac9be381917e9be0b4133cd4ac5a7ad875 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:21 +01:00
Chuck Lever
502e31b392 NFSD: Replace READ* macros that decode the fattr4 mode attribute
[ Upstream commit 1c8f0ad7dd35fd12307904036c7c839f77b6e3f9 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:21 +01:00
Chuck Lever
9887990f86 NFSD: Replace READ* macros that decode the fattr4 acl attribute
[ Upstream commit c941a96823cf52e742606b486b81ab346bf111c9 ]

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

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:21 +01:00
Chuck Lever
17ef759688 NFSD: Replace READ* macros that decode the fattr4 size attribute
[ Upstream commit 2ac1b9b2afbbacf597dbec722b23b6be62e4e41e ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:21 +01:00
Chuck Lever
a2eb30f28a NFSD: Change the way the expected length of a fattr4 is checked
[ Upstream commit 081d53fe0b43c47c36d1832b759bf14edde9cdbb ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:21 +01:00
Chuck Lever
d480a578fc NFSD: Replace READ* macros in nfsd4_decode_commit()
[ Upstream commit cbd9abb3706e96563b36af67595707a7054ab693 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:21 +01:00
Chuck Lever
20599d6a9c NFSD: Replace READ* macros in nfsd4_decode_close()
[ Upstream commit d3d2f38154571e70d5806b5c5264bf61c101ea15 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:21 +01:00
Chuck Lever
0458d025b4 NFSD: Replace READ* macros in nfsd4_decode_access()
[ Upstream commit d169a6a9e5fd7f9e4b74e5e5d2e5a4fd0f84ef05 ]

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:21 +01:00
Chuck Lever
ff3549728d NFSD: Replace the internals of the READ_BUF() macro
[ Upstream commit c1346a1216ab5cb04a265380ac9035d91b16b6d5 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:21 +01:00
Chuck Lever
66617e658d NFSD: Add tracepoints in nfsd4_decode/encode_compound()
[ Upstream commit 08281341be8ebc97ee47999812bcf411942baa1e ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:20 +01:00
Chuck Lever
9bbac049aa NFSD: Add tracepoints in nfsd_dispatch()
[ Upstream commit 0dfdad1c1d1b77b9b085f4da390464dd0ac5647a ]

For troubleshooting purposes, record GARBAGE_ARGS and CANT_ENCODE
failures.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:20 +01:00
Chuck Lever
cfa6efa018 NFSD: Add common helpers to decode void args and encode void results
[ Upstream commit 788f7183fba86b46074c16e7d57ea09302badff4 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:20 +01:00
Chuck Lever
59542e5bca SUNRPC: Prepare for xdr_stream-style decoding on the server-side
[ Upstream commit 5191955d6fc65e6d4efe8f4f10a6028298f57281 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:20 +01:00
Chuck Lever
bd5678273e SUNRPC: Add xdr_set_scratch_page() and xdr_reset_scratch_buffer()
[ Upstream commit 0ae4c3e8a64ace1b8d7de033b0751afe43024416 ]

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

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:20 +01:00
Huang Guobin
07967244be nfsd: Fix error return code in nfsd_file_cache_init()
[ Upstream commit 231307df246eb29f30092836524ebb1fcb8f5b25 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:20 +01:00
Chuck Lever
b815d3f735 NFSD: Add SPDX header for fs/nfsd/trace.c
[ Upstream commit f45a444cfe582b85af937a30d35d68d9a84399dd ]

Clean up.

The file was contributed in 2014 by Christoph Hellwig in commit
31ef83dc0538 ("nfsd: add trace events").

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:20 +01:00
Chuck Lever
731537ff61 NFSD: Remove extra "0x" in tracepoint format specifier
[ Upstream commit 3a90e1dff16afdae6e1c918bfaff24f4d0f84869 ]

Clean up: %p adds its own 0x already.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:20 +01:00
Chuck Lever
ab7a21346a NFSD: Clean up the show_nf_may macro
[ Upstream commit b76278ae68848cea13b325d247aa5cf31c87edac ]

Display all currently possible NFSD_MAY permission flags.

Move and rename show_nf_may with a more generic name because the
NFSD_MAY permission flags are used in other places besides the file
cache.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:20 +01:00
Alex Shi
a610070535 nfsd/nfs3: remove unused macro nfsd3_fhandleres
[ Upstream commit 71fd721839a74d945c242299f6be29a246fc2131 ]

The macro is unused, remove it to tame gcc warning:
fs/nfsd/nfs3proc.c:702:0: warning: macro "nfsd3_fhandleres" is not used
[-Wunused-macros]

Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
Cc: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Chuck Lever <chuck.lever@oracle.com>
Cc: linux-nfs@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:20 +01:00
Tom Rix
f124b3bcd6 NFSD: A semicolon is not needed after a switch statement.
[ Upstream commit 25fef48bdbe7cac5ba5577eab6a750e1caea43bc ]

Signed-off-by: Tom Rix <trix@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:20 +01:00
Chuck Lever
8a1b5ced4f NFSD: Invoke svc_encode_result_payload() in "read" NFSD encoders
[ Upstream commit 76e5492b161f555c0fb69cad9eb39a7d8467f5fe ]

Have the NFSD encoders annotate the boundaries of every
direct-data-placement eligible result data payload. Then change
svcrdma to use that annotation instead of the xdr->page_len
when handling Write chunks.

For NFSv4 on RDMA, that enables the ability to recognize multiple
result payloads per compound. This is a pre-requisite for supporting
multiple Write chunks per RPC transaction.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:20 +01:00
Chuck Lever
f146b690af SUNRPC: Rename svc_encode_read_payload()
[ Upstream commit 03493bca084fdca48abc59b00e06ce733aa9eb7d ]

Clean up: "result payload" is a less confusing name for these
payloads. "READ payload" reflects only the NFS usage.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:27:20 +01:00
Al Viro
1c4699d5db nfsd: lock_rename() needs both directories to live on the same fs
commit 1aee9158bc978f91701c5992e395efbc6da2de3c upstream.

... checking that after lock_rename() is too late.  Incidentally,
NFSv2 had no nfserr_xdev...

Fixes: aa387d6ce153 "nfsd: fix EXDEV checking in rename"
Cc: stable@vger.kernel.org # v3.9+
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Acked-by: Chuck Lever <chuck.lever@oracle.com>
Tested-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-11-18 12:10:57 +01:00
Mahmoud Adam
0a9f067ae1 nfsd: fix file memleak on client_opens_release
commit bc1b5acb40201a0746d68a7d7cfc141899937f4f upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-11-18 11:43:31 +01:00
Gabriel2392
7ed7ee9edf Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00