In order to reduce useless negative dentries in upper/lower layers, specify LOOKUP_DONTCACHE_NEGATIVE flag in lookup so that we can drop negative dentries which generated in slow path of lookup. Signed-off-by: Chengguang Xu <cgxu519@xxxxxxxxxxxx> --- fs/overlayfs/namei.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c index 0db23baf98e7..a400a7d126bd 100644 --- a/fs/overlayfs/namei.c +++ b/fs/overlayfs/namei.c @@ -200,7 +200,8 @@ static int ovl_lookup_single(struct dentry *base, struct ovl_lookup_data *d, int err; bool last_element = !post[0]; - this = lookup_positive_unlocked(name, base, namelen); + this = lookup_positive_unlocked(name, base, namelen, + LOOKUP_DONTCACHE_NEGATIVE); if (IS_ERR(this)) { err = PTR_ERR(this); this = NULL; @@ -657,7 +658,7 @@ struct dentry *ovl_get_index_fh(struct ovl_fs *ofs, struct ovl_fh *fh) if (err) return ERR_PTR(err); - index = lookup_positive_unlocked(name.name, ofs->indexdir, name.len); + index = lookup_positive_unlocked(name.name, ofs->indexdir, name.len, 0); kfree(name.name); if (IS_ERR(index)) { if (PTR_ERR(index) == -ENOENT) @@ -689,7 +690,7 @@ struct dentry *ovl_lookup_index(struct ovl_fs *ofs, struct dentry *upper, if (err) return ERR_PTR(err); - index = lookup_positive_unlocked(name.name, ofs->indexdir, name.len); + index = lookup_positive_unlocked(name.name, ofs->indexdir, name.len, 0); if (IS_ERR(index)) { err = PTR_ERR(index); if (err == -ENOENT) { @@ -1137,7 +1138,7 @@ bool ovl_lower_positive(struct dentry *dentry) struct dentry *lowerdir = poe->lowerstack[i].dentry; this = lookup_positive_unlocked(name->name, lowerdir, - name->len); + name->len, 0); if (IS_ERR(this)) { switch (PTR_ERR(this)) { case -ENOENT: -- 2.20.1