瀏覽代碼

NFS: Don't call iput() in nfs_access_cache_shrinker

iput() can potentially attempt to allocate memory, so we should avoid
calling it in a memory shrinker. Instead, rely on the fact that iput() will
call nfs_access_zap_cache().

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Trond Myklebust 15 年之前
父節點
當前提交
9c7e7e2337
共有 1 個文件被更改,包括 4 次插入15 次删除
  1. 4 15
      fs/nfs/dir.c

+ 4 - 15
fs/nfs/dir.c

@@ -1716,22 +1716,14 @@ int nfs_access_cache_shrinker(int nr_to_scan, gfp_t gfp_mask)
 
 
 	if ((gfp_mask & GFP_KERNEL) != GFP_KERNEL)
 	if ((gfp_mask & GFP_KERNEL) != GFP_KERNEL)
 		return (nr_to_scan == 0) ? 0 : -1;
 		return (nr_to_scan == 0) ? 0 : -1;
-restart:
+
 	spin_lock(&nfs_access_lru_lock);
 	spin_lock(&nfs_access_lru_lock);
 	list_for_each_entry(nfsi, &nfs_access_lru_list, access_cache_inode_lru) {
 	list_for_each_entry(nfsi, &nfs_access_lru_list, access_cache_inode_lru) {
-		struct rw_semaphore *s_umount;
 		struct inode *inode;
 		struct inode *inode;
 
 
 		if (nr_to_scan-- == 0)
 		if (nr_to_scan-- == 0)
 			break;
 			break;
-		s_umount = &nfsi->vfs_inode.i_sb->s_umount;
-		if (!down_read_trylock(s_umount))
-			continue;
-		inode = igrab(&nfsi->vfs_inode);
-		if (inode == NULL) {
-			up_read(s_umount);
-			continue;
-		}
+		inode = &nfsi->vfs_inode;
 		spin_lock(&inode->i_lock);
 		spin_lock(&inode->i_lock);
 		if (list_empty(&nfsi->access_cache_entry_lru))
 		if (list_empty(&nfsi->access_cache_entry_lru))
 			goto remove_lru_entry;
 			goto remove_lru_entry;
@@ -1745,13 +1737,10 @@ restart:
 		else {
 		else {
 remove_lru_entry:
 remove_lru_entry:
 			list_del_init(&nfsi->access_cache_inode_lru);
 			list_del_init(&nfsi->access_cache_inode_lru);
+			smp_mb__before_clear_bit();
 			clear_bit(NFS_INO_ACL_LRU_SET, &nfsi->flags);
 			clear_bit(NFS_INO_ACL_LRU_SET, &nfsi->flags);
+			smp_mb__after_clear_bit();
 		}
 		}
-		spin_unlock(&inode->i_lock);
-		spin_unlock(&nfs_access_lru_lock);
-		iput(inode);
-		up_read(s_umount);
-		goto restart;
 	}
 	}
 	spin_unlock(&nfs_access_lru_lock);
 	spin_unlock(&nfs_access_lru_lock);
 	nfs_access_free_list(&head);
 	nfs_access_free_list(&head);