lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <m1y6k3913z.fsf@fess.ebiederm.org>
Date:	Tue, 12 Jan 2010 00:30:24 -0800
From:	ebiederm@...ssion.com (Eric W. Biederman)
To:	"Serge E. Hallyn" <serue@...ibm.com>
Cc:	Greg Kroah-Hartman <gregkh@...e.de>,
	Kay Sievers <kay.sievers@...y.org>,
	linux-kernel@...r.kernel.org, Tejun Heo <tj@...nel.org>,
	Cornelia Huck <cornelia.huck@...ibm.com>,
	linux-fsdevel@...r.kernel.org,
	Eric Dumazet <eric.dumazet@...il.com>,
	Benjamin LaHaise <bcrl@...et.ca>,
	"Eric W. Biederman" <ebiederm@...stanetworks.com>
Subject: Re: [PATCH 3/7] sysfs: Keep an nlink count on sysfs directories.

"Serge E. Hallyn" <serue@...ibm.com> writes:

> Quoting Eric W. Biederman (ebiederm@...ssion.com):
>> From: Eric W. Biederman <ebiederm@...stanetworks.com>
>> 
>> On large directories sysfs_count_nlinks can be a significant
>> bottleneck, so keep a count in sysfs_dirent.  If we exceed
>> the maximum number of directory entries we can store return
>> nlink of 1.  An nlink of 1 matches what reiserfs does in
>> this case, and it let's find and similar utlities know that
>> we have a the directory nlink can not be used for optimization
>> purposes.
>> 
>> Signed-off-by: Eric W. Biederman <ebiederm@...stanetworks.com>
>> ---
>>  fs/sysfs/dir.c   |   20 ++++++++++++++++++++
>>  fs/sysfs/inode.c |   15 +--------------
>>  fs/sysfs/mount.c |    1 +
>>  fs/sysfs/sysfs.h |    1 +
>>  4 files changed, 23 insertions(+), 14 deletions(-)
>> 
>> diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
>> index 5c4703d..1c364be 100644
>> --- a/fs/sysfs/dir.c
>> +++ b/fs/sysfs/dir.c
>> @@ -359,6 +359,7 @@ struct sysfs_dirent *sysfs_new_dirent(const char *name, umode_t mode, int type)
>>  	sd->s_name = name;
>>  	sd->s_mode = mode;
>>  	sd->s_flags = type;
>> +	sd->s_nlink = type == SYSFS_DIR? 2:1;
>> 
>>  	return sd;
>> 
>> @@ -392,6 +393,23 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt,
>>  	mutex_lock(&sysfs_mutex);
>>  }
>> 
>> +static void sysfs_dir_inc_nlink(struct sysfs_dirent *sd)
>> +{
>> +	/* If we overflow force nlink to be 1 */
>> +	if (sd->s_nlink > 1) {
>> +		sd->s_nlink++;
>> +		if (sd->s_nlink == 0)
>> +			sd->s_nlink = 1;
>> +	}
>> +}
>
> Now, the original code only ups nlink on parent if child is a dir.
> IIUC your code will now inc nlink for files as well.  Is any userspace
> going to be confused by that?

Good point.  nlink should only be upped for directories.

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ