Commit 8a34e562 authored by Hugh Dickins's avatar Hugh Dickins Committed by Linus Torvalds

[PATCH] simple fs stop -ve dentries

A tmpfs user reported increasingly slow directory reads when repeatedly
creating and unlinking in a mkstemp-like way.  The negative dentries
accumulate alarmingly (until memory pressure finally frees them), and are
just a hindrance to any in-memory filesystem.  simple_lookup set d_op to
arrange for negative dentries to be deleted immediately.

(But I failed to discover how it is that on-disk filesystems seem to keep
their negative dentries within manageable bounds: this effect was gross
with tmpfs or ramfs, but no problem at all with extN or reiser.)
Signed-off-by: default avatarHugh Dickins <hugh@veritas.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 7dbb1d67
...@@ -27,14 +27,27 @@ int simple_statfs(struct super_block *sb, struct kstatfs *buf) ...@@ -27,14 +27,27 @@ int simple_statfs(struct super_block *sb, struct kstatfs *buf)
} }
/* /*
* Lookup the data. This is trivial - if the dentry didn't already * Retaining negative dentries for an in-memory filesystem just wastes
* exist, we know it is negative. * memory and lookup time: arrange for them to be deleted immediately.
*/ */
static int simple_delete_dentry(struct dentry *dentry)
{
return 1;
}
/*
* Lookup the data. This is trivial - if the dentry didn't already
* exist, we know it is negative. Set d_op to delete negative dentries.
*/
struct dentry *simple_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) struct dentry *simple_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
{ {
static struct dentry_operations simple_dentry_operations = {
.d_delete = simple_delete_dentry,
};
if (dentry->d_name.len > NAME_MAX) if (dentry->d_name.len > NAME_MAX)
return ERR_PTR(-ENAMETOOLONG); return ERR_PTR(-ENAMETOOLONG);
dentry->d_op = &simple_dentry_operations;
d_add(dentry, NULL); d_add(dentry, NULL);
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment