[rtems commit] libblock: PR2040: Fix recycle destination update

Sebastian Huber sebh at rtems.org
Mon Apr 16 09:04:45 UTC 2012


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Mar 30 11:00:37 2012 +0200

libblock: PR2040: Fix recycle destination update

Check the availablity of a recycle destination segment only when it is
necessary to avoid missing resycle source segment erasures.

---

 cpukit/libblock/src/flashdisk.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/cpukit/libblock/src/flashdisk.c b/cpukit/libblock/src/flashdisk.c
index 418c663..b778ab5 100644
--- a/cpukit/libblock/src/flashdisk.c
+++ b/cpukit/libblock/src/flashdisk.c
@@ -1261,12 +1261,18 @@ rtems_fdisk_recycle_segment (rtems_flashdisk*         fd,
 
   for (spage = 0; spage < ssc->pages; spage++)
   {
-    uint32_t               dst_pages;
     rtems_fdisk_page_desc* spd = &ssc->page_descriptors[spage];
 
+    if (!dsc && ssc->pages_active > 0)
+    {
+      rtems_fdisk_error ("recycle: no available dst segment");
+      return EIO;
+    }
+
     if (rtems_fdisk_page_desc_flags_set (spd, RTEMS_FDISK_PAGE_ACTIVE) &&
         !rtems_fdisk_page_desc_flags_set (spd, RTEMS_FDISK_PAGE_USED))
     {
+      uint32_t               dst_pages;
       rtems_fdisk_page_desc* dpd;
       uint32_t               dpage;
 
@@ -1352,14 +1358,7 @@ rtems_fdisk_recycle_segment (rtems_flashdisk*         fd,
        */
       dst_pages = rtems_fdisk_seg_pages_available (dsc);
       if (dst_pages == 0)
-      {
         dsc = rtems_fdisk_seg_most_available (&fd->available);
-        if (!dsc)
-        {
-          rtems_fdisk_error ("recycle: no available dst segment");
-          return EIO;
-        }
-      }
 
       (*pages)--;
     }




More information about the vc mailing list