<div dir="ltr">Despite using the fsync() , the file was restored to size 0.<br><div><br></div><div>Both fsync() and fsyncdata() are mapped to 'rtems_rtems_fdatasync'.<br></div><div><br></div><div>file path : cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c<br>const rtems_filesystem_file_handlers_r rtems_rfs_rtems_file_handlers = {<br> .open_h = rtems_rfs_rtems_file_open,<br> .close_h = rtems_rfs_rtems_file_close,<br> .read_h = rtems_rfs_rtems_file_read,<br> .write_h = rtems_rfs_rtems_file_write,<br> .ioctl_h = rtems_filesystem_default_ioctl,<br> .lseek_h = rtems_rfs_rtems_file_lseek,<br> .fstat_h = rtems_rfs_rtems_fstat,<br> .ftruncate_h = rtems_rfs_rtems_file_ftruncate,<br> .fsync_h = rtems_rfs_rtems_fdatasync,<br> .fdatasync_h = rtems_rfs_rtems_fdatasync,<br> .fcntl_h = rtems_filesystem_default_fcntl,<br> .kqfilter_h = rtems_filesystem_default_kqfilter,<br> .poll_h = rtems_filesystem_default_poll,<br> .readv_h = rtems_filesystem_default_readv,<br> .writev_h = rtems_filesystem_default_writev<br>};<br></div><div><br></div><div>I think fsyncdata() is not updating the file's metadata.<br></div><div><br></div><div>Therefore, the file does not appear to be fully recovered. Is it possible to update the metadata by modifying the code?<br></div><div><br></div><div>thanks!</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 5, 2021 at 10:46 PM Joel Sherrill <<a href="mailto:joel@rtems.org">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>--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>
</blockquote></div>