Re: [RFC PATCH] vfs: optimization to /proc/<pid>/mountinfo patch

From: Miklos Szeredi
Date: Mon Feb 04 2008 - 06:50:23 EST


> 1) reports deleted inode in dentry_path() consistent with that in __d_path()
> 2) modified __d_path() to use prepend(), reducing the size of __d_path()
> 3) moved all the functionality that reports mount information in /proc under
> CONFIG_PROC_FS.
>
> Could not verify if the code would work with CONFIG_PROC_FS=n, since it was
> impossible to disable CONFIG_PROC_FS. Looking for ideas on how to disable
> CONFIG_PROC_FS.
>
>
>
> Signed-off-by: Ram Pai <linuxram@xxxxxxxxxx>
> ---
> fs/dcache.c | 59 +++++++++++++++++++----------------------------
> fs/namespace.c | 2 +
> fs/seq_file.c | 2 +
> include/linux/dcache.h | 3 ++
> include/linux/seq_file.h | 3 ++
> 5 files changed, 34 insertions(+), 35 deletions(-)
>
> Index: linux-2.6.23/fs/dcache.c
> ===================================================================
> --- linux-2.6.23.orig/fs/dcache.c
> +++ linux-2.6.23/fs/dcache.c
> @@ -1747,6 +1747,17 @@ shouldnt_be_hashed:
> goto shouldnt_be_hashed;
> }
>
> +static int prepend(char **buffer, int *buflen, const char *str,
> + int namelen)
> +{
> + *buflen -= namelen;
> + if (*buflen < 0)
> + return 1;

This is confusing. Should return -ENAMETOOLONG intead (see Chapter 16
in Documentation/CodingStyle).

> + *buffer -= namelen;
> + memcpy(*buffer, str, namelen);
> + return 0;
> +}
> +
> /**
> * d_path - return the path of a dentry
> * @dentry: dentry to report
> @@ -1768,17 +1779,11 @@ static char *__d_path(struct dentry *den
> {
> char * end = buffer+buflen;
> char * retval;
> - int namelen;
>
> - *--end = '\0';
> - buflen--;
> - if (!IS_ROOT(dentry) && d_unhashed(dentry)) {
> - buflen -= 10;
> - end -= 10;
> - if (buflen < 0)
> + prepend(&end, &buflen, "\0", 1);
> + if (!IS_ROOT(dentry) && d_unhashed(dentry) &&
> + prepend(&end, &buflen, " (deleted)", 10))

And this should test for "prepend() != 0" or "prepend() < 0" instead,
otherwise it could easily be misread as "if prepend() succeeded,
then...".

And similarly for all the later calls.

Thanks,
Miklos
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/