[Novalug] where are they?

Jon LaBadie novalugml@jgcomp.com
Tue Mar 10 18:08:24 EDT 2015


On Tue, Mar 10, 2015 at 03:00:07PM -0400, Rich Kulawiec via Novalug wrote:
> On Tue, Mar 10, 2015 at 10:05:01AM -0400, John Franklin via Novalug wrote:
> > The technical term is "reference counts", and i includes both hard
> > links (but not soft links) and open file descriptors.  When the reference
> > count is reduced to zero, then inode is ready to be freed.
> 
> Yeah, I know.  I tend to use terminology from the Unix (or more precisely,
> the BSD) world because I've spent rather a lot of time there -- and still do.

My recollection from SysV was two different inode structures.
was the on-disk, stored version, the other the in-memory, in-use
version.  Reference counts did not exist on disk and the in-memory
version's reference count did not have the hard link count added in.
It was kept separate.

The reference count determined whether the inode could be freed
from memory.  When released, a non-zero hard link count meant the
inode had to be written back to disk.  If both the reference count
and the hard link count were zero, there were no directory entries
remaining and besides releasing the memory version of the inode,
the data blocks for the file and the disk version of the inode
were also released.

IIRC, inodes for things other than files explicitly opened were kept
in memory.  For example, inodes of the root directory of every mounted
file system and the directory it is mounted on were kept available in
memory.  Similarly, the inodes of every loaded object file (libraries
and executables) plus the current working directory of every process
(and its parent directory) were in memory.

While they had entries in the system's open file table, no process
may have explicitely opened them so no file descriptor exists.  The
reference count then refered to the number of processes using the
file table entry and its corresponding inode.

Jon
-- 
Jon H. LaBadie                  novalugml@jgcomp.com
 11226 South Shore Rd		(703) 787-0688 (H)
 Reston, VA  20190		(703) 935-6720 (C)



More information about the Novalug mailing list