From: "Adam J. Richter" Subject: drop sysfs inode number functionality? Date: Sun, 12 Dec 2004 15:09:52 +0800 Message-ID: <200412120709.iBC79qQ02057@freya.yggdrasil.com> Return-path: Received: from [61.49.148.248] ([61.49.148.248]:59887 "EHLO freya.yggdrasil.com") by vger.kernel.org with ESMTP id S262049AbULLHOG (ORCPT ); Sun, 12 Dec 2004 02:14:06 -0500 To: greg@kroah.com, linux-fsdevel@vger.kernel.org, maneesh@in.ibm.com Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org There are some further reductions in sysfs memory consumption that I would like to make which would be easier if sysfs would make no attempt to avoid duplicate inode numbers. Currently, the readdir routine in sysfs generates a new inode number for any node that does not at that moment have a struct dentry. Repeated calls to readdir will return different inode numbers, but it is very rare that reading information about two different nodes will return the same inode number. If a struct dentry exists (normally because someone has a file descriptor open on the node), then readdir and stat will always consistently return the same inode number for the same node. To accomplish this, sysfs_readdir currently reads sysfs_dirent.s_dentry. I want to eliminate sysfs_dirent.s_dentry for non-directories and eliminate the sysfs_dirent structures for attributes that are part of an attribute_group directory. The approach which would involve the smallest implementation would be just to return zero or some other constant for the inode number in all cases. My inclination is to try this first, and then switch to another approach if it causes problems. A second approach would be to find some unique memory address to cast to the inode number (the address of the sysfs_dirent perhaps, or even different addresses for different types of sysfs nodes). This is a slight problem for members of attribute groups, since there is no unique address (the struct attribute may be pointed to by many instances of the same type of kobject), but I could use addresses of bytes within the sysfs_dirent structure as unique addresses as long as their are fewer than about 28 attributes, and I could even allocate extra bytes on the struct sysfs_dirent to guarantee enough unique addresses in cases where a group has more than 28 attributes. A third approach would be actually to allocate inode numbers or ranges of them, and store them in struct sysfs_dirent. This would increasee memory consumption, and if it is necessary to worry about the index wrapping around and potentially being duplicated, then the implementation will be slightly more involved. My inclination is to try to make sysfs always return 0 or something similar as the inode number. Comments? __ ______________ Adam J. Richter \ / adam@yggdrasil.com | g g d r a s i l