fs/ext4/inline.c
Source file repositories/reference/linux-study-clean/fs/ext4/inline.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ext4/inline.c- Extension
.c- Size
- 50807 bytes
- Lines
- 2001
- 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/iomap.hlinux/fiemap.hlinux/namei.hlinux/iversion.hlinux/sched/mm.hext4_jbd2.hext4.hxattr.htruncate.h
Detected Declarations
function ext4_get_inline_sizefunction get_max_inline_xattr_value_sizefunction ext4_get_max_inline_sizefunction ext4_find_inline_data_nolockfunction ext4_read_inline_datafunction ext4_write_inline_datafunction ext4_create_inline_datafunction ext4_update_inline_datafunction ext4_prepare_inline_datafunction ext4_destroy_inline_data_nolockfunction ext4_read_inline_foliofunction ext4_readpage_inlinefunction ext4_convert_inline_data_to_extentfunction writepagesfunction ext4_try_to_write_inline_datafunction ext4_write_inline_data_endfunction ext4_da_convert_inline_data_to_extentfunction ext4_show_inline_dirfunction ext4_add_dirent_to_inlinefunction ext4_update_final_defunction ext4_update_inline_dirfunction ext4_restore_inline_datafunction ext4_convert_inline_data_nolockfunction ext4_try_add_inline_entryfunction ext4_inlinedir_to_treefunction ext4_read_inline_dirfunction readdirfunction ext4_try_create_inline_dirfunction ext4_delete_inline_entryfunction ext4_get_inline_entryfunction empty_inline_dirfunction ext4_destroy_inline_datafunction ext4_inline_data_iomapfunction ext4_inline_data_truncatefunction ext4_convert_inline_data
Annotated Snippet
if (next >= end) {
EXT4_ERROR_INODE(inode,
"corrupt xattr in inline inode");
return 0;
}
if (!entry->e_value_inum && entry->e_value_size) {
size_t offs = le16_to_cpu(entry->e_value_offs);
if (offs < min_offs)
min_offs = offs;
}
entry = next;
}
free = min_offs -
((void *)entry - (void *)IFIRST(header)) - sizeof(__u32);
if (EXT4_I(inode)->i_inline_off) {
entry = (struct ext4_xattr_entry *)
((void *)raw_inode + EXT4_I(inode)->i_inline_off);
free += EXT4_XATTR_SIZE(le32_to_cpu(entry->e_value_size));
goto out;
}
free -= EXT4_XATTR_LEN(strlen(EXT4_XATTR_SYSTEM_DATA));
if (free > EXT4_XATTR_ROUND)
free = EXT4_XATTR_SIZE(free - EXT4_XATTR_ROUND);
else
free = 0;
out:
return free;
}
/*
* Get the maximum size we now can store in an inode.
* If we can't find the space for a xattr entry, don't use the space
* of the extents since we have no space to indicate the inline data.
*/
int ext4_get_max_inline_size(struct inode *inode)
{
int error, max_inline_size;
struct ext4_iloc iloc;
if (EXT4_I(inode)->i_extra_isize == 0)
return 0;
error = ext4_get_inode_loc(inode, &iloc);
if (error) {
ext4_error_inode_err(inode, __func__, __LINE__, 0, -error,
"can't get inode location %llu",
inode->i_ino);
return 0;
}
down_read(&EXT4_I(inode)->xattr_sem);
max_inline_size = get_max_inline_xattr_value_size(inode, &iloc);
up_read(&EXT4_I(inode)->xattr_sem);
brelse(iloc.bh);
if (!max_inline_size)
return 0;
return max_inline_size + EXT4_MIN_INLINE_DATA_SIZE;
}
/*
* this function does not take xattr_sem, which is OK because it is
* currently only used in a code path coming form ext4_iget, before
* the new inode has been unlocked
*/
int ext4_find_inline_data_nolock(struct inode *inode)
{
struct ext4_xattr_ibody_find is = {
.s = { .not_found = -ENODATA, },
};
struct ext4_xattr_info i = {
.name_index = EXT4_XATTR_INDEX_SYSTEM,
.name = EXT4_XATTR_SYSTEM_DATA,
};
int error;
if (EXT4_I(inode)->i_extra_isize == 0)
return 0;
error = ext4_get_inode_loc(inode, &is.iloc);
if (error)
return error;
Annotation
- Immediate include surface: `linux/iomap.h`, `linux/fiemap.h`, `linux/namei.h`, `linux/iversion.h`, `linux/sched/mm.h`, `ext4_jbd2.h`, `ext4.h`, `xattr.h`.
- Detected declarations: `function ext4_get_inline_size`, `function get_max_inline_xattr_value_size`, `function ext4_get_max_inline_size`, `function ext4_find_inline_data_nolock`, `function ext4_read_inline_data`, `function ext4_write_inline_data`, `function ext4_create_inline_data`, `function ext4_update_inline_data`, `function ext4_prepare_inline_data`, `function ext4_destroy_inline_data_nolock`.
- 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.