From 4f992242554dc205a18c9f11509a0f19dc9a2306 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Sun, 17 Mar 2019 13:37:02 +0100 Subject: [PATCH] ram_fs: increase max file size on 64 bit to 8 GiB Fixes #2315 --- repos/os/include/ram_fs/chunk.h | 8 ++--- repos/os/include/ram_fs/param.h | 42 ++++++++++++++++++++++++++ repos/os/recipes/src/vfs/content.mk | 6 ++-- repos/os/src/lib/vfs/ram_file_system.h | 12 +++++--- repos/os/src/server/ram_fs/file.h | 9 +++--- 5 files changed, 63 insertions(+), 14 deletions(-) create mode 100644 repos/os/include/ram_fs/param.h diff --git a/repos/os/include/ram_fs/chunk.h b/repos/os/include/ram_fs/chunk.h index 22b6a1f3ed..f0ebbd4f6f 100644 --- a/repos/os/include/ram_fs/chunk.h +++ b/repos/os/include/ram_fs/chunk.h @@ -28,8 +28,8 @@ namespace File_system { class Chunk_base; - template class Chunk; - template class Chunk_index; + template class Chunk; + template class Chunk_index; } @@ -97,7 +97,7 @@ class File_system::Chunk_base : Noncopyable /** * Chunk of bytes used as leaf in hierarchy of chunk indices */ -template +template class File_system::Chunk : public Chunk_base { private: @@ -177,7 +177,7 @@ class File_system::Chunk : public Chunk_base }; -template +template class File_system::Chunk_index : public Chunk_base { public: diff --git a/repos/os/include/ram_fs/param.h b/repos/os/include/ram_fs/param.h new file mode 100644 index 0000000000..288fec135d --- /dev/null +++ b/repos/os/include/ram_fs/param.h @@ -0,0 +1,42 @@ +/* + * \brief Dimensioning of the hierarchic 'Chunk' structure for the RAM fs + * \author Norman Feske + * \date 2019-03-17 + */ + +/* + * Copyright (C) 2019 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. + */ + +#ifndef _INCLUDE__RAM_FS__PARAM_H_ +#define _INCLUDE__RAM_FS__PARAM_H_ + +/* Genode includes */ +#include + +namespace Ram_fs +{ + using Genode::size_t; + + /* + * Let number of level-0 and level-1 entries depend on the machine-word + * size to allow the use of more than 2 GiB on 64-bit machines. + * + * 32 bit: 64*64*128*4096 = 2 GiB + * 64 bit: 128*128*128*4096 = 8 GiB + */ + static constexpr size_t num_level_0_entries() + { + return sizeof(size_t) == 8 ? 128 : 64; + } + + static constexpr size_t num_level_1_entries() { return num_level_0_entries(); } + static constexpr size_t num_level_2_entries() { return 128; } + static constexpr size_t num_level_3_entries() { return 4096; } +} + +#endif /* _INCLUDE__RAM_FS__PARAM_H_ */ + diff --git a/repos/os/recipes/src/vfs/content.mk b/repos/os/recipes/src/vfs/content.mk index ad62f2736d..9d6690aa74 100644 --- a/repos/os/recipes/src/vfs/content.mk +++ b/repos/os/recipes/src/vfs/content.mk @@ -1,8 +1,10 @@ SRC_DIR = include/file_system src/server/vfs include $(GENODE_DIR)/repos/base/recipes/src/content.inc +MIRROR_FROM_REP_DIR += $(addprefix include/ram_fs/,chunk.h param.h) \ + lib/mk/vfs.mk src/lib/vfs -content: include/ram_fs/chunk.h lib/mk/vfs.mk src/lib/vfs +content: $(MIRROR_FROM_REP_DIR) -include/vfs include/ram_fs/chunk.h lib/mk/vfs.mk src/lib/vfs: +$(MIRROR_FROM_REP_DIR): $(mirror_from_rep_dir) diff --git a/repos/os/src/lib/vfs/ram_file_system.h b/repos/os/src/lib/vfs/ram_file_system.h index 69b7ce1d17..9096958e96 100644 --- a/repos/os/src/lib/vfs/ram_file_system.h +++ b/repos/os/src/lib/vfs/ram_file_system.h @@ -15,6 +15,7 @@ #define _INCLUDE__VFS__RAM_FILE_SYSTEM_H_ #include +#include #include #include #include @@ -25,6 +26,9 @@ namespace Vfs_ram { using namespace Genode; using namespace Vfs; + using namespace Ram_fs; + using File_system::Chunk; + using File_system::Chunk_index; struct Io_handle; struct Watch_handle; @@ -235,10 +239,10 @@ class Vfs_ram::File : public Vfs_ram::Node { private: - typedef ::File_system::Chunk<4096> Chunk_level_3; - typedef ::File_system::Chunk_index<128, Chunk_level_3> Chunk_level_2; - typedef ::File_system::Chunk_index<64, Chunk_level_2> Chunk_level_1; - typedef ::File_system::Chunk_index<64, Chunk_level_1> Chunk_level_0; + typedef Chunk Chunk_level_3; + typedef Chunk_index Chunk_level_2; + typedef Chunk_index Chunk_level_1; + typedef Chunk_index Chunk_level_0; Chunk_level_0 _chunk; file_size _length = 0; diff --git a/repos/os/src/server/ram_fs/file.h b/repos/os/src/server/ram_fs/file.h index a1cfc9e820..e7df3cd4c9 100644 --- a/repos/os/src/server/ram_fs/file.h +++ b/repos/os/src/server/ram_fs/file.h @@ -20,6 +20,7 @@ /* local includes */ #include +#include #include "node.h" namespace Ram_fs @@ -36,10 +37,10 @@ class Ram_fs::File : public Node { private: - typedef Chunk<4096> Chunk_level_3; - typedef Chunk_index<128, Chunk_level_3> Chunk_level_2; - typedef Chunk_index<64, Chunk_level_2> Chunk_level_1; - typedef Chunk_index<64, Chunk_level_1> Chunk_level_0; + typedef Chunk Chunk_level_3; + typedef Chunk_index Chunk_level_2; + typedef Chunk_index Chunk_level_1; + typedef Chunk_index Chunk_level_0; Chunk_level_0 _chunk;