Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/raidframe - update RF_CREATE_THREAD to handle a 'pro...



details:   https://anonhg.NetBSD.org/src/rev/de3650142bda
branches:  trunk
changeset: 480134:de3650142bda
user:      oster <oster%NetBSD.org@localhost>
date:      Wed Jan 05 02:57:28 2000 +0000

description:
- update RF_CREATE_THREAD to handle a 'process name' argument.
- fire up a new thread for parity re-writes, copybacks, and reconstructs.
  The ioctl's which trigger these actions now return immediately.
- add progress accounting for the above actions.
- minor rototillage of rf_netbsdkintf.c to deal with all of the above.

diffstat:

 sys/dev/raidframe/rf_copyback.c      |    4 +-
 sys/dev/raidframe/rf_engine.c        |    4 +-
 sys/dev/raidframe/rf_kintf.h         |    3 +-
 sys/dev/raidframe/rf_netbsdkintf.c   |  255 +++++++++++++++++++++++-----------
 sys/dev/raidframe/rf_paritylogging.c |    4 +-
 sys/dev/raidframe/rf_parityscan.c    |    5 +-
 sys/dev/raidframe/rf_raid.h          |   12 +-
 sys/dev/raidframe/rf_raidframe.h     |    6 +-
 sys/dev/raidframe/rf_reconstruct.c   |    8 +-
 sys/dev/raidframe/rf_threadstuff.h   |    6 +-
 10 files changed, 205 insertions(+), 102 deletions(-)

diffs (truncated from 599 to 300 lines):

diff -r 8fdb1d8129bb -r de3650142bda sys/dev/raidframe/rf_copyback.c
--- a/sys/dev/raidframe/rf_copyback.c   Wed Jan 05 02:54:55 2000 +0000
+++ b/sys/dev/raidframe/rf_copyback.c   Wed Jan 05 02:57:28 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_copyback.c,v 1.9 1999/08/14 03:10:03 oster Exp $    */
+/*     $NetBSD: rf_copyback.c,v 1.10 2000/01/05 02:57:28 oster Exp $   */
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -271,6 +271,8 @@
        old_pctg = (-1);
        while (1) {
                stripeAddr = desc->stripeAddr;
+               desc->raidPtr->copyback_stripes_done = stripeAddr
+                       / desc->sectPerStripe;
                if (rf_prReconSched) {
                        old_pctg = 100 * desc->stripeAddr / raidPtr->totalSectors;
                }
diff -r 8fdb1d8129bb -r de3650142bda sys/dev/raidframe/rf_engine.c
--- a/sys/dev/raidframe/rf_engine.c     Wed Jan 05 02:54:55 2000 +0000
+++ b/sys/dev/raidframe/rf_engine.c     Wed Jan 05 02:57:28 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_engine.c,v 1.5 1999/03/14 21:53:31 oster Exp $      */
+/*     $NetBSD: rf_engine.c,v 1.6 2000/01/05 02:57:29 oster Exp $      */
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -130,7 +130,7 @@
        if (rf_engineDebug) {
                printf("[%d] Creating engine thread\n", tid);
        }
-       if (RF_CREATE_THREAD(raidPtr->engine_thread, DAGExecutionThread, raidPtr)) {
+       if (RF_CREATE_THREAD(raidPtr->engine_thread, DAGExecutionThread, raidPtr,"raid")) {
                RF_ERRORMSG("RAIDFRAME: Unable to create engine thread\n");
                return (ENOMEM);
        }
diff -r 8fdb1d8129bb -r de3650142bda sys/dev/raidframe/rf_kintf.h
--- a/sys/dev/raidframe/rf_kintf.h      Wed Jan 05 02:54:55 2000 +0000
+++ b/sys/dev/raidframe/rf_kintf.h      Wed Jan 05 02:57:28 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_kintf.h,v 1.5 1999/12/12 20:52:16 oster Exp $       */
+/*     $NetBSD: rf_kintf.h,v 1.6 2000/01/05 02:57:29 oster Exp $       */
 /*
  * rf_kintf.h
  *
@@ -36,7 +36,6 @@
 
 #include "rf_types.h"
 
-void    rf_ReconKernelThread(void);
 int     rf_GetSpareTableFromDaemon(RF_SparetWait_t * req);
 
 void    raidstart(RF_Raid_t * raidPtr);
diff -r 8fdb1d8129bb -r de3650142bda sys/dev/raidframe/rf_netbsdkintf.c
--- a/sys/dev/raidframe/rf_netbsdkintf.c        Wed Jan 05 02:54:55 2000 +0000
+++ b/sys/dev/raidframe/rf_netbsdkintf.c        Wed Jan 05 02:57:28 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_netbsdkintf.c,v 1.36 1999/12/15 02:02:16 oster Exp $        */
+/*     $NetBSD: rf_netbsdkintf.c,v 1.37 2000/01/05 02:57:29 oster Exp $        */
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -179,15 +179,6 @@
 static RF_SparetWait_t *rf_sparet_resp_queue;  /* responses from
                                                 * installation process */
 
-static struct rf_recon_req *recon_queue = NULL;        /* used to communicate
-                                                * reconstruction
-                                                * requests */
-
-
-decl_simple_lock_data(, recon_queue_mutex)
-#define LOCK_RECON_Q_MUTEX() simple_lock(&recon_queue_mutex)
-#define UNLOCK_RECON_Q_MUTEX() simple_unlock(&recon_queue_mutex)
-
 /* prototypes */
 static void KernelWakeupFunc(struct buf * bp);
 static void InitBP(struct buf * bp, struct vnode *, unsigned rw_flag, 
@@ -302,6 +293,13 @@
 
 static void rf_markalldirty __P((RF_Raid_t *));
 
+void rf_ReconThread __P((struct rf_recon_req *));
+/* XXX what I want is: */
+/*void rf_ReconThread __P((RF_Raid_t *raidPtr));  */
+void rf_RewriteParityThread __P((RF_Raid_t *raidPtr));
+void rf_CopybackThread __P((RF_Raid_t *raidPtr));
+void rf_ReconstructInPlaceThread __P((struct rf_recon_req *));
+
 void
 raidattach(num)
        int     num;
@@ -334,7 +332,6 @@
        }
 
        rf_sparet_wait_queue = rf_sparet_resp_queue = NULL;
-       recon_queue = NULL;
 
        for (i = 0; i < numraid; i++)
                raidPtrs[i] = NULL;
@@ -676,7 +673,6 @@
        int retcode = 0;
        int row;
        int column;
-       int s;
        struct rf_recon_req *rrcopy, *rr;
        RF_ComponentLabel_t *component_label;
        RF_ComponentLabel_t ci_label;
@@ -718,7 +714,7 @@
        case RAIDFRAME_GET_SIZE:
        case RAIDFRAME_FAIL_DISK:
        case RAIDFRAME_COPYBACK:
-       case RAIDFRAME_CHECKRECON:
+       case RAIDFRAME_CHECK_RECON_STATUS:
        case RAIDFRAME_GET_COMPONENT_LABEL:
        case RAIDFRAME_SET_COMPONENT_LABEL:
        case RAIDFRAME_ADD_HOT_SPARE:
@@ -726,6 +722,8 @@
        case RAIDFRAME_INIT_LABELS:
        case RAIDFRAME_REBUILD_IN_PLACE:
        case RAIDFRAME_CHECK_PARITY:
+       case RAIDFRAME_CHECK_PARITYREWRITE_STATUS:
+       case RAIDFRAME_CHECK_COPYBACK_STATUS:
                if ((rs->sc_flags & RAIDF_INITED) == 0)
                        return (ENXIO);
        }
@@ -795,6 +793,12 @@
                /* allow this many simultaneous IO's to this RAID device */
                raidPtrs[unit]->openings = RAIDOUTSTANDING;
 
+               /* XXX should be moved to rf_Configure() */
+
+               raidPtrs[unit]->copyback_in_progress = 0;
+               raidPtrs[unit]->parity_rewrite_in_progress = 0;
+               raidPtrs[unit]->recon_in_progress = 0;
+               
                if (retcode == 0) {
                        retcode = raidinit(dev, raidPtrs[unit], unit);
                        rf_markalldirty( raidPtrs[unit] );
@@ -971,22 +975,17 @@
                        raidPtrs[unit]->parity_good = RF_RAID_CLEAN;
                        return(0);
                }
+               
+               if (raidPtrs[unit]->parity_rewrite_in_progress == 1) {
+                       /* Re-write is already in progress! */
+                       return(EINVAL);
+               }
 
                /* borrow the thread of the requesting process */
 
-               s = splbio();
-               retcode = rf_RewriteParity(raidPtrs[unit]);
-               splx(s);
-               /* return I/O Error if the parity rewrite fails */
-
-               if (retcode) {
-                       retcode = EIO;
-               } else {
-                       /* set the clean bit!  If we shutdown correctly,
-                        the clean bit on each component label will get
-                        set */
-                       raidPtrs[unit]->parity_good = RF_RAID_CLEAN;
-               }
+               retcode = RF_CREATE_THREAD(raidPtrs[unit]->parity_rewrite_thread,
+                                          rf_RewriteParityThread,
+                                          raidPtrs[unit],"raid_parity");
                return (retcode);
 
 
@@ -1007,6 +1006,11 @@
                        return(EINVAL);
                }
 
+               if (raidPtrs[unit]->recon_in_progress == 1) {
+                       /* a reconstruct is already in progress! */
+                       return(EINVAL);
+               }
+
                componentPtr = (RF_SingleComponent_t *) data;
                memcpy( &component, componentPtr, 
                        sizeof(RF_SingleComponent_t));
@@ -1017,10 +1021,16 @@
                    (column < 0) || (column >= raidPtrs[unit]->numCol)) {
                        return(EINVAL);
                }
-               printf("Attempting a rebuild in place\n");
-               s = splbio();
-               retcode = rf_ReconstructInPlace(raidPtrs[unit], row, column);
-               splx(s);
+
+               RF_Malloc(rrcopy, sizeof(*rrcopy), (struct rf_recon_req *));
+
+               rrcopy->raidPtr = (void *) raidPtrs[unit];
+               rrcopy->row = row;
+               rrcopy->col = column;
+
+               retcode = RF_CREATE_THREAD(raidPtrs[unit]->recon_thread,
+                                          rf_ReconstructInPlaceThread,
+                                          rrcopy,"raid_reconip");
                return(retcode);
 
        case RAIDFRAME_GET_INFO:
@@ -1126,12 +1136,9 @@
                bcopy(rr, rrcopy, sizeof(*rr));
                rrcopy->raidPtr = (void *) raidPtrs[unit];
 
-               LOCK_RECON_Q_MUTEX();
-               rrcopy->next = recon_queue;
-               recon_queue = rrcopy;
-               wakeup(&recon_queue);
-               UNLOCK_RECON_Q_MUTEX();
-
+               retcode = RF_CREATE_THREAD(raidPtrs[unit]->recon_thread,
+                                          rf_ReconThread,
+                                          rrcopy,"raid_recon");
                return (0);
 
                /* invoke a copyback operation after recon on whatever disk
@@ -1143,29 +1150,54 @@
                        return(EINVAL);
                }
 
-               /* borrow the current thread to get this done */
+               if (raidPtrs[unit]->copyback_in_progress == 1) {
+                       /* Copyback is already in progress! */
+                       return(EINVAL);
+               }
 
-               s = splbio();
-               rf_CopybackReconstructedData(raidPtrs[unit]);
-               splx(s);
-               return (0);
+               retcode = RF_CREATE_THREAD(raidPtrs[unit]->copyback_thread,
+                                          rf_CopybackThread,
+                                          raidPtrs[unit],"raid_copyback");
+               return (retcode);
 
                /* return the percentage completion of reconstruction */
-       case RAIDFRAME_CHECKRECON:
+       case RAIDFRAME_CHECK_RECON_STATUS:
                if (raidPtrs[unit]->Layout.map->faultsTolerated == 0) {
                        /* This makes no sense on a RAID 0 */
                        return(EINVAL);
                }
-
-               row = *(int *) data;
-               if (row < 0 || row >= raidPtrs[unit]->numRow)
-                       return (EINVAL);
+               row = 0; /* XXX we only consider a single row... */
                if (raidPtrs[unit]->status[row] != rf_rs_reconstructing)
                        *(int *) data = 100;
                else
                        *(int *) data = raidPtrs[unit]->reconControl[row]->percentComplete;
                return (0);
 
+       case RAIDFRAME_CHECK_PARITYREWRITE_STATUS:
+               if (raidPtrs[unit]->Layout.map->faultsTolerated == 0) {
+                       /* This makes no sense on a RAID 0 */
+                       return(EINVAL);
+               }
+               if (raidPtrs[unit]->parity_rewrite_in_progress == 1) {
+                       *(int *) data = 100 * raidPtrs[unit]->parity_rewrite_stripes_done / raidPtrs[unit]->Layout.numStripe;
+               } else {
+                       *(int *) data = 100;
+               }
+               return (0);
+
+       case RAIDFRAME_CHECK_COPYBACK_STATUS:
+               if (raidPtrs[unit]->Layout.map->faultsTolerated == 0) {
+                       /* This makes no sense on a RAID 0 */
+                       return(EINVAL);
+               }
+               if (raidPtrs[unit]->copyback_in_progress == 1) {
+                       *(int *) data = 100 * raidPtrs[unit]->copyback_stripes_done / raidPtrs[unit]->Layout.numStripe;
+               } else {
+                       *(int *) data = 100;
+               }
+               return (0);
+
+
                /* the sparetable daemon calls this to wait for the kernel to
                 * need a spare table. this ioctl does not return until a
                 * spare table is needed. XXX -- calling mpsleep here in the
@@ -1336,45 +1368,6 @@
        return (retcode);
 }
 
-/*
- * This kernel thread never exits.  It is created once, and persists
- * until the system reboots.
- */
-
-void 
-rf_ReconKernelThread()
-{
-       struct rf_recon_req *req;
-       int     s;
-
-       /* XXX not sure what spl() level we should be at here... probably



Home | Main Index | Thread Index | Old Index