arch/powerpc/platforms/cell/spufs/inode.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/cell/spufs/inode.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/cell/spufs/inode.c- Extension
.c- Size
- 17801 bytes
- Lines
- 816
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- 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.
- 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/file.hlinux/fs.hlinux/fs_context.hlinux/fs_parser.hlinux/fsnotify.hlinux/backing-dev.hlinux/init.hlinux/ioctl.hlinux/module.hlinux/mount.hlinux/namei.hlinux/pagemap.hlinux/poll.hlinux/of.hlinux/seq_file.hlinux/slab.hasm/spu.hasm/spu_priv1.hlinux/uaccess.hspufs.h
Detected Declarations
struct spufs_sb_infostruct spufs_fs_contextfunction spufs_alloc_inodefunction spufs_free_inodefunction spufs_init_oncefunction spufs_new_inodefunction spufs_setattrfunction spufs_new_filefunction spufs_evict_inodefunction spufs_rmdirfunction spufs_fill_dirfunction unuse_gangfunction spufs_dir_closefunction spufs_mkdirfunction spufs_context_openfunction spufs_assert_affinityfunction spufs_set_affinityfunction spufs_create_contextfunction spufs_mkgangfunction spufs_gang_closefunction spufs_gang_openfunction spufs_create_gangfunction spufs_createfunction spufs_show_optionsfunction spufs_parse_paramfunction spufs_exit_isolated_loaderfunction spufs_init_isolated_loaderfunction spufs_create_rootfunction spufs_fill_superfunction spufs_get_treefunction spufs_free_fcfunction spufs_init_fs_contextfunction spufs_initfunction spufs_exitmodule init spufs_initexport spufs_context_fops
Annotated Snippet
const struct file_operations *fops, umode_t mode,
size_t size, struct spu_context *ctx)
{
static const struct inode_operations spufs_file_iops = {
.setattr = spufs_setattr,
};
struct inode *inode;
int ret;
ret = -ENOSPC;
inode = spufs_new_inode(sb, S_IFREG | mode);
if (!inode)
goto out;
ret = 0;
inode->i_op = &spufs_file_iops;
inode->i_fop = fops;
inode->i_size = size;
inode->i_private = SPUFS_I(inode)->i_ctx = get_spu_context(ctx);
d_make_persistent(dentry, inode);
out:
return ret;
}
static void
spufs_evict_inode(struct inode *inode)
{
struct spufs_inode_info *ei = SPUFS_I(inode);
clear_inode(inode);
if (ei->i_ctx)
put_spu_context(ei->i_ctx);
if (ei->i_gang)
put_spu_gang(ei->i_gang);
}
/* Caller must hold parent->i_mutex */
static void spufs_rmdir(struct inode *parent, struct dentry *dir)
{
struct spu_context *ctx = SPUFS_I(d_inode(dir))->i_ctx;
locked_recursive_removal(dir, NULL);
spu_forget(ctx);
}
static int spufs_fill_dir(struct dentry *dir,
const struct spufs_tree_descr *files, umode_t mode,
struct spu_context *ctx)
{
while (files->name && files->name[0]) {
int ret;
struct dentry *dentry = d_alloc_name(dir, files->name);
if (!dentry)
return -ENOMEM;
ret = spufs_new_file(dir->d_sb, dentry, files->ops,
files->mode & mode, files->size, ctx);
dput(dentry);
if (ret)
return ret;
files++;
}
return 0;
}
static void unuse_gang(struct dentry *dir)
{
struct inode *inode = dir->d_inode;
struct spu_gang *gang = SPUFS_I(inode)->i_gang;
if (gang) {
bool dead;
inode_lock(inode); // exclusion with spufs_create_context()
dead = !--gang->alive;
inode_unlock(inode);
if (dead)
simple_recursive_removal(dir, NULL);
}
}
static int spufs_dir_close(struct inode *inode, struct file *file)
{
struct inode *parent;
struct dentry *dir;
dir = file->f_path.dentry;
parent = d_inode(dir->d_parent);
inode_lock_nested(parent, I_MUTEX_PARENT);
spufs_rmdir(parent, dir);
Annotation
- Immediate include surface: `linux/file.h`, `linux/fs.h`, `linux/fs_context.h`, `linux/fs_parser.h`, `linux/fsnotify.h`, `linux/backing-dev.h`, `linux/init.h`, `linux/ioctl.h`.
- Detected declarations: `struct spufs_sb_info`, `struct spufs_fs_context`, `function spufs_alloc_inode`, `function spufs_free_inode`, `function spufs_init_once`, `function spufs_new_inode`, `function spufs_setattr`, `function spufs_new_file`, `function spufs_evict_inode`, `function spufs_rmdir`.
- Atlas domain: Architecture Layer / arch/powerpc.
- 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.