[RHEL7,COMMIT] fixup: negative dcache accounting

Submitted by Vasily Averin on Sept. 7, 2020, 10:11 a.m.

Details

Message ID 202009071011.087ABcfW027289@vz7build.vvs.sw.ru
State New
Series "fixup: negative dcache accounting"
Headers show

Commit Message

Vasily Averin Sept. 7, 2020, 10:11 a.m.
The commit is pushed to "branch-rh7-3.10.0-1127.18.2.vz7.163.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.18.2.vz7.163.17
------>
commit 1460eeff9a1e818c8dfb3cc3418596678fcf1bc3
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Mon Sep 7 13:11:38 2020 +0300

    fixup: negative dcache accounting
    
    Negative dcache accounting was added in RHEL7.7 but was broken during
    vz7 rebase. It affects nothing but /proc/sys/fs/dentry-state output.
    
    This patch adds missing hunks from original ms commit af0c9af1b3f6
    ("fs/dcache: Track & report number of negative dentries")
    
    Fixes vz7 commit "ms/dcache: convert to use new lru list infrastructure"
    
    https://jira.sw.ru/browse/PSBM-107699
    Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
---
 fs/dcache.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Patch hide | download patch | download mbox

diff --git a/fs/dcache.c b/fs/dcache.c
index 6e3e53d..739ed7b 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -418,6 +418,11 @@  static void dentry_unlink_inode(struct dentry * dentry)
  * The per-cpu "nr_dentry_unused" counters are updated with
  * the DCACHE_LRU_LIST bit.
  *
+ * The per-cpu "nr_dentry_negative" counters are only updated
+ * when deleted from or added to the per-superblock LRU list, not
+ * from/to the shrink list. That is to avoid an unneeded dec/inc
+ * pair when moving from LRU to shrink list in select_collect().
+ *
  * These helper functions make sure we always follow the
  * rules. d_lock must be held by the caller.
  */
@@ -427,6 +432,8 @@  static void d_lru_add(struct dentry *dentry)
 	D_FLAG_VERIFY(dentry, 0);
 	dentry->d_flags |= DCACHE_LRU_LIST;
 	this_cpu_inc(nr_dentry_unused);
+	if (d_is_negative(dentry))
+		this_cpu_inc(nr_dentry_negative);
 	WARN_ON_ONCE(!list_lru_add(&dentry->d_sb->s_dentry_lru, &dentry->d_lru));
 }
 
@@ -435,6 +442,8 @@  static void d_lru_del(struct dentry *dentry)
 	D_FLAG_VERIFY(dentry, DCACHE_LRU_LIST);
 	dentry->d_flags &= ~DCACHE_LRU_LIST;
 	this_cpu_dec(nr_dentry_unused);
+	if (d_is_negative(dentry))
+		this_cpu_dec(nr_dentry_negative);
 	WARN_ON_ONCE(!list_lru_del(&dentry->d_sb->s_dentry_lru, &dentry->d_lru));
 }
 
@@ -465,6 +474,8 @@  static void d_lru_isolate(struct list_lru_one *lru, struct dentry *dentry)
 	D_FLAG_VERIFY(dentry, DCACHE_LRU_LIST);
 	dentry->d_flags &= ~DCACHE_LRU_LIST;
 	this_cpu_dec(nr_dentry_unused);
+	if (d_is_negative(dentry))
+		this_cpu_dec(nr_dentry_negative);
 	list_lru_isolate(lru, &dentry->d_lru);
 }
 
@@ -473,6 +484,8 @@  static void d_lru_shrink_move(struct list_lru_one *lru, struct dentry *dentry,
 {
 	D_FLAG_VERIFY(dentry, DCACHE_LRU_LIST);
 	dentry->d_flags |= DCACHE_SHRINK_LIST;
+	if (d_is_negative(dentry))
+		this_cpu_dec(nr_dentry_negative);
 	list_lru_isolate_move(lru, &dentry->d_lru, list);
 }