In the Unix File system (UFS), the file is represented as an inode structure which has 15 pointers that reference the direct blocks or indirect blocks.
Taking the below images is an example.
Each block represented as
Data on the right hand side contains the actual file data. And the size of this
data block usually is 4096 and is decided during the file system creation.
For a huge file of 40 MB it would occupy nearly 1K data blocks. Given this scenario, if we append data to this file I see it would only impact the last block or if there is no space in the last data block it will create new data block.
But if we add some data (some 200 bytes) at the start of file, would it have cascade effect on the below data blocks and results in moving (or pushing) last 200 bytes of its each data block to the next data block?
Similarly when we delete the first 200 bytes from the first data block, will it have cascade effect on the lower data blocks?
Or is there an efficient way that UFS or in general file systems employ to handle such scenarios, may be some buffer space is reserved for each data block?
Thanks in advance.