fs/nfs/nfs42xattr.c
Source file repositories/reference/linux-study-clean/fs/nfs/nfs42xattr.c
File Facts
- System
- Linux kernel
- Corpus path
fs/nfs/nfs42xattr.c- Extension
.c- Size
- 26438 bytes
- Lines
- 1068
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source 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.
- 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/errno.hlinux/nfs_fs.hlinux/hashtable.hlinux/refcount.huapi/linux/xattr.hnfs4_fs.hinternal.h
Detected Declarations
struct nfs4_xattr_cachestruct nfs4_xattr_entrystruct nfs4_xattr_bucketstruct nfs4_xattr_cachestruct nfs4_xattr_entryfunction nfs4_xattr_hash_initfunction nfs4_xattr_entry_lru_addfunction nfs4_xattr_entry_lru_delfunction allocationfunction nfs4_xattr_free_entryfunction nfs4_xattr_free_entry_cbfunction nfs4_xattr_free_cache_cbfunction nfs4_xattr_alloc_cachefunction ERR_PTRfunction nfs4_xattr_cache_unlinkfunction nfs4_xattr_discard_cachefunction hlist_for_each_entry_safefunction nfs4_xattr_get_cachefunction nfs4_xattr_hash_bucketfunction nfs4_xattr_get_entryfunction hlist_for_each_entryfunction nfs4_xattr_hash_addfunction nfs4_xattr_hash_removefunction nfs4_xattr_hash_findfunction nfs4_xattr_cache_getfunction nfs4_xattr_cache_listfunction nfs4_xattr_cache_addfunction nfs4_xattr_cache_removefunction nfs4_xattr_cache_set_listfunction nfs4_xattr_cache_zapfunction cache_lru_isolatefunction nfs4_xattr_cache_scanfunction nfs4_xattr_cache_countfunction entry_lru_isolatefunction parentfunction nfs4_xattr_entry_scanfunction nfs4_xattr_entry_countfunction nfs4_xattr_cache_init_oncefunction nfs4_xattr_shrinker_initfunction nfs4_xattr_shrinker_destroyfunction nfs4_xattr_cache_initfunction nfs4_xattr_cache_exit
Annotated Snippet
struct nfs4_xattr_bucket {
spinlock_t lock;
struct hlist_head hlist;
struct nfs4_xattr_cache *cache;
bool draining;
};
struct nfs4_xattr_cache {
struct kref ref;
struct nfs4_xattr_bucket buckets[NFS4_XATTR_HASH_SIZE];
struct list_head lru;
struct list_head dispose;
atomic_long_t nent;
spinlock_t listxattr_lock;
struct inode *inode;
struct nfs4_xattr_entry *listxattr;
};
struct nfs4_xattr_entry {
struct kref ref;
struct hlist_node hnode;
struct list_head lru;
struct list_head dispose;
char *xattr_name;
void *xattr_value;
size_t xattr_size;
struct nfs4_xattr_bucket *bucket;
uint32_t flags;
};
#define NFS4_XATTR_ENTRY_EXTVAL 0x0001
/*
* LRU list of NFS inodes that have xattr caches.
*/
static struct list_lru nfs4_xattr_cache_lru;
static struct list_lru nfs4_xattr_entry_lru;
static struct list_lru nfs4_xattr_large_entry_lru;
static struct kmem_cache *nfs4_xattr_cache_cachep;
/*
* Hashing helper functions.
*/
static void
nfs4_xattr_hash_init(struct nfs4_xattr_cache *cache)
{
unsigned int i;
for (i = 0; i < NFS4_XATTR_HASH_SIZE; i++) {
INIT_HLIST_HEAD(&cache->buckets[i].hlist);
spin_lock_init(&cache->buckets[i].lock);
cache->buckets[i].cache = cache;
cache->buckets[i].draining = false;
}
}
/*
* Locking order:
* 1. inode i_lock or bucket lock
* 2. list_lru lock (taken by list_lru_* functions)
*/
/*
* Wrapper functions to add a cache entry to the right LRU.
*/
static bool
nfs4_xattr_entry_lru_add(struct nfs4_xattr_entry *entry)
{
struct list_lru *lru;
lru = (entry->flags & NFS4_XATTR_ENTRY_EXTVAL) ?
&nfs4_xattr_large_entry_lru : &nfs4_xattr_entry_lru;
return list_lru_add_obj(lru, &entry->lru);
}
static bool
nfs4_xattr_entry_lru_del(struct nfs4_xattr_entry *entry)
{
struct list_lru *lru;
lru = (entry->flags & NFS4_XATTR_ENTRY_EXTVAL) ?
&nfs4_xattr_large_entry_lru : &nfs4_xattr_entry_lru;
return list_lru_del_obj(lru, &entry->lru);
}
/*
* This function allocates cache entries. They are the normal
Annotation
- Immediate include surface: `linux/errno.h`, `linux/nfs_fs.h`, `linux/hashtable.h`, `linux/refcount.h`, `uapi/linux/xattr.h`, `nfs4_fs.h`, `internal.h`.
- Detected declarations: `struct nfs4_xattr_cache`, `struct nfs4_xattr_entry`, `struct nfs4_xattr_bucket`, `struct nfs4_xattr_cache`, `struct nfs4_xattr_entry`, `function nfs4_xattr_hash_init`, `function nfs4_xattr_entry_lru_add`, `function nfs4_xattr_entry_lru_del`, `function allocation`, `function nfs4_xattr_free_entry`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source 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.