gaffcz gaffcz - 1 month ago 6
Linux Question

VFS and FS i-node difference

What is the difference between

i-node and
) i-node?

Is it possible that
i-node is persistent (contains/points to data blocks), but
i-node is created just in i-node cache after read/use of

Or the
i-node is just an image of
i-node (it's the same) and i-nodes in those systems, which are not working with i-nodes (e.g.
) has to be emulated (HOW?) to allow
work with those
like they would support i-nodes?


You seem to have answered your questions yourself :)

Let's consider the case of EXT4:

The file system inode is stored on disk in the format as exactly described by struct ext4_inode. The struct ext4_inode_info is just an in-memory representation of the same. The VFS inode also an in-memory object that contains inode information that is common irrespective of the file system type and thus can be abstracted. It is allocated from the inode cache (a memory pool got using the slab allocator).The VFS struct inode is embedded in the filesystem specific in-memory struct inode. For example, struct ext4_inode_info has a member called struct inode vfs_inode. Given a VFS inode, you can get the FS specific inode using the standard container_of macro found in the kernel code. Thus any FS can get to it's own inode struct when it is handed over the generic inode struct by VFS.

Checkout what happens when a new inode is created using __ext4_new_inode()

FAT usually stores the metadata (i.e. inode information) on a directory entry. So the linux fat driver just reads it, populates the necessary fields in memory. Since there's no concept of inodes in FAT, the inode number is a random number- a call to iunique() to be precise.

Some good resources on VFS: