aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2005-11-25 17:10:06 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2005-11-25 17:11:29 -0500
commitb37b03b7051493c9f9a6b336c9c0f81334885b7d (patch)
tree8bb06ddeb952e4399b94bb556f715edb2dbffd34 /fs/nfs
parentff6040667ad5a21fa1090e02941ecefb94ebe32c (diff)
NFS: Fix a spinlock recursion inside nfs_update_inode()
In cases where the server has gone insane, nfs_update_inode() may end up calling nfs_invalidate_inode(), which again calls stuff that takes the inode->i_lock that we're already holding. In addition, given the sort of things we have in NFS these days that need to be cleaned up on inode release, I'm not sure we should ever be calling make_bad_inode(). Fix up spinlock recursion, and limit nfs_invalidate_inode() to clearing the caches, and marking the inode as being stale. Thanks to Steve Dickson <SteveD@redhat.com> for spotting this. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/inode.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 6391d8964214..aaab1a5ac461 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -643,14 +643,11 @@ static int nfs_show_options(struct seq_file *m, struct vfsmount *mnt)
643/* 643/*
644 * Invalidate the local caches 644 * Invalidate the local caches
645 */ 645 */
646void 646static void nfs_zap_caches_locked(struct inode *inode)
647nfs_zap_caches(struct inode *inode)
648{ 647{
649 struct nfs_inode *nfsi = NFS_I(inode); 648 struct nfs_inode *nfsi = NFS_I(inode);
650 int mode = inode->i_mode; 649 int mode = inode->i_mode;
651 650
652 spin_lock(&inode->i_lock);
653
654 NFS_ATTRTIMEO(inode) = NFS_MINATTRTIMEO(inode); 651 NFS_ATTRTIMEO(inode) = NFS_MINATTRTIMEO(inode);
655 NFS_ATTRTIMEO_UPDATE(inode) = jiffies; 652 NFS_ATTRTIMEO_UPDATE(inode) = jiffies;
656 653
@@ -659,7 +656,12 @@ nfs_zap_caches(struct inode *inode)
659 nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL|NFS_INO_REVAL_PAGECACHE; 656 nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL|NFS_INO_REVAL_PAGECACHE;
660 else 657 else
661 nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL|NFS_INO_REVAL_PAGECACHE; 658 nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL|NFS_INO_REVAL_PAGECACHE;
659}
662 660
661void nfs_zap_caches(struct inode *inode)
662{
663 spin_lock(&inode->i_lock);
664 nfs_zap_caches_locked(inode);
663 spin_unlock(&inode->i_lock); 665 spin_unlock(&inode->i_lock);
664} 666}
665 667
@@ -676,16 +678,13 @@ static void nfs_zap_acl_cache(struct inode *inode)
676} 678}
677 679
678/* 680/*
679 * Invalidate, but do not unhash, the inode 681 * Invalidate, but do not unhash, the inode.
682 * NB: must be called with inode->i_lock held!
680 */ 683 */
681static void 684static void nfs_invalidate_inode(struct inode *inode)
682nfs_invalidate_inode(struct inode *inode)
683{ 685{
684 umode_t save_mode = inode->i_mode; 686 set_bit(NFS_INO_STALE, &NFS_FLAGS(inode));
685 687 nfs_zap_caches_locked(inode);
686 make_bad_inode(inode);
687 inode->i_mode = save_mode;
688 nfs_zap_caches(inode);
689} 688}
690 689
691struct nfs_find_desc { 690struct nfs_find_desc {
@@ -1528,14 +1527,13 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr, unsign
1528 printk(KERN_DEBUG "%s: inode %ld mode changed, %07o to %07o\n", 1527 printk(KERN_DEBUG "%s: inode %ld mode changed, %07o to %07o\n",
1529 __FUNCTION__, inode->i_ino, inode->i_mode, fattr->mode); 1528 __FUNCTION__, inode->i_ino, inode->i_mode, fattr->mode);
1530#endif 1529#endif
1530 out_err:
1531 /* 1531 /*
1532 * No need to worry about unhashing the dentry, as the 1532 * No need to worry about unhashing the dentry, as the
1533 * lookup validation will know that the inode is bad. 1533 * lookup validation will know that the inode is bad.
1534 * (But we fall through to invalidate the caches.) 1534 * (But we fall through to invalidate the caches.)
1535 */ 1535 */
1536 nfs_invalidate_inode(inode); 1536 nfs_invalidate_inode(inode);
1537 out_err:
1538 set_bit(NFS_INO_STALE, &NFS_FLAGS(inode));
1539 return -ESTALE; 1537 return -ESTALE;
1540} 1538}
1541 1539