diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2008-06-11 15:44:04 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2008-07-15 18:10:50 -0400 |
commit | 1b83d707032a1be40a60ed0a9bd841662cc04a5d (patch) | |
tree | 4c39cb618026a4480e06e5ed0d30c7a553a6fabf /fs/nfs/dir.c | |
parent | d67d1c7bf948341fd8678c8e337ec27f4b46b206 (diff) |
NFS: Protect inode->i_nlink updates using inode->i_lock
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/dir.c')
-rw-r--r-- | fs/nfs/dir.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index b1940660502f..d6ec1c85995a 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -870,6 +870,14 @@ static int nfs_dentry_delete(struct dentry *dentry) | |||
870 | 870 | ||
871 | } | 871 | } |
872 | 872 | ||
873 | static void nfs_drop_nlink(struct inode *inode) | ||
874 | { | ||
875 | spin_lock(&inode->i_lock); | ||
876 | if (inode->i_nlink > 0) | ||
877 | drop_nlink(inode); | ||
878 | spin_unlock(&inode->i_lock); | ||
879 | } | ||
880 | |||
873 | /* | 881 | /* |
874 | * Called when the dentry loses inode. | 882 | * Called when the dentry loses inode. |
875 | * We use it to clean up silly-renamed files. | 883 | * We use it to clean up silly-renamed files. |
@@ -1420,7 +1428,7 @@ static int nfs_safe_remove(struct dentry *dentry) | |||
1420 | error = NFS_PROTO(dir)->remove(dir, &dentry->d_name); | 1428 | error = NFS_PROTO(dir)->remove(dir, &dentry->d_name); |
1421 | /* The VFS may want to delete this inode */ | 1429 | /* The VFS may want to delete this inode */ |
1422 | if (error == 0) | 1430 | if (error == 0) |
1423 | drop_nlink(inode); | 1431 | nfs_drop_nlink(inode); |
1424 | nfs_mark_for_revalidate(inode); | 1432 | nfs_mark_for_revalidate(inode); |
1425 | } else | 1433 | } else |
1426 | error = NFS_PROTO(dir)->remove(dir, &dentry->d_name); | 1434 | error = NFS_PROTO(dir)->remove(dir, &dentry->d_name); |
@@ -1647,7 +1655,7 @@ static int nfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1647 | /* dentry still busy? */ | 1655 | /* dentry still busy? */ |
1648 | goto out; | 1656 | goto out; |
1649 | } else | 1657 | } else |
1650 | drop_nlink(new_inode); | 1658 | nfs_drop_nlink(new_inode); |
1651 | 1659 | ||
1652 | go_ahead: | 1660 | go_ahead: |
1653 | /* | 1661 | /* |