2008-02-15 06:34:32 +03:00
|
|
|
|
2005-11-15 23:53:48 +03:00
|
|
|
/*
|
|
|
|
* SPU file system
|
|
|
|
*
|
|
|
|
* (C) Copyright IBM Deutschland Entwicklung GmbH 2005
|
|
|
|
*
|
|
|
|
* Author: Arnd Bergmann <arndb@de.ibm.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/file.h>
|
|
|
|
#include <linux/fs.h>
|
2008-05-06 03:24:24 +04:00
|
|
|
#include <linux/fsnotify.h>
|
2005-11-15 23:53:48 +03:00
|
|
|
#include <linux/backing-dev.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/ioctl.h>
|
|
|
|
#include <linux/module.h>
|
2006-01-04 22:31:26 +03:00
|
|
|
#include <linux/mount.h>
|
2005-11-15 23:53:48 +03:00
|
|
|
#include <linux/namei.h>
|
|
|
|
#include <linux/pagemap.h>
|
|
|
|
#include <linux/poll.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/parser.h>
|
|
|
|
|
2006-10-24 20:31:18 +04:00
|
|
|
#include <asm/prom.h>
|
2005-11-15 23:53:48 +03:00
|
|
|
#include <asm/spu.h>
|
2007-04-23 23:08:29 +04:00
|
|
|
#include <asm/spu_priv1.h>
|
2005-11-15 23:53:48 +03:00
|
|
|
#include <asm/uaccess.h>
|
|
|
|
|
|
|
|
#include "spufs.h"
|
|
|
|
|
2008-07-03 05:42:20 +04:00
|
|
|
struct spufs_sb_info {
|
|
|
|
int debug;
|
|
|
|
};
|
|
|
|
|
2006-12-07 07:33:20 +03:00
|
|
|
static struct kmem_cache *spufs_inode_cache;
|
2006-11-20 20:45:10 +03:00
|
|
|
char *isolated_loader;
|
2007-09-19 08:38:12 +04:00
|
|
|
static int isolated_loader_size;
|
2005-11-15 23:53:48 +03:00
|
|
|
|
2008-07-03 05:42:20 +04:00
|
|
|
static struct spufs_sb_info *spufs_get_sb_info(struct super_block *sb)
|
|
|
|
{
|
|
|
|
return sb->s_fs_info;
|
|
|
|
}
|
|
|
|
|
2005-11-15 23:53:48 +03:00
|
|
|
static struct inode *
|
|
|
|
spufs_alloc_inode(struct super_block *sb)
|
|
|
|
{
|
|
|
|
struct spufs_inode_info *ei;
|
|
|
|
|
2006-12-07 07:33:17 +03:00
|
|
|
ei = kmem_cache_alloc(spufs_inode_cache, GFP_KERNEL);
|
2005-11-15 23:53:48 +03:00
|
|
|
if (!ei)
|
|
|
|
return NULL;
|
2006-10-04 19:26:15 +04:00
|
|
|
|
|
|
|
ei->i_gang = NULL;
|
|
|
|
ei->i_ctx = NULL;
|
2007-04-23 23:08:07 +04:00
|
|
|
ei->i_openers = 0;
|
2006-10-04 19:26:15 +04:00
|
|
|
|
2005-11-15 23:53:48 +03:00
|
|
|
return &ei->vfs_inode;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
spufs_destroy_inode(struct inode *inode)
|
|
|
|
{
|
|
|
|
kmem_cache_free(spufs_inode_cache, SPUFS_I(inode));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-07-26 06:45:34 +04:00
|
|
|
spufs_init_once(void *p)
|
2005-11-15 23:53:48 +03:00
|
|
|
{
|
|
|
|
struct spufs_inode_info *ei = p;
|
|
|
|
|
2007-05-17 09:10:57 +04:00
|
|
|
inode_init_once(&ei->vfs_inode);
|
2005-11-15 23:53:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct inode *
|
|
|
|
spufs_new_inode(struct super_block *sb, int mode)
|
|
|
|
{
|
|
|
|
struct inode *inode;
|
|
|
|
|
|
|
|
inode = new_inode(sb);
|
|
|
|
if (!inode)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
inode->i_mode = mode;
|
2008-11-14 02:38:39 +03:00
|
|
|
inode->i_uid = current_fsuid();
|
|
|
|
inode->i_gid = current_fsgid();
|
2005-11-15 23:53:48 +03:00
|
|
|
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
|
|
|
|
out:
|
|
|
|
return inode;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
spufs_setattr(struct dentry *dentry, struct iattr *attr)
|
|
|
|
{
|
|
|
|
struct inode *inode = dentry->d_inode;
|
|
|
|
|
|
|
|
if ((attr->ia_valid & ATTR_SIZE) &&
|
|
|
|
(attr->ia_size != inode->i_size))
|
|
|
|
return -EINVAL;
|
|
|
|
return inode_setattr(inode, attr);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
spufs_new_file(struct super_block *sb, struct dentry *dentry,
|
2006-03-28 13:56:41 +04:00
|
|
|
const struct file_operations *fops, int mode,
|
2008-06-30 06:17:28 +04:00
|
|
|
size_t size, struct spu_context *ctx)
|
2005-11-15 23:53:48 +03:00
|
|
|
{
|
|
|
|
static 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;
|
2008-06-30 06:17:28 +04:00
|
|
|
inode->i_size = size;
|
2006-09-27 12:50:46 +04:00
|
|
|
inode->i_private = SPUFS_I(inode)->i_ctx = get_spu_context(ctx);
|
2005-11-15 23:53:48 +03:00
|
|
|
d_add(dentry, inode);
|
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
spufs_delete_inode(struct inode *inode)
|
|
|
|
{
|
2006-10-04 19:26:15 +04:00
|
|
|
struct spufs_inode_info *ei = SPUFS_I(inode);
|
|
|
|
|
|
|
|
if (ei->i_ctx)
|
|
|
|
put_spu_context(ei->i_ctx);
|
|
|
|
if (ei->i_gang)
|
|
|
|
put_spu_gang(ei->i_gang);
|
2005-11-15 23:53:48 +03:00
|
|
|
clear_inode(inode);
|
|
|
|
}
|
|
|
|
|
2006-01-04 22:31:27 +03:00
|
|
|
static void spufs_prune_dir(struct dentry *dir)
|
2005-11-15 23:53:48 +03:00
|
|
|
{
|
2005-11-15 23:53:52 +03:00
|
|
|
struct dentry *dentry, *tmp;
|
2006-10-04 19:26:15 +04:00
|
|
|
|
2006-01-10 02:59:24 +03:00
|
|
|
mutex_lock(&dir->d_inode->i_mutex);
|
2006-01-10 07:51:24 +03:00
|
|
|
list_for_each_entry_safe(dentry, tmp, &dir->d_subdirs, d_u.d_child) {
|
2005-11-15 23:53:52 +03:00
|
|
|
spin_lock(&dcache_lock);
|
2005-11-15 23:53:48 +03:00
|
|
|
spin_lock(&dentry->d_lock);
|
2005-11-15 23:53:52 +03:00
|
|
|
if (!(d_unhashed(dentry)) && dentry->d_inode) {
|
|
|
|
dget_locked(dentry);
|
|
|
|
__d_drop(dentry);
|
|
|
|
spin_unlock(&dentry->d_lock);
|
2006-01-04 22:31:27 +03:00
|
|
|
simple_unlink(dir->d_inode, dentry);
|
2005-11-15 23:53:52 +03:00
|
|
|
spin_unlock(&dcache_lock);
|
|
|
|
dput(dentry);
|
|
|
|
} else {
|
|
|
|
spin_unlock(&dentry->d_lock);
|
|
|
|
spin_unlock(&dcache_lock);
|
|
|
|
}
|
2005-11-15 23:53:48 +03:00
|
|
|
}
|
2006-01-04 22:31:27 +03:00
|
|
|
shrink_dcache_parent(dir);
|
2006-01-10 02:59:24 +03:00
|
|
|
mutex_unlock(&dir->d_inode->i_mutex);
|
2006-01-04 22:31:27 +03:00
|
|
|
}
|
|
|
|
|
2006-10-04 19:26:15 +04:00
|
|
|
/* Caller must hold parent->i_mutex */
|
|
|
|
static int spufs_rmdir(struct inode *parent, struct dentry *dir)
|
2006-01-04 22:31:27 +03:00
|
|
|
{
|
|
|
|
/* remove all entries */
|
2006-10-04 19:26:15 +04:00
|
|
|
spufs_prune_dir(dir);
|
2007-11-16 05:32:23 +03:00
|
|
|
d_drop(dir);
|
2005-11-15 23:53:52 +03:00
|
|
|
|
2006-10-04 19:26:15 +04:00
|
|
|
return simple_rmdir(parent, dir);
|
2005-11-15 23:53:48 +03:00
|
|
|
}
|
|
|
|
|
2008-06-30 06:17:28 +04:00
|
|
|
static int spufs_fill_dir(struct dentry *dir, struct spufs_tree_descr *files,
|
2006-01-04 22:31:27 +03:00
|
|
|
int mode, struct spu_context *ctx)
|
|
|
|
{
|
2007-06-06 08:03:58 +04:00
|
|
|
struct dentry *dentry, *tmp;
|
2006-01-04 22:31:27 +03:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
while (files->name && files->name[0]) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
dentry = d_alloc_name(dir, files->name);
|
|
|
|
if (!dentry)
|
|
|
|
goto out;
|
|
|
|
ret = spufs_new_file(dir->d_sb, dentry, files->ops,
|
2008-06-30 06:17:28 +04:00
|
|
|
files->mode & mode, files->size, ctx);
|
2006-01-04 22:31:27 +03:00
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
files++;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
out:
|
2007-06-06 08:03:58 +04:00
|
|
|
/*
|
|
|
|
* remove all children from dir. dir->inode is not set so don't
|
|
|
|
* just simply use spufs_prune_dir() and panic afterwards :)
|
|
|
|
* dput() looks like it will do the right thing:
|
|
|
|
* - dec parent's ref counter
|
|
|
|
* - remove child from parent's child list
|
|
|
|
* - free child's inode if possible
|
|
|
|
* - free child
|
|
|
|
*/
|
|
|
|
list_for_each_entry_safe(dentry, tmp, &dir->d_subdirs, d_u.d_child) {
|
|
|
|
dput(dentry);
|
|
|
|
}
|
|
|
|
|
|
|
|
shrink_dcache_parent(dir);
|
2006-01-04 22:31:27 +03:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-11-15 23:53:48 +03:00
|
|
|
static int spufs_dir_close(struct inode *inode, struct file *file)
|
|
|
|
{
|
2006-06-19 22:33:22 +04:00
|
|
|
struct spu_context *ctx;
|
2006-10-04 19:26:15 +04:00
|
|
|
struct inode *parent;
|
|
|
|
struct dentry *dir;
|
2005-11-15 23:53:48 +03:00
|
|
|
int ret;
|
|
|
|
|
2006-12-08 13:37:30 +03:00
|
|
|
dir = file->f_path.dentry;
|
2006-10-04 19:26:15 +04:00
|
|
|
parent = dir->d_parent->d_inode;
|
|
|
|
ctx = SPUFS_I(dir->d_inode)->i_ctx;
|
2006-01-04 22:31:22 +03:00
|
|
|
|
2008-05-08 09:29:12 +04:00
|
|
|
mutex_lock_nested(&parent->i_mutex, I_MUTEX_PARENT);
|
2006-10-04 19:26:15 +04:00
|
|
|
ret = spufs_rmdir(parent, dir);
|
|
|
|
mutex_unlock(&parent->i_mutex);
|
2005-11-15 23:53:48 +03:00
|
|
|
WARN_ON(ret);
|
2006-01-04 22:31:22 +03:00
|
|
|
|
2006-06-19 22:33:22 +04:00
|
|
|
/* We have to give up the mm_struct */
|
|
|
|
spu_forget(ctx);
|
|
|
|
|
2005-11-15 23:53:48 +03:00
|
|
|
return dcache_dir_close(inode, file);
|
|
|
|
}
|
|
|
|
|
2007-02-12 11:55:31 +03:00
|
|
|
const struct file_operations spufs_context_fops = {
|
2005-11-15 23:53:48 +03:00
|
|
|
.open = dcache_dir_open,
|
|
|
|
.release = spufs_dir_close,
|
|
|
|
.llseek = dcache_dir_lseek,
|
|
|
|
.read = generic_read_dir,
|
|
|
|
.readdir = dcache_readdir,
|
|
|
|
.fsync = simple_sync_file,
|
|
|
|
};
|
[POWERPC] coredump: Add SPU elf notes to coredump.
This patch adds SPU elf notes to the coredump. It creates a separate note
for each of /regs, /fpcr, /lslr, /decr, /decr_status, /mem, /signal1,
/signal1_type, /signal2, /signal2_type, /event_mask, /event_status,
/mbox_info, /ibox_info, /wbox_info, /dma_info, /proxydma_info, /object-id.
A new macro, ARCH_HAVE_EXTRA_NOTES, was created for architectures to
specify they have extra elf core notes.
A new macro, ELF_CORE_EXTRA_NOTES_SIZE, was created so the size of the
additional notes could be calculated and added to the notes phdr entry.
A new macro, ELF_CORE_WRITE_EXTRA_NOTES, was created so the new notes
would be written after the existing notes.
The SPU coredump code resides in spufs. Stub functions are provided in the
kernel which are hooked into the spufs code which does the actual work via
register_arch_coredump_calls().
A new set of __spufs_<file>_read/get() functions was provided to allow the
coredump code to read from the spufs files without having to lock the
SPU context for each file read from.
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Dwayne Grant McConnell <decimal@us.ibm.com>
Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
2006-11-23 02:46:37 +03:00
|
|
|
EXPORT_SYMBOL_GPL(spufs_context_fops);
|
2005-11-15 23:53:48 +03:00
|
|
|
|
|
|
|
static int
|
2006-10-04 19:26:14 +04:00
|
|
|
spufs_mkdir(struct inode *dir, struct dentry *dentry, unsigned int flags,
|
|
|
|
int mode)
|
2005-11-15 23:53:48 +03:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct inode *inode;
|
|
|
|
struct spu_context *ctx;
|
|
|
|
|
|
|
|
ret = -ENOSPC;
|
|
|
|
inode = spufs_new_inode(dir->i_sb, mode | S_IFDIR);
|
|
|
|
if (!inode)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (dir->i_mode & S_ISGID) {
|
|
|
|
inode->i_gid = dir->i_gid;
|
|
|
|
inode->i_mode &= S_ISGID;
|
|
|
|
}
|
2006-10-04 19:26:15 +04:00
|
|
|
ctx = alloc_spu_context(SPUFS_I(dir)->i_gang); /* XXX gang */
|
2005-11-15 23:53:48 +03:00
|
|
|
SPUFS_I(inode)->i_ctx = ctx;
|
|
|
|
if (!ctx)
|
|
|
|
goto out_iput;
|
|
|
|
|
2006-10-04 19:26:14 +04:00
|
|
|
ctx->flags = flags;
|
2007-06-29 04:57:59 +04:00
|
|
|
inode->i_op = &simple_dir_inode_operations;
|
2005-11-15 23:53:48 +03:00
|
|
|
inode->i_fop = &simple_dir_operations;
|
2006-10-24 20:31:16 +04:00
|
|
|
if (flags & SPU_CREATE_NOSCHED)
|
|
|
|
ret = spufs_fill_dir(dentry, spufs_dir_nosched_contents,
|
|
|
|
mode, ctx);
|
|
|
|
else
|
|
|
|
ret = spufs_fill_dir(dentry, spufs_dir_contents, mode, ctx);
|
|
|
|
|
2005-11-15 23:53:48 +03:00
|
|
|
if (ret)
|
|
|
|
goto out_free_ctx;
|
|
|
|
|
2008-07-03 05:42:20 +04:00
|
|
|
if (spufs_get_sb_info(dir->i_sb)->debug)
|
|
|
|
ret = spufs_fill_dir(dentry, spufs_dir_debug_contents,
|
|
|
|
mode, ctx);
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
goto out_free_ctx;
|
|
|
|
|
2005-11-15 23:53:48 +03:00
|
|
|
d_instantiate(dentry, inode);
|
|
|
|
dget(dentry);
|
2008-10-09 03:39:21 +04:00
|
|
|
inc_nlink(dir);
|
|
|
|
inc_nlink(dentry->d_inode);
|
2005-11-15 23:53:48 +03:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
out_free_ctx:
|
2007-06-04 17:26:51 +04:00
|
|
|
spu_forget(ctx);
|
2005-11-15 23:53:48 +03:00
|
|
|
put_spu_context(ctx);
|
|
|
|
out_iput:
|
|
|
|
iput(inode);
|
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-01-04 22:31:26 +03:00
|
|
|
static int spufs_context_open(struct dentry *dentry, struct vfsmount *mnt)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct file *filp;
|
|
|
|
|
|
|
|
ret = get_unused_fd();
|
|
|
|
if (ret < 0) {
|
|
|
|
dput(dentry);
|
|
|
|
mntput(mnt);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2008-11-14 02:39:22 +03:00
|
|
|
filp = dentry_open(dentry, mnt, O_RDONLY, current_cred());
|
2006-01-04 22:31:26 +03:00
|
|
|
if (IS_ERR(filp)) {
|
|
|
|
put_unused_fd(ret);
|
|
|
|
ret = PTR_ERR(filp);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
filp->f_op = &spufs_context_fops;
|
|
|
|
fd_install(ret, filp);
|
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-07-20 23:39:47 +04:00
|
|
|
static struct spu_context *
|
|
|
|
spufs_assert_affinity(unsigned int flags, struct spu_gang *gang,
|
|
|
|
struct file *filp)
|
|
|
|
{
|
2008-01-11 07:03:26 +03:00
|
|
|
struct spu_context *tmp, *neighbor, *err;
|
2007-07-20 23:39:47 +04:00
|
|
|
int count, node;
|
|
|
|
int aff_supp;
|
|
|
|
|
|
|
|
aff_supp = !list_empty(&(list_entry(cbe_spu_info[0].spus.next,
|
|
|
|
struct spu, cbe_list))->aff_list);
|
|
|
|
|
|
|
|
if (!aff_supp)
|
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
|
|
|
|
if (flags & SPU_CREATE_GANG)
|
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
|
|
|
|
if (flags & SPU_CREATE_AFFINITY_MEM &&
|
|
|
|
gang->aff_ref_ctx &&
|
|
|
|
gang->aff_ref_ctx->flags & SPU_CREATE_AFFINITY_MEM)
|
|
|
|
return ERR_PTR(-EEXIST);
|
|
|
|
|
|
|
|
if (gang->aff_flags & AFF_MERGED)
|
|
|
|
return ERR_PTR(-EBUSY);
|
|
|
|
|
|
|
|
neighbor = NULL;
|
|
|
|
if (flags & SPU_CREATE_AFFINITY_SPU) {
|
|
|
|
if (!filp || filp->f_op != &spufs_context_fops)
|
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
|
|
|
|
neighbor = get_spu_context(
|
|
|
|
SPUFS_I(filp->f_dentry->d_inode)->i_ctx);
|
|
|
|
|
|
|
|
if (!list_empty(&neighbor->aff_list) && !(neighbor->aff_head) &&
|
|
|
|
!list_is_last(&neighbor->aff_list, &gang->aff_list_head) &&
|
|
|
|
!list_entry(neighbor->aff_list.next, struct spu_context,
|
2008-01-11 07:03:26 +03:00
|
|
|
aff_list)->aff_head) {
|
|
|
|
err = ERR_PTR(-EEXIST);
|
|
|
|
goto out_put_neighbor;
|
|
|
|
}
|
2007-07-20 23:39:47 +04:00
|
|
|
|
2008-01-11 07:03:26 +03:00
|
|
|
if (gang != neighbor->gang) {
|
|
|
|
err = ERR_PTR(-EINVAL);
|
|
|
|
goto out_put_neighbor;
|
|
|
|
}
|
2007-07-20 23:39:47 +04:00
|
|
|
|
|
|
|
count = 1;
|
|
|
|
list_for_each_entry(tmp, &gang->aff_list_head, aff_list)
|
|
|
|
count++;
|
|
|
|
if (list_empty(&neighbor->aff_list))
|
|
|
|
count++;
|
|
|
|
|
|
|
|
for (node = 0; node < MAX_NUMNODES; node++) {
|
|
|
|
if ((cbe_spu_info[node].n_spus - atomic_read(
|
|
|
|
&cbe_spu_info[node].reserved_spus)) >= count)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-01-11 07:03:26 +03:00
|
|
|
if (node == MAX_NUMNODES) {
|
|
|
|
err = ERR_PTR(-EEXIST);
|
|
|
|
goto out_put_neighbor;
|
|
|
|
}
|
2007-07-20 23:39:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return neighbor;
|
2008-01-11 07:03:26 +03:00
|
|
|
|
|
|
|
out_put_neighbor:
|
|
|
|
put_spu_context(neighbor);
|
|
|
|
return err;
|
2007-07-20 23:39:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
spufs_set_affinity(unsigned int flags, struct spu_context *ctx,
|
|
|
|
struct spu_context *neighbor)
|
|
|
|
{
|
|
|
|
if (flags & SPU_CREATE_AFFINITY_MEM)
|
|
|
|
ctx->gang->aff_ref_ctx = ctx;
|
|
|
|
|
|
|
|
if (flags & SPU_CREATE_AFFINITY_SPU) {
|
|
|
|
if (list_empty(&neighbor->aff_list)) {
|
|
|
|
list_add_tail(&neighbor->aff_list,
|
|
|
|
&ctx->gang->aff_list_head);
|
|
|
|
neighbor->aff_head = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (list_is_last(&neighbor->aff_list, &ctx->gang->aff_list_head)
|
|
|
|
|| list_entry(neighbor->aff_list.next, struct spu_context,
|
|
|
|
aff_list)->aff_head) {
|
|
|
|
list_add(&ctx->aff_list, &neighbor->aff_list);
|
|
|
|
} else {
|
|
|
|
list_add_tail(&ctx->aff_list, &neighbor->aff_list);
|
|
|
|
if (neighbor->aff_head) {
|
|
|
|
neighbor->aff_head = 0;
|
|
|
|
ctx->aff_head = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ctx->gang->aff_ref_ctx)
|
|
|
|
ctx->gang->aff_ref_ctx = ctx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
spufs_create_context(struct inode *inode, struct dentry *dentry,
|
|
|
|
struct vfsmount *mnt, int flags, int mode,
|
|
|
|
struct file *aff_filp)
|
2006-10-04 19:26:15 +04:00
|
|
|
{
|
|
|
|
int ret;
|
2007-07-20 23:39:47 +04:00
|
|
|
int affinity;
|
|
|
|
struct spu_gang *gang;
|
|
|
|
struct spu_context *neighbor;
|
2006-10-04 19:26:15 +04:00
|
|
|
|
2006-10-24 20:31:16 +04:00
|
|
|
ret = -EPERM;
|
|
|
|
if ((flags & SPU_CREATE_NOSCHED) &&
|
|
|
|
!capable(CAP_SYS_NICE))
|
|
|
|
goto out_unlock;
|
|
|
|
|
|
|
|
ret = -EINVAL;
|
|
|
|
if ((flags & (SPU_CREATE_NOSCHED | SPU_CREATE_ISOLATE))
|
|
|
|
== SPU_CREATE_ISOLATE)
|
|
|
|
goto out_unlock;
|
|
|
|
|
2006-11-27 21:18:52 +03:00
|
|
|
ret = -ENODEV;
|
|
|
|
if ((flags & SPU_CREATE_ISOLATE) && !isolated_loader)
|
|
|
|
goto out_unlock;
|
|
|
|
|
2007-07-20 23:39:47 +04:00
|
|
|
gang = NULL;
|
|
|
|
neighbor = NULL;
|
|
|
|
affinity = flags & (SPU_CREATE_AFFINITY_MEM | SPU_CREATE_AFFINITY_SPU);
|
|
|
|
if (affinity) {
|
|
|
|
gang = SPUFS_I(inode)->i_gang;
|
|
|
|
ret = -EINVAL;
|
|
|
|
if (!gang)
|
|
|
|
goto out_unlock;
|
|
|
|
mutex_lock(&gang->aff_mutex);
|
|
|
|
neighbor = spufs_assert_affinity(flags, gang, aff_filp);
|
|
|
|
if (IS_ERR(neighbor)) {
|
|
|
|
ret = PTR_ERR(neighbor);
|
|
|
|
goto out_aff_unlock;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-04 19:26:15 +04:00
|
|
|
ret = spufs_mkdir(inode, dentry, flags, mode & S_IRWXUGO);
|
|
|
|
if (ret)
|
2007-07-20 23:39:47 +04:00
|
|
|
goto out_aff_unlock;
|
|
|
|
|
2008-01-11 07:03:26 +03:00
|
|
|
if (affinity) {
|
2007-07-20 23:39:47 +04:00
|
|
|
spufs_set_affinity(flags, SPUFS_I(dentry->d_inode)->i_ctx,
|
|
|
|
neighbor);
|
2008-01-11 07:03:26 +03:00
|
|
|
if (neighbor)
|
|
|
|
put_spu_context(neighbor);
|
|
|
|
}
|
2006-10-04 19:26:15 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* get references for dget and mntget, will be released
|
|
|
|
* in error path of *_open().
|
|
|
|
*/
|
|
|
|
ret = spufs_context_open(dget(dentry), mntget(mnt));
|
|
|
|
if (ret < 0) {
|
|
|
|
WARN_ON(spufs_rmdir(inode, dentry));
|
2008-10-09 03:45:49 +04:00
|
|
|
if (affinity)
|
|
|
|
mutex_unlock(&gang->aff_mutex);
|
2006-10-04 19:26:15 +04:00
|
|
|
mutex_unlock(&inode->i_mutex);
|
|
|
|
spu_forget(SPUFS_I(dentry->d_inode)->i_ctx);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2007-07-20 23:39:47 +04:00
|
|
|
out_aff_unlock:
|
|
|
|
if (affinity)
|
|
|
|
mutex_unlock(&gang->aff_mutex);
|
2006-10-04 19:26:15 +04:00
|
|
|
out_unlock:
|
|
|
|
mutex_unlock(&inode->i_mutex);
|
|
|
|
out:
|
|
|
|
dput(dentry);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
spufs_mkgang(struct inode *dir, struct dentry *dentry, int mode)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct inode *inode;
|
|
|
|
struct spu_gang *gang;
|
|
|
|
|
|
|
|
ret = -ENOSPC;
|
|
|
|
inode = spufs_new_inode(dir->i_sb, mode | S_IFDIR);
|
|
|
|
if (!inode)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
if (dir->i_mode & S_ISGID) {
|
|
|
|
inode->i_gid = dir->i_gid;
|
|
|
|
inode->i_mode &= S_ISGID;
|
|
|
|
}
|
|
|
|
gang = alloc_spu_gang();
|
|
|
|
SPUFS_I(inode)->i_ctx = NULL;
|
|
|
|
SPUFS_I(inode)->i_gang = gang;
|
|
|
|
if (!gang)
|
|
|
|
goto out_iput;
|
|
|
|
|
2007-06-29 04:57:59 +04:00
|
|
|
inode->i_op = &simple_dir_inode_operations;
|
2006-10-04 19:26:15 +04:00
|
|
|
inode->i_fop = &simple_dir_operations;
|
|
|
|
|
|
|
|
d_instantiate(dentry, inode);
|
2008-10-09 03:39:21 +04:00
|
|
|
inc_nlink(dir);
|
|
|
|
inc_nlink(dentry->d_inode);
|
2006-10-04 19:26:15 +04:00
|
|
|
return ret;
|
|
|
|
|
|
|
|
out_iput:
|
|
|
|
iput(inode);
|
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int spufs_gang_open(struct dentry *dentry, struct vfsmount *mnt)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct file *filp;
|
|
|
|
|
|
|
|
ret = get_unused_fd();
|
|
|
|
if (ret < 0) {
|
|
|
|
dput(dentry);
|
|
|
|
mntput(mnt);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2008-11-14 02:39:22 +03:00
|
|
|
filp = dentry_open(dentry, mnt, O_RDONLY, current_cred());
|
2006-10-04 19:26:15 +04:00
|
|
|
if (IS_ERR(filp)) {
|
|
|
|
put_unused_fd(ret);
|
|
|
|
ret = PTR_ERR(filp);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2007-06-04 17:26:51 +04:00
|
|
|
filp->f_op = &simple_dir_operations;
|
2006-10-04 19:26:15 +04:00
|
|
|
fd_install(ret, filp);
|
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int spufs_create_gang(struct inode *inode,
|
|
|
|
struct dentry *dentry,
|
|
|
|
struct vfsmount *mnt, int mode)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = spufs_mkgang(inode, dentry, mode & S_IRWXUGO);
|
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* get references for dget and mntget, will be released
|
|
|
|
* in error path of *_open().
|
|
|
|
*/
|
|
|
|
ret = spufs_gang_open(dget(dentry), mntget(mnt));
|
2007-06-04 17:26:51 +04:00
|
|
|
if (ret < 0) {
|
|
|
|
int err = simple_rmdir(inode, dentry);
|
|
|
|
WARN_ON(err);
|
|
|
|
}
|
2006-10-04 19:26:15 +04:00
|
|
|
|
|
|
|
out:
|
|
|
|
mutex_unlock(&inode->i_mutex);
|
|
|
|
dput(dentry);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-01-04 22:31:26 +03:00
|
|
|
static struct file_system_type spufs_type;
|
|
|
|
|
2007-07-20 23:39:47 +04:00
|
|
|
long spufs_create(struct nameidata *nd, unsigned int flags, mode_t mode,
|
|
|
|
struct file *filp)
|
2005-11-15 23:53:48 +03:00
|
|
|
{
|
|
|
|
struct dentry *dentry;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = -EINVAL;
|
2006-10-04 19:26:15 +04:00
|
|
|
/* check if we are on spufs */
|
2008-02-15 06:34:32 +03:00
|
|
|
if (nd->path.dentry->d_sb->s_type != &spufs_type)
|
2005-11-15 23:53:48 +03:00
|
|
|
goto out;
|
|
|
|
|
2006-10-04 19:26:15 +04:00
|
|
|
/* don't accept undefined flags */
|
2006-10-04 19:26:14 +04:00
|
|
|
if (flags & (~SPU_CREATE_FLAG_ALL))
|
2006-06-19 22:33:34 +04:00
|
|
|
goto out;
|
|
|
|
|
2006-10-04 19:26:15 +04:00
|
|
|
/* only threads can be underneath a gang */
|
2008-02-15 06:34:32 +03:00
|
|
|
if (nd->path.dentry != nd->path.dentry->d_sb->s_root) {
|
2006-10-04 19:26:15 +04:00
|
|
|
if ((flags & SPU_CREATE_GANG) ||
|
2008-02-15 06:34:32 +03:00
|
|
|
!SPUFS_I(nd->path.dentry->d_inode)->i_gang)
|
2006-10-04 19:26:15 +04:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2005-11-15 23:53:48 +03:00
|
|
|
dentry = lookup_create(nd, 1);
|
|
|
|
ret = PTR_ERR(dentry);
|
|
|
|
if (IS_ERR(dentry))
|
|
|
|
goto out_dir;
|
|
|
|
|
|
|
|
ret = -EEXIST;
|
|
|
|
if (dentry->d_inode)
|
|
|
|
goto out_dput;
|
|
|
|
|
|
|
|
mode &= ~current->fs->umask;
|
|
|
|
|
2006-10-04 19:26:15 +04:00
|
|
|
if (flags & SPU_CREATE_GANG)
|
2008-05-06 03:24:24 +04:00
|
|
|
ret = spufs_create_gang(nd->path.dentry->d_inode,
|
2008-02-15 06:34:32 +03:00
|
|
|
dentry, nd->path.mnt, mode);
|
2006-10-04 19:26:15 +04:00
|
|
|
else
|
2008-05-06 03:24:24 +04:00
|
|
|
ret = spufs_create_context(nd->path.dentry->d_inode,
|
2008-02-15 06:34:32 +03:00
|
|
|
dentry, nd->path.mnt, flags, mode,
|
|
|
|
filp);
|
2008-05-06 03:24:24 +04:00
|
|
|
if (ret >= 0)
|
|
|
|
fsnotify_mkdir(nd->path.dentry->d_inode, dentry);
|
|
|
|
return ret;
|
2005-11-15 23:53:48 +03:00
|
|
|
|
|
|
|
out_dput:
|
|
|
|
dput(dentry);
|
|
|
|
out_dir:
|
2008-02-15 06:34:32 +03:00
|
|
|
mutex_unlock(&nd->path.dentry->d_inode->i_mutex);
|
2005-11-15 23:53:48 +03:00
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* File system initialization */
|
|
|
|
enum {
|
2008-07-03 05:42:20 +04:00
|
|
|
Opt_uid, Opt_gid, Opt_mode, Opt_debug, Opt_err,
|
2005-11-15 23:53:48 +03:00
|
|
|
};
|
|
|
|
|
2008-10-13 13:46:57 +04:00
|
|
|
static const match_table_t spufs_tokens = {
|
2008-07-03 05:42:20 +04:00
|
|
|
{ Opt_uid, "uid=%d" },
|
|
|
|
{ Opt_gid, "gid=%d" },
|
|
|
|
{ Opt_mode, "mode=%o" },
|
|
|
|
{ Opt_debug, "debug" },
|
|
|
|
{ Opt_err, NULL },
|
2005-11-15 23:53:48 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2008-07-03 05:42:20 +04:00
|
|
|
spufs_parse_options(struct super_block *sb, char *options, struct inode *root)
|
2005-11-15 23:53:48 +03:00
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
substring_t args[MAX_OPT_ARGS];
|
|
|
|
|
|
|
|
while ((p = strsep(&options, ",")) != NULL) {
|
|
|
|
int token, option;
|
|
|
|
|
|
|
|
if (!*p)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
token = match_token(p, spufs_tokens, args);
|
|
|
|
switch (token) {
|
|
|
|
case Opt_uid:
|
|
|
|
if (match_int(&args[0], &option))
|
|
|
|
return 0;
|
|
|
|
root->i_uid = option;
|
|
|
|
break;
|
|
|
|
case Opt_gid:
|
|
|
|
if (match_int(&args[0], &option))
|
|
|
|
return 0;
|
|
|
|
root->i_gid = option;
|
|
|
|
break;
|
2007-04-23 23:08:23 +04:00
|
|
|
case Opt_mode:
|
|
|
|
if (match_octal(&args[0], &option))
|
|
|
|
return 0;
|
|
|
|
root->i_mode = option | S_IFDIR;
|
|
|
|
break;
|
2008-07-03 05:42:20 +04:00
|
|
|
case Opt_debug:
|
|
|
|
spufs_get_sb_info(sb)->debug = 1;
|
|
|
|
break;
|
2005-11-15 23:53:48 +03:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-04-23 23:08:20 +04:00
|
|
|
static void spufs_exit_isolated_loader(void)
|
|
|
|
{
|
2007-09-19 08:38:12 +04:00
|
|
|
free_pages((unsigned long) isolated_loader,
|
|
|
|
get_order(isolated_loader_size));
|
2007-04-23 23:08:20 +04:00
|
|
|
}
|
|
|
|
|
2006-10-24 20:31:18 +04:00
|
|
|
static void
|
|
|
|
spufs_init_isolated_loader(void)
|
|
|
|
{
|
|
|
|
struct device_node *dn;
|
|
|
|
const char *loader;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
dn = of_find_node_by_path("/spu-isolation");
|
|
|
|
if (!dn)
|
|
|
|
return;
|
|
|
|
|
2007-04-03 16:26:41 +04:00
|
|
|
loader = of_get_property(dn, "loader", &size);
|
2006-10-24 20:31:18 +04:00
|
|
|
if (!loader)
|
|
|
|
return;
|
|
|
|
|
2007-09-19 08:38:12 +04:00
|
|
|
/* the loader must be align on a 16 byte boundary */
|
|
|
|
isolated_loader = (char *)__get_free_pages(GFP_KERNEL, get_order(size));
|
2006-10-24 20:31:18 +04:00
|
|
|
if (!isolated_loader)
|
|
|
|
return;
|
|
|
|
|
2007-09-19 08:38:12 +04:00
|
|
|
isolated_loader_size = size;
|
2006-10-24 20:31:18 +04:00
|
|
|
memcpy(isolated_loader, loader, size);
|
|
|
|
printk(KERN_INFO "spufs: SPU isolation mode enabled\n");
|
|
|
|
}
|
|
|
|
|
2005-11-15 23:53:48 +03:00
|
|
|
static int
|
2005-11-15 23:53:52 +03:00
|
|
|
spufs_create_root(struct super_block *sb, void *data)
|
|
|
|
{
|
2005-11-15 23:53:48 +03:00
|
|
|
struct inode *inode;
|
|
|
|
int ret;
|
|
|
|
|
2007-06-04 17:26:51 +04:00
|
|
|
ret = -ENODEV;
|
|
|
|
if (!spu_management_ops)
|
|
|
|
goto out;
|
|
|
|
|
2005-11-15 23:53:48 +03:00
|
|
|
ret = -ENOMEM;
|
|
|
|
inode = spufs_new_inode(sb, S_IFDIR | 0775);
|
|
|
|
if (!inode)
|
|
|
|
goto out;
|
|
|
|
|
2007-06-29 04:57:59 +04:00
|
|
|
inode->i_op = &simple_dir_inode_operations;
|
2005-11-15 23:53:48 +03:00
|
|
|
inode->i_fop = &simple_dir_operations;
|
|
|
|
SPUFS_I(inode)->i_ctx = NULL;
|
2008-10-07 11:26:55 +04:00
|
|
|
inc_nlink(inode);
|
2005-11-15 23:53:48 +03:00
|
|
|
|
|
|
|
ret = -EINVAL;
|
2008-07-03 05:42:20 +04:00
|
|
|
if (!spufs_parse_options(sb, data, inode))
|
2005-11-15 23:53:48 +03:00
|
|
|
goto out_iput;
|
|
|
|
|
|
|
|
ret = -ENOMEM;
|
|
|
|
sb->s_root = d_alloc_root(inode);
|
|
|
|
if (!sb->s_root)
|
|
|
|
goto out_iput;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
out_iput:
|
|
|
|
iput(inode);
|
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
spufs_fill_super(struct super_block *sb, void *data, int silent)
|
|
|
|
{
|
2008-07-03 05:42:20 +04:00
|
|
|
struct spufs_sb_info *info;
|
2005-11-15 23:53:48 +03:00
|
|
|
static struct super_operations s_ops = {
|
|
|
|
.alloc_inode = spufs_alloc_inode,
|
|
|
|
.destroy_inode = spufs_destroy_inode,
|
|
|
|
.statfs = simple_statfs,
|
|
|
|
.delete_inode = spufs_delete_inode,
|
|
|
|
.drop_inode = generic_delete_inode,
|
2008-02-08 15:21:47 +03:00
|
|
|
.show_options = generic_show_options,
|
2005-11-15 23:53:48 +03:00
|
|
|
};
|
|
|
|
|
2008-02-08 15:21:47 +03:00
|
|
|
save_mount_options(sb, data);
|
|
|
|
|
2008-07-03 05:42:20 +04:00
|
|
|
info = kzalloc(sizeof(*info), GFP_KERNEL);
|
|
|
|
if (!info)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2005-11-15 23:53:48 +03:00
|
|
|
sb->s_maxbytes = MAX_LFS_FILESIZE;
|
|
|
|
sb->s_blocksize = PAGE_CACHE_SIZE;
|
|
|
|
sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
|
|
|
|
sb->s_magic = SPUFS_MAGIC;
|
|
|
|
sb->s_op = &s_ops;
|
2008-07-03 05:42:20 +04:00
|
|
|
sb->s_fs_info = info;
|
2005-11-15 23:53:48 +03:00
|
|
|
|
|
|
|
return spufs_create_root(sb, data);
|
|
|
|
}
|
|
|
|
|
[PATCH] VFS: Permit filesystem to override root dentry on mount
Extend the get_sb() filesystem operation to take an extra argument that
permits the VFS to pass in the target vfsmount that defines the mountpoint.
The filesystem is then required to manually set the superblock and root dentry
pointers. For most filesystems, this should be done with simple_set_mnt()
which will set the superblock pointer and then set the root dentry to the
superblock's s_root (as per the old default behaviour).
The get_sb() op now returns an integer as there's now no need to return the
superblock pointer.
This patch permits a superblock to be implicitly shared amongst several mount
points, such as can be done with NFS to avoid potential inode aliasing. In
such a case, simple_set_mnt() would not be called, and instead the mnt_root
and mnt_sb would be set directly.
The patch also makes the following changes:
(*) the get_sb_*() convenience functions in the core kernel now take a vfsmount
pointer argument and return an integer, so most filesystems have to change
very little.
(*) If one of the convenience function is not used, then get_sb() should
normally call simple_set_mnt() to instantiate the vfsmount. This will
always return 0, and so can be tail-called from get_sb().
(*) generic_shutdown_super() now calls shrink_dcache_sb() to clean up the
dcache upon superblock destruction rather than shrink_dcache_anon().
This is required because the superblock may now have multiple trees that
aren't actually bound to s_root, but that still need to be cleaned up. The
currently called functions assume that the whole tree is rooted at s_root,
and that anonymous dentries are not the roots of trees which results in
dentries being left unculled.
However, with the way NFS superblock sharing are currently set to be
implemented, these assumptions are violated: the root of the filesystem is
simply a dummy dentry and inode (the real inode for '/' may well be
inaccessible), and all the vfsmounts are rooted on anonymous[*] dentries
with child trees.
[*] Anonymous until discovered from another tree.
(*) The documentation has been adjusted, including the additional bit of
changing ext2_* into foo_* in the documentation.
[akpm@osdl.org: convert ipath_fs, do other stuff]
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Cc: Nathan Scott <nathans@sgi.com>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-23 13:02:57 +04:00
|
|
|
static int
|
2005-11-15 23:53:48 +03:00
|
|
|
spufs_get_sb(struct file_system_type *fstype, int flags,
|
[PATCH] VFS: Permit filesystem to override root dentry on mount
Extend the get_sb() filesystem operation to take an extra argument that
permits the VFS to pass in the target vfsmount that defines the mountpoint.
The filesystem is then required to manually set the superblock and root dentry
pointers. For most filesystems, this should be done with simple_set_mnt()
which will set the superblock pointer and then set the root dentry to the
superblock's s_root (as per the old default behaviour).
The get_sb() op now returns an integer as there's now no need to return the
superblock pointer.
This patch permits a superblock to be implicitly shared amongst several mount
points, such as can be done with NFS to avoid potential inode aliasing. In
such a case, simple_set_mnt() would not be called, and instead the mnt_root
and mnt_sb would be set directly.
The patch also makes the following changes:
(*) the get_sb_*() convenience functions in the core kernel now take a vfsmount
pointer argument and return an integer, so most filesystems have to change
very little.
(*) If one of the convenience function is not used, then get_sb() should
normally call simple_set_mnt() to instantiate the vfsmount. This will
always return 0, and so can be tail-called from get_sb().
(*) generic_shutdown_super() now calls shrink_dcache_sb() to clean up the
dcache upon superblock destruction rather than shrink_dcache_anon().
This is required because the superblock may now have multiple trees that
aren't actually bound to s_root, but that still need to be cleaned up. The
currently called functions assume that the whole tree is rooted at s_root,
and that anonymous dentries are not the roots of trees which results in
dentries being left unculled.
However, with the way NFS superblock sharing are currently set to be
implemented, these assumptions are violated: the root of the filesystem is
simply a dummy dentry and inode (the real inode for '/' may well be
inaccessible), and all the vfsmounts are rooted on anonymous[*] dentries
with child trees.
[*] Anonymous until discovered from another tree.
(*) The documentation has been adjusted, including the additional bit of
changing ext2_* into foo_* in the documentation.
[akpm@osdl.org: convert ipath_fs, do other stuff]
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Cc: Nathan Scott <nathans@sgi.com>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-23 13:02:57 +04:00
|
|
|
const char *name, void *data, struct vfsmount *mnt)
|
2005-11-15 23:53:48 +03:00
|
|
|
{
|
[PATCH] VFS: Permit filesystem to override root dentry on mount
Extend the get_sb() filesystem operation to take an extra argument that
permits the VFS to pass in the target vfsmount that defines the mountpoint.
The filesystem is then required to manually set the superblock and root dentry
pointers. For most filesystems, this should be done with simple_set_mnt()
which will set the superblock pointer and then set the root dentry to the
superblock's s_root (as per the old default behaviour).
The get_sb() op now returns an integer as there's now no need to return the
superblock pointer.
This patch permits a superblock to be implicitly shared amongst several mount
points, such as can be done with NFS to avoid potential inode aliasing. In
such a case, simple_set_mnt() would not be called, and instead the mnt_root
and mnt_sb would be set directly.
The patch also makes the following changes:
(*) the get_sb_*() convenience functions in the core kernel now take a vfsmount
pointer argument and return an integer, so most filesystems have to change
very little.
(*) If one of the convenience function is not used, then get_sb() should
normally call simple_set_mnt() to instantiate the vfsmount. This will
always return 0, and so can be tail-called from get_sb().
(*) generic_shutdown_super() now calls shrink_dcache_sb() to clean up the
dcache upon superblock destruction rather than shrink_dcache_anon().
This is required because the superblock may now have multiple trees that
aren't actually bound to s_root, but that still need to be cleaned up. The
currently called functions assume that the whole tree is rooted at s_root,
and that anonymous dentries are not the roots of trees which results in
dentries being left unculled.
However, with the way NFS superblock sharing are currently set to be
implemented, these assumptions are violated: the root of the filesystem is
simply a dummy dentry and inode (the real inode for '/' may well be
inaccessible), and all the vfsmounts are rooted on anonymous[*] dentries
with child trees.
[*] Anonymous until discovered from another tree.
(*) The documentation has been adjusted, including the additional bit of
changing ext2_* into foo_* in the documentation.
[akpm@osdl.org: convert ipath_fs, do other stuff]
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Cc: Nathan Scott <nathans@sgi.com>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-23 13:02:57 +04:00
|
|
|
return get_sb_single(fstype, flags, data, spufs_fill_super, mnt);
|
2005-11-15 23:53:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct file_system_type spufs_type = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.name = "spufs",
|
|
|
|
.get_sb = spufs_get_sb,
|
|
|
|
.kill_sb = kill_litter_super,
|
|
|
|
};
|
|
|
|
|
2006-03-27 23:27:40 +04:00
|
|
|
static int __init spufs_init(void)
|
2005-11-15 23:53:48 +03:00
|
|
|
{
|
|
|
|
int ret;
|
[POWERPC] coredump: Add SPU elf notes to coredump.
This patch adds SPU elf notes to the coredump. It creates a separate note
for each of /regs, /fpcr, /lslr, /decr, /decr_status, /mem, /signal1,
/signal1_type, /signal2, /signal2_type, /event_mask, /event_status,
/mbox_info, /ibox_info, /wbox_info, /dma_info, /proxydma_info, /object-id.
A new macro, ARCH_HAVE_EXTRA_NOTES, was created for architectures to
specify they have extra elf core notes.
A new macro, ELF_CORE_EXTRA_NOTES_SIZE, was created so the size of the
additional notes could be calculated and added to the notes phdr entry.
A new macro, ELF_CORE_WRITE_EXTRA_NOTES, was created so the new notes
would be written after the existing notes.
The SPU coredump code resides in spufs. Stub functions are provided in the
kernel which are hooked into the spufs code which does the actual work via
register_arch_coredump_calls().
A new set of __spufs_<file>_read/get() functions was provided to allow the
coredump code to read from the spufs files without having to lock the
SPU context for each file read from.
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Dwayne Grant McConnell <decimal@us.ibm.com>
Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
2006-11-23 02:46:37 +03:00
|
|
|
|
2007-04-23 23:08:29 +04:00
|
|
|
ret = -ENODEV;
|
|
|
|
if (!spu_management_ops)
|
|
|
|
goto out;
|
|
|
|
|
2005-11-15 23:53:48 +03:00
|
|
|
ret = -ENOMEM;
|
|
|
|
spufs_inode_cache = kmem_cache_create("spufs_inode_cache",
|
|
|
|
sizeof(struct spufs_inode_info), 0,
|
2007-07-20 05:11:58 +04:00
|
|
|
SLAB_HWCACHE_ALIGN, spufs_init_once);
|
2005-11-15 23:53:48 +03:00
|
|
|
|
|
|
|
if (!spufs_inode_cache)
|
|
|
|
goto out;
|
2007-04-23 23:08:19 +04:00
|
|
|
ret = spu_sched_init();
|
2005-11-15 23:53:48 +03:00
|
|
|
if (ret)
|
|
|
|
goto out_cache;
|
2007-04-23 23:08:19 +04:00
|
|
|
ret = register_filesystem(&spufs_type);
|
|
|
|
if (ret)
|
|
|
|
goto out_sched;
|
2005-11-15 23:53:48 +03:00
|
|
|
ret = register_spu_syscalls(&spufs_calls);
|
[POWERPC] coredump: Add SPU elf notes to coredump.
This patch adds SPU elf notes to the coredump. It creates a separate note
for each of /regs, /fpcr, /lslr, /decr, /decr_status, /mem, /signal1,
/signal1_type, /signal2, /signal2_type, /event_mask, /event_status,
/mbox_info, /ibox_info, /wbox_info, /dma_info, /proxydma_info, /object-id.
A new macro, ARCH_HAVE_EXTRA_NOTES, was created for architectures to
specify they have extra elf core notes.
A new macro, ELF_CORE_EXTRA_NOTES_SIZE, was created so the size of the
additional notes could be calculated and added to the notes phdr entry.
A new macro, ELF_CORE_WRITE_EXTRA_NOTES, was created so the new notes
would be written after the existing notes.
The SPU coredump code resides in spufs. Stub functions are provided in the
kernel which are hooked into the spufs code which does the actual work via
register_arch_coredump_calls().
A new set of __spufs_<file>_read/get() functions was provided to allow the
coredump code to read from the spufs files without having to lock the
SPU context for each file read from.
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Dwayne Grant McConnell <decimal@us.ibm.com>
Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
2006-11-23 02:46:37 +03:00
|
|
|
if (ret)
|
|
|
|
goto out_fs;
|
2006-10-24 20:31:18 +04:00
|
|
|
|
|
|
|
spufs_init_isolated_loader();
|
[POWERPC] coredump: Add SPU elf notes to coredump.
This patch adds SPU elf notes to the coredump. It creates a separate note
for each of /regs, /fpcr, /lslr, /decr, /decr_status, /mem, /signal1,
/signal1_type, /signal2, /signal2_type, /event_mask, /event_status,
/mbox_info, /ibox_info, /wbox_info, /dma_info, /proxydma_info, /object-id.
A new macro, ARCH_HAVE_EXTRA_NOTES, was created for architectures to
specify they have extra elf core notes.
A new macro, ELF_CORE_EXTRA_NOTES_SIZE, was created so the size of the
additional notes could be calculated and added to the notes phdr entry.
A new macro, ELF_CORE_WRITE_EXTRA_NOTES, was created so the new notes
would be written after the existing notes.
The SPU coredump code resides in spufs. Stub functions are provided in the
kernel which are hooked into the spufs code which does the actual work via
register_arch_coredump_calls().
A new set of __spufs_<file>_read/get() functions was provided to allow the
coredump code to read from the spufs files without having to lock the
SPU context for each file read from.
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Dwayne Grant McConnell <decimal@us.ibm.com>
Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
2006-11-23 02:46:37 +03:00
|
|
|
|
2005-11-15 23:53:48 +03:00
|
|
|
return 0;
|
2007-04-23 23:08:19 +04:00
|
|
|
|
2005-11-15 23:53:48 +03:00
|
|
|
out_fs:
|
|
|
|
unregister_filesystem(&spufs_type);
|
2007-04-23 23:08:19 +04:00
|
|
|
out_sched:
|
|
|
|
spu_sched_exit();
|
2005-11-15 23:53:48 +03:00
|
|
|
out_cache:
|
|
|
|
kmem_cache_destroy(spufs_inode_cache);
|
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
module_init(spufs_init);
|
|
|
|
|
2006-03-27 23:27:40 +04:00
|
|
|
static void __exit spufs_exit(void)
|
2005-11-15 23:53:48 +03:00
|
|
|
{
|
2005-11-15 23:53:52 +03:00
|
|
|
spu_sched_exit();
|
2007-04-23 23:08:20 +04:00
|
|
|
spufs_exit_isolated_loader();
|
2005-11-15 23:53:48 +03:00
|
|
|
unregister_spu_syscalls(&spufs_calls);
|
|
|
|
unregister_filesystem(&spufs_type);
|
|
|
|
kmem_cache_destroy(spufs_inode_cache);
|
|
|
|
}
|
|
|
|
module_exit(spufs_exit);
|
|
|
|
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_AUTHOR("Arnd Bergmann <arndb@de.ibm.com>");
|
|
|
|
|