浏览代码

fs: improve DCACHE_REFERENCED usage

dentry referenced bit is only set when installing the dentry back
onto the LRU. However with lazy LRU, the dentry can already be on
the LRU list at dput time, thus missing out on setting the referenced
bit. Fix this.

Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Nick Piggin 14 年之前
父节点
当前提交
265ac90230
共有 1 个文件被更改,包括 6 次插入3 次删除
  1. 6 3
      fs/dcache.c

+ 6 - 3
fs/dcache.c

@@ -246,13 +246,16 @@ repeat:
 		if (dentry->d_op->d_delete(dentry))
 		if (dentry->d_op->d_delete(dentry))
 			goto unhash_it;
 			goto unhash_it;
 	}
 	}
+
 	/* Unreachable? Get rid of it */
 	/* Unreachable? Get rid of it */
  	if (d_unhashed(dentry))
  	if (d_unhashed(dentry))
 		goto kill_it;
 		goto kill_it;
-  	if (list_empty(&dentry->d_lru)) {
-  		dentry->d_flags |= DCACHE_REFERENCED;
+
+	/* Otherwise leave it cached and ensure it's on the LRU */
+	dentry->d_flags |= DCACHE_REFERENCED;
+	if (list_empty(&dentry->d_lru))
 		dentry_lru_add(dentry);
 		dentry_lru_add(dentry);
-  	}
+
  	spin_unlock(&dentry->d_lock);
  	spin_unlock(&dentry->d_lock);
 	spin_unlock(&dcache_lock);
 	spin_unlock(&dcache_lock);
 	return;
 	return;