From: ebiederm@xmission.com (Eric W. Biederman)
To: Al Viro <viro@ftp.linux.org.uk>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 8/8] fix handling of st_nlink on procfs root
Date: Wed, 15 Feb 2006 02:20:17 -0700 [thread overview]
Message-ID: <m1slql3rn2.fsf@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <E1F6vyO-00009r-3a@ZenIV.linux.org.uk> (Al Viro's message of "Wed, 08 Feb 2006 20:31:32 +0000")
Al Viro <viro@ftp.linux.org.uk> writes:
> Date: 1139427460 -0500
>
> 1) it should use nr_processes(), not nr_threads; otherwise we are getting
> very confused find(1) and friends, among other things.
> 2) better do that at stat() time than at every damn lookup in procfs root.
>
> Patch had been sitting in FC4 kernels for many months now...
And it is actually wrong. It fails to take into account the static
/proc entries.
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
> diff --git a/fs/proc/root.c b/fs/proc/root.c
> index 6889628..c3fd361 100644
> --- a/fs/proc/root.c
> +++ b/fs/proc/root.c
> @@ -80,16 +80,16 @@ void __init proc_root_init(void)
> proc_bus = proc_mkdir("bus", NULL);
> }
>
> -static struct dentry *proc_root_lookup(struct inode * dir, struct dentry *
> dentry, struct nameidata *nd)
> +static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry,
> struct kstat *stat
> +)
> {
> - /*
> - * nr_threads is actually protected by the tasklist_lock;
> - * however, it's conventional to do reads, especially for
> - * reporting, without any locking whatsoever.
> - */
> - if (dir->i_ino == PROC_ROOT_INO) /* check for safety... */
> - dir->i_nlink = proc_root.nlink + nr_threads;
> + generic_fillattr(dentry->d_inode, stat);
> + stat->nlink = proc_root.nlink + nr_processes();
> + return 0;
> +}
proc_root_getattr should look more like below.
Notice the addition of de->nlink, which accounts for the
static entries as well.
static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry,
struct kstat *stat)
{
struct inode *inode = dentry->d_inode;
struct proc_dir_entry *de = PDE(inode);
generic_fillattr(inode, stat);
if (de && de->nlink)
inode->i_nlink = de->nlink;
/* Get the proper hardlink count */
stat->nlink += nr_processes();
return 0;
}
next prev parent reply other threads:[~2006-02-15 9:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-08 20:31 [PATCH 8/8] fix handling of st_nlink on procfs root Al Viro
2006-02-09 1:04 ` Eric W. Biederman
2006-02-09 2:17 ` Al Viro
2006-02-09 3:14 ` Eric W. Biederman
2006-02-15 9:20 ` Eric W. Biederman [this message]
2006-02-15 10:39 ` Al Viro
2006-02-15 17:35 ` Eric W. Biederman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m1slql3rn2.fsf@ebiederm.dsl.xmission.com \
--to=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@ftp.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox