[rtems commit] libblock: Fix read-ahead trigger and next update

Sebastian Huber sebh at rtems.org
Mon Jul 2 14:13:15 UTC 2012


Module:    rtems
Branch:    master
Commit:    f29d969a72622c8d30eba7bae9a37d128fe9b5a4
Changeset: http://git.rtems.org/rtems/commit/?id=f29d969a72622c8d30eba7bae9a37d128fe9b5a4

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Jul  2 16:06:10 2012 +0200

libblock: Fix read-ahead trigger and next update

---

 cpukit/libblock/src/bdbuf.c             |    4 +-
 testsuites/libtests/block13/block13.scn |   12 +++--
 testsuites/libtests/block13/init.c      |   80 +++++++++++++++++-------------
 3 files changed, 54 insertions(+), 42 deletions(-)

diff --git a/cpukit/libblock/src/bdbuf.c b/cpukit/libblock/src/bdbuf.c
index 034e5a8..77d8555 100644
--- a/cpukit/libblock/src/bdbuf.c
+++ b/cpukit/libblock/src/bdbuf.c
@@ -3027,8 +3027,8 @@ rtems_bdbuf_read_ahead_task (rtems_task_argument arg)
           if (transfer_count >= max_transfer_count)
           {
             transfer_count = max_transfer_count;
-            dd->read_ahead.trigger += max_transfer_count / 2 + 1;
-            dd->read_ahead.next += max_transfer_count;
+            dd->read_ahead.trigger = block + (transfer_count + 1) / 2;
+            dd->read_ahead.next = block + transfer_count;
           }
           else
           {
diff --git a/testsuites/libtests/block13/block13.scn b/testsuites/libtests/block13/block13.scn
index 8cce718..d929eb0 100644
--- a/testsuites/libtests/block13/block13.scn
+++ b/testsuites/libtests/block13/block13.scn
@@ -1,11 +1,13 @@
 *** TEST BLOCK 13 ***
-0 2 3 4 5 6 7 8 
+0 2 3 4 5 6 7 8 9 10 
 reset
-8 
+10 
+reset
+9 
 reset
-7 
+8 
 reset
-6 7 
+7 8 
 reset
-5 6 8 
+6 7 10 
 *** END OF TEST BLOCK 13 ***
diff --git a/testsuites/libtests/block13/init.c b/testsuites/libtests/block13/init.c
index fa8ebc0..cd62e8b 100644
--- a/testsuites/libtests/block13/init.c
+++ b/testsuites/libtests/block13/init.c
@@ -24,47 +24,53 @@
 #include <rtems/blkdev.h>
 #include <rtems/bdbuf.h>
 
-#define BLOCK_COUNT 9
-#define READ_COUNT 19
+#define BLOCK_COUNT 11
+#define READ_COUNT 23
 
 static int block_access_counts [BLOCK_COUNT];
 
 #define RESET_CACHE (-1)
 
 static const int action_sequence [READ_COUNT] = {
-  0, 2, 3, 4, 5, 6, 7, 8,
+  0, 2, 3, 4, 5, 6, 7, 8, 9, 10,
   RESET_CACHE,
-  8,
+  10,
   RESET_CACHE,
-  7,
+  9,
   RESET_CACHE,
-  6, 7,
+  8,
   RESET_CACHE,
-  5, 6, 8
+  7, 8,
+  RESET_CACHE,
+  6, 7, 10
 };
 
-#define UNUSED_LINE { 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+#define UNUSED_LINE { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
 
 static const int expected_block_access_counts [READ_COUNT] [BLOCK_COUNT] = {
-   { 1, 0, 0, 0, 0, 0, 0, 0, 0 },
-   { 1, 0, 1, 0, 0, 0, 0, 0, 0 },
-   { 1, 0, 1, 1, 1, 1, 0, 0, 0 },
-   { 1, 0, 1, 1, 1, 1, 0, 0, 0 },
-   { 1, 0, 1, 1, 1, 1, 1, 1, 0 },
-   { 1, 0, 1, 1, 1, 1, 1, 1, 0 },
-   { 1, 0, 1, 1, 1, 1, 1, 1, 1 },
-   { 1, 0, 1, 1, 1, 1, 1, 1, 1 },
+   { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+   { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
+   { 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
+   { 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
+   { 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
+   { 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
+   { 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
+   { 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
+   { 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
+   { 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
+   UNUSED_LINE,
+   { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
    UNUSED_LINE,
-   { 0, 0, 0, 0, 0, 0, 0, 0, 1 },
+   { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 },
    UNUSED_LINE,
-   { 0, 0, 0, 0, 0, 0, 0, 1, 0 },
+   { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 },
    UNUSED_LINE,
-   { 0, 0, 0, 0, 0, 0, 1, 0, 0 },
-   { 0, 0, 0, 0, 0, 0, 1, 1, 1 },
+   { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 },
+   { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1 },
    UNUSED_LINE,
-   { 0, 0, 0, 0, 0, 1, 0, 0, 0 },
-   { 0, 0, 0, 0, 0, 1, 1, 1, 1 },
-   { 0, 0, 0, 0, 0, 1, 1, 1, 1 }
+   { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 },
+   { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1 },
+   { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1 }
 };
 
 #define NO_TRIGGER RTEMS_DISK_READ_AHEAD_NO_TRIGGER
@@ -72,29 +78,33 @@ static const int expected_block_access_counts [READ_COUNT] [BLOCK_COUNT] = {
 #define TRIGGER_AFTER_RESET RTEMS_DISK_READ_AHEAD_NO_TRIGGER
 
 static const rtems_blkdev_bnum trigger [READ_COUNT] = {
-  1, 3, 5, 5, 7, 7, NO_TRIGGER, NO_TRIGGER,
+  1, 3, 6, 6, 6, 9, 9, 9, NO_TRIGGER, NO_TRIGGER,
   TRIGGER_AFTER_RESET,
-  9,
+  11,
   TRIGGER_AFTER_RESET,
-  8,
+  10,
+  TRIGGER_AFTER_RESET,
+  9,
   TRIGGER_AFTER_RESET,
-  7, NO_TRIGGER,
+  8, NO_TRIGGER,
   TRIGGER_AFTER_RESET,
-  6, 8, NO_TRIGGER
+  7, 10, NO_TRIGGER
 };
 
 #define NOT_CHANGED_BY_RESET(i) (i)
 
 static const rtems_blkdev_bnum next [READ_COUNT] = {
-  2, 4, 6, 6, 8, 8, 8, 8,
-  NOT_CHANGED_BY_RESET(8),
+  2, 4, 7, 7, 7, 10, 10, 10, 10, 10,
+  NOT_CHANGED_BY_RESET(10),
+  12,
+  NOT_CHANGED_BY_RESET(12),
+  11,
+  NOT_CHANGED_BY_RESET(11),
   10,
   NOT_CHANGED_BY_RESET(10),
-  9,
+  9, 9,
   NOT_CHANGED_BY_RESET(9),
-  8, 8,
-  NOT_CHANGED_BY_RESET(8),
-  7, 9, 9
+  8, 11, 11
 };
 
 static int test_disk_ioctl(rtems_disk_device *dd, uint32_t req, void *arg)
@@ -215,7 +225,7 @@ static void Init(rtems_task_argument arg)
 #define CONFIGURE_BDBUF_BUFFER_MIN_SIZE 1
 #define CONFIGURE_BDBUF_BUFFER_MAX_SIZE 1
 #define CONFIGURE_BDBUF_CACHE_MEMORY_SIZE BLOCK_COUNT
-#define CONFIGURE_BDBUF_MAX_READ_AHEAD_BLOCKS 2
+#define CONFIGURE_BDBUF_MAX_READ_AHEAD_BLOCKS 3
 #define CONFIGURE_BDBUF_READ_AHEAD_TASK_PRIORITY 1
 
 #define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM




More information about the vc mailing list