fs/erofs/ishare.c
Source file repositories/reference/linux-study-clean/fs/erofs/ishare.c
File Facts
- System
- Linux kernel
- Corpus path
fs/erofs/ishare.c- Extension
.c- Size
- 5889 bytes
- Lines
- 230
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/xxhash.hlinux/mount.hlinux/security.hinternal.hxattr.h../internal.h
Detected Declarations
function erofs_is_ishare_inodefunction erofs_ishare_iget5_eqfunction erofs_ishare_iget5_setfunction erofs_ishare_fill_inodefunction erofs_ishare_free_inodefunction erofs_ishare_file_openfunction erofs_ishare_file_releasefunction erofs_ishare_file_read_iterfunction erofs_ishare_mmapfunction erofs_ishare_fadvisefunction erofs_init_isharefunction erofs_exit_ishare
Annotated Snippet
const struct file_operations erofs_ishare_fops = {
.open = erofs_ishare_file_open,
.llseek = generic_file_llseek,
.read_iter = erofs_ishare_file_read_iter,
.mmap = erofs_ishare_mmap,
.release = erofs_ishare_file_release,
.get_unmapped_area = thp_get_unmapped_area,
.splice_read = filemap_splice_read,
.fadvise = erofs_ishare_fadvise,
};
struct inode *erofs_real_inode(struct inode *inode, bool *need_iput)
{
struct erofs_inode *vi, *vi_share;
struct inode *realinode;
*need_iput = false;
if (!erofs_is_ishare_inode(inode))
return inode;
vi_share = EROFS_I(inode);
spin_lock(&vi_share->ishare_lock);
/* fetch any one as real inode */
DBG_BUGON(list_empty(&vi_share->ishare_list));
list_for_each_entry(vi, &vi_share->ishare_list, ishare_list) {
realinode = igrab(&vi->vfs_inode);
if (realinode) {
*need_iput = true;
break;
}
}
spin_unlock(&vi_share->ishare_lock);
DBG_BUGON(!realinode);
return realinode;
}
int __init erofs_init_ishare(void)
{
struct vfsmount *mnt;
int ret;
mnt = kern_mount(&erofs_anon_fs_type);
if (IS_ERR(mnt))
return PTR_ERR(mnt);
/* generic_fadvise() doesn't work if s_bdi == &noop_backing_dev_info */
ret = super_setup_bdi(mnt->mnt_sb);
if (ret)
kern_unmount(mnt);
else
erofs_ishare_mnt = mnt;
return ret;
}
void erofs_exit_ishare(void)
{
kern_unmount(erofs_ishare_mnt);
}
Annotation
- Immediate include surface: `linux/xxhash.h`, `linux/mount.h`, `linux/security.h`, `internal.h`, `xattr.h`, `../internal.h`.
- Detected declarations: `function erofs_is_ishare_inode`, `function erofs_ishare_iget5_eq`, `function erofs_ishare_iget5_set`, `function erofs_ishare_fill_inode`, `function erofs_ishare_free_inode`, `function erofs_ishare_file_open`, `function erofs_ishare_file_release`, `function erofs_ishare_file_read_iter`, `function erofs_ishare_mmap`, `function erofs_ishare_fadvise`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: pattern 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.