NFS: Remove the BKL from the rename, rmdir and unlink operations
Attribute updates are safe, and dentry operations are protected using VFS level locks. Defer removing the BKL from sillyrename until a separate patch. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
parent
fc0f684c21
commit
bd9bb454b7
|
@ -1297,14 +1297,12 @@ static int nfs_rmdir(struct inode *dir, struct dentry *dentry)
|
||||||
dfprintk(VFS, "NFS: rmdir(%s/%ld), %s\n",
|
dfprintk(VFS, "NFS: rmdir(%s/%ld), %s\n",
|
||||||
dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
|
dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
|
||||||
|
|
||||||
lock_kernel();
|
|
||||||
error = NFS_PROTO(dir)->rmdir(dir, &dentry->d_name);
|
error = NFS_PROTO(dir)->rmdir(dir, &dentry->d_name);
|
||||||
/* Ensure the VFS deletes this inode */
|
/* Ensure the VFS deletes this inode */
|
||||||
if (error == 0 && dentry->d_inode != NULL)
|
if (error == 0 && dentry->d_inode != NULL)
|
||||||
clear_nlink(dentry->d_inode);
|
clear_nlink(dentry->d_inode);
|
||||||
else if (error == -ENOENT)
|
else if (error == -ENOENT)
|
||||||
nfs_dentry_handle_enoent(dentry);
|
nfs_dentry_handle_enoent(dentry);
|
||||||
unlock_kernel();
|
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
@ -1429,7 +1427,6 @@ static int nfs_unlink(struct inode *dir, struct dentry *dentry)
|
||||||
dfprintk(VFS, "NFS: unlink(%s/%ld, %s)\n", dir->i_sb->s_id,
|
dfprintk(VFS, "NFS: unlink(%s/%ld, %s)\n", dir->i_sb->s_id,
|
||||||
dir->i_ino, dentry->d_name.name);
|
dir->i_ino, dentry->d_name.name);
|
||||||
|
|
||||||
lock_kernel();
|
|
||||||
spin_lock(&dcache_lock);
|
spin_lock(&dcache_lock);
|
||||||
spin_lock(&dentry->d_lock);
|
spin_lock(&dentry->d_lock);
|
||||||
if (atomic_read(&dentry->d_count) > 1) {
|
if (atomic_read(&dentry->d_count) > 1) {
|
||||||
|
@ -1437,6 +1434,7 @@ static int nfs_unlink(struct inode *dir, struct dentry *dentry)
|
||||||
spin_unlock(&dcache_lock);
|
spin_unlock(&dcache_lock);
|
||||||
/* Start asynchronous writeout of the inode */
|
/* Start asynchronous writeout of the inode */
|
||||||
write_inode_now(dentry->d_inode, 0);
|
write_inode_now(dentry->d_inode, 0);
|
||||||
|
lock_kernel();
|
||||||
error = nfs_sillyrename(dir, dentry);
|
error = nfs_sillyrename(dir, dentry);
|
||||||
unlock_kernel();
|
unlock_kernel();
|
||||||
return error;
|
return error;
|
||||||
|
@ -1452,7 +1450,6 @@ static int nfs_unlink(struct inode *dir, struct dentry *dentry)
|
||||||
nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
|
nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
|
||||||
} else if (need_rehash)
|
} else if (need_rehash)
|
||||||
d_rehash(dentry);
|
d_rehash(dentry);
|
||||||
unlock_kernel();
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1587,7 +1584,6 @@ static int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||||
* To prevent any new references to the target during the rename,
|
* To prevent any new references to the target during the rename,
|
||||||
* we unhash the dentry and free the inode in advance.
|
* we unhash the dentry and free the inode in advance.
|
||||||
*/
|
*/
|
||||||
lock_kernel();
|
|
||||||
if (!d_unhashed(new_dentry)) {
|
if (!d_unhashed(new_dentry)) {
|
||||||
d_drop(new_dentry);
|
d_drop(new_dentry);
|
||||||
rehash = new_dentry;
|
rehash = new_dentry;
|
||||||
|
@ -1621,7 +1617,9 @@ static int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* silly-rename the existing target ... */
|
/* silly-rename the existing target ... */
|
||||||
|
lock_kernel();
|
||||||
err = nfs_sillyrename(new_dir, new_dentry);
|
err = nfs_sillyrename(new_dir, new_dentry);
|
||||||
|
unlock_kernel();
|
||||||
if (!err) {
|
if (!err) {
|
||||||
new_dentry = rehash = dentry;
|
new_dentry = rehash = dentry;
|
||||||
new_inode = NULL;
|
new_inode = NULL;
|
||||||
|
@ -1665,7 +1663,6 @@ out:
|
||||||
/* new dentry created? */
|
/* new dentry created? */
|
||||||
if (dentry)
|
if (dentry)
|
||||||
dput(dentry);
|
dput(dentry);
|
||||||
unlock_kernel();
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue