fs/ocfs2/xattr.c
Source file repositories/reference/linux-study-clean/fs/ocfs2/xattr.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ocfs2/xattr.c- Extension
.c- Size
- 198942 bytes
- Lines
- 7439
- 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/capability.hlinux/fs.hlinux/types.hlinux/slab.hlinux/highmem.hlinux/pagemap.hlinux/uio.hlinux/sched.hlinux/splice.hlinux/mount.hlinux/writeback.hlinux/falloc.hlinux/sort.hlinux/init.hlinux/module.hlinux/string.hlinux/security.hcluster/masklog.hocfs2.halloc.hblockcheck.hdlmglue.hfile.hsymlink.hsysfile.hinode.hjournal.hocfs2_fs.hsuballoc.huptodate.hbuffer_head_io.hsuper.h
Detected Declarations
struct ocfs2_xattr_def_value_rootstruct ocfs2_xattr_bucketstruct ocfs2_xattr_set_ctxtstruct ocfs2_xattr_infostruct ocfs2_xattr_searchstruct ocfs2_xa_locstruct ocfs2_xa_loc_operationsstruct ocfs2_xa_locstruct ocfs2_rm_xattr_bucket_parastruct ocfs2_xattr_tree_liststruct ocfs2_xattr_tree_value_refcount_parastruct ocfs2_xattr_reflinkstruct ocfs2_reflink_xattr_tree_argsstruct ocfs2_value_tree_metasfunction namevalue_sizefunction namevalue_size_xifunction namevalue_size_xefunction ocfs2_xattr_buckets_per_clusterfunction ocfs2_blocks_per_xattr_bucketfunction ocfs2_xattr_bucket_relsefunction ocfs2_xattr_bucket_freefunction ocfs2_init_xattr_bucketfunction ocfs2_read_xattr_bucketfunction ocfs2_xattr_bucket_journal_accessfunction ocfs2_xattr_bucket_journal_dirtyfunction ocfs2_xattr_bucket_copy_datafunction ocfs2_validate_xattr_blockfunction ocfs2_read_xattr_blockfunction ocfs2_xattr_name_hashfunction ocfs2_xattr_entry_real_sizefunction ocfs2_xi_entry_usagefunction ocfs2_xe_entry_usagefunction ocfs2_calc_security_initfunction ocfs2_calc_xattr_initfunction ocfs2_xattr_extend_allocationfunction __ocfs2_remove_xattr_rangefunction ocfs2_xattr_shrink_sizefunction ocfs2_xattr_value_truncatefunction ocfs2_xattr_list_entryfunction ocfs2_xattr_list_entriesfunction ocfs2_xattr_ibody_lookup_headerfunction ocfs2_has_inline_xattr_value_outsidefunction ocfs2_xattr_ibody_listfunction ocfs2_xattr_block_listfunction ocfs2_listxattrfunction ocfs2_xattr_find_entryfunction ocfs2_xattr_get_value_outsidefunction ocfs2_xattr_ibody_get
Annotated Snippet
struct ocfs2_xattr_def_value_root {
/* Must be last as it ends in a flexible-array member. */
TRAILING_OVERLAP(struct ocfs2_xattr_value_root, xv, xr_list.l_recs,
struct ocfs2_extent_rec er;
);
};
static_assert(offsetof(struct ocfs2_xattr_def_value_root, xv.xr_list.l_recs) ==
offsetof(struct ocfs2_xattr_def_value_root, er));
struct ocfs2_xattr_bucket {
/* The inode these xattrs are associated with */
struct inode *bu_inode;
/* The actual buffers that make up the bucket */
struct buffer_head *bu_bhs[OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET];
/* How many blocks make up one bucket for this filesystem */
int bu_blocks;
};
struct ocfs2_xattr_set_ctxt {
handle_t *handle;
struct ocfs2_alloc_context *meta_ac;
struct ocfs2_alloc_context *data_ac;
struct ocfs2_cached_dealloc_ctxt dealloc;
int set_abort;
};
#define OCFS2_XATTR_ROOT_SIZE (sizeof(struct ocfs2_xattr_def_value_root))
#define OCFS2_XATTR_INLINE_SIZE 80
#define OCFS2_XATTR_HEADER_GAP 4
#define OCFS2_XATTR_FREE_IN_IBODY (OCFS2_MIN_XATTR_INLINE_SIZE \
- sizeof(struct ocfs2_xattr_header) \
- OCFS2_XATTR_HEADER_GAP)
#define OCFS2_XATTR_FREE_IN_BLOCK(ptr) ((ptr)->i_sb->s_blocksize \
- sizeof(struct ocfs2_xattr_block) \
- sizeof(struct ocfs2_xattr_header) \
- OCFS2_XATTR_HEADER_GAP)
static struct ocfs2_xattr_def_value_root def_xv = {
.xv.xr_list.l_count = cpu_to_le16(1),
};
const struct xattr_handler * const ocfs2_xattr_handlers[] = {
&ocfs2_xattr_user_handler,
&ocfs2_xattr_trusted_handler,
&ocfs2_xattr_security_handler,
NULL
};
static const struct xattr_handler * const ocfs2_xattr_handler_map[OCFS2_XATTR_MAX] = {
[OCFS2_XATTR_INDEX_USER] = &ocfs2_xattr_user_handler,
[OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS] = &nop_posix_acl_access,
[OCFS2_XATTR_INDEX_POSIX_ACL_DEFAULT] = &nop_posix_acl_default,
[OCFS2_XATTR_INDEX_TRUSTED] = &ocfs2_xattr_trusted_handler,
[OCFS2_XATTR_INDEX_SECURITY] = &ocfs2_xattr_security_handler,
};
struct ocfs2_xattr_info {
int xi_name_index;
const char *xi_name;
int xi_name_len;
const void *xi_value;
size_t xi_value_len;
};
struct ocfs2_xattr_search {
struct buffer_head *inode_bh;
/*
* xattr_bh point to the block buffer head which has extended attribute
* when extended attribute in inode, xattr_bh is equal to inode_bh.
*/
struct buffer_head *xattr_bh;
struct ocfs2_xattr_header *header;
struct ocfs2_xattr_bucket *bucket;
void *base;
void *end;
struct ocfs2_xattr_entry *here;
int not_found;
};
/* Operations on struct ocfs2_xa_entry */
struct ocfs2_xa_loc;
struct ocfs2_xa_loc_operations {
/*
* Journal functions
*/
int (*xlo_journal_access)(handle_t *handle, struct ocfs2_xa_loc *loc,
int type);
void (*xlo_journal_dirty)(handle_t *handle, struct ocfs2_xa_loc *loc);
Annotation
- Immediate include surface: `linux/capability.h`, `linux/fs.h`, `linux/types.h`, `linux/slab.h`, `linux/highmem.h`, `linux/pagemap.h`, `linux/uio.h`, `linux/sched.h`.
- Detected declarations: `struct ocfs2_xattr_def_value_root`, `struct ocfs2_xattr_bucket`, `struct ocfs2_xattr_set_ctxt`, `struct ocfs2_xattr_info`, `struct ocfs2_xattr_search`, `struct ocfs2_xa_loc`, `struct ocfs2_xa_loc_operations`, `struct ocfs2_xa_loc`, `struct ocfs2_rm_xattr_bucket_para`, `struct ocfs2_xattr_tree_list`.
- 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.