diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2007-07-03 16:10:55 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2007-07-10 23:40:41 -0400 |
commit | 412c77cee6d6e73fbe1dc3d67f52163efed33fc4 (patch) | |
tree | f7ea21158a76f8b3fd6450ee66dcc053f94b3fbd | |
parent | 8383e4602c89857ef926f29ca61ac0a83a614443 (diff) |
NFSv4: Defer inode revalidation when setting up a delegation
Currently we force a synchronous call to __nfs_revalidate_inode() in
nfs_inode_set_delegation(). This not only ensures that we cannot call
nfs_inode_set_delegation from an asynchronous context, but it also slows
down any call to open().
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r-- | fs/nfs/delegation.c | 10 | ||||
-rw-r--r-- | fs/nfs/inode.c | 4 | ||||
-rw-r--r-- | include/linux/nfs_fs.h | 1 |
3 files changed, 10 insertions, 5 deletions
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 56f4f6a99d4e..20ac403469a0 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c | |||
@@ -124,10 +124,6 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct | |||
124 | struct nfs_delegation *delegation; | 124 | struct nfs_delegation *delegation; |
125 | int status = 0; | 125 | int status = 0; |
126 | 126 | ||
127 | /* Ensure we first revalidate the attributes and page cache! */ | ||
128 | if ((nfsi->cache_validity & (NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_ATTR))) | ||
129 | __nfs_revalidate_inode(NFS_SERVER(inode), inode); | ||
130 | |||
131 | delegation = kmalloc(sizeof(*delegation), GFP_KERNEL); | 127 | delegation = kmalloc(sizeof(*delegation), GFP_KERNEL); |
132 | if (delegation == NULL) | 128 | if (delegation == NULL) |
133 | return -ENOMEM; | 129 | return -ENOMEM; |
@@ -154,6 +150,12 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct | |||
154 | status = -EIO; | 150 | status = -EIO; |
155 | } | 151 | } |
156 | } | 152 | } |
153 | |||
154 | /* Ensure we revalidate the attributes and page cache! */ | ||
155 | spin_lock(&inode->i_lock); | ||
156 | nfsi->cache_validity |= NFS_INO_REVAL_FORCED; | ||
157 | spin_unlock(&inode->i_lock); | ||
158 | |||
157 | spin_unlock(&clp->cl_lock); | 159 | spin_unlock(&clp->cl_lock); |
158 | kfree(delegation); | 160 | kfree(delegation); |
159 | return status; | 161 | return status; |
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 9d5124166d20..3d9fccf4ef93 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -1072,8 +1072,10 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1072 | invalid &= ~NFS_INO_INVALID_DATA; | 1072 | invalid &= ~NFS_INO_INVALID_DATA; |
1073 | if (data_stable) | 1073 | if (data_stable) |
1074 | invalid &= ~(NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ATIME|NFS_INO_REVAL_PAGECACHE); | 1074 | invalid &= ~(NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ATIME|NFS_INO_REVAL_PAGECACHE); |
1075 | if (!nfs_have_delegation(inode, FMODE_READ)) | 1075 | if (!nfs_have_delegation(inode, FMODE_READ) || |
1076 | (nfsi->cache_validity & NFS_INO_REVAL_FORCED)) | ||
1076 | nfsi->cache_validity |= invalid; | 1077 | nfsi->cache_validity |= invalid; |
1078 | nfsi->cache_validity &= ~NFS_INO_REVAL_FORCED; | ||
1077 | 1079 | ||
1078 | return 0; | 1080 | return 0; |
1079 | out_changed: | 1081 | out_changed: |
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index cf395351cdd4..e94971040de9 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h | |||
@@ -184,6 +184,7 @@ struct nfs_inode { | |||
184 | #define NFS_INO_INVALID_ACCESS 0x0008 /* cached access cred invalid */ | 184 | #define NFS_INO_INVALID_ACCESS 0x0008 /* cached access cred invalid */ |
185 | #define NFS_INO_INVALID_ACL 0x0010 /* cached acls are invalid */ | 185 | #define NFS_INO_INVALID_ACL 0x0010 /* cached acls are invalid */ |
186 | #define NFS_INO_REVAL_PAGECACHE 0x0020 /* must revalidate pagecache */ | 186 | #define NFS_INO_REVAL_PAGECACHE 0x0020 /* must revalidate pagecache */ |
187 | #define NFS_INO_REVAL_FORCED 0x0040 /* force revalidation ignoring a delegation */ | ||
187 | 188 | ||
188 | /* | 189 | /* |
189 | * Bit offsets in flags field | 190 | * Bit offsets in flags field |