Subject: Re: kern/31944 - Fix to reduce tmpfs memory usage
To: Julio M. Merino Vidal <jmmv84@gmail.com>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 04/23/2006 19:26:28
On Fri, Apr 14, 2006 at 07:51:14PM +0200, Julio M. Merino Vidal wrote:
> Hello,
> 
> PR kern/31944 lists three issues that make tmpfs consume too much
> memory.  The attached patch addresses the first of them.  It does the
> following:
> 
> - Only keep the node identifier/generation number when deleting a node.
>   The size of tmpfs_nid is much smaller than that of tmpfs_node.
> - Avoid keeping nodes that were initialized but then discarded due to some
>   error.  See the keepit parameter to the tmpfs_free_node function.
> 
> I have read the replies to that PR but the proposed solutions seem to be
> "not right".  Also, one question that arises... can there be two live files in
> a file system with the same node number?  If not, all those solutions do not
> seem to address this...

As pointed out by others, POSIX requires that a file be uniquelly identifyable
by its device/inode pair.  This is visible to userland via stat().

The NetBSD kernel was recently changed to support 64bit inode numbers, so
maybe you just use increment a 64bit inode number on every create?
(with a random(ish) generation number).

Alternatively you just need to keep the last used generation number for
each inode number - which should just cost 4 bytes/inode, and ought to
be pagable.

	David

-- 
David Laight: david@l8s.co.uk