summaryrefslogtreecommitdiff
path: root/tools/lib/python
diff options
context:
space:
mode:
authorChuck Lever <cel@kernel.org>2026-09-16 12:28:58 -0400
committerChuck Lever <cel@kernel.org>2026-10-11 23:13:03 -0400
commitf08cfa10c4c26daa1fb60dcdf9812a59c3f5f0e5 (patch)
tree5a72e2785e66f222986a6656c49a8d032938b240 /tools/lib/python
parent7f99da631a4e981860907de2a90bb0978abbcfa4 (diff)
downloadlinux-next-f08cfa10c4c26daa1fb60dcdf9812a59c3f5f0e5.tar.gz
linux-next-f08cfa10c4c26daa1fb60dcdf9812a59c3f5f0e5.zip
NFSD: Use xdrgen XDR functions for NFSv2 READDIR results
READDIR is the last NFSv2 procedure whose reply is still produced by a hand-written encoder. Its entry list is the value-follows form of RFC 1094's "entry *entries" -- each entry prefixed by TRUE, the sequence closed by FALSE -- streamed straight from the directory as it is read rather than from a materialized array. The generated encoder could not drive that: the union encoder writes the reply status word before the entry list, yet a streamed read does not learn the status until the directory has been read, and the aggregate loop was bounded by a count the begin hook had to supply up front. The preceding patches remove both obstacles. The optional-data aggregate encoder now pulls entries until the hook signals end, so no count is needed, and the streaming directory reader yields one entry at a time during encode. Mark readdirok's entry list as an aggregate and regenerate; the struct definitions stay the verbatim RFC 1094 types, and the lone "pragma aggregate readdirok entries" selects the hook-driven codec. Split the read across the two phases so the generated encoder owns the framing. nfsd_proc_readdir() opens the directory, where an open error becomes the reply status the union encoder then writes, and the encode hooks stream the entries: each pull reserves a placeholder cookie and back-patches the preceding entry's cookie once the following entry's resume offset is known; the end hook back-patches the final cookie and reports eof. nfssvc_release_readdirres() closes the reader and releases the file handle. The decode hooks are stubs -- a server never decodes a READDIR result -- present only to satisfy the generated decoder's linkage. Retire struct nfsd_readdirres for an embedded struct readdirres so the RPC dispatch layer can cast the response to its xdrgen type. The directory's svc_fh moves into that wrapper and struct readdirargs_wrapper goes away. svc_process() zeroes the result buffer before decode but leaves the argument buffer as the previous request left it, and ->pc_release runs even when decoding fails. A file handle kept in the argument wrapper would reach fh_put() on that path uninitialized. The generated encoder reserves reply space through the xdr_stream, which does not advance rq_next_page as it moves onto the next page. svcrdma retains only the pages below rq_next_page across Send completion, so the end hook sets rq_next_page past the last page the reply uses, as nfsd4_encode_operation() does. A host error during the streamed read cannot retract entries already on the wire, so it ends the list as a truncated, non-eof reply rather than an error status; an error opening the directory is still reported as the reply status. The bytes on the wire are otherwise unchanged. Acked-by: Jeff Layton <jlayton@kernel.org> Link: https://patch.msgid.link/20260916162859.2051-30-cel@kernel.org Signed-off-by: Chuck Lever <cel@kernel.org>
Diffstat (limited to 'tools/lib/python')
0 files changed, 0 insertions, 0 deletions