fs/nfs/nfs4session.c
Source file repositories/reference/linux-study-clean/fs/nfs/nfs4session.c
File Facts
- System
- Linux kernel
- Corpus path
fs/nfs/nfs4session.c- Extension
.c- Size
- 17235 bytes
- Lines
- 654
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/errno.hlinux/string.hlinux/printk.hlinux/slab.hlinux/sunrpc/sched.hlinux/sunrpc/bc_xprt.hlinux/nfs.hlinux/nfs4.hlinux/nfs_fs.hlinux/module.hnfs4_fs.hinternal.hnfs4session.hcallback.h
Detected Declarations
function Copyrightfunction nfs4_shrink_slot_tablefunction nfs4_slot_tbl_drain_completefunction nfs4_free_slotfunction nfs4_lock_slotfunction nfs4_try_to_lock_slotfunction nfs4_slot_get_seqidfunction nfs4_slot_seqid_in_usefunction nfs4_slot_wait_on_seqidfunction nfs4_grow_slot_tablefunction nfs4_reset_slot_tablefunction nfs4_realloc_slot_tablefunction nfs4_release_slot_tablefunction nfs4_shutdown_slot_tablefunction nfs4_setup_slot_tablefunction nfs41_assign_slotfunction __nfs41_wake_and_assign_slotfunction nfs41_wake_and_assign_slotfunction nfs41_try_wake_next_slot_table_entryfunction nfs41_wake_slot_tablefunction nfs41_set_max_slotid_lockedfunction nfs41_set_target_slotid_lockedfunction nfs41_set_target_slotidfunction nfs41_set_server_slotid_lockedfunction nfs41_derivative_target_slotidfunction nfs41_sign_s32function nfs41_same_sign_or_zero_s32function nfs41_is_outlier_target_slotidfunction nfs41_update_target_slotidfunction nfs4_release_session_slot_tablesfunction nfs4_setup_session_slot_tablesfunction nfs4_destroy_session_slot_tablesfunction nfs4_destroy_sessionfunction nfs41_check_session_readyfunction nfs4_init_sessionfunction nfs4_init_ds_sessionexport nfs4_init_ds_session
Annotated Snippet
if (*p == NULL) {
*p = nfs4_new_slot(tbl, tbl->max_slots,
seq_init, gfp_mask);
if (*p == NULL)
break;
tbl->max_slots++;
}
slot = *p;
if (slot->slot_nr == slotid)
return slot;
p = &slot->next;
}
return ERR_PTR(-ENOMEM);
}
static void nfs4_lock_slot(struct nfs4_slot_table *tbl,
struct nfs4_slot *slot)
{
u32 slotid = slot->slot_nr;
__set_bit(slotid, tbl->used_slots);
if (slotid > tbl->highest_used_slotid ||
tbl->highest_used_slotid == NFS4_NO_SLOT)
tbl->highest_used_slotid = slotid;
slot->generation = tbl->generation;
}
/*
* nfs4_try_to_lock_slot - Given a slot try to allocate it
*
* Note: must be called with the slot_tbl_lock held.
*/
bool nfs4_try_to_lock_slot(struct nfs4_slot_table *tbl, struct nfs4_slot *slot)
{
if (nfs4_test_locked_slot(tbl, slot->slot_nr))
return false;
nfs4_lock_slot(tbl, slot);
return true;
}
/*
* nfs4_lookup_slot - Find a slot but don't allocate it
*
* Note: must be called with the slot_tbl_lock held.
*/
struct nfs4_slot *nfs4_lookup_slot(struct nfs4_slot_table *tbl, u32 slotid)
{
if (slotid <= tbl->max_slotid)
return nfs4_find_or_create_slot(tbl, slotid, 0, GFP_NOWAIT);
return ERR_PTR(-E2BIG);
}
static int nfs4_slot_get_seqid(struct nfs4_slot_table *tbl, u32 slotid,
u32 *seq_nr)
__must_hold(&tbl->slot_tbl_lock)
{
struct nfs4_slot *slot;
int ret;
slot = nfs4_lookup_slot(tbl, slotid);
ret = PTR_ERR_OR_ZERO(slot);
if (!ret)
*seq_nr = slot->seq_nr;
return ret;
}
/*
* nfs4_slot_seqid_in_use - test if a slot sequence id is still in use
*
* Given a slot table, slot id and sequence number, determine if the
* RPC call in question is still in flight. This function is mainly
* intended for use by the callback channel.
*/
static bool nfs4_slot_seqid_in_use(struct nfs4_slot_table *tbl,
u32 slotid, u32 seq_nr)
{
u32 cur_seq = 0;
bool ret = false;
spin_lock(&tbl->slot_tbl_lock);
if (nfs4_slot_get_seqid(tbl, slotid, &cur_seq) == 0 &&
cur_seq == seq_nr && test_bit(slotid, tbl->used_slots))
ret = true;
spin_unlock(&tbl->slot_tbl_lock);
return ret;
}
/*
* nfs4_slot_wait_on_seqid - wait until a slot sequence id is complete
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/errno.h`, `linux/string.h`, `linux/printk.h`, `linux/slab.h`, `linux/sunrpc/sched.h`, `linux/sunrpc/bc_xprt.h`, `linux/nfs.h`.
- Detected declarations: `function Copyright`, `function nfs4_shrink_slot_table`, `function nfs4_slot_tbl_drain_complete`, `function nfs4_free_slot`, `function nfs4_lock_slot`, `function nfs4_try_to_lock_slot`, `function nfs4_slot_get_seqid`, `function nfs4_slot_seqid_in_use`, `function nfs4_slot_wait_on_seqid`, `function nfs4_grow_slot_table`.
- 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.