[PATCH, take2] VFS : Delay the dentry name generation on sockets and pipes.

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Eric Dumazet
Date: Friday, March 9, 2007 - 3:18 am

Hi Andrew

Please find a new version of this patch : I realized d_path() has very 
uncommon semantic (it seems nobody caught the point in previous patches), and 
had to change the documentation and pipefs_dname() / sockfs_dname() 
accordingly.

Now, readlink("/proc/pid/fd/xx", buffer, 4096) returns the exact number of 
bytes, not the whole 4095 bytes :)

Extract of new Documentation:

	CAUTION : d_path() logic is quite  tricky. 
	The correct way to return for example "Hello" is to put it
	at the end of the buffer, and returns a pointer to the first char.

       Example :

static char *somefs_dname(struct dentry *dent, char *buffer, int buflen)
{
       char *string = "Hello";
       int sz = strlen(string) + 1;
       if (sz > buflen)
               return ERR_PTR(-ENAMETOOLONG);
       buffer += (buflen - sz);
       return memcpy(buffer, string, sz);
}



Thank you

[PATCH] 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) Use this new method for sockets : No more sprintf() at socket creation. 
This is delayed up to the moment someone does an access to /proc/pid/fd/...

3) Use this new 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>

 Documentation/filesystems/Locking |    2 ++
 Documentation/filesystems/vfs.txt |   26 +++++++++++++++++++++++++-
 fs/dcache.c                       |   10 ++++++++++
 fs/pipe.c                         |   23 +++++++++++++++++------
 include/linux/dcache.h            |    1 +
 net/socket.c                      |   25 ++++++++++++++++++-------
 6 files changed, 73 insertions(+), 14 deletions(-)
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [patch] epoll use a single inode ..., Davide Libenzi, (Tue Mar 6, 5:37 pm)
Re: [patch] epoll use a single inode ..., Linus Torvalds, (Tue Mar 6, 5:51 pm)
Re: [patch] epoll use a single inode ..., Davide Libenzi, (Tue Mar 6, 6:01 pm)
Re: [patch] epoll use a single inode ..., Linus Torvalds, (Tue Mar 6, 6:27 pm)
Re: [patch] epoll use a single inode ..., Davide Libenzi, (Tue Mar 6, 6:47 pm)
Re: [patch] epoll use a single inode ..., Eric Dumazet, (Tue Mar 6, 11:52 pm)
Re: [patch] epoll use a single inode ..., Davide Libenzi, (Wed Mar 7, 12:15 am)
Re: [patch] epoll use a single inode ..., Eric Dumazet, (Wed Mar 7, 12:16 am)
Re: [patch] epoll use a single inode ..., Christoph Hellwig, (Wed Mar 7, 1:56 am)
Re: [patch] epoll use a single inode ..., Linus Torvalds, (Wed Mar 7, 10:02 am)
Re: [patch] epoll use a single inode ..., Linus Torvalds, (Wed Mar 7, 10:21 am)
Re: [patch] epoll use a single inode ..., Eric Dumazet, (Wed Mar 7, 10:31 am)
Re: [patch] epoll use a single inode ..., Eric Dumazet, (Wed Mar 7, 10:36 am)
Re: [patch] epoll use a single inode ..., Linus Torvalds, (Wed Mar 7, 10:45 am)
Re: [patch] epoll use a single inode ..., Eric Dumazet, (Wed Mar 7, 11:06 am)
Re: [patch] epoll use a single inode ..., Linus Torvalds, (Wed Mar 7, 11:30 am)
Re: [patch] epoll use a single inode ..., Eric Dumazet, (Wed Mar 7, 11:52 am)
Re: [patch] epoll use a single inode ..., Linus Torvalds, (Wed Mar 7, 12:07 pm)
Re: [patch] epoll use a single inode ..., Anton Blanchard, (Wed Mar 7, 3:14 pm)
Re: [patch] epoll use a single inode ..., Linus Torvalds, (Wed Mar 7, 3:57 pm)
Re: [patch] epoll use a single inode ..., Michael K. Edwards, (Wed Mar 7, 6:25 pm)
Re: [patch] epoll use a single inode ..., Kyle Moffett, (Wed Mar 7, 7:48 pm)
Re: [patch] epoll use a single inode ..., Linus Torvalds, (Wed Mar 7, 8:20 pm)
Re: [patch] epoll use a single inode ..., Eric Dumazet, (Thu Mar 8, 12:24 am)
Re: [patch] epoll use a single inode ..., Michael K. Edwards, (Thu Mar 8, 1:37 am)
Re: [patch] epoll use a single inode ..., Christoph Hellwig, (Thu Mar 8, 1:56 am)
Re: [patch] epoll use a single inode ..., Eric Dumazet, (Thu Mar 8, 2:42 am)
Re: [patch] epoll use a single inode ..., Christoph Hellwig, (Thu Mar 8, 3:21 am)
Re: [patch] epoll use a single inode ..., Eric Dumazet, (Thu Mar 8, 4:11 am)
Re: [patch] epoll use a single inode ..., Christoph Hellwig, (Thu Mar 8, 4:18 am)
Re: [patch] epoll use a single inode ..., Linus Torvalds, (Thu Mar 8, 8:52 am)
Re: [patch] epoll use a single inode ..., Valdis.Kletnieks, (Thu Mar 8, 9:57 am)
Re: [patch] epoll use a single inode ..., Bob Copeland, (Thu Mar 8, 1:00 pm)
Re: [patch] epoll use a single inode ..., Kyle Moffett, (Thu Mar 8, 6:34 pm)
Re: [patch] epoll use a single inode ..., Anton Blanchard, (Thu Mar 8, 7:46 pm)
Re: [patch] epoll use a single inode ..., Anton Blanchard, (Thu Mar 8, 7:51 pm)
Re: [patch] epoll use a single inode ..., Anton Blanchard, (Thu Mar 8, 7:52 pm)
[PATCH, take2] VFS : Delay the dentry name generation on s ..., Eric Dumazet, (Fri Mar 9, 3:18 am)