Commit f7cc02b8 authored by Yoshihisa Abe's avatar Yoshihisa Abe Committed by Linus Torvalds

Coda: push BKL regions into coda_upcall()

Now that shared inode state is locked using the cii->c_lock, the BKL is
only used to protect the upcall queues used to communicate with the
userspace cache manager. The remaining state is all local and we can
push the lock further down into coda_upcall().
Signed-off-by: default avatarYoshihisa Abe <yoshiabe@cs.cmu.edu>
Signed-off-by: default avatarJan Harkes <jaharkes@cs.cmu.edu>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b5ce1d83
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/smp_lock.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -117,15 +116,11 @@ static struct dentry *coda_lookup(struct inode *dir, struct dentry *entry, struc ...@@ -117,15 +116,11 @@ static struct dentry *coda_lookup(struct inode *dir, struct dentry *entry, struc
goto exit; goto exit;
} }
lock_kernel();
error = venus_lookup(dir->i_sb, coda_i2f(dir), name, length, error = venus_lookup(dir->i_sb, coda_i2f(dir), name, length,
&type, &resfid); &type, &resfid);
if (!error) if (!error)
error = coda_cnode_make(&inode, &resfid, dir->i_sb); error = coda_cnode_make(&inode, &resfid, dir->i_sb);
unlock_kernel();
if (error && error != -ENOENT) if (error && error != -ENOENT)
return ERR_PTR(error); return ERR_PTR(error);
...@@ -141,7 +136,7 @@ static struct dentry *coda_lookup(struct inode *dir, struct dentry *entry, struc ...@@ -141,7 +136,7 @@ static struct dentry *coda_lookup(struct inode *dir, struct dentry *entry, struc
int coda_permission(struct inode *inode, int mask) int coda_permission(struct inode *inode, int mask)
{ {
int error = 0; int error;
mask &= MAY_READ | MAY_WRITE | MAY_EXEC; mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
...@@ -151,18 +146,14 @@ int coda_permission(struct inode *inode, int mask) ...@@ -151,18 +146,14 @@ int coda_permission(struct inode *inode, int mask)
if ((mask & MAY_EXEC) && !execute_ok(inode)) if ((mask & MAY_EXEC) && !execute_ok(inode))
return -EACCES; return -EACCES;
lock_kernel();
if (coda_cache_check(inode, mask)) if (coda_cache_check(inode, mask))
goto out; return 0;
error = venus_access(inode->i_sb, coda_i2f(inode), mask); error = venus_access(inode->i_sb, coda_i2f(inode), mask);
if (!error) if (!error)
coda_cache_enter(inode, mask); coda_cache_enter(inode, mask);
out:
unlock_kernel();
return error; return error;
} }
...@@ -201,41 +192,34 @@ static inline void coda_dir_drop_nlink(struct inode *dir) ...@@ -201,41 +192,34 @@ static inline void coda_dir_drop_nlink(struct inode *dir)
/* creation routines: create, mknod, mkdir, link, symlink */ /* creation routines: create, mknod, mkdir, link, symlink */
static int coda_create(struct inode *dir, struct dentry *de, int mode, struct nameidata *nd) static int coda_create(struct inode *dir, struct dentry *de, int mode, struct nameidata *nd)
{ {
int error=0; int error;
const char *name=de->d_name.name; const char *name=de->d_name.name;
int length=de->d_name.len; int length=de->d_name.len;
struct inode *inode; struct inode *inode;
struct CodaFid newfid; struct CodaFid newfid;
struct coda_vattr attrs; struct coda_vattr attrs;
lock_kernel(); if (coda_isroot(dir) && coda_iscontrol(name, length))
if (coda_isroot(dir) && coda_iscontrol(name, length)) {
unlock_kernel();
return -EPERM; return -EPERM;
}
error = venus_create(dir->i_sb, coda_i2f(dir), name, length, error = venus_create(dir->i_sb, coda_i2f(dir), name, length,
0, mode, &newfid, &attrs); 0, mode, &newfid, &attrs);
if (error)
if ( error ) { goto err_out;
unlock_kernel();
d_drop(de);
return error;
}
inode = coda_iget(dir->i_sb, &newfid, &attrs); inode = coda_iget(dir->i_sb, &newfid, &attrs);
if ( IS_ERR(inode) ) { if (IS_ERR(inode)) {
unlock_kernel(); error = PTR_ERR(inode);
d_drop(de); goto err_out;
return PTR_ERR(inode);
} }
/* invalidate the directory cnode's attributes */ /* invalidate the directory cnode's attributes */
coda_dir_update_mtime(dir); coda_dir_update_mtime(dir);
unlock_kernel();
d_instantiate(de, inode); d_instantiate(de, inode);
return 0; return 0;
err_out:
d_drop(de);
return error;
} }
static int coda_mkdir(struct inode *dir, struct dentry *de, int mode) static int coda_mkdir(struct inode *dir, struct dentry *de, int mode)
...@@ -247,36 +231,29 @@ static int coda_mkdir(struct inode *dir, struct dentry *de, int mode) ...@@ -247,36 +231,29 @@ static int coda_mkdir(struct inode *dir, struct dentry *de, int mode)
int error; int error;
struct CodaFid newfid; struct CodaFid newfid;
lock_kernel(); if (coda_isroot(dir) && coda_iscontrol(name, len))
if (coda_isroot(dir) && coda_iscontrol(name, len)) {
unlock_kernel();
return -EPERM; return -EPERM;
}
attrs.va_mode = mode; attrs.va_mode = mode;
error = venus_mkdir(dir->i_sb, coda_i2f(dir), error = venus_mkdir(dir->i_sb, coda_i2f(dir),
name, len, &newfid, &attrs); name, len, &newfid, &attrs);
if (error)
if ( error ) { goto err_out;
unlock_kernel();
d_drop(de);
return error;
}
inode = coda_iget(dir->i_sb, &newfid, &attrs); inode = coda_iget(dir->i_sb, &newfid, &attrs);
if ( IS_ERR(inode) ) { if (IS_ERR(inode)) {
unlock_kernel(); error = PTR_ERR(inode);
d_drop(de); goto err_out;
return PTR_ERR(inode);
} }
/* invalidate the directory cnode's attributes */ /* invalidate the directory cnode's attributes */
coda_dir_inc_nlink(dir); coda_dir_inc_nlink(dir);
coda_dir_update_mtime(dir); coda_dir_update_mtime(dir);
unlock_kernel();
d_instantiate(de, inode); d_instantiate(de, inode);
return 0; return 0;
err_out:
d_drop(de);
return error;
} }
/* try to make de an entry in dir_inodde linked to source_de */ /* try to make de an entry in dir_inodde linked to source_de */
...@@ -288,29 +265,21 @@ static int coda_link(struct dentry *source_de, struct inode *dir_inode, ...@@ -288,29 +265,21 @@ static int coda_link(struct dentry *source_de, struct inode *dir_inode,
int len = de->d_name.len; int len = de->d_name.len;
int error; int error;
lock_kernel(); if (coda_isroot(dir_inode) && coda_iscontrol(name, len))
if (coda_isroot(dir_inode) && coda_iscontrol(name, len)) {
unlock_kernel();
return -EPERM; return -EPERM;
}
error = venus_link(dir_inode->i_sb, coda_i2f(inode), error = venus_link(dir_inode->i_sb, coda_i2f(inode),
coda_i2f(dir_inode), (const char *)name, len); coda_i2f(dir_inode), (const char *)name, len);
if (error) { if (error) {
d_drop(de); d_drop(de);
goto out; return error;
} }
coda_dir_update_mtime(dir_inode); coda_dir_update_mtime(dir_inode);
atomic_inc(&inode->i_count); atomic_inc(&inode->i_count);
d_instantiate(de, inode); d_instantiate(de, inode);
inc_nlink(inode); inc_nlink(inode);
return 0;
out:
unlock_kernel();
return(error);
} }
...@@ -320,20 +289,14 @@ static int coda_symlink(struct inode *dir_inode, struct dentry *de, ...@@ -320,20 +289,14 @@ static int coda_symlink(struct inode *dir_inode, struct dentry *de,
const char *name = de->d_name.name; const char *name = de->d_name.name;
int len = de->d_name.len; int len = de->d_name.len;
int symlen; int symlen;
int error = 0; int error;
lock_kernel();
if (coda_isroot(dir_inode) && coda_iscontrol(name, len)) { if (coda_isroot(dir_inode) && coda_iscontrol(name, len))
unlock_kernel();
return -EPERM; return -EPERM;
}
symlen = strlen(symname); symlen = strlen(symname);
if ( symlen > CODA_MAXPATHLEN ) { if (symlen > CODA_MAXPATHLEN)
unlock_kernel();
return -ENAMETOOLONG; return -ENAMETOOLONG;
}
/* /*
* This entry is now negative. Since we do not create * This entry is now negative. Since we do not create
...@@ -344,10 +307,9 @@ static int coda_symlink(struct inode *dir_inode, struct dentry *de, ...@@ -344,10 +307,9 @@ static int coda_symlink(struct inode *dir_inode, struct dentry *de,
symname, symlen); symname, symlen);
/* mtime is no good anymore */ /* mtime is no good anymore */
if ( !error ) if (!error)
coda_dir_update_mtime(dir_inode); coda_dir_update_mtime(dir_inode);
unlock_kernel();
return error; return error;
} }
...@@ -358,17 +320,12 @@ static int coda_unlink(struct inode *dir, struct dentry *de) ...@@ -358,17 +320,12 @@ static int coda_unlink(struct inode *dir, struct dentry *de)
const char *name = de->d_name.name; const char *name = de->d_name.name;
int len = de->d_name.len; int len = de->d_name.len;
lock_kernel();
error = venus_remove(dir->i_sb, coda_i2f(dir), name, len); error = venus_remove(dir->i_sb, coda_i2f(dir), name, len);
if ( error ) { if (error)
unlock_kernel();
return error; return error;
}
coda_dir_update_mtime(dir); coda_dir_update_mtime(dir);
drop_nlink(de->d_inode); drop_nlink(de->d_inode);
unlock_kernel();
return 0; return 0;
} }
...@@ -378,8 +335,6 @@ static int coda_rmdir(struct inode *dir, struct dentry *de) ...@@ -378,8 +335,6 @@ static int coda_rmdir(struct inode *dir, struct dentry *de)
int len = de->d_name.len; int len = de->d_name.len;
int error; int error;
lock_kernel();
error = venus_rmdir(dir->i_sb, coda_i2f(dir), name, len); error = venus_rmdir(dir->i_sb, coda_i2f(dir), name, len);
if (!error) { if (!error) {
/* VFS may delete the child */ /* VFS may delete the child */
...@@ -390,7 +345,6 @@ static int coda_rmdir(struct inode *dir, struct dentry *de) ...@@ -390,7 +345,6 @@ static int coda_rmdir(struct inode *dir, struct dentry *de)
coda_dir_drop_nlink(dir); coda_dir_drop_nlink(dir);
coda_dir_update_mtime(dir); coda_dir_update_mtime(dir);
} }
unlock_kernel();
return error; return error;
} }
...@@ -404,15 +358,12 @@ static int coda_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -404,15 +358,12 @@ static int coda_rename(struct inode *old_dir, struct dentry *old_dentry,
int new_length = new_dentry->d_name.len; int new_length = new_dentry->d_name.len;
int error; int error;
lock_kernel();
error = venus_rename(old_dir->i_sb, coda_i2f(old_dir), error = venus_rename(old_dir->i_sb, coda_i2f(old_dir),
coda_i2f(new_dir), old_length, new_length, coda_i2f(new_dir), old_length, new_length,
(const char *) old_name, (const char *)new_name); (const char *) old_name, (const char *)new_name);
if (!error) {
if ( !error ) { if (new_dentry->d_inode) {
if ( new_dentry->d_inode ) { if (S_ISDIR(new_dentry->d_inode->i_mode)) {
if ( S_ISDIR(new_dentry->d_inode->i_mode) ) {
coda_dir_drop_nlink(old_dir); coda_dir_drop_nlink(old_dir);
coda_dir_inc_nlink(new_dir); coda_dir_inc_nlink(new_dir);
} }
...@@ -424,8 +375,6 @@ static int coda_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -424,8 +375,6 @@ static int coda_rename(struct inode *old_dir, struct dentry *old_dentry,
coda_flag_inode(new_dir, C_VATTR); coda_flag_inode(new_dir, C_VATTR);
} }
} }
unlock_kernel();
return error; return error;
} }
...@@ -595,10 +544,7 @@ static int coda_dentry_revalidate(struct dentry *de, struct nameidata *nd) ...@@ -595,10 +544,7 @@ static int coda_dentry_revalidate(struct dentry *de, struct nameidata *nd)
struct inode *inode = de->d_inode; struct inode *inode = de->d_inode;
struct coda_inode_info *cii; struct coda_inode_info *cii;
if (!inode) if (!inode || coda_isroot(inode))
return 1;
lock_kernel();
if (coda_isroot(inode))
goto out; goto out;
if (is_bad_inode(inode)) if (is_bad_inode(inode))
goto bad; goto bad;
...@@ -621,12 +567,9 @@ static int coda_dentry_revalidate(struct dentry *de, struct nameidata *nd) ...@@ -621,12 +567,9 @@ static int coda_dentry_revalidate(struct dentry *de, struct nameidata *nd)
spin_lock(&cii->c_lock); spin_lock(&cii->c_lock);
cii->c_flags &= ~(C_VATTR | C_PURGE | C_FLUSH); cii->c_flags &= ~(C_VATTR | C_PURGE | C_FLUSH);
spin_unlock(&cii->c_lock); spin_unlock(&cii->c_lock);
bad: bad:
unlock_kernel();
return 0; return 0;
out: out:
unlock_kernel();
return 1; return 1;
} }
...@@ -659,20 +602,19 @@ static int coda_dentry_delete(struct dentry * dentry) ...@@ -659,20 +602,19 @@ static int coda_dentry_delete(struct dentry * dentry)
int coda_revalidate_inode(struct dentry *dentry) int coda_revalidate_inode(struct dentry *dentry)
{ {
struct coda_vattr attr; struct coda_vattr attr;
int error = 0; int error;
int old_mode; int old_mode;
ino_t old_ino; ino_t old_ino;
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
struct coda_inode_info *cii = ITOC(inode); struct coda_inode_info *cii = ITOC(inode);
lock_kernel(); if (!cii->c_flags)
if ( !cii->c_flags ) return 0;
goto ok;
if (cii->c_flags & (C_VATTR | C_PURGE | C_FLUSH)) { if (cii->c_flags & (C_VATTR | C_PURGE | C_FLUSH)) {
error = venus_getattr(inode->i_sb, &(cii->c_fid), &attr); error = venus_getattr(inode->i_sb, &(cii->c_fid), &attr);
if ( error ) if (error)
goto return_bad; return -EIO;
/* this inode may be lost if: /* this inode may be lost if:
- it's ino changed - it's ino changed
...@@ -691,7 +633,7 @@ int coda_revalidate_inode(struct dentry *dentry) ...@@ -691,7 +633,7 @@ int coda_revalidate_inode(struct dentry *dentry)
/* the following can happen when a local fid is replaced /* the following can happen when a local fid is replaced
with a global one, here we lose and declare the inode bad */ with a global one, here we lose and declare the inode bad */
if (inode->i_ino != old_ino) if (inode->i_ino != old_ino)
goto return_bad; return -EIO;
coda_flag_inode_children(inode, C_FLUSH); coda_flag_inode_children(inode, C_FLUSH);
...@@ -699,12 +641,5 @@ int coda_revalidate_inode(struct dentry *dentry) ...@@ -699,12 +641,5 @@ int coda_revalidate_inode(struct dentry *dentry)
cii->c_flags &= ~(C_VATTR | C_PURGE | C_FLUSH); cii->c_flags &= ~(C_VATTR | C_PURGE | C_FLUSH);
spin_unlock(&cii->c_lock); spin_unlock(&cii->c_lock);
} }
ok:
unlock_kernel();
return 0; return 0;
return_bad:
unlock_kernel();
return -EIO;
} }
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/cred.h> #include <linux/cred.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/smp_lock.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -144,8 +143,6 @@ int coda_open(struct inode *coda_inode, struct file *coda_file) ...@@ -144,8 +143,6 @@ int coda_open(struct inode *coda_inode, struct file *coda_file)
if (!cfi) if (!cfi)
return -ENOMEM; return -ENOMEM;
lock_kernel();
error = venus_open(coda_inode->i_sb, coda_i2f(coda_inode), coda_flags, error = venus_open(coda_inode->i_sb, coda_i2f(coda_inode), coda_flags,
&host_file); &host_file);
if (!host_file) if (!host_file)
...@@ -153,7 +150,6 @@ int coda_open(struct inode *coda_inode, struct file *coda_file) ...@@ -153,7 +150,6 @@ int coda_open(struct inode *coda_inode, struct file *coda_file)
if (error) { if (error) {
kfree(cfi); kfree(cfi);
unlock_kernel();
return error; return error;
} }
...@@ -165,8 +161,6 @@ int coda_open(struct inode *coda_inode, struct file *coda_file) ...@@ -165,8 +161,6 @@ int coda_open(struct inode *coda_inode, struct file *coda_file)
BUG_ON(coda_file->private_data != NULL); BUG_ON(coda_file->private_data != NULL);
coda_file->private_data = cfi; coda_file->private_data = cfi;
unlock_kernel();
return 0; return 0;
} }
...@@ -177,9 +171,7 @@ int coda_release(struct inode *coda_inode, struct file *coda_file) ...@@ -177,9 +171,7 @@ int coda_release(struct inode *coda_inode, struct file *coda_file)
struct coda_file_info *cfi; struct coda_file_info *cfi;
struct coda_inode_info *cii; struct coda_inode_info *cii;
struct inode *host_inode; struct inode *host_inode;
int err = 0; int err;
lock_kernel();
cfi = CODA_FTOC(coda_file); cfi = CODA_FTOC(coda_file);
BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
...@@ -203,8 +195,6 @@ int coda_release(struct inode *coda_inode, struct file *coda_file) ...@@ -203,8 +195,6 @@ int coda_release(struct inode *coda_inode, struct file *coda_file)
kfree(coda_file->private_data); kfree(coda_file->private_data);
coda_file->private_data = NULL; coda_file->private_data = NULL;
unlock_kernel();
/* VFS fput ignores the return value from file_operations->release, so /* VFS fput ignores the return value from file_operations->release, so
* there is no use returning an error here */ * there is no use returning an error here */
return 0; return 0;
...@@ -215,7 +205,7 @@ int coda_fsync(struct file *coda_file, int datasync) ...@@ -215,7 +205,7 @@ int coda_fsync(struct file *coda_file, int datasync)
struct file *host_file; struct file *host_file;
struct inode *coda_inode = coda_file->f_path.dentry->d_inode; struct inode *coda_inode = coda_file->f_path.dentry->d_inode;
struct coda_file_info *cfi; struct coda_file_info *cfi;
int err = 0; int err;
if (!(S_ISREG(coda_inode->i_mode) || S_ISDIR(coda_inode->i_mode) || if (!(S_ISREG(coda_inode->i_mode) || S_ISDIR(coda_inode->i_mode) ||
S_ISLNK(coda_inode->i_mode))) S_ISLNK(coda_inode->i_mode)))
...@@ -226,11 +216,8 @@ int coda_fsync(struct file *coda_file, int datasync) ...@@ -226,11 +216,8 @@ int coda_fsync(struct file *coda_file, int datasync)
host_file = cfi->cfi_container; host_file = cfi->cfi_container;
err = vfs_fsync(host_file, datasync); err = vfs_fsync(host_file, datasync);
if ( !err && !datasync ) { if (!err && !datasync)
lock_kernel();
err = venus_fsync(coda_inode->i_sb, coda_i2f(coda_inode)); err = venus_fsync(coda_inode->i_sb, coda_i2f(coda_inode));
unlock_kernel();
}
return err; return err;
} }
......
...@@ -150,8 +150,6 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent) ...@@ -150,8 +150,6 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent)
int error; int error;
int idx; int idx;
lock_kernel();
idx = get_device_index((struct coda_mount_data *) data); idx = get_device_index((struct coda_mount_data *) data);
/* Ignore errors in data, for backward compatibility */ /* Ignore errors in data, for backward compatibility */
...@@ -161,23 +159,26 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent) ...@@ -161,23 +159,26 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent)
printk(KERN_INFO "coda_read_super: device index: %i\n", idx); printk(KERN_INFO "coda_read_super: device index: %i\n", idx);
vc = &coda_comms[idx]; vc = &coda_comms[idx];
lock_kernel();
if (!vc->vc_inuse) { if (!vc->vc_inuse) {
printk("coda_read_super: No pseudo device\n"); printk("coda_read_super: No pseudo device\n");
unlock_kernel(); error = -EINVAL;
return -EINVAL; goto unlock_out;
} }
if ( vc->vc_sb ) { if (vc->vc_sb) {
printk("coda_read_super: Device already mounted\n"); printk("coda_read_super: Device already mounted\n");
unlock_kernel(); error = -EBUSY;
return -EBUSY; goto unlock_out;
} }
error = bdi_setup_and_register(&vc->bdi, "coda", BDI_CAP_MAP_COPY); error = bdi_setup_and_register(&vc->bdi, "coda", BDI_CAP_MAP_COPY);
if (error) if (error)
goto bdi_err; goto unlock_out;
vc->vc_sb = sb; vc->vc_sb = sb;
unlock_kernel();
sb->s_fs_info = vc; sb->s_fs_info = vc;
sb->s_flags |= MS_NOATIME; sb->s_flags |= MS_NOATIME;
...@@ -206,21 +207,23 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent) ...@@ -206,21 +207,23 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent)
printk("coda_read_super: rootinode is %ld dev %s\n", printk("coda_read_super: rootinode is %ld dev %s\n",
root->i_ino, root->i_sb->s_id); root->i_ino, root->i_sb->s_id);
sb->s_root = d_alloc_root(root); sb->s_root = d_alloc_root(root);
if (!sb->s_root) if (!sb->s_root) {
error = -EINVAL;
goto error; goto error;
unlock_kernel(); }
return 0; return 0;
error: error:
bdi_destroy(&vc->bdi);
bdi_err:
if (root) if (root)
iput(root); iput(root);
if (vc)
vc->vc_sb = NULL;
lock_kernel();
bdi_destroy(&vc->bdi);
vc->vc_sb = NULL;
sb->s_fs_info = NULL;
unlock_out:
unlock_kernel(); unlock_kernel();
return -EINVAL; return error;
} }
static void coda_put_super(struct super_block *sb) static void coda_put_super(struct super_block *sb)
...@@ -253,8 +256,6 @@ int coda_setattr(struct dentry *de, struct iattr *iattr) ...@@ -253,8 +256,6 @@ int coda_setattr(struct dentry *de, struct iattr *iattr)
struct coda_vattr vattr; struct coda_vattr vattr;
int error; int error;
lock_kernel();
memset(&vattr, 0, sizeof(vattr)); memset(&vattr, 0, sizeof(vattr));
inode->i_ctime = CURRENT_TIME_SEC; inode->i_ctime = CURRENT_TIME_SEC;
...@@ -264,13 +265,10 @@ int coda_setattr(struct dentry *de, struct iattr *iattr) ...@@ -264,13 +265,10 @@ int coda_setattr(struct dentry *de, struct iattr *iattr)
/* Venus is responsible for truncating the container-file!!! */ /* Venus is responsible for truncating the container-file!!! */
error = venus_setattr(inode->i_sb, coda_i2f(inode), &vattr); error = venus_setattr(inode->i_sb, coda_i2f(inode), &vattr);
if ( !error ) { if (!error) {
coda_vattr_to_iattr(inode, &vattr); coda_vattr_to_iattr(inode, &vattr);
coda_cache_clear_inode(inode); coda_cache_clear_inode(inode);
} }
unlock_kernel();
return error; return error;
} }
...@@ -284,12 +282,8 @@ static int coda_statfs(struct dentry *dentry, struct kstatfs *buf) ...@@ -284,12 +282,8 @@ static int coda_statfs(struct dentry *dentry, struct kstatfs *buf)
{ {
int error; int error;
lock_kernel();
error = venus_statfs(dentry, buf); error = venus_statfs(dentry, buf);
unlock_kernel();
if (error) { if (error) {
/* fake something like AFS does */ /* fake something like AFS does */
buf->f_blocks = 9000000; buf->f_blocks = 9000000;
......
...@@ -23,8 +23,6 @@ ...@@ -23,8 +23,6 @@
#include <linux/coda_fs_i.h> #include <linux/coda_fs_i.h>
#include <linux/coda_psdev.h> #include <linux/coda_psdev.h>
#include <linux/smp_lock.h>
/* pioctl ops */ /* pioctl ops */
static int coda_ioctl_permission(struct inode *inode, int mask); static int coda_ioctl_permission(struct inode *inode, int mask);
static long coda_pioctl(struct file *filp, unsigned int cmd, static long coda_pioctl(struct file *filp, unsigned int cmd,
...@@ -58,13 +56,9 @@ static long coda_pioctl(struct file *filp, unsigned int cmd, ...@@ -58,13 +56,9 @@ static long coda_pioctl(struct file *filp, unsigned int cmd,
struct inode *target_inode = NULL; struct inode *target_inode = NULL;
struct coda_inode_info *cnp; struct coda_inode_info *cnp;
lock_kernel();
/* get the Pioctl data arguments from user space */ /* get the Pioctl data arguments from user space */
if (copy_from_user(&data, (void __user *)user_data, sizeof(data))) { if (copy_from_user(&data, (void __user *)user_data, sizeof(data)))
error = -EINVAL; return -EINVAL;
goto out;
}
/* /*
* Look up the pathname. Note that the pathname is in * Look up the pathname. Note that the pathname is in
...@@ -76,13 +70,12 @@ static long coda_pioctl(struct file *filp, unsigned int cmd, ...@@ -76,13 +70,12 @@ static long coda_pioctl(struct file *filp, unsigned int cmd,
error = user_lpath(data.path, &path); error = user_lpath(data.path, &path);
if (error) if (error)
goto out; return error;
else
target_inode = path.dentry->d_inode; target_inode = path.dentry->d_inode;
/* return if it is not a Coda inode */ /* return if it is not a Coda inode */
if (target_inode->i_sb != inode->i_sb) { if (target_inode->i_sb != inode->i_sb) {
path_put(&path);
error = -EINVAL; error = -EINVAL;
goto out; goto out;
} }
...@@ -91,10 +84,7 @@ static long coda_pioctl(struct file *filp, unsigned int cmd, ...@@ -91,10 +84,7 @@ static long coda_pioctl(struct file *filp, unsigned int cmd,
cnp = ITOC(target_inode); cnp = ITOC(target_inode);
error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data); error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data);
path_put(&path);
out: out:
unlock_kernel(); path_put(&path);
return error; return error;
} }
...@@ -108,16 +108,9 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf, ...@@ -108,16 +108,9 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf,
return -EFAULT; return -EFAULT;
if (DOWNCALL(hdr.opcode)) { if (DOWNCALL(hdr.opcode)) {
struct super_block *sb = NULL;
union outputArgs *dcbuf; union outputArgs *dcbuf;
int size = sizeof(*dcbuf); int size = sizeof(*dcbuf);
sb = vcp->vc_sb;
if ( !sb ) {
count = nbytes;
goto out;
}
if ( nbytes < sizeof(struct coda_out_hdr) ) { if ( nbytes < sizeof(struct coda_out_hdr) ) {
printk("coda_downcall opc %d uniq %d, not enough!\n", printk("coda_downcall opc %d uniq %d, not enough!\n",
hdr.opcode, hdr.unique); hdr.opcode, hdr.unique);
...@@ -137,9 +130,7 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf, ...@@ -137,9 +130,7 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf,
} }
/* what downcall errors does Venus handle ? */ /* what downcall errors does Venus handle ? */
lock_kernel(); error = coda_downcall(vcp, hdr.opcode, dcbuf);
error = coda_downcall(hdr.opcode, dcbuf, sb);
unlock_kernel();
CODA_FREE(dcbuf, nbytes); CODA_FREE(dcbuf, nbytes);
if (error) { if (error) {
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/pagemap.h> #include <linux/pagemap.h>
#include <linux/smp_lock.h>
#include <linux/coda.h> #include <linux/coda.h>
#include <linux/coda_linux.h> #include <linux/coda_linux.h>
...@@ -29,11 +28,9 @@ static int coda_symlink_filler(struct file *file, struct page *page) ...@@ -29,11 +28,9 @@ static int coda_symlink_filler(struct file *file, struct page *page)
unsigned int len = PAGE_SIZE; unsigned int len = PAGE_SIZE;
char *p = kmap(page); char *p = kmap(page);
lock_kernel();
cii = ITOC(inode); cii = ITOC(inode);
error = venus_readlink(inode->i_sb, &cii->c_fid, p, &len); error = venus_readlink(inode->i_sb, &cii->c_fid, p, &len);
unlock_kernel();
if (error) if (error)
goto fail; goto fail;
SetPageUptodate(page); SetPageUptodate(page);
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/smp_lock.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/vfs.h> #include <linux/vfs.h>
...@@ -667,18 +668,23 @@ static int coda_upcall(struct venus_comm *vcp, ...@@ -667,18 +668,23 @@ static int coda_upcall(struct venus_comm *vcp,
{ {
union outputArgs *out; union outputArgs *out;
union inputArgs *sig_inputArgs; union inputArgs *sig_inputArgs;
struct upc_req *req, *sig_req; struct upc_req *req = NULL, *sig_req;
int error = 0; int error;
lock_kernel();
if (!vcp->vc_inuse) { if (!vcp->vc_inuse) {
printk(KERN_NOTICE "coda: Venus dead, not sending upcall\n"); printk(KERN_NOTICE "coda: Venus dead, not sending upcall\n");
return -ENXIO; error = -ENXIO;
goto exit;
} }
/* Format the request message. */ /* Format the request message. */
req = kmalloc(sizeof(struct upc_req), GFP_KERNEL); req = kmalloc(sizeof(struct upc_req), GFP_KERNEL);
if (!req) if (!req) {
return -ENOMEM; error = -ENOMEM;
goto exit;
}
req->uc_data = (void *)buffer; req->uc_data = (void *)buffer;
req->uc_flags = 0; req->uc_flags = 0;
...@@ -759,6 +765,7 @@ static int coda_upcall(struct venus_comm *vcp, ...@@ -759,6 +765,7 @@ static int coda_upcall(struct venus_comm *vcp,
exit: exit:
kfree(req); kfree(req);
unlock_kernel();
return error; return error;
} }
...@@ -796,14 +803,17 @@ static int coda_upcall(struct venus_comm *vcp, ...@@ -796,14 +803,17 @@ static int coda_upcall(struct venus_comm *vcp,
* *
* CODA_REPLACE -- replace one CodaFid with another throughout the name cache */ * CODA_REPLACE -- replace one CodaFid with another throughout the name cache */
int coda_downcall(int opcode, union outputArgs * out, struct super_block *sb) int coda_downcall(struct venus_comm *vcp, int opcode, union outputArgs *out)
{ {
struct inode *inode = NULL; struct inode *inode = NULL;
struct CodaFid *fid, *newfid; struct CodaFid *fid, *newfid;
struct super_block *sb;
/* Handle invalidation requests. */ /* Handle invalidation requests. */
if ( !sb || !sb->s_root) lock_kernel();
return 0; sb = vcp->vc_sb;
if (!sb || !sb->s_root)
goto unlock_out;
switch (opcode) { switch (opcode) {
case CODA_FLUSH: case CODA_FLUSH:
...@@ -855,9 +865,11 @@ int coda_downcall(int opcode, union outputArgs * out, struct super_block *sb) ...@@ -855,9 +865,11 @@ int coda_downcall(int opcode, union outputArgs * out, struct super_block *sb)
break; break;
} }
unlock_out:
unlock_kernel();
if (inode) if (inode)
iput(inode); iput(inode);
return 0; return 0;
} }
...@@ -63,7 +63,7 @@ int venus_symlink(struct super_block *sb, struct CodaFid *fid, ...@@ -63,7 +63,7 @@ int venus_symlink(struct super_block *sb, struct CodaFid *fid,
int venus_access(struct super_block *sb, struct CodaFid *fid, int mask); int venus_access(struct super_block *sb, struct CodaFid *fid, int mask);
int venus_pioctl(struct super_block *sb, struct CodaFid *fid, int venus_pioctl(struct super_block *sb, struct CodaFid *fid,
unsigned int cmd, struct PioctlData *data); unsigned int cmd, struct PioctlData *data);
int coda_downcall(int opcode, union outputArgs *out, struct super_block *sb); int coda_downcall(struct venus_comm *vcp, int opcode, union outputArgs *out);
int venus_fsync(struct super_block *sb, struct CodaFid *fid); int venus_fsync(struct super_block *sb, struct CodaFid *fid);
int venus_statfs(struct dentry *dentry, struct kstatfs *sfs); int venus_statfs(struct dentry *dentry, struct kstatfs *sfs);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment