fs/nfs/nfs4xdr.c
Source file repositories/reference/linux-study-clean/fs/nfs/nfs4xdr.c
File Facts
- System
- Linux kernel
- Corpus path
fs/nfs/nfs4xdr.c- Extension
.c- Size
- 208696 bytes
- Lines
- 7787
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/param.hlinux/time.hlinux/mm.hlinux/errno.hlinux/string.hlinux/in.hlinux/pagemap.hlinux/proc_fs.hlinux/kdev_t.hlinux/module.hlinux/utsname.hlinux/sunrpc/clnt.hlinux/sunrpc/msg_prot.hlinux/sunrpc/gss_api.hlinux/nfs.hlinux/nfs4.hlinux/nfs_fs.hlinux/nfs_common.hnfs4_fs.hnfs4trace.hinternal.hnfs4idmap.hnfs4session.hpnfs.hnetns.hnfs42xdr.c
Detected Declarations
struct compound_hdrstruct compound_hdrfunction encode_stringfunction encode_uint32function encode_uint64function xdr_encode_bitmap4function mask_bitmap4function encode_nfs4_seqidfunction encode_compound_hdrfunction encode_op_hdrfunction encode_nopsfunction encode_nfs4_stateidfunction encode_nfs4_verifierfunction xdr_encode_nfstime4function encode_attrsfunction encode_accessfunction encode_closefunction encode_commitfunction encode_createfunction encode_getattrfunction encode_getfattrfunction encode_getfattr_openfunction encode_fsinfofunction encode_fs_locationsfunction encode_getfhfunction encode_linkfunction nfs4_lock_typefunction nfs4_lock_lengthfunction encode_lockownerfunction encode_lockfunction encode_locktfunction encode_lockufunction encode_release_lockownerfunction encode_lookupfunction encode_lookuppfunction encode_share_accessfunction encode_openhdrfunction encode_createmodefunction encode_opentypefunction encode_delegation_typefunction encode_claim_nullfunction encode_claim_previousfunction encode_claim_delegate_curfunction encode_claim_fhfunction encode_claim_delegate_cur_fhfunction encode_openfunction encode_open_confirmfunction encode_open_downgrade
Annotated Snippet
struct compound_hdr {
int32_t status;
uint32_t nops;
__be32 * nops_p;
uint32_t taglen;
char * tag;
uint32_t replen; /* expected reply words */
u32 minorversion;
};
static __be32 *reserve_space(struct xdr_stream *xdr, size_t nbytes)
{
__be32 *p = xdr_reserve_space(xdr, nbytes);
BUG_ON(!p);
return p;
}
static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str)
{
WARN_ON_ONCE(xdr_stream_encode_opaque(xdr, str, len) < 0);
}
static void encode_uint32(struct xdr_stream *xdr, u32 n)
{
WARN_ON_ONCE(xdr_stream_encode_u32(xdr, n) < 0);
}
static void encode_uint64(struct xdr_stream *xdr, u64 n)
{
WARN_ON_ONCE(xdr_stream_encode_u64(xdr, n) < 0);
}
static ssize_t xdr_encode_bitmap4(struct xdr_stream *xdr,
const __u32 *bitmap, size_t len)
{
ssize_t ret;
/* Trim empty words */
while (len > 0 && bitmap[len-1] == 0)
len--;
ret = xdr_stream_encode_uint32_array(xdr, bitmap, len);
if (WARN_ON_ONCE(ret < 0))
return ret;
return len;
}
static size_t mask_bitmap4(const __u32 *bitmap, const __u32 *mask,
__u32 *res, size_t len)
{
size_t i;
__u32 tmp;
while (len > 0 && (bitmap[len-1] == 0 || mask[len-1] == 0))
len--;
for (i = len; i-- > 0;) {
tmp = bitmap[i] & mask[i];
res[i] = tmp;
}
return len;
}
static void encode_nfs4_seqid(struct xdr_stream *xdr,
const struct nfs_seqid *seqid)
{
if (seqid != NULL)
encode_uint32(xdr, seqid->sequence->counter);
else
encode_uint32(xdr, 0);
}
static void encode_compound_hdr(struct xdr_stream *xdr,
struct rpc_rqst *req,
struct compound_hdr *hdr)
{
__be32 *p;
/* initialize running count of expected bytes in reply.
* NOTE: the replied tag SHOULD be the same is the one sent,
* but this is not required as a MUST for the server to do so. */
hdr->replen = 3 + hdr->taglen;
WARN_ON_ONCE(hdr->taglen > NFS4_MAXTAGLEN);
encode_string(xdr, hdr->taglen, hdr->tag);
p = reserve_space(xdr, 8);
*p++ = cpu_to_be32(hdr->minorversion);
hdr->nops_p = p;
*p = cpu_to_be32(hdr->nops);
}
static void encode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 op,
Annotation
- Immediate include surface: `linux/param.h`, `linux/time.h`, `linux/mm.h`, `linux/errno.h`, `linux/string.h`, `linux/in.h`, `linux/pagemap.h`, `linux/proc_fs.h`.
- Detected declarations: `struct compound_hdr`, `struct compound_hdr`, `function encode_string`, `function encode_uint32`, `function encode_uint64`, `function xdr_encode_bitmap4`, `function mask_bitmap4`, `function encode_nfs4_seqid`, `function encode_compound_hdr`, `function encode_op_hdr`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.