[PATCH] CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK was undocumented and not error checked

Joel Sherrill joel.sherrill at oarcorp.com
Tue Oct 20 19:47:57 UTC 2015


closes #2431.
---
 cpukit/sapi/include/confdefs.h       |   14 ++++++++
 doc/user/conf.t                      |   55 ++++++++++++++++++++++++++++++++++
 testsuites/psxtests/psximfs02/init.c |    4 +-
 3 files changed, 71 insertions(+), 2 deletions(-)

diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h
index 66c8c7e..db2bedd 100644
--- a/cpukit/sapi/include/confdefs.h
+++ b/cpukit/sapi/include/confdefs.h
@@ -3823,5 +3823,19 @@ const rtems_libio_helper rtems_fs_init_helper =
   #endif
 #endif
 
+/*
+ * IMFS block size for in memory files (memfiles) must be a power of
+ * two between 16 and 512 inclusive.
+ */
+#if ((CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 16) && \
+     (CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 32) && \
+     (CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 64) && \
+     (CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 128) && \
+     (CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 256) && \
+     (CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 512))
+  #error "IMFS Memfile block size must be a power of 2 between 16 and 512"
+#endif
+
+
 #endif
 /* end of include file */
diff --git a/doc/user/conf.t b/doc/user/conf.t
index ec9b1f8..9905454 100644
--- a/doc/user/conf.t
+++ b/doc/user/conf.t
@@ -2749,6 +2749,61 @@ options will be defined as well
 @end itemize
 
 @c
+ at c === CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK ===
+ at c
+ at subsection Specify Block Size for IMFS
+
+ at findex CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK
+
+ at table @b
+ at item CONSTANT:
+ at code{CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK}
+
+ at item DATA TYPE:
+Boolean feature macro.
+
+ at item RANGE:
+Valid values for this configuration parameter are are a power of two (2)
+between 16 and 512 inclusively.  In other words, valid values are 16,
+32, 64, 128, 257,and 512.
+
+ at item DEFAULT VALUE:
+The default IMFS block size is 128 bytes.
+
+ at end table
+
+ at subheading DESCRIPTION:
+This configuration parameter specifies the block size for in-memory files
+managed by the IMFS. The configured block size has two impacts. The first
+is the average amount of unused memory in the last block of each file. For
+example, when the block size is 512, on average one-half of the last block
+of each file will remain unused and the memory is wasted. In contrast,
+when the block size is 16, the average unused memory per file is only
+8 bytes. However, it requires more allocations for the same size file
+and thus more overhead per block for the dynamic memory management.
+
+Second, the block size has an impact on the maximum size file that can
+be stored in the IMFS. With smaller block size, the maximum file size
+is correspondingly smaller. The following shows the maximum file size
+possible based on the configured block size:
+
+ at itemize @bullet
+ at item when the block size is 16 bytes, the maximum file size is 1,328
+bytes.
+ at item when the block size is 32 bytes, the maximum file size is 18,656
+bytes.
+ at item when the block size is 64 bytes, the maximum file size is 279,488
+bytes.
+ at item when the block size is 128 bytes, the maximum file size is
+4,329,344 bytes.
+ at item when the block size is 256 bytes, the maximum file size is
+68,173,568 bytes.
+ at item when the block size is 512 bytes, the maximum file size is
+1,082,195,456 bytes.
+ at end itemize
+
+
+ at c
 @c === CONFIGURE_IMFS_DISABLE_CHOWN ===
 @c
 @subsection Disable Change Owner Support of Root IMFS
diff --git a/testsuites/psxtests/psximfs02/init.c b/testsuites/psxtests/psximfs02/init.c
index d372a6f..2a55d08 100644
--- a/testsuites/psxtests/psximfs02/init.c
+++ b/testsuites/psxtests/psximfs02/init.c
@@ -1,5 +1,5 @@
 /*
- *  COPYRIGHT (c) 1989-2014.
+ *  COPYRIGHT (c) 1989-2015.
  *  On-Line Applications Research Corporation (OAR).
  *
  *  The license and distribution terms for this file may be
@@ -211,7 +211,7 @@ rtems_task Init(
 #define CONFIGURE_FILESYSTEM_IMFS
 
 #define CONFIGURE_MAXIMUM_TASKS                  1
-#define CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK   15
+#define CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK   16
 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
 
-- 
1.7.1



More information about the devel mailing list