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.

Dependency Surface

Detected Declarations

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

Implementation Notes