Hello Adrian,

* a3an <[email protected]> [2015-01-30 10:56:45 +0100]:
> I've got some new indications.
> I used the fsync() call to see how that worked out.
> It did not work either. By plowing through the vfs header files, I noticed
> that File_system contains a virtual function called sync() followed by
> {}, and
> some comments that only Fs_file_system needs sync.
> I placed a PWRN macro call with a msg within the braces and run the test
> test again.
> The msg appeared on the console.

I added debug messages to the code (see the patch file) to trace the
fsync() call and it actually calls the sync() method of rump_fs in the
end:

[init -> test-libc_vfs] open(file_name, O_CREAT | O_WRONLY) succeeded
[init -> test-libc_vfs] calling fsync(fd)
[init -> test-libc_vfs] virtual int 
Libc::Vfs_plugin::fsync(Libc::File_descriptor*):
[init -> test-libc_vfs] virtual void Vfs::Dir_file_system::sync():
[init -> test-libc_vfs] virtual void Vfs::Dir_file_system::sync():
[init -> test-libc_vfs] virtual void Vfs::Fs_file_system::sync():
[init -> rump_fs] virtual void File_system::Session_component::sync():
[init -> test-libc_vfs] fsync(fd) succeeded

> It means there is no overriding implementation for sync(), presumably in
> Fs_file_system.
> I assume rump_fs has been used in read mode only.

We use rump_fs with Ext2 r/w on a regular basis and it worked fine so
far. Since Ext2 does not support any journaling we call sync [1] once
a second to mitigate problems resulting from a potential power loss. I
admit that this is not the best solution to tackle this issue, however
it has to suffice for now. There are plans to port the Ext4 driver from
Linux but there is no concrete schedule, though.

Cheers
Josef

[1] repos/dde_rump/src/server/rump_fs/file_system.cc:91
diff --git a/repos/dde_rump/src/server/rump_fs/main.cc b/repos/dde_rump/src/server/rump_fs/main.cc
index 98370f2..ed03202 100644
--- a/repos/dde_rump/src/server/rump_fs/main.cc
+++ b/repos/dde_rump/src/server/rump_fs/main.cc
@@ -322,7 +322,7 @@ class File_system::Session_component : public Session_rpc_object
 			_handle_registry.sigh(node_handle, sigh);
 		}
 
-		void sync() { rump_sys_sync(); }
+		void sync() { PDBG(""); rump_sys_sync(); }
 };
 
 class File_system::Root : public Root_component<Session_component>
diff --git a/repos/libports/src/lib/libc/vfs_plugin.cc b/repos/libports/src/lib/libc/vfs_plugin.cc
index d43ab6a..358cec1 100644
--- a/repos/libports/src/lib/libc/vfs_plugin.cc
+++ b/repos/libports/src/lib/libc/vfs_plugin.cc
@@ -826,6 +826,7 @@ int Libc::Vfs_plugin::fcntl(Libc::File_descriptor *fd, int cmd, long arg)
 
 int Libc::Vfs_plugin::fsync(Libc::File_descriptor *fd)
 {
+	PDBG("");
 	_root_dir.sync();
 	return 0;
 }
diff --git a/repos/libports/src/test/libc_ffat/main.cc b/repos/libports/src/test/libc_ffat/main.cc
index 36ddb8f..80f6309 100644
--- a/repos/libports/src/test/libc_ffat/main.cc
+++ b/repos/libports/src/test/libc_ffat/main.cc
@@ -71,6 +71,8 @@ int main(int argc, char *argv[])
 
 		/* write pattern to a file */
 		CALL_AND_CHECK(fd, open(file_name, O_CREAT | O_WRONLY), fd >= 0, "file_name=%s", file_name);
+		CALL_AND_CHECK(ret, fsync(fd), (ret == 0), "");
+
 		CALL_AND_CHECK(count, write(fd, pattern, pattern_size), (size_t)count == pattern_size, "");
 		CALL_AND_CHECK(ret, close(fd), ret == 0, "");
 
diff --git a/repos/os/include/vfs/dir_file_system.h b/repos/os/include/vfs/dir_file_system.h
index 2a42355..2edc40c 100644
--- a/repos/os/include/vfs/dir_file_system.h
+++ b/repos/os/include/vfs/dir_file_system.h
@@ -512,6 +512,7 @@ class Vfs::Dir_file_system : public File_system
 		 */
 		void sync() override
 		{
+			PDBG("");
 			for (File_system *fs = _first_file_system; fs; fs = fs->next)
 				fs->sync();
 		}
diff --git a/repos/os/include/vfs/fs_file_system.h b/repos/os/include/vfs/fs_file_system.h
index 3817aab..10f79f7 100644
--- a/repos/os/include/vfs/fs_file_system.h
+++ b/repos/os/include/vfs/fs_file_system.h
@@ -574,6 +574,7 @@ class Vfs::Fs_file_system : public File_system
 
 		void sync() override
 		{
+			PDBG("");
 			_fs.sync();
 		}
 
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
genode-main mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/genode-main

Reply via email to