0

What is the difference between VFS i-node and FS (e.g. EXT) i-node?

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

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

gaffcz
  • 3,469
  • 14
  • 68
  • 108

1 Answers1

4

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:

http://www.win.tue.nl/~aeb/linux/lk/lk-8.html

http://lxr.free-electrons.com/source/Documentation/filesystems/vfs.txt

itisravi
  • 3,406
  • 3
  • 23
  • 30