[rtems commit] PR2040: libblock: Flash disk starvations statistic

Sebastian Huber sebh at rtems.org
Wed Mar 14 10:48:58 UTC 2012


Module:    rtems
Branch:    4.10
Commit:    941d470db4835c96b2ee7039c4ca17ba6fec52a4
Changeset: http://git.rtems.org/rtems/commit/?id=941d470db4835c96b2ee7039c4ca17ba6fec52a4

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Mar 14 10:45:36 2012 +0100

PR2040: libblock: Flash disk starvations statistic

---

 cpukit/libblock/src/flashdisk.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/cpukit/libblock/src/flashdisk.c b/cpukit/libblock/src/flashdisk.c
index 107f8b4..254528e 100644
--- a/cpukit/libblock/src/flashdisk.c
+++ b/cpukit/libblock/src/flashdisk.c
@@ -196,6 +196,8 @@ typedef struct rtems_flashdisk
   uint8_t* copy_buffer;                    /**< Copy buf used during compacting */
 
   uint32_t info_level;                     /**< The info trace level. */
+
+  uint32_t starvations;                    /**< Erased blocks starvations counter. */
 } rtems_flashdisk;
 
 /**
@@ -276,9 +278,14 @@ rtems_fdisk_printf (const rtems_flashdisk* fd, const char *format, ...)
 }
 
 static bool
-rtems_fdisk_is_erased_blocks_starvation (const rtems_flashdisk* fd)
+rtems_fdisk_is_erased_blocks_starvation (rtems_flashdisk* fd)
 {
-  return fd->erased_blocks < fd->unavail_blocks;
+  bool starvation = fd->erased_blocks < fd->unavail_blocks;
+
+  if (starvation)
+    fd->starvations++;
+
+  return starvation;
 }
 
 /**
@@ -2218,6 +2225,7 @@ rtems_fdisk_print_status (rtems_flashdisk* fd)
 
   rtems_fdisk_printf (fd, "Block count\t%d", fd->block_count);
   rtems_fdisk_printf (fd, "Unavail blocks\t%d", fd->unavail_blocks);
+  rtems_fdisk_printf (fd, "Starvations\t%d", fd->starvations);
   count = rtems_fdisk_segment_count_queue (&fd->available);
   total = count;
   rtems_fdisk_printf (fd, "Available queue\t%ld (%ld)",




More information about the vc mailing list