<div dir="ltr"><div><div><div>Hi,<br><br></div>I am not familiar with btrfs. So i would like to follow in the foot steps of ext3/ext4 file system.<br><br></div>I figure that the most basic functionality (and mandatory for my project) is to recover from a system crash taking place before a file write is complete. So, in order to this what should be the steps ?<br>
<br></div>Thanks.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jun 21, 2013 at 8:31 AM,  <span dir="ltr">&lt;<a href="mailto:Valdis.Kletnieks@vt.edu" target="_blank">Valdis.Kletnieks@vt.edu</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Fri, 21 Jun 2013 07:06:37 +0530, Dibyayan Chakraborty said:<br>
<br>
&gt; I am obviously one step closer to implementing the journaling in file<br>
&gt; system. But i didn&#39;t et the following things.<br>
&gt;<br>
&gt; What would be the correct sequence of steps in implementing it?<br>
<br>
</div>That will depend on how *your* file system implements journalling.<br>
The correct sequence of steps for ext4 to do journaling is different<br>
from how btrfs does its transaction journal.<br>
<br>
In general, the tricky part is that after you log to the journal, you<br>
still have to apply the updates to the filesystem - and do so in such a<br>
way that if the system crashes while updating, you can always look at the<br>
filesystem and the journal, and find a way to replay or rollback to put<br>
the filesystem back to a consistent state. And there&#39;s *plenty* of corner<br>
cases to deal with. For instance, log a file allocation to the journal, then<br>
update the filesystem - but then die before you can flag the journal entry as<br>
&quot;written to filesystem&quot;.  You need to detect that it&#39;s a replay of an already<br>
done event, and do something about it.<br>
<br>
The *real* fun is trying to distinguish between &quot;written to disk but not<br>
removed from journal&quot; and &quot;90% updated to disk but not removed from journal&quot; :)<br>
</blockquote></div><br><br clear="all"><br>-- <br>With Regards<br>Dibyayan Chakraborty<br>
</div>