From 6a12a6b4bae5a667044047e429c2003341af3e93 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Thu, 19 Apr 2018 11:54:00 +0200 Subject: [PATCH] vfs: reduce ROM-update rate Rom_file_system::stat The 'stat' method is called for all paths, not just the specific file system node of the ROM module. The ROM update is needed only in the latter case. Otherwise, when always updating the ROM on stat, stat calls on the VFS become very expensive in the presence of a mounted ROM module if the ROM is obtained from fs_rom (which re-watches the file and all its individual path elements whenever the 'update' RPC function is called). --- repos/os/src/lib/vfs/rom_file_system.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/repos/os/src/lib/vfs/rom_file_system.h b/repos/os/src/lib/vfs/rom_file_system.h index f3b754fb9e..3d4c256e1d 100644 --- a/repos/os/src/lib/vfs/rom_file_system.h +++ b/repos/os/src/lib/vfs/rom_file_system.h @@ -146,10 +146,17 @@ class Vfs::Rom_file_system : public Single_file_system Stat_result stat(char const *path, Stat &out) override { - Stat_result result = Single_file_system::stat(path, out); + Stat_result const result = Single_file_system::stat(path, out); - _rom.update(); - out.size = _rom.valid() ? _rom.size() : 0; + /* + * If the stat call refers to our node ('Single_file_system::stat' + * found a file), obtain the size of the most current ROM module + * version. + */ + if (out.mode == STAT_MODE_FILE) { + _rom.update(); + out.size = _rom.valid() ? _rom.size() : 0; + } return result; }