hard links - Re: [TriLUG] mkfs vs mke2fs

Tanner Lovelace lovelace at wayfarer.org
Fri May 14 13:38:12 EDT 2004


David Rasch said the following on 5/14/04 1:13 PM:
> 
> With an inode -> filename hash, couldn't this be done linearly O(N) ?
> Check each file against the hash looking for a file already using this
> inode?

Theoretically, but the data structures could get tricky.  You'd need to
sure the hashing function was large enough so that there weren't collisions.
But, since the inode is a number, the perfect (as far as no collisions go)
hashing function is the identity function.  But, then how do you store it.
If you allocate an array for all possible values, then yes, you can do
it O(N) by just checking that bucket but at the cost of a huge amount
of memory.  With each bit you lower the hash function you decrease memory
requirements but also increase the number of things you must check to
avoid collisions.  It would be interesting to see the curve that
results from this tradeoff.  You have to pay somewhere, be it memory or
operations.

Cheers,
Tanner

-- 
Tanner Lovelace       | Don't move! Or I'll fill ya full of... little
lovelace at wayfarer.org | yellow bolts of light! - Commander John Crichton



More information about the TriLUG mailing list