I believe there are two types of inodes - on-disk and in-core inode ('struct inode' in fs.h). An on-disk inode is based on filesystem implementation. I am trying to understand the underlying concept and have a few questions -
- Can someone point me to the code (or walk through the steps) where the on-disk inode is read/copied to the in-core inode? i.e., when in-core inode is created it has to be from an on-disk inode. So, how does this happen?
- Why doesn't the in-core inode store a pointer to the on-disk inode?
- If there is a modification to the in-core inode then how is it propagated to the on-disk inode? Any pointers to the code or code-flow would be helpful.
Thanks!
In core inode is getting copied from disk inode in algorithm ialloc after allocating a free inode for the newly assigned disk inode using algorithm iget.
Kernel set flags to indicate discrepancies between the disk inode and in-core copy.When Kernel need to record changes to the file or to the inode, it writes the in-core copy of the inode to the disk after examining these flags.