Commit 93ce4af7 authored by Trond Myklebust's avatar Trond Myklebust

NFS: Clean up process of marking inode stale.

Instead of the various open coded calls to set the NFS_INO_STALE bit
and call nfs_zap_caches(), consolidate them into a single function
nfs_set_inode_stale().
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 1fab7dc4
...@@ -2669,9 +2669,10 @@ static int nfs_do_access(struct inode *inode, const struct cred *cred, int mask) ...@@ -2669,9 +2669,10 @@ static int nfs_do_access(struct inode *inode, const struct cred *cred, int mask)
status = NFS_PROTO(inode)->access(inode, &cache); status = NFS_PROTO(inode)->access(inode, &cache);
if (status != 0) { if (status != 0) {
if (status == -ESTALE) { if (status == -ESTALE) {
nfs_zap_caches(inode);
if (!S_ISDIR(inode->i_mode)) if (!S_ISDIR(inode->i_mode))
set_bit(NFS_INO_STALE, &NFS_I(inode)->flags); nfs_set_inode_stale(inode);
else
nfs_zap_caches(inode);
} }
goto out; goto out;
} }
......
...@@ -62,7 +62,6 @@ ...@@ -62,7 +62,6 @@
/* Default is to see 64-bit inode numbers */ /* Default is to see 64-bit inode numbers */
static bool enable_ino64 = NFS_64_BIT_INODE_NUMBERS_ENABLED; static bool enable_ino64 = NFS_64_BIT_INODE_NUMBERS_ENABLED;
static void nfs_invalidate_inode(struct inode *);
static int nfs_update_inode(struct inode *, struct nfs_fattr *); static int nfs_update_inode(struct inode *, struct nfs_fattr *);
static struct kmem_cache * nfs_inode_cachep; static struct kmem_cache * nfs_inode_cachep;
...@@ -284,10 +283,18 @@ EXPORT_SYMBOL_GPL(nfs_invalidate_atime); ...@@ -284,10 +283,18 @@ EXPORT_SYMBOL_GPL(nfs_invalidate_atime);
* Invalidate, but do not unhash, the inode. * Invalidate, but do not unhash, the inode.
* NB: must be called with inode->i_lock held! * NB: must be called with inode->i_lock held!
*/ */
static void nfs_invalidate_inode(struct inode *inode) static void nfs_set_inode_stale_locked(struct inode *inode)
{ {
set_bit(NFS_INO_STALE, &NFS_I(inode)->flags); set_bit(NFS_INO_STALE, &NFS_I(inode)->flags);
nfs_zap_caches_locked(inode); nfs_zap_caches_locked(inode);
trace_nfs_set_inode_stale(inode);
}
void nfs_set_inode_stale(struct inode *inode)
{
spin_lock(&inode->i_lock);
nfs_set_inode_stale_locked(inode);
spin_unlock(&inode->i_lock);
} }
struct nfs_find_desc { struct nfs_find_desc {
...@@ -1163,9 +1170,10 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) ...@@ -1163,9 +1170,10 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
status = 0; status = 0;
break; break;
case -ESTALE: case -ESTALE:
nfs_zap_caches(inode);
if (!S_ISDIR(inode->i_mode)) if (!S_ISDIR(inode->i_mode))
set_bit(NFS_INO_STALE, &NFS_I(inode)->flags); nfs_set_inode_stale(inode);
else
nfs_zap_caches(inode);
} }
goto err_out; goto err_out;
} }
...@@ -2064,7 +2072,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) ...@@ -2064,7 +2072,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
* lookup validation will know that the inode is bad. * lookup validation will know that the inode is bad.
* (But we fall through to invalidate the caches.) * (But we fall through to invalidate the caches.)
*/ */
nfs_invalidate_inode(inode); nfs_set_inode_stale_locked(inode);
return -ESTALE; return -ESTALE;
} }
......
...@@ -181,6 +181,7 @@ DECLARE_EVENT_CLASS(nfs_inode_event_done, ...@@ -181,6 +181,7 @@ DECLARE_EVENT_CLASS(nfs_inode_event_done,
int error \ int error \
), \ ), \
TP_ARGS(inode, error)) TP_ARGS(inode, error))
DEFINE_NFS_INODE_EVENT(nfs_set_inode_stale);
DEFINE_NFS_INODE_EVENT(nfs_refresh_inode_enter); DEFINE_NFS_INODE_EVENT(nfs_refresh_inode_enter);
DEFINE_NFS_INODE_EVENT_DONE(nfs_refresh_inode_exit); DEFINE_NFS_INODE_EVENT_DONE(nfs_refresh_inode_exit);
DEFINE_NFS_INODE_EVENT(nfs_revalidate_inode_enter); DEFINE_NFS_INODE_EVENT(nfs_revalidate_inode_enter);
......
...@@ -250,7 +250,7 @@ static int nfs_readpage_done(struct rpc_task *task, ...@@ -250,7 +250,7 @@ static int nfs_readpage_done(struct rpc_task *task,
trace_nfs_readpage_done(task, hdr); trace_nfs_readpage_done(task, hdr);
if (task->tk_status == -ESTALE) { if (task->tk_status == -ESTALE) {
set_bit(NFS_INO_STALE, &NFS_I(inode)->flags); nfs_set_inode_stale(inode);
nfs_mark_for_revalidate(inode); nfs_mark_for_revalidate(inode);
} }
return 0; return 0;
......
...@@ -354,6 +354,7 @@ static inline unsigned long nfs_save_change_attribute(struct inode *dir) ...@@ -354,6 +354,7 @@ static inline unsigned long nfs_save_change_attribute(struct inode *dir)
extern int nfs_sync_mapping(struct address_space *mapping); extern int nfs_sync_mapping(struct address_space *mapping);
extern void nfs_zap_mapping(struct inode *inode, struct address_space *mapping); extern void nfs_zap_mapping(struct inode *inode, struct address_space *mapping);
extern void nfs_zap_caches(struct inode *); extern void nfs_zap_caches(struct inode *);
extern void nfs_set_inode_stale(struct inode *inode);
extern void nfs_invalidate_atime(struct inode *); extern void nfs_invalidate_atime(struct inode *);
extern struct inode *nfs_fhget(struct super_block *, struct nfs_fh *, extern struct inode *nfs_fhget(struct super_block *, struct nfs_fh *,
struct nfs_fattr *, struct nfs4_label *); struct nfs_fattr *, struct nfs4_label *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment