Commit 4b936885 authored by Nick Piggin's avatar Nick Piggin

fs: improve scalability of pseudo filesystems

Regardless of how much we possibly try to scale dcache, there is likely
always going to be some fundamental contention when adding or removing children
under the same parent. Pseudo filesystems do not seem need to have connected
dentries because by definition they are disconnected.
Signed-off-by: default avatarNick Piggin <npiggin@kernel.dk>
parent 873feea0
...@@ -102,7 +102,7 @@ struct file *anon_inode_getfile(const char *name, ...@@ -102,7 +102,7 @@ struct file *anon_inode_getfile(const char *name,
this.name = name; this.name = name;
this.len = strlen(name); this.len = strlen(name);
this.hash = 0; this.hash = 0;
path.dentry = d_alloc(anon_inode_mnt->mnt_sb->s_root, &this); path.dentry = d_alloc_pseudo(anon_inode_mnt->mnt_sb, &this);
if (!path.dentry) if (!path.dentry)
goto err_module; goto err_module;
......
...@@ -1330,6 +1330,18 @@ struct dentry *d_alloc(struct dentry * parent, const struct qstr *name) ...@@ -1330,6 +1330,18 @@ struct dentry *d_alloc(struct dentry * parent, const struct qstr *name)
} }
EXPORT_SYMBOL(d_alloc); EXPORT_SYMBOL(d_alloc);
struct dentry *d_alloc_pseudo(struct super_block *sb, const struct qstr *name)
{
struct dentry *dentry = d_alloc(NULL, name);
if (dentry) {
dentry->d_sb = sb;
dentry->d_parent = dentry;
dentry->d_flags |= DCACHE_DISCONNECTED;
}
return dentry;
}
EXPORT_SYMBOL(d_alloc_pseudo);
struct dentry *d_alloc_name(struct dentry *parent, const char *name) struct dentry *d_alloc_name(struct dentry *parent, const char *name)
{ {
struct qstr q; struct qstr q;
......
...@@ -999,7 +999,7 @@ struct file *create_write_pipe(int flags) ...@@ -999,7 +999,7 @@ struct file *create_write_pipe(int flags)
goto err; goto err;
err = -ENOMEM; err = -ENOMEM;
path.dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &name); path.dentry = d_alloc_pseudo(pipe_mnt->mnt_sb, &name);
if (!path.dentry) if (!path.dentry)
goto err_inode; goto err_inode;
path.mnt = mntget(pipe_mnt); path.mnt = mntget(pipe_mnt);
......
...@@ -211,6 +211,7 @@ extern void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op ...@@ -211,6 +211,7 @@ extern void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op
/* allocate/de-allocate */ /* allocate/de-allocate */
extern struct dentry * d_alloc(struct dentry *, const struct qstr *); extern struct dentry * d_alloc(struct dentry *, const struct qstr *);
extern struct dentry * d_alloc_pseudo(struct super_block *, const struct qstr *);
extern struct dentry * d_splice_alias(struct inode *, struct dentry *); extern struct dentry * d_splice_alias(struct inode *, struct dentry *);
extern struct dentry * d_add_ci(struct dentry *, struct inode *, struct qstr *); extern struct dentry * d_add_ci(struct dentry *, struct inode *, struct qstr *);
extern struct dentry * d_obtain_alias(struct inode *); extern struct dentry * d_obtain_alias(struct inode *);
......
...@@ -361,7 +361,7 @@ static int sock_alloc_file(struct socket *sock, struct file **f, int flags) ...@@ -361,7 +361,7 @@ static int sock_alloc_file(struct socket *sock, struct file **f, int flags)
if (unlikely(fd < 0)) if (unlikely(fd < 0))
return fd; return fd;
path.dentry = d_alloc(sock_mnt->mnt_sb->s_root, &name); path.dentry = d_alloc_pseudo(sock_mnt->mnt_sb, &name);
if (unlikely(!path.dentry)) { if (unlikely(!path.dentry)) {
put_unused_fd(fd); put_unused_fd(fd);
return -ENOMEM; return -ENOMEM;
......
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