[Devel] [PATCH RH7] fixup: negative dcache accounting
Vasily Averin
vvs at virtuozzo.com
Mon Sep 7 13:01:30 MSK 2020
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 at virtuozzo.com>
---
fs/dcache.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/fs/dcache.c b/fs/dcache.c
index 06d78ca61fe4..96ac93f74660 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);
}
--
2.17.1
More information about the Devel
mailing list