threaded-volserver-and-protoization-update-20040922
authorDerrick Brashear <shadow@dementia.org>
Thu, 23 Sep 2004 04:55:52 +0000 (04:55 +0000)
committerDerrick Brashear <shadow@dementia.org>
Thu, 23 Sep 2004 04:55:52 +0000 (04:55 +0000)
fix a deadlock between GCTrans and DeleteTrans
more protoization

src/volser/volmain.c
src/volser/volprocs.c
src/volser/voltrans.c

index ea53c5a..28d701e 100644 (file)
@@ -100,7 +100,7 @@ int Testing = 0;            /* for ListViceInodes */
                       }
 
 
-static
+static afs_int32
 MyBeforeProc(struct rx_call *acall)
 {
     VTRANS_LOCK;
@@ -109,7 +109,7 @@ MyBeforeProc(struct rx_call *acall)
     return 0;
 }
 
-static
+static afs_int32
 MyAfterProc(struct rx_call *acall, afs_int32 code)
 {
     VTRANS_LOCK;
@@ -121,7 +121,7 @@ MyAfterProc(struct rx_call *acall, afs_int32 code)
 /* Called every GCWAKEUP seconds to try to unlock all our partitions,
  * if we're idle and there are no active transactions 
  */
-static
+static void
 TryUnlock()
 {
     /* if there are no running calls, and there are no active transactions, then
@@ -135,7 +135,7 @@ TryUnlock()
 }
 
 /* background daemon for timing out transactions */
-static
+static void
 BKGLoop()
 {
     struct timeval tv;
@@ -161,7 +161,7 @@ BKGLoop()
 
 /* Background daemon for sleeping so the volserver does not become I/O bound */
 afs_int32 TTsleep, TTrun;
-static
+static void
 BKGSleep()
 {
     struct volser_trans *tt;
@@ -194,9 +194,7 @@ BKGSleep()
 
 #ifndef AFS_NT40_ENV
 int
-volser_syscall(a3, a4, a5)
-     afs_uint32 a3, a4;
-     void *a5;
+volser_syscall(afs_uint32 a3, afs_uint32 a4, void *a5)
 {
     afs_uint32 rcode;
     void (*old) ();
@@ -218,16 +216,14 @@ volser_syscall(a3, a4, a5)
 
 /* check whether caller is authorized to manage RX statistics */
 int
-vol_rxstat_userok(call)
-     struct rx_call *call;
+vol_rxstat_userok(struct rx_call *call)
 {
     return afsconf_SuperUser(tdir, call, NULL);
 }
 
 #include "AFS_component_version_number.c"
-main(argc, argv)
-     int argc;
-     char **argv;
+int 
+main(int argc, char **argv)
 {
     register afs_int32 code;
     struct rx_securityClass *(securityObjects[3]);
index a4276ae..95796aa 100644 (file)
@@ -425,7 +425,7 @@ VolCreateVolume(struct rx_call *acid, afs_int32 apart, char *aname,
     if (error) {
        Log("1 Volser: CreateVolume: Unable to create the volume; aborted, error code %u\n", error);
        LogError(error);
-       DeleteTrans(tt);
+       DeleteTrans(tt, 1);
        return EIO;
     }
     V_uniquifier(vp) = 1;
@@ -442,7 +442,7 @@ VolCreateVolume(struct rx_call *acid, afs_int32 apart, char *aname,
     if (error) {
        Log("1 Volser: create UpdateVolume failed, code %d\n", error);
        LogError(error);
-       DeleteTrans(tt);
+       DeleteTrans(tt, 1);
        VDetachVolume(&junk, vp);       /* rather return the real error code */
        return error;
     }
@@ -677,7 +677,7 @@ VolClone(struct rx_call *acid, afs_int32 atrans, afs_int32 purgeId,
        error = VOLSERTRELE_ERROR;
        goto fail;
     }
-    DeleteTrans(ttc);
+    DeleteTrans(ttc, 1);
     return 0;
 
   fail:
@@ -690,7 +690,7 @@ VolClone(struct rx_call *acid, afs_int32 atrans, afs_int32 purgeId,
        TRELE(tt);
     }
     if (ttc)
-       DeleteTrans(ttc);
+       DeleteTrans(ttc, 1);
     return error;
 }
 
@@ -840,7 +840,7 @@ VolReClone(struct rx_call *acid, afs_int32 atrans, afs_int32 cloneId)
        goto fail;
     }
 
-    DeleteTrans(ttc);
+    DeleteTrans(ttc, 1);
 
     {
        struct DiskPartition *tpartp = originalvp->partition;
@@ -856,7 +856,7 @@ VolReClone(struct rx_call *acid, afs_int32 atrans, afs_int32 cloneId)
        TRELE(tt);
     }
     if (ttc)
-       DeleteTrans(ttc);
+       DeleteTrans(ttc, 1);
     return error;
 }
 
@@ -913,7 +913,7 @@ VolTransCreate(struct rx_call *acid, afs_int32 volume, afs_int32 partition,
        /* give up */
        if (tv)
            VDetachVolume(&code, tv);
-       DeleteTrans(tt);
+       DeleteTrans(tt, 1);
        return error;
     }
     tt->volume = tv;
@@ -1387,7 +1387,7 @@ VolEndTrans(struct rx_call *acid, afs_int32 destTrans, afs_int32 *rcode)
        return ENOENT;
     }
     *rcode = tt->returnCode;
-    DeleteTrans(tt);           /* this does an implicit TRELE */
+    DeleteTrans(tt, 1);                /* this does an implicit TRELE */
 
     return 0;
 }
@@ -1868,7 +1868,7 @@ VolListOneVolume(struct rx_call *acid, afs_int32 partid, afs_int32
        tv = (Volume *) 0;
     }
     if (ttc) {
-       DeleteTrans(ttc);
+       DeleteTrans(ttc, 1);
        ttc = (struct volser_trans *)0;
     }
 
@@ -2099,7 +2099,7 @@ VolXListOneVolume(struct rx_call *a_rxCidP, afs_int32 a_partID,
        tv = (Volume *) 0;
     }
     if (ttc) {
-       DeleteTrans(ttc);
+       DeleteTrans(ttc, 1);
        ttc = (struct volser_trans *)0;
     }
 
@@ -2241,7 +2241,7 @@ VolListVolumes(struct rx_call *acid, afs_int32 partid, afs_int32 flags,
 
       drop:
        if (ttc) {
-           DeleteTrans(ttc);
+           DeleteTrans(ttc, 1);
            ttc = (struct volser_trans *)0;
        }
        pntr++;
@@ -2258,7 +2258,7 @@ VolListVolumes(struct rx_call *acid, afs_int32 partid, afs_int32 flags,
                    tv = (Volume *) 0;
                }
                if (ttc) {
-                   DeleteTrans(ttc);
+                   DeleteTrans(ttc, 1);
                    ttc = (struct volser_trans *)0;
                }
                closedir(dirp);
@@ -2276,7 +2276,7 @@ VolListVolumes(struct rx_call *acid, afs_int32 partid, afs_int32 flags,
            tv = (Volume *) 0;
        }
        if (ttc) {
-           DeleteTrans(ttc);
+           DeleteTrans(ttc, 1);
            ttc = (struct volser_trans *)0;
        }
        GetNextVol(dirp, volname, &volid);
@@ -2284,7 +2284,7 @@ VolListVolumes(struct rx_call *acid, afs_int32 partid, afs_int32 flags,
     }
     closedir(dirp);
     if (ttc)
-       DeleteTrans(ttc);
+       DeleteTrans(ttc, 1);
 
     return 0;
 }
@@ -2495,7 +2495,7 @@ VolXListVolumes(struct rx_call *a_rxCidP, afs_int32 a_partID,
         * Drop the transaction we have for this volume.
         */
        if (ttc) {
-           DeleteTrans(ttc);
+           DeleteTrans(ttc, 1);
            ttc = (struct volser_trans *)0;
        }
 
@@ -2522,7 +2522,7 @@ VolXListVolumes(struct rx_call *a_rxCidP, afs_int32 a_partID,
                    tv = (Volume *) 0;
                }
                if (ttc) {
-                   DeleteTrans(ttc);
+                   DeleteTrans(ttc, 1);
                    ttc = (struct volser_trans *)0;
                }
                closedir(dirp);
@@ -2550,7 +2550,7 @@ VolXListVolumes(struct rx_call *a_rxCidP, afs_int32 a_partID,
            tv = (Volume *) 0;
        }
        if (ttc) {
-           DeleteTrans(ttc);
+           DeleteTrans(ttc, 1);
            ttc = (struct volser_trans *)0;
        }
        GetNextVol(dirp, volname, &volid);
@@ -2562,7 +2562,7 @@ VolXListVolumes(struct rx_call *a_rxCidP, afs_int32 a_partID,
      */
     closedir(dirp);
     if (ttc)
-       DeleteTrans(ttc);
+       DeleteTrans(ttc, 1);
     return (0);
 
 }                              /*SAFSVolXListVolumes */
index 6dd744c..8a137bc 100644 (file)
@@ -79,9 +79,7 @@ static afs_int32 transCounter = 1;
 
 /* create a new transaction, returning ptr to same with high ref count */
 struct volser_trans *
-NewTrans(avol, apart)
-     afs_int32 avol;
-     afs_int32 apart;
+NewTrans(afs_int32 avol, afs_int32 apart)
 {
     /* set volid, next, partition */
     register struct volser_trans *tt;
@@ -117,8 +115,7 @@ NewTrans(avol, apart)
 
 /* find a trans, again returning with high ref count */
 struct volser_trans *
-FindTrans(atrans)
-     register afs_int32 atrans;
+FindTrans(register afs_int32 atrans)
 {
     register struct volser_trans *tt;
     VTRANS_LOCK;
@@ -135,8 +132,8 @@ FindTrans(atrans)
 }
 
 /* delete transaction if refcount == 1, otherwise queue delete for later.  Does implicit TRELE */
-DeleteTrans(atrans)
-     register struct volser_trans *atrans;
+afs_int32 
+DeleteTrans(register struct volser_trans *atrans, afs_int32 lock)
 {
     register struct volser_trans *tt, **lt;
     afs_int32 error;
@@ -149,7 +146,7 @@ DeleteTrans(atrans)
     }
 
     /* otherwise we zap it ourselves */
-    VTRANS_LOCK;
+    if (lock) VTRANS_LOCK;
     lt = &allTrans;
     for (tt = *lt; tt; lt = &tt->next, tt = *lt) {
        if (tt == atrans) {
@@ -158,19 +155,19 @@ DeleteTrans(atrans)
            tt->volume = NULL;
            *lt = tt->next;
            free(tt);
-           VTRANS_UNLOCK;
+           if (lock) VTRANS_UNLOCK;
            return 0;
        }
     }
-    VTRANS_UNLOCK;
+    if (lock) VTRANS_UNLOCK;
     return -1;                 /* failed to find the transaction in the generic list */
 }
 
 /* THOLD is a macro defined in volser.h */
 
 /* put a transaction back */
-TRELE(at)
-     register struct volser_trans *at;
+afs_int32 
+TRELE(register struct volser_trans *at)
 {
     if (at->refCount == 0) {
        Log("TRELE: bad refcount\n");
@@ -179,7 +176,7 @@ TRELE(at)
 
     at->time = FT_ApproxTime();        /* we're still using it */
     if (at->refCount == 1 && (at->tflags & TTDeleted)) {
-       DeleteTrans(at);
+       DeleteTrans(at, 1);
        return 0;
     }
     /* otherwise simply drop refcount */
@@ -191,6 +188,7 @@ TRELE(at)
 #define        OLDTRANSTIME        600 /* seconds */
 #define        OLDTRANSWARN        300 /* seconds */
 static int GCDeletes = 0;
+afs_int32
 GCTrans()
 {
     register struct volser_trans *tt, *nt;
@@ -212,7 +210,7 @@ GCTrans()
        if (tt->time + OLDTRANSTIME < now) {
            Log("trans %u on volume %u has timed out\n", tt->tid, tt->volid);
            tt->refCount++;     /* we're using it now */
-           DeleteTrans(tt);    /* drops refCount or deletes it */
+           DeleteTrans(tt, 0); /* drops refCount or deletes it */
            GCDeletes++;
        }
     }