LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-18-2014, 05:49 AM   #1
vinayak099
Member
 
Registered: Jan 2014
Posts: 31

Rep: Reputation: Disabled
how ext2/3/4 handles random writes.


Hi,

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.
 
Old 03-18-2014, 06:33 AM   #2
gengisdave
Member
 
Registered: Dec 2013
Location: Turin, Italy
Distribution: slackware
Posts: 326

Rep: Reputation: 73
how ext2/3/4 handles random writes.

Fast explanation: to preserve file fragmentations, ext4 allocate a new file far after the end of the previous one, so it can grow without being fragmented.
 
Old 03-18-2014, 06:50 AM   #3
vinayak099
Member
 
Registered: Jan 2014
Posts: 31

Original Poster
Rep: Reputation: Disabled
But how ext4 handles the data integrity ?

ex : I will open the file 10 times and each time I will add some strings at different positions randomly ( assume that file is of 100 MB ).

Now, ext4 should handle the case by inserting the string at different offsets.

In this case, does ext4 will allocate new block for every addition of the string (it results in disk fragmentation.) or creates new file every time and writes the modified data again (time overhead is more in this case )?

How it handles data integrity and performance in this case ?

Can you please help me in understanding it.
 
Old 03-18-2014, 07:24 AM   #4
gengisdave
Member
 
Registered: Dec 2013
Location: Turin, Italy
Distribution: slackware
Posts: 326

Rep: Reputation: 73
how ext2/3/4 handles random writes.

https://ext4.wiki.kernel.org/index.php/Ext4_Disk_Layout

long explanation
 
Old 03-18-2014, 08:00 AM   #5
vinayak099
Member
 
Registered: Jan 2014
Posts: 31

Original Poster
Rep: Reputation: Disabled
Thank you. Hope it will clear my doubts.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
DB clustering/replication scheme where each node handles reads & writes? sneakyimp Linux - Server 5 01-11-2013 04:25 AM
kernel file handles vs userspace file handles. jiml8 Programming 7 05-13-2008 06:32 PM
random access writes to compressed files pelkeyj Programming 5 03-31-2008 04:01 PM
Have any of you used the Windows driver that allows ext2,3 filesystem read and writes brjoon1021 Linux - Hardware 4 02-19-2007 06:14 PM
Multible newbie questions (pppd, ext2 vs ext3, and random inode read errors) (Slack10 Nicolae Slackware 8 08-28-2004 04:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration