Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/raidframe convert RF_CommonLogData_s/RF_ReconMap_s m...



details:   https://anonhg.NetBSD.org/src/rev/a2ddaa15c7f6
branches:  trunk
changeset: 764874:a2ddaa15c7f6
user:      mrg <mrg%NetBSD.org@localhost>
date:      Tue May 10 07:04:17 2011 +0000

description:
convert RF_CommonLogData_s/RF_ReconMap_s mutex to a kmutex/cv.

diffstat:

 sys/dev/raidframe/rf_paritylog.c     |  11 ++++++-----
 sys/dev/raidframe/rf_paritylog.h     |   6 +++---
 sys/dev/raidframe/rf_paritylogging.c |   9 +++++----
 sys/dev/raidframe/rf_reconmap.c      |  24 ++++++++++++++----------
 sys/dev/raidframe/rf_reconmap.h      |   5 +++--
 sys/dev/raidframe/rf_states.c        |   9 ++++-----
 6 files changed, 35 insertions(+), 29 deletions(-)

diffs (214 lines):

diff -r 8031c821ce93 -r a2ddaa15c7f6 sys/dev/raidframe/rf_paritylog.c
--- a/sys/dev/raidframe/rf_paritylog.c  Tue May 10 06:58:17 2011 +0000
+++ b/sys/dev/raidframe/rf_paritylog.c  Tue May 10 07:04:17 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_paritylog.c,v 1.13 2007/03/04 06:02:38 christos Exp $       */
+/*     $NetBSD: rf_paritylog.c,v 1.14 2011/05/10 07:04:17 mrg Exp $    */
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_paritylog.c,v 1.13 2007/03/04 06:02:38 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_paritylog.c,v 1.14 2011/05/10 07:04:17 mrg Exp $");
 
 #include "rf_archs.h"
 
@@ -75,7 +75,8 @@
        } else {
                RF_UNLOCK_MUTEX(raidPtr->parityLogDiskQueue.mutex);
                RF_Malloc(common, sizeof(RF_CommonLogData_t), (RF_CommonLogData_t *));
-               rf_mutex_init(&common->mutex);
+               /* destroy is in rf_paritylogging.c */
+               rf_init_mutex2(common->mutex, IPL_VM);
        }
        common->next = NULL;
        return (common);
@@ -815,13 +816,13 @@
                        /* Processed this item completely, decrement count of
                         * items to be processed. */
                        RF_ASSERT(item->diskAddress.numSector == 0);
-                       RF_LOCK_MUTEX(item->common->mutex);
+                       rf_lock_mutex2(item->common->mutex);
                        item->common->cnt--;
                        if (item->common->cnt == 0)
                                itemDone = RF_TRUE;
                        else
                                itemDone = RF_FALSE;
-                       RF_UNLOCK_MUTEX(item->common->mutex);
+                       rf_unlock_mutex2(item->common->mutex);
                        if (itemDone) {
                                /* Finished processing all log data for this
                                 * IO Return structs to free list and invoke
diff -r 8031c821ce93 -r a2ddaa15c7f6 sys/dev/raidframe/rf_paritylog.h
--- a/sys/dev/raidframe/rf_paritylog.h  Tue May 10 06:58:17 2011 +0000
+++ b/sys/dev/raidframe/rf_paritylog.h  Tue May 10 07:04:17 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_paritylog.h,v 1.5 2007/03/04 06:02:38 christos Exp $        */
+/*     $NetBSD: rf_paritylog.h,v 1.6 2011/05/10 07:04:17 mrg Exp $     */
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -46,8 +46,8 @@
 }       RF_ParityRecordType_t;
 
 struct RF_CommonLogData_s {
-       RF_DECLARE_MUTEX(mutex) /* protects cnt */
-       int     cnt;            /* when 0, time to call wakeFunc */
+       rf_declare_mutex2(mutex);       /* protects cnt */
+       int     cnt;                    /* when 0, time to call wakeFunc */
        RF_Raid_t *raidPtr;
 /*   int                    (*wakeFunc)(struct buf *); */
        int     (*wakeFunc) (RF_DagNode_t * node, int status);
diff -r 8031c821ce93 -r a2ddaa15c7f6 sys/dev/raidframe/rf_paritylogging.c
--- a/sys/dev/raidframe/rf_paritylogging.c      Tue May 10 06:58:17 2011 +0000
+++ b/sys/dev/raidframe/rf_paritylogging.c      Tue May 10 07:04:17 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_paritylogging.c,v 1.28 2007/03/04 06:02:39 christos Exp $   */
+/*     $NetBSD: rf_paritylogging.c,v 1.29 2011/05/10 07:04:17 mrg Exp $        */
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_paritylogging.c,v 1.28 2007/03/04 06:02:39 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_paritylogging.c,v 1.29 2011/05/10 07:04:17 mrg Exp $");
 
 #include "rf_archs.h"
 
@@ -637,8 +637,9 @@
        }
        while (raidPtr->parityLogDiskQueue.freeCommonList) {
                c = raidPtr->parityLogDiskQueue.freeCommonList;
-               raidPtr->parityLogDiskQueue.freeCommonList =
-                       raidPtr->parityLogDiskQueue.freeCommonList->next;
+               raidPtr->parityLogDiskQueue.freeCommonList = c->next;
+               /* init is in rf_paritylog.c */
+               rf_destroy_mutex2(c->mutex);
                RF_Free(c, sizeof(RF_CommonLogData_t));
        }
 }
diff -r 8031c821ce93 -r a2ddaa15c7f6 sys/dev/raidframe/rf_reconmap.c
--- a/sys/dev/raidframe/rf_reconmap.c   Tue May 10 06:58:17 2011 +0000
+++ b/sys/dev/raidframe/rf_reconmap.c   Tue May 10 07:04:17 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_reconmap.c,v 1.31 2008/05/19 19:49:54 oster Exp $   */
+/*     $NetBSD: rf_reconmap.c,v 1.32 2011/05/10 07:04:17 mrg Exp $     */
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -34,7 +34,7 @@
  *************************************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_reconmap.c,v 1.31 2008/05/19 19:49:54 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_reconmap.c,v 1.32 2011/05/10 07:04:17 mrg Exp $");
 
 #include "rf_raid.h"
 #include <sys/time.h>
@@ -109,7 +109,9 @@
            0, 0, "raidreconpl", NULL, IPL_BIO);
        pool_prime(&p->elem_pool, RF_NUM_RECON_POOL_ELEM);
 
-       rf_mutex_init(&p->mutex);
+       rf_init_mutex2(p->mutex, IPL_VM);
+       rf_init_cond2(p->cv, "reconupdate");
+
        return (p);
 }
 
@@ -139,13 +141,12 @@
        RF_SectorNum_t i, first_in_RU, last_in_RU, ru;
        RF_ReconMapListElem_t *p, *pt;
 
-       RF_LOCK_MUTEX(mapPtr->mutex);
+       rf_lock_mutex2(mapPtr->mutex);
        while(mapPtr->lock) {
-               ltsleep(&mapPtr->lock, PRIBIO, "reconupdate", 0, 
-                       &mapPtr->mutex);
+               rf_wait_cond2(mapPtr->cv, mapPtr->mutex);
        }
        mapPtr->lock = 1;
-       RF_UNLOCK_MUTEX(mapPtr->mutex);
+       rf_unlock_mutex2(mapPtr->mutex);
        RF_ASSERT(startSector >= 0 && stopSector < mapPtr->sectorsInDisk &&
                  stopSector >= startSector);
 
@@ -211,10 +212,10 @@
                }
                startSector = RF_MIN(stopSector, last_in_RU) + 1;
        }
-       RF_LOCK_MUTEX(mapPtr->mutex);    
+       rf_lock_mutex2(mapPtr->mutex);    
        mapPtr->lock = 0;
-       wakeup(&mapPtr->lock);
-       RF_UNLOCK_MUTEX(mapPtr->mutex);
+       rf_broadcast_cond2(mapPtr->cv);
+       rf_unlock_mutex2(mapPtr->mutex);
 }
 
 
@@ -331,6 +332,9 @@
                }
        }
 
+       rf_destroy_mutex2(mapPtr->mutex);
+       rf_destroy_cond2(mapPtr->cv);
+
        pool_destroy(&mapPtr->elem_pool);
        RF_Free(mapPtr->status, mapPtr->status_size *
                sizeof(RF_ReconMapListElem_t *));
diff -r 8031c821ce93 -r a2ddaa15c7f6 sys/dev/raidframe/rf_reconmap.h
--- a/sys/dev/raidframe/rf_reconmap.h   Tue May 10 06:58:17 2011 +0000
+++ b/sys/dev/raidframe/rf_reconmap.h   Tue May 10 07:04:17 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_reconmap.h,v 1.11 2008/05/19 19:49:54 oster Exp $   */
+/*     $NetBSD: rf_reconmap.h,v 1.12 2011/05/10 07:04:17 mrg Exp $     */
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -63,7 +63,8 @@
                                                 * stripes in array */
        RF_ReconMapListElem_t **status; /* array of ptrs to list elements */
        struct pool elem_pool;          /* pool of RF_ReconMapListElem_t's */
-       RF_DECLARE_MUTEX(mutex)
+       rf_declare_mutex2(mutex);
+       rf_declare_cond2(cv);
        int lock;                       /* 1 if someone has the recon map
                                           locked, 0 otherwise */
 };
diff -r 8031c821ce93 -r a2ddaa15c7f6 sys/dev/raidframe/rf_states.c
--- a/sys/dev/raidframe/rf_states.c     Tue May 10 06:58:17 2011 +0000
+++ b/sys/dev/raidframe/rf_states.c     Tue May 10 07:04:17 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_states.c,v 1.47 2011/05/05 07:12:58 mrg Exp $       */
+/*     $NetBSD: rf_states.c,v 1.48 2011/05/10 07:04:17 mrg Exp $       */
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_states.c,v 1.47 2011/05/05 07:12:58 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_states.c,v 1.48 2011/05/10 07:04:17 mrg Exp $");
 
 #include <sys/errno.h>
 
@@ -217,10 +217,9 @@
        callbackArg.p = desc->callbackArg;
 
        /*
-        * If this is not an async request, wake up the caller
+        * We don't support non-async IO.
         */
-       if (desc->async_flag == 0)
-               wakeup(desc->bp);
+       KASSERT(desc->async_flag);
 
        /*
         * That's all the IO for this one... unbusy the 'disk'.



Home | Main Index | Thread Index | Old Index