Skip to content

Commit 93ce4af

Browse files
author
Trond Myklebust
committed
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: Trond Myklebust <[email protected]>
1 parent 1fab7dc commit 93ce4af

File tree

5 files changed

+19
-8
lines changed

5 files changed

+19
-8
lines changed

fs/nfs/dir.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2669,9 +2669,10 @@ static int nfs_do_access(struct inode *inode, const struct cred *cred, int mask)
26692669
status = NFS_PROTO(inode)->access(inode, &cache);
26702670
if (status != 0) {
26712671
if (status == -ESTALE) {
2672-
nfs_zap_caches(inode);
26732672
if (!S_ISDIR(inode->i_mode))
2674-
set_bit(NFS_INO_STALE, &NFS_I(inode)->flags);
2673+
nfs_set_inode_stale(inode);
2674+
else
2675+
nfs_zap_caches(inode);
26752676
}
26762677
goto out;
26772678
}

fs/nfs/inode.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
/* Default is to see 64-bit inode numbers */
6363
static bool enable_ino64 = NFS_64_BIT_INODE_NUMBERS_ENABLED;
6464

65-
static void nfs_invalidate_inode(struct inode *);
6665
static int nfs_update_inode(struct inode *, struct nfs_fattr *);
6766

6867
static struct kmem_cache * nfs_inode_cachep;
@@ -284,10 +283,18 @@ EXPORT_SYMBOL_GPL(nfs_invalidate_atime);
284283
* Invalidate, but do not unhash, the inode.
285284
* NB: must be called with inode->i_lock held!
286285
*/
287-
static void nfs_invalidate_inode(struct inode *inode)
286+
static void nfs_set_inode_stale_locked(struct inode *inode)
288287
{
289288
set_bit(NFS_INO_STALE, &NFS_I(inode)->flags);
290289
nfs_zap_caches_locked(inode);
290+
trace_nfs_set_inode_stale(inode);
291+
}
292+
293+
void nfs_set_inode_stale(struct inode *inode)
294+
{
295+
spin_lock(&inode->i_lock);
296+
nfs_set_inode_stale_locked(inode);
297+
spin_unlock(&inode->i_lock);
291298
}
292299

293300
struct nfs_find_desc {
@@ -1163,9 +1170,10 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
11631170
status = 0;
11641171
break;
11651172
case -ESTALE:
1166-
nfs_zap_caches(inode);
11671173
if (!S_ISDIR(inode->i_mode))
1168-
set_bit(NFS_INO_STALE, &NFS_I(inode)->flags);
1174+
nfs_set_inode_stale(inode);
1175+
else
1176+
nfs_zap_caches(inode);
11691177
}
11701178
goto err_out;
11711179
}
@@ -2064,7 +2072,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
20642072
* lookup validation will know that the inode is bad.
20652073
* (But we fall through to invalidate the caches.)
20662074
*/
2067-
nfs_invalidate_inode(inode);
2075+
nfs_set_inode_stale_locked(inode);
20682076
return -ESTALE;
20692077
}
20702078

fs/nfs/nfstrace.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ DECLARE_EVENT_CLASS(nfs_inode_event_done,
181181
int error \
182182
), \
183183
TP_ARGS(inode, error))
184+
DEFINE_NFS_INODE_EVENT(nfs_set_inode_stale);
184185
DEFINE_NFS_INODE_EVENT(nfs_refresh_inode_enter);
185186
DEFINE_NFS_INODE_EVENT_DONE(nfs_refresh_inode_exit);
186187
DEFINE_NFS_INODE_EVENT(nfs_revalidate_inode_enter);

fs/nfs/read.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ static int nfs_readpage_done(struct rpc_task *task,
250250
trace_nfs_readpage_done(task, hdr);
251251

252252
if (task->tk_status == -ESTALE) {
253-
set_bit(NFS_INO_STALE, &NFS_I(inode)->flags);
253+
nfs_set_inode_stale(inode);
254254
nfs_mark_for_revalidate(inode);
255255
}
256256
return 0;

include/linux/nfs_fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ static inline unsigned long nfs_save_change_attribute(struct inode *dir)
354354
extern int nfs_sync_mapping(struct address_space *mapping);
355355
extern void nfs_zap_mapping(struct inode *inode, struct address_space *mapping);
356356
extern void nfs_zap_caches(struct inode *);
357+
extern void nfs_set_inode_stale(struct inode *inode);
357358
extern void nfs_invalidate_atime(struct inode *);
358359
extern struct inode *nfs_fhget(struct super_block *, struct nfs_fh *,
359360
struct nfs_fattr *, struct nfs4_label *);

0 commit comments

Comments
 (0)