diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2008-10-05 12:07:23 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2008-10-07 17:29:49 -0400 |
commit | 870a5be8b92151332da65021b7b21104e9c1de07 (patch) | |
tree | 041ec4a0c5304ff74b7b1cd2c09a7d92e08d6cac /fs/nfs/inode.c | |
parent | 7973c1f15a0687f47ed70e591e4642d6fc4334d0 (diff) |
NFS: Clean up nfs_refresh_inode() and nfs_post_op_update_inode()
Try to avoid taking and dropping the inode->i_lock more than once. Do so by
moving the code in nfs_refresh_inode() that needs to be done under the
spinlock into a function nfs_refresh_inode_locked(), and then having both
nfs_refresh_inode() and nfs_post_op_update_inode() call it directly.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/inode.c')
-rw-r--r-- | fs/nfs/inode.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 52daefa2f521..f189169348b1 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -948,6 +948,15 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat | |||
948 | return 0; | 948 | return 0; |
949 | } | 949 | } |
950 | 950 | ||
951 | static int nfs_refresh_inode_locked(struct inode *inode, struct nfs_fattr *fattr) | ||
952 | { | ||
953 | struct nfs_inode *nfsi = NFS_I(inode); | ||
954 | |||
955 | if (time_after(fattr->time_start, nfsi->last_updated)) | ||
956 | return nfs_update_inode(inode, fattr); | ||
957 | return nfs_check_inode_attributes(inode, fattr); | ||
958 | } | ||
959 | |||
951 | /** | 960 | /** |
952 | * nfs_refresh_inode - try to update the inode attribute cache | 961 | * nfs_refresh_inode - try to update the inode attribute cache |
953 | * @inode - pointer to inode | 962 | * @inode - pointer to inode |
@@ -960,17 +969,12 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat | |||
960 | */ | 969 | */ |
961 | int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr) | 970 | int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr) |
962 | { | 971 | { |
963 | struct nfs_inode *nfsi = NFS_I(inode); | ||
964 | int status; | 972 | int status; |
965 | 973 | ||
966 | if ((fattr->valid & NFS_ATTR_FATTR) == 0) | 974 | if ((fattr->valid & NFS_ATTR_FATTR) == 0) |
967 | return 0; | 975 | return 0; |
968 | spin_lock(&inode->i_lock); | 976 | spin_lock(&inode->i_lock); |
969 | if (time_after(fattr->time_start, nfsi->last_updated)) | 977 | status = nfs_refresh_inode_locked(inode, fattr); |
970 | status = nfs_update_inode(inode, fattr); | ||
971 | else | ||
972 | status = nfs_check_inode_attributes(inode, fattr); | ||
973 | |||
974 | spin_unlock(&inode->i_lock); | 978 | spin_unlock(&inode->i_lock); |
975 | return status; | 979 | return status; |
976 | } | 980 | } |
@@ -992,13 +996,16 @@ int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
992 | int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr) | 996 | int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr) |
993 | { | 997 | { |
994 | struct nfs_inode *nfsi = NFS_I(inode); | 998 | struct nfs_inode *nfsi = NFS_I(inode); |
999 | int status = 0; | ||
995 | 1000 | ||
996 | spin_lock(&inode->i_lock); | 1001 | spin_lock(&inode->i_lock); |
997 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; | 1002 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; |
998 | if (S_ISDIR(inode->i_mode)) | 1003 | if (S_ISDIR(inode->i_mode)) |
999 | nfsi->cache_validity |= NFS_INO_INVALID_DATA; | 1004 | nfsi->cache_validity |= NFS_INO_INVALID_DATA; |
1005 | if ((fattr->valid & NFS_ATTR_FATTR) != 0) | ||
1006 | status = nfs_refresh_inode_locked(inode, fattr); | ||
1000 | spin_unlock(&inode->i_lock); | 1007 | spin_unlock(&inode->i_lock); |
1001 | return nfs_refresh_inode(inode, fattr); | 1008 | return status; |
1002 | } | 1009 | } |
1003 | 1010 | ||
1004 | /** | 1011 | /** |