Skip to content

Commit

Permalink
Merge branch 'bkl-removal' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
Trond Myklebust authored and Trond Myklebust committed Jul 15, 2008
2 parents e89e896 + f839c4c commit cadc723
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 86 deletions.
6 changes: 6 additions & 0 deletions fs/lockd/clntproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@ void nlm_release_call(struct nlm_rqst *call)

static void nlmclnt_rpc_release(void *data)
{
lock_kernel();
nlm_release_call(data);
unlock_kernel();
}

static int nlm_wait_on_grace(wait_queue_head_t *queue)
Expand Down Expand Up @@ -710,7 +712,9 @@ static void nlmclnt_unlock_callback(struct rpc_task *task, void *data)
die:
return;
retry_rebind:
lock_kernel();
nlm_rebind_host(req->a_host);
unlock_kernel();
retry_unlock:
rpc_restart_call(task);
}
Expand Down Expand Up @@ -788,7 +792,9 @@ static void nlmclnt_cancel_callback(struct rpc_task *task, void *data)
/* Don't ever retry more than 3 times */
if (req->a_retries++ >= NLMCLNT_MAX_RETRIES)
goto die;
lock_kernel();
nlm_rebind_host(req->a_host);
unlock_kernel();
rpc_restart_call(task);
rpc_delay(task, 30 * HZ);
}
Expand Down
2 changes: 2 additions & 0 deletions fs/lockd/svc4proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ static void nlm4svc_callback_exit(struct rpc_task *task, void *data)

static void nlm4svc_callback_release(void *data)
{
lock_kernel();
nlm_release_call(data);
unlock_kernel();
}

static const struct rpc_call_ops nlm4svc_callback_ops = {
Expand Down
7 changes: 6 additions & 1 deletion fs/lockd/svclock.c
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,7 @@ static void nlmsvc_grant_callback(struct rpc_task *task, void *data)

dprintk("lockd: GRANT_MSG RPC callback\n");

lock_kernel();
/* if the block is not on a list at this point then it has
* been invalidated. Don't try to requeue it.
*
Expand All @@ -804,7 +805,7 @@ static void nlmsvc_grant_callback(struct rpc_task *task, void *data)
* for nlm_blocked?
*/
if (list_empty(&block->b_list))
return;
goto out;

/* Technically, we should down the file semaphore here. Since we
* move the block towards the head of the queue only, no harm
Expand All @@ -818,13 +819,17 @@ static void nlmsvc_grant_callback(struct rpc_task *task, void *data)
}
nlmsvc_insert_block(block, timeout);
svc_wake_up(block->b_daemon);
out:
unlock_kernel();
}

static void nlmsvc_grant_release(void *data)
{
struct nlm_rqst *call = data;

lock_kernel();
nlmsvc_release_block(call->a_block);
unlock_kernel();
}

static const struct rpc_call_ops nlmsvc_grant_ops = {
Expand Down
2 changes: 2 additions & 0 deletions fs/lockd/svcproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,9 @@ static void nlmsvc_callback_exit(struct rpc_task *task, void *data)

static void nlmsvc_callback_release(void *data)
{
lock_kernel();
nlm_release_call(data);
unlock_kernel();
}

static const struct rpc_call_ops nlmsvc_callback_ops = {
Expand Down
62 changes: 12 additions & 50 deletions fs/nfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,8 @@ nfs_opendir(struct inode *inode, struct file *filp)

nfs_inc_stats(inode, NFSIOS_VFSOPEN);

lock_kernel();
/* Call generic open code in order to cache credentials */
res = nfs_open(inode, filp);
unlock_kernel();
return res;
}

Expand Down Expand Up @@ -536,8 +534,6 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
(long long)filp->f_pos);
nfs_inc_stats(inode, NFSIOS_VFSGETDENTS);

lock_kernel();

/*
* filp->f_pos points to the dirent entry number.
* *desc->dir_cookie has the cookie for the next entry. We have
Expand Down Expand Up @@ -595,7 +591,6 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
}
out:
nfs_unblock_sillyrename(dentry);
unlock_kernel();
if (res > 0)
res = 0;
dfprintk(FILE, "NFS: readdir(%s/%s) returns %ld\n",
Expand Down Expand Up @@ -779,7 +774,6 @@ static int nfs_lookup_revalidate(struct dentry * dentry, struct nameidata *nd)
struct nfs_fattr fattr;

parent = dget_parent(dentry);
lock_kernel();
dir = parent->d_inode;
nfs_inc_stats(dir, NFSIOS_DENTRYREVALIDATE);
inode = dentry->d_inode;
Expand Down Expand Up @@ -817,7 +811,6 @@ static int nfs_lookup_revalidate(struct dentry * dentry, struct nameidata *nd)

nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
out_valid:
unlock_kernel();
dput(parent);
dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) is valid\n",
__func__, dentry->d_parent->d_name.name,
Expand All @@ -836,7 +829,6 @@ static int nfs_lookup_revalidate(struct dentry * dentry, struct nameidata *nd)
shrink_dcache_parent(dentry);
}
d_drop(dentry);
unlock_kernel();
dput(parent);
dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) is invalid\n",
__func__, dentry->d_parent->d_name.name,
Expand Down Expand Up @@ -870,6 +862,14 @@ static int nfs_dentry_delete(struct dentry *dentry)

}

static void nfs_drop_nlink(struct inode *inode)
{
spin_lock(&inode->i_lock);
if (inode->i_nlink > 0)
drop_nlink(inode);
spin_unlock(&inode->i_lock);
}

/*
* Called when the dentry loses inode.
* We use it to clean up silly-renamed files.
Expand All @@ -881,10 +881,8 @@ static void nfs_dentry_iput(struct dentry *dentry, struct inode *inode)
NFS_I(inode)->cache_validity |= NFS_INO_INVALID_DATA;

if (dentry->d_flags & DCACHE_NFSFS_RENAMED) {
lock_kernel();
drop_nlink(inode);
nfs_complete_unlink(dentry, inode);
unlock_kernel();
}
iput(inode);
}
Expand Down Expand Up @@ -915,16 +913,14 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru
res = ERR_PTR(-ENOMEM);
dentry->d_op = NFS_PROTO(dir)->dentry_ops;

lock_kernel();

/*
* If we're doing an exclusive create, optimize away the lookup
* but don't hash the dentry.
*/
if (nfs_is_exclusive_create(dir, nd)) {
d_instantiate(dentry, NULL);
res = NULL;
goto out_unlock;
goto out;
}

parent = dentry->d_parent;
Expand Down Expand Up @@ -952,8 +948,6 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru
nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
out_unblock_sillyrename:
nfs_unblock_sillyrename(parent);
out_unlock:
unlock_kernel();
out:
return res;
}
Expand Down Expand Up @@ -1011,9 +1005,7 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry
}

/* Open the file on the server */
lock_kernel();
res = nfs4_atomic_open(dir, dentry, nd);
unlock_kernel();
if (IS_ERR(res)) {
error = PTR_ERR(res);
switch (error) {
Expand Down Expand Up @@ -1075,9 +1067,7 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd)
* operations that change the directory. We therefore save the
* change attribute *before* we do the RPC call.
*/
lock_kernel();
ret = nfs4_open_revalidate(dir, dentry, openflags, nd);
unlock_kernel();
out:
dput(parent);
if (!ret)
Expand Down Expand Up @@ -1230,14 +1220,11 @@ static int nfs_create(struct inode *dir, struct dentry *dentry, int mode,
if ((nd->flags & LOOKUP_CREATE) != 0)
open_flags = nd->intent.open.flags;

lock_kernel();
error = NFS_PROTO(dir)->create(dir, dentry, &attr, open_flags, nd);
if (error != 0)
goto out_err;
unlock_kernel();
return 0;
out_err:
unlock_kernel();
d_drop(dentry);
return error;
}
Expand All @@ -1260,14 +1247,11 @@ nfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
attr.ia_mode = mode;
attr.ia_valid = ATTR_MODE;

lock_kernel();
status = NFS_PROTO(dir)->mknod(dir, dentry, &attr, rdev);
if (status != 0)
goto out_err;
unlock_kernel();
return 0;
out_err:
unlock_kernel();
d_drop(dentry);
return status;
}
Expand All @@ -1286,15 +1270,12 @@ static int nfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
attr.ia_valid = ATTR_MODE;
attr.ia_mode = mode | S_IFDIR;

lock_kernel();
error = NFS_PROTO(dir)->mkdir(dir, dentry, &attr);
if (error != 0)
goto out_err;
unlock_kernel();
return 0;
out_err:
d_drop(dentry);
unlock_kernel();
return error;
}

Expand All @@ -1311,14 +1292,12 @@ static int nfs_rmdir(struct inode *dir, struct dentry *dentry)
dfprintk(VFS, "NFS: rmdir(%s/%ld), %s\n",
dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);

lock_kernel();
error = NFS_PROTO(dir)->rmdir(dir, &dentry->d_name);
/* Ensure the VFS deletes this inode */
if (error == 0 && dentry->d_inode != NULL)
clear_nlink(dentry->d_inode);
else if (error == -ENOENT)
nfs_dentry_handle_enoent(dentry);
unlock_kernel();

return error;
}
Expand Down Expand Up @@ -1420,7 +1399,7 @@ static int nfs_safe_remove(struct dentry *dentry)
error = NFS_PROTO(dir)->remove(dir, &dentry->d_name);
/* The VFS may want to delete this inode */
if (error == 0)
drop_nlink(inode);
nfs_drop_nlink(inode);
nfs_mark_for_revalidate(inode);
} else
error = NFS_PROTO(dir)->remove(dir, &dentry->d_name);
Expand All @@ -1443,7 +1422,6 @@ static int nfs_unlink(struct inode *dir, struct dentry *dentry)
dfprintk(VFS, "NFS: unlink(%s/%ld, %s)\n", dir->i_sb->s_id,
dir->i_ino, dentry->d_name.name);

lock_kernel();
spin_lock(&dcache_lock);
spin_lock(&dentry->d_lock);
if (atomic_read(&dentry->d_count) > 1) {
Expand All @@ -1452,7 +1430,6 @@ static int nfs_unlink(struct inode *dir, struct dentry *dentry)
/* Start asynchronous writeout of the inode */
write_inode_now(dentry->d_inode, 0);
error = nfs_sillyrename(dir, dentry);
unlock_kernel();
return error;
}
if (!d_unhashed(dentry)) {
Expand All @@ -1466,7 +1443,6 @@ static int nfs_unlink(struct inode *dir, struct dentry *dentry)
nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
} else if (need_rehash)
d_rehash(dentry);
unlock_kernel();
return error;
}

Expand Down Expand Up @@ -1503,13 +1479,9 @@ static int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *sym
attr.ia_mode = S_IFLNK | S_IRWXUGO;
attr.ia_valid = ATTR_MODE;

lock_kernel();

page = alloc_page(GFP_HIGHUSER);
if (!page) {
unlock_kernel();
if (!page)
return -ENOMEM;
}

kaddr = kmap_atomic(page, KM_USER0);
memcpy(kaddr, symname, pathlen);
Expand All @@ -1524,7 +1496,6 @@ static int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *sym
dentry->d_name.name, symname, error);
d_drop(dentry);
__free_page(page);
unlock_kernel();
return error;
}

Expand All @@ -1542,7 +1513,6 @@ static int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *sym
} else
__free_page(page);

unlock_kernel();
return 0;
}

Expand All @@ -1556,14 +1526,12 @@ nfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
old_dentry->d_parent->d_name.name, old_dentry->d_name.name,
dentry->d_parent->d_name.name, dentry->d_name.name);

lock_kernel();
d_drop(dentry);
error = NFS_PROTO(dir)->link(inode, dir, &dentry->d_name);
if (error == 0) {
atomic_inc(&inode->i_count);
d_add(dentry, inode);
}
unlock_kernel();
return error;
}

Expand Down Expand Up @@ -1603,7 +1571,6 @@ static int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
* To prevent any new references to the target during the rename,
* we unhash the dentry and free the inode in advance.
*/
lock_kernel();
if (!d_unhashed(new_dentry)) {
d_drop(new_dentry);
rehash = new_dentry;
Expand Down Expand Up @@ -1647,7 +1614,7 @@ static int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
/* dentry still busy? */
goto out;
} else
drop_nlink(new_inode);
nfs_drop_nlink(new_inode);

go_ahead:
/*
Expand Down Expand Up @@ -1681,7 +1648,6 @@ static int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
/* new dentry created? */
if (dentry)
dput(dentry);
unlock_kernel();
return error;
}

Expand Down Expand Up @@ -1974,8 +1940,6 @@ int nfs_permission(struct inode *inode, int mask, struct nameidata *nd)
}

force_lookup:
lock_kernel();

if (!NFS_PROTO(inode)->access)
goto out_notsup;

Expand All @@ -1985,7 +1949,6 @@ int nfs_permission(struct inode *inode, int mask, struct nameidata *nd)
put_rpccred(cred);
} else
res = PTR_ERR(cred);
unlock_kernel();
out:
dfprintk(VFS, "NFS: permission(%s/%ld), mask=0x%x, res=%d\n",
inode->i_sb->s_id, inode->i_ino, mask, res);
Expand All @@ -1994,7 +1957,6 @@ int nfs_permission(struct inode *inode, int mask, struct nameidata *nd)
res = nfs_revalidate_inode(NFS_SERVER(inode), inode);
if (res == 0)
res = generic_permission(inode, mask, NULL);
unlock_kernel();
goto out;
}

Expand Down
Loading

0 comments on commit cadc723

Please sign in to comment.