fs/f2fs/xattr.c
Source file repositories/reference/linux-study-clean/fs/f2fs/xattr.c
File Facts
- System
- Linux kernel
- Corpus path
fs/f2fs/xattr.c- Extension
.c- Size
- 21429 bytes
- Lines
- 845
- 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.
- 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/rwsem.hlinux/f2fs_fs.hlinux/security.hlinux/posix_acl_xattr.hf2fs.hxattr.hsegment.h
Detected Declarations
function xattr_freefunction f2fs_xattr_generic_getfunction f2fs_xattr_generic_setfunction f2fs_xattr_user_listfunction f2fs_xattr_trusted_listfunction f2fs_xattr_advise_getfunction f2fs_xattr_advise_setfunction f2fs_initxattrsfunction f2fs_init_securityfunction list_for_each_xattrfunction read_inline_xattrfunction read_xattr_blockfunction lookup_all_xattrsfunction read_all_xattrsfunction write_all_xattrsfunction f2fs_getxattrfunction f2fs_listxattrfunction list_for_each_xattrfunction f2fs_xattr_value_samefunction __f2fs_setxattrfunction f2fs_setxattrfunction f2fs_init_xattr_cachefunction f2fs_destroy_xattr_cache
Annotated Snippet
if (*xe) {
*base_size = inline_size;
goto check;
}
}
/* read from xattr node block */
if (xnid) {
err = read_xattr_block(inode, txattr_addr);
if (err)
goto out;
}
if (last_addr)
cur_addr = XATTR_HDR(last_addr) - 1;
else
cur_addr = txattr_addr;
*xe = __find_xattr(cur_addr, last_txattr_addr, NULL, index, len, name);
if (!*xe) {
f2fs_err(F2FS_I_SB(inode), "lookup inode (%llu) has corrupted xattr",
inode->i_ino);
set_sbi_flag(F2FS_I_SB(inode), SBI_NEED_FSCK);
err = -ENODATA;
f2fs_handle_error(F2FS_I_SB(inode),
ERROR_CORRUPTED_XATTR);
goto out;
}
check:
if (IS_XATTR_LAST_ENTRY(*xe)) {
err = -ENODATA;
goto out;
}
*base_addr = txattr_addr;
return 0;
out:
xattr_free(F2FS_I_SB(inode), txattr_addr, *is_inline);
return err;
}
static int read_all_xattrs(struct inode *inode, struct folio *ifolio,
void **base_addr)
{
struct f2fs_xattr_header *header;
nid_t xnid = F2FS_I(inode)->i_xattr_nid;
unsigned int size = VALID_XATTR_BLOCK_SIZE;
unsigned int inline_size = inline_xattr_size(inode);
void *txattr_addr;
int err;
txattr_addr = f2fs_kzalloc(F2FS_I_SB(inode),
inline_size + size + XATTR_PADDING_SIZE, GFP_NOFS);
if (!txattr_addr)
return -ENOMEM;
/* read from inline xattr */
if (inline_size) {
err = read_inline_xattr(inode, ifolio, txattr_addr);
if (err)
goto fail;
}
/* read from xattr node block */
if (xnid) {
err = read_xattr_block(inode, txattr_addr);
if (err)
goto fail;
}
header = XATTR_HDR(txattr_addr);
/* never been allocated xattrs */
if (le32_to_cpu(header->h_magic) != F2FS_XATTR_MAGIC) {
header->h_magic = cpu_to_le32(F2FS_XATTR_MAGIC);
header->h_refcount = cpu_to_le32(1);
}
*base_addr = txattr_addr;
return 0;
fail:
kfree(txattr_addr);
return err;
}
static inline int write_all_xattrs(struct inode *inode, __u32 hsize,
void *txattr_addr, struct folio *ifolio)
{
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
size_t inline_size = inline_xattr_size(inode);
struct folio *in_folio = NULL;
Annotation
- Immediate include surface: `linux/rwsem.h`, `linux/f2fs_fs.h`, `linux/security.h`, `linux/posix_acl_xattr.h`, `f2fs.h`, `xattr.h`, `segment.h`.
- Detected declarations: `function xattr_free`, `function f2fs_xattr_generic_get`, `function f2fs_xattr_generic_set`, `function f2fs_xattr_user_list`, `function f2fs_xattr_trusted_list`, `function f2fs_xattr_advise_get`, `function f2fs_xattr_advise_set`, `function f2fs_initxattrs`, `function f2fs_init_security`, `function list_for_each_xattr`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
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.