mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
VFS: delay the dentry name generation on sockets and pipes
1) Introduces a new method in 'struct dentry_operations'. This method called d_dname() might be called from d_path() to build a pathname for special filesystems. It is called without locks. Future patches (if we succeed in having one common dentry for all pipes/sockets) may need to change prototype of this method, but we now use : char *d_dname(struct dentry *dentry, char *buffer, int buflen); 2) Adds a dynamic_dname() helper function that eases d_dname() implementations 3) Defines d_dname method for sockets : No more sprintf() at socket creation. This is delayed up to the moment someone does an access to /proc/pid/fd/... 4) Defines d_dname method for pipes : No more sprintf() at pipe creation. This is delayed up to the moment someone does an access to /proc/pid/fd/... A benchmark consisting of 1.000.000 calls to pipe()/close()/close() gives a *nice* speedup on my Pentium(M) 1.6 Ghz : 3.090 s instead of 3.450 s Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> Acked-by: Christoph Hellwig <hch@infradead.org> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
2793274298
commit
c23fbb6bcb
6 changed files with 86 additions and 14 deletions
20
net/socket.c
20
net/socket.c
|
@ -313,8 +313,19 @@ static int sockfs_delete_dentry(struct dentry *dentry)
|
|||
dentry->d_flags |= DCACHE_UNHASHED;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* sockfs_dname() is called from d_path().
|
||||
*/
|
||||
static char *sockfs_dname(struct dentry *dentry, char *buffer, int buflen)
|
||||
{
|
||||
return dynamic_dname(dentry, buffer, buflen, "socket:[%lu]",
|
||||
dentry->d_inode->i_ino);
|
||||
}
|
||||
|
||||
static struct dentry_operations sockfs_dentry_operations = {
|
||||
.d_delete = sockfs_delete_dentry,
|
||||
.d_dname = sockfs_dname,
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -354,14 +365,9 @@ static int sock_alloc_fd(struct file **filep)
|
|||
|
||||
static int sock_attach_fd(struct socket *sock, struct file *file)
|
||||
{
|
||||
struct qstr this;
|
||||
char name[32];
|
||||
struct qstr name = { .name = "" };
|
||||
|
||||
this.len = sprintf(name, "[%lu]", SOCK_INODE(sock)->i_ino);
|
||||
this.name = name;
|
||||
this.hash = 0;
|
||||
|
||||
file->f_path.dentry = d_alloc(sock_mnt->mnt_sb->s_root, &this);
|
||||
file->f_path.dentry = d_alloc(sock_mnt->mnt_sb->s_root, &name);
|
||||
if (unlikely(!file->f_path.dentry))
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue