30 #include <linux/module.h>
34 #include <linux/poll.h>
35 #include <linux/slab.h>
41 #include <asm/uaccess.h>
51 static int isolated_loader_size;
80 static void spufs_destroy_inode(
struct inode *inode)
86 spufs_init_once(
void *
p)
113 struct inode *inode = dentry->
d_inode;
119 mark_inode_dirty(inode);
125 spufs_new_file(
struct super_block *sb,
struct dentry *dentry,
136 inode = spufs_new_inode(sb,
S_IFREG | mode);
141 inode->
i_op = &spufs_file_iops;
145 d_add(dentry, inode);
151 spufs_evict_inode(
struct inode *inode)
161 static void spufs_prune_dir(
struct dentry *dir)
163 struct dentry *dentry, *
tmp;
167 spin_lock(&dentry->
d_lock);
168 if (!(d_unhashed(dentry)) && dentry->
d_inode) {
171 spin_unlock(&dentry->
d_lock);
178 spin_unlock(&dentry->
d_lock);
186 static int spufs_rmdir(
struct inode *parent,
struct dentry *dir)
190 spufs_prune_dir(dir);
198 static int spufs_fill_dir(
struct dentry *dir,
202 struct dentry *dentry, *
tmp;
205 while (files->
name && files->
name[0]) {
210 ret = spufs_new_file(dir->
d_sb, dentry, files->
ops,
211 files->
mode & mode, files->
size, ctx);
235 static int spufs_dir_close(
struct inode *inode,
struct file *
file)
238 struct inode *parent;
242 dir = file->
f_path.dentry;
247 ret = spufs_rmdir(parent, dir);
256 .release = spufs_dir_close,
265 spufs_mkdir(
struct inode *dir,
struct dentry *dentry,
unsigned int flags,
273 inode = spufs_new_inode(dir->
i_sb, mode |
S_IFDIR);
289 if (flags & SPU_CREATE_NOSCHED)
298 if (spufs_get_sb_info(dir->
i_sb)->debug)
320 static int spufs_context_open(
struct path *
path)
332 return PTR_ERR(filp);
341 spufs_assert_affinity(
unsigned int flags,
struct spu_gang *
gang,
349 struct spu, cbe_list))->aff_list);
354 if (flags & SPU_CREATE_GANG)
357 if (flags & SPU_CREATE_AFFINITY_MEM &&
359 gang->
aff_ref_ctx->flags & SPU_CREATE_AFFINITY_MEM)
363 return ERR_PTR(-
EBUSY);
366 if (flags & SPU_CREATE_AFFINITY_SPU) {
367 if (!filp || filp->
f_op != &spufs_context_fops)
371 SPUFS_I(filp->f_dentry->d_inode)->i_ctx);
378 goto out_put_neighbor;
381 if (gang != neighbor->
gang) {
383 goto out_put_neighbor;
398 if (node == MAX_NUMNODES) {
400 goto out_put_neighbor;
412 spufs_set_affinity(
unsigned int flags,
struct spu_context *ctx,
415 if (flags & SPU_CREATE_AFFINITY_MEM)
418 if (flags & SPU_CREATE_AFFINITY_SPU) {
419 if (list_empty(&neighbor->
aff_list)) {
421 &ctx->
gang->aff_list_head);
425 if (list_is_last(&neighbor->
aff_list, &ctx->
gang->aff_list_head)
437 if (!ctx->
gang->aff_ref_ctx)
443 spufs_create_context(
struct inode *inode,
struct dentry *dentry,
445 struct file *aff_filp)
451 struct path path = {.
mnt =
mnt, .dentry = dentry};
453 if ((flags & SPU_CREATE_NOSCHED) &&
457 if ((flags & (SPU_CREATE_NOSCHED | SPU_CREATE_ISOLATE))
458 == SPU_CREATE_ISOLATE)
466 affinity = flags & (SPU_CREATE_AFFINITY_MEM | SPU_CREATE_AFFINITY_SPU);
472 neighbor = spufs_assert_affinity(flags, gang, aff_filp);
473 if (IS_ERR(neighbor)) {
474 ret = PTR_ERR(neighbor);
479 ret = spufs_mkdir(inode, dentry, flags, mode &
S_IRWXUGO);
490 ret = spufs_context_open(&path);
492 WARN_ON(spufs_rmdir(inode, dentry));
501 spufs_mkgang(
struct inode *dir,
struct dentry *dentry,
umode_t mode)
508 inode = spufs_new_inode(dir->
i_sb, mode |
S_IFDIR);
537 static int spufs_gang_open(
struct path *path)
553 return PTR_ERR(filp);
561 static int spufs_create_gang(
struct inode *inode,
562 struct dentry *dentry,
565 struct path path = {.
mnt =
mnt, .dentry = dentry};
568 ret = spufs_mkgang(inode, dentry, mode &
S_IRWXUGO);
570 ret = spufs_gang_open(&path);
583 unsigned int flags,
umode_t mode,
struct file *filp)
585 struct inode *dir = path->
dentry->d_inode;
589 if (path->
dentry->d_sb->s_type != &spufs_type)
593 if (flags & (~SPU_CREATE_FLAG_ALL))
598 if ((flags & SPU_CREATE_GANG) || !
SPUFS_I(dir)->i_gang)
603 if (flags & SPU_CREATE_GANG)
604 ret = spufs_create_gang(dir, dentry, path->
mnt, mode);
606 ret = spufs_create_context(dir, dentry, path->
mnt, flags, mode,
609 fsnotify_mkdir(dir, dentry);
657 spufs_get_sb_info(sb)->debug = 1;
666 static void spufs_exit_isolated_loader(
void)
673 spufs_init_isolated_loader(
void)
692 isolated_loader_size =
size;
708 inode = spufs_new_inode(sb,
S_IFDIR | 0775);
718 if (!spufs_parse_options(sb, data, inode))
734 spufs_fill_super(
struct super_block *sb,
void *data,
int silent)
739 .destroy_inode = spufs_destroy_inode,
741 .evict_inode = spufs_evict_inode,
758 return spufs_create_root(sb, data);
761 static struct dentry *
763 const char *
name,
void *data)
765 return mount_single(fstype, flags, data, spufs_fill_super);
771 .mount = spufs_mount,
775 static int __init spufs_init(
void)
788 if (!spufs_inode_cache)
800 spufs_init_isolated_loader();
815 static void __exit spufs_exit(
void)
818 spufs_exit_isolated_loader();