lkml.org 
[lkml]   [2008]   [Jun]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: find: WARNING: Hard link count is wrong for /proc/1
On Tue, Jun 3, 2008 at 5:46 AM, Eric W. Biederman <ebiederm@xmission.com> wrote:
> Andrew Morton <akpm@linux-foundation.org> writes:
>>> #ifdef CONFIG_SECURITY
>>> inode->i_nlink += 1;
>>> #endif
>>> +#ifdef CONFIG_NET
>>> + inode->i_nlink += 1;
>>> +#endif
>>>
>>> dentry->d_op = &pid_dentry_operations;
>>
>> A bit more explanation would be nice.
>>
>> I assume that here we're accounting for a reference which net applies
>> to this dentry. But it would be clearer and more robust to do that at
>> the site where that reference is really taken, not over in
>> proc_pid_instantiate(). Possible?
>
> Yes. Potentially we can read through the tid_base_stuff and
> count the total number of directories at runtime whenever we
> open a /proc/<pid> directory. It is a smallish table and walking the
> entire table is likely to be lost in the noise, and that would
> certainly improve the maintainability of the code.
>
> Currently what we do is:
> inode->i_nlink = 5;
> #ifdef CONFIG_SECURITY
> inode->i_nlink += 1;
> #endif
>
> To get the hard link count of /proc/<pid> correct.
> With /proc/<pid>/net we have added one more optional possibly absent
> directory.
>
> So the above patch is trivially correct in the current form of the
> code but does not improve maintenance.
>
> I am tired and all I have the energy to do today is to review the
> patch and say: "Yes. The patch works for the correct reasons, let's
> fix this bug."

I can try for the counting fix if you give me a bit of time. I have an
exam today and tomorrow, so I'll likely be able to submit a fix after
that :-)

Maybe you can apply the fix for now and I can follow up with the nicer
counting patch afterwards? (Or if anybody else wants to write it
that's also fine :-))


Vegard

--
"The animistic metaphor of the bug that maliciously sneaked in while
the programmer was not looking is intellectually dishonest as it
disguises that the error is the programmer's own creation."
-- E. W. Dijkstra, EWD1036


\
 
 \ /
  Last update: 2008-06-03 06:09    [W:0.240 / U:0.312 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site