<div dir="ltr"><div>What you get will depend very much on what file system you are using. Each file system has different behaviours.</div><div><br></div><div>If you have an application where you can yank power without a clean shutdown then it is advisable to use a file system with a more predictable caching policy.</div><div><br></div><div>For example, Yaffs (the file system I wrote) guarantees that the write has made it to media when the file is synced (<span class="gmail-im">fsync() and fdatasync() )</span> or closed.</div><div><br></div><div>If the file system's <span class="gmail-im">fsync()and close() only guarantee that that data is written into the block device's buffers then you have no guarantees.</span></div><div><span class="gmail-im"><br></span></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 6, 2021 at 5:07 AM Gedare Bloom <<a href="mailto:gedare@rtems.org">gedare@rtems.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 5, 2021 at 6:47 AM Joel Sherrill <<a href="mailto:joel@rtems.org" target="_blank">joel@rtems.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 5, 2021 at 12:48 AM jaeho jo <<a href="mailto:hot486two@gmail.com" target="_blank">hot486two@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello!<div><br></div><div>I am testing filesystem recovery and I have a question.</div><div><br></div><div>If the reset is not a power-on reset, my application attempts to restore the filesystem.</div><div><br></div><div>If the file was closed prior to reset, the file was restored.</div><div><br></div><div>If a reset occurs while a file is open, the file was not recovered after the reset. The file was created, but its size is 0. Is this the intended behavior of RTEMS?</div><div><br></div><div>I tested the OS version using RTEMS4.11.1 and 5.1, and the file system using RFS and dosFS. The results were all the same. A file of size 0 has been created.<br></div></div></blockquote><div><br></div><div>If the file and underlying disk buffers are not flushed before reset, then nothing has been committed to the non-volatile storage.</div><div><br></div><div>I would say this is expected and intended behavior if you do not have an orderly write of a file on shutdown/reset on any operating system.</div><div><br></div><div>My quick look at the source code for both filesystems you mention indicate the sync calls like fsync() and fdatasync() are supported. Here is the POSIX page for fsync(). Notice the discussion at the bottom about automated testing and reset.</div><div><br></div><div><a href="https://pubs.opengroup.org/onlinepubs/009695399/functions/fsync.html" target="_blank">https://pubs.opengroup.org/onlinepubs/009695399/functions/fsync.html</a></div><div><br></div><div>I assume this also flushes the block device cache but I didn't look beyond the file system implementations.</div><div><br></div></div></div></blockquote><div><br></div><div>In general, a filesystem needs journalling (or an equivalent transaction-based mechanism) to support arbitrary recovery after reset.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div></div><div>--joel</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div></div><div><br></div><div>thanks!</div><div>jhjo</div></div>
_______________________________________________<br>
users mailing list<br>
<a href="mailto:users@rtems.org" target="_blank">users@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/users</a></blockquote></div></div>
_______________________________________________<br>
users mailing list<br>
<a href="mailto:users@rtems.org" target="_blank">users@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/users</a></blockquote></div></div>
_______________________________________________<br>
users mailing list<br>
<a href="mailto:users@rtems.org" target="_blank">users@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/users</a></blockquote></div>