how ext2/3/4 handles random writes.
I am little curious to know and understand ext4 file system. But I am not able to understand how the ext4 handles random write.
ex : assume that I have file called
"f1.txt", initilally constains
"HI I am vinayak, trying to learn ext4 file system"
now I will insert "good morning," between "HI" and "I"
Now the file contents of f1.txt will be
"HI good morning, I am vinayak, trying to learn ext4 file system"
In this case file content is very small and I can easily read the contents of the file, can insert the string and other content can be moved by the length of the string.
But how it is handled in case of big file (1 GB etc), if I want to apply the patch to such a big file. Because applying patch requires changes in several places and each time data should be moved across the blocks.
Can anybody explain me how write to such big files will happen. I mean how the insertion of the string happens and blocks will be adjusted.