diff --git a/repos/dde_rump/lib/mk/rump_fs.mk b/repos/dde_rump/lib/mk/rump_fs.mk index c9c8542f4b..4f4b26363a 100644 --- a/repos/dde_rump/lib/mk/rump_fs.mk +++ b/repos/dde_rump/lib/mk/rump_fs.mk @@ -54,6 +54,7 @@ SRC_NOLINK += bufq_disksort.c compat.c devnull.c genfs_vfsops.c \ bufq_readprio.c devnodes.c genfs_rename.c kern_module_vfs.c rumpblk.c \ rumpvfs_syscalls.c subr_kobj_vfs.c vfs_bio.c vfs_getcwd.c \ vfs_lookup.c vfs_syscalls_50.c vfs_vnops.c +SRC_NOLINK += sync_thread.c INC_DIR += $(RUMP_PORT_DIR)/src/sys/rump/librump/rumpkern/opt @@ -67,6 +68,7 @@ vpath %.c $(RUMP_PORT_DIR)/src/sys/miscfs/syncfs vpath %.c $(RUMP_PORT_DIR)/src/sys/ufs/mfs vpath %.c $(RUMP_PORT_DIR)/src/sys/ufs/ufs vpath %.c $(RUMP_PORT_DIR)/src/sys/uvm +vpath %.c $(REP_DIR)/src/lib/rump # diff --git a/repos/dde_rump/patches/sync.patch b/repos/dde_rump/patches/sync.patch new file mode 100644 index 0000000000..75eedcf910 --- /dev/null +++ b/repos/dde_rump/patches/sync.patch @@ -0,0 +1,25 @@ +diff --git a/src/sys/rump/librump/rumpkern/rump.c b/src/sys/rump/librump/rumpkern/rump.c +index 24466eb..031906e 100644 +--- src/lib/dde_rump/src/sys/rump/librump/rumpkern/rump.c ++++ src/lib/dde_rump/src/sys/rump/librump/rumpkern/rump.c +@@ -209,6 +209,8 @@ RUMP_COMPONENT(RUMP_COMPONENT_POSTINIT) + } + #endif + ++void genode_sync_thread(void *); ++ + int + rump_init(void) + { +@@ -468,6 +470,11 @@ rump_init(void) + rump_consdev_init(); + rump_lwproc_switch(NULL); + ++ /* start the Genode sync thread */ ++ if (kthread_create(PRI_IOFLUSH, KTHREAD_MPSAFE, NULL, ++ genode_sync_thread, NULL, NULL, "genode_sync_thread") != 0) ++ panic("Genode syncer thread create failed"); ++ + /* release cpu */ + rump_unschedule(); + diff --git a/repos/dde_rump/ports/dde_rump.hash b/repos/dde_rump/ports/dde_rump.hash index 44adadcff9..fc6f4dcf18 100644 --- a/repos/dde_rump/ports/dde_rump.hash +++ b/repos/dde_rump/ports/dde_rump.hash @@ -1 +1 @@ -9afe5679a00a8df0f3c5a9a5838956dc993f1b0a +bb358512dc48cc6c2221de4e3fe105ed0a3ed847 diff --git a/repos/dde_rump/ports/dde_rump.port b/repos/dde_rump/ports/dde_rump.port index 842dcdc604..16f14ab2c2 100644 --- a/repos/dde_rump/ports/dde_rump.port +++ b/repos/dde_rump/ports/dde_rump.port @@ -14,4 +14,4 @@ URL(libc) := https://github.com/justincormack/netbsd-src/trunk/src/common/lib/li REV(libc) := HEAD DIR(libc) := src/lib/libc -PATCHES := patches/rump.patch patches/aarch64.patch +PATCHES := patches/rump.patch patches/aarch64.patch patches/sync.patch diff --git a/repos/dde_rump/src/include/rump_fs/fs.h b/repos/dde_rump/src/include/rump_fs/fs.h index ab2789b8dd..a84da163e8 100644 --- a/repos/dde_rump/src/include/rump_fs/fs.h +++ b/repos/dde_rump/src/include/rump_fs/fs.h @@ -5,7 +5,7 @@ */ /* - * Copyright (C) 2014-2017 Genode Labs GmbH + * Copyright (C) 2014-2022 Genode Labs GmbH * * This file is part of the Genode OS framework, which is distributed * under the terms of the GNU Affero General Public License version 3. @@ -34,7 +34,7 @@ void rump_io_backend_init(); /** * Sync I/O back-end with underlying Genode subsystems */ -void rump_io_backend_sync(); +extern "C" void rump_io_backend_sync(); /** * Return true if an I/O backend-request is pending diff --git a/repos/dde_rump/src/lib/rump/sync_thread.c b/repos/dde_rump/src/lib/rump/sync_thread.c new file mode 100644 index 0000000000..8a231d58fd --- /dev/null +++ b/repos/dde_rump/src/lib/rump/sync_thread.c @@ -0,0 +1,33 @@ +/* + * \brief Rump kernel thread which syncs the file system every 10s + * \author Christian Prochaska + * \date 2022-04-08 + */ + +/* + * Copyright (C) 2022 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU Affero General Public License version 3. + */ + +#include +#include +#include +#include + +extern void rump_io_backend_sync(); + +void genode_sync_thread(void *arg) +{ + for (;;) { + /* sleep for 10 seconds */ + rumpuser_clock_sleep(RUMPUSER_CLOCK_RELWALL, 10, 0); + + /* sync through front-end */ + do_sys_sync(curlwp); + + /* sync Genode back-end */ + rump_io_backend_sync(); + } +} diff --git a/repos/dde_rump/src/lib/vfs/rump/vfs_rump.cc b/repos/dde_rump/src/lib/vfs/rump/vfs_rump.cc index 3859dfa3f8..c59e54f27a 100644 --- a/repos/dde_rump/src/lib/vfs/rump/vfs_rump.cc +++ b/repos/dde_rump/src/lib/vfs/rump/vfs_rump.cc @@ -7,7 +7,7 @@ */ /* - * Copyright (C) 2014-2018 Genode Labs GmbH + * Copyright (C) 2014-2022 Genode Labs GmbH * * This file is part of the Genode OS framework, which is distributed * under the terms of the GNU Affero General Public License version 3. @@ -18,7 +18,6 @@ #include #include #include -#include #include extern "C" { @@ -846,19 +845,10 @@ class Vfs::Rump_file_system : public File_system class Rump_factory : public Vfs::File_system_factory { - private: - - Timer::Connection _timer; - Genode::Io_signal_handler _sync_handler; - - void _sync() { _rump_sync(); } - public: Rump_factory(Genode::Env &env, Genode::Allocator &alloc, Genode::Xml_node config) - : _timer(env, "rump-sync"), - _sync_handler(env.ep(), *this, &Rump_factory::_sync) { Rump::construct_env(env); @@ -892,12 +882,6 @@ class Rump_factory : public Vfs::File_system_factory rlim.rlim_cur = rlim.rlim_max; rump_sys_setrlimit(RLIMIT_NOFILE, &rlim); } - - /* start syncing */ - enum { TEN_SEC = 10*1000*1000 }; - _timer.sigh(_sync_handler); - _timer.trigger_periodic(TEN_SEC); - } Vfs::File_system *create(Vfs::Env &env, Genode::Xml_node config) override