number of dentry and i-node

1.2k Views Asked by At

I had the following question on an exam:

In a ext3 filesystem the number of dentries is higher than the number of i-nodes.

I had to answer with True or False and explain.

My answer:

It is false because dentries are links between directories, and basically everything is an i-node ( even a directory ) so # i-nodes > # dentries.

However i haven't taken into cosideration the ext3 file-system. Is there something I missed or my answer is correct ?

3

There are 3 best solutions below

3
On

But you can have hardlinks. So you can reasonably have many dentries pointing at the same inode.

0
On

We'll probably have more dentries due to the following:

  1. All hardlinks have unique dentries, but point to the same inode.
  2. Lookups returning ENOENT (file or directory does not exist) creates a dentry and marks its inode pointer as NULL(which is technically called a negative dentry). This helps is quickening up negative lookups, ie lookup on non-existent path.
1
On

The number of dentries is always higher than the number of inodes in a cleanly unmounted filesystem.

Consider: Every inode (excluding unlinked files that are kept alive through open file handles - these are purged in a clean unmount, or during recovery after an unclean unmount) has at least one dentry associated with it. Every directory inode has at least two - a link from its parent (or its own .. for the root) and from .. Additionally directories have an additional dentry associated with them for each subdirectory's .. dentry.

Thus, at an absolute minimum, there is one more dentry than inode (for a FS with only the root directory). Additional directories and hardlinks inflate this further.