]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE12-avoid-deadlock-while-upgrading-vcache-lock-20020605
authorNickolai Zeldovich <kolya@mit.edu>
Sat, 8 Jun 2002 01:31:42 +0000 (01:31 +0000)
committerDerrick Brashear <shadow@dementia.org>
Sat, 8 Jun 2002 01:31:42 +0000 (01:31 +0000)
Delay calling afs_ProcessFS() and upgrading the shared vcache lock
until after the dcache locks have been released, to obey lock ordering
and avoid deadlock.

(cherry picked from commit 9ab8961c3106402de12f4d0dd80c65e249293fdb)

src/afs/afs_segments.c

index f67ab9f36e5f15c8156be4c32cc2cc1e96cb299b..ea18b8e9ad6c22bba3096fd6214db40bbba04fa9 100644 (file)
@@ -284,6 +284,8 @@ afs_StoreAllSegments(avc, areq, sync)
       if (j) {
        static afs_uint32 lp1 = 10000, lp2 = 10000;
        struct AFSStoreStatus InStatus;
+       struct AFSFetchStatus OutStatus;
+       int doProcessFS = 0;
        afs_uint32 base, bytes, nchunks;
        int nomore;
        unsigned int first;
@@ -475,7 +477,6 @@ afs_StoreAllSegments(avc, areq, sync)
                      * one which has the writing bit turned on. */
                }
                if (!code) {
-                   struct AFSFetchStatus OutStatus;
                    struct AFSVolSync tsync;
 #ifdef RX_ENABLE_LOCKS
                    AFS_GUNLOCK();
@@ -486,19 +487,7 @@ afs_StoreAllSegments(avc, areq, sync)
 #endif /* RX_ENABLE_LOCKS */
                    hadd32(newDV, 1);
                    XSTATS_END_TIME;
-      
-                   /* Now copy out return params */
-                   UpgradeSToWLock(&avc->lock,28);    /* keep out others for a while */
-                   if (!code) {  /* must wait til RPC completes to be sure of this info */
-                       afs_ProcessFS(avc, &OutStatus, areq);
-                       /* Keep last (max) size of file on server to see if
-                        * we need to call afs_StoreMini to extend the file.
-                        */
-                       if (!moredata)
-                           maxStoredLength = OutStatus.Length;
-
-                   }
-                   ConvertWToSLock(&avc->lock);
+                   if (!code) doProcessFS = 1; /* Flag to run afs_ProcessFS() later on */                  
                }
                if (tcall) {
 #ifdef RX_ENABLE_LOCKS
@@ -538,6 +527,19 @@ afs_StoreAllSegments(avc, areq, sync)
                lockedPutDCache(tdc);
            }
 
+           if (doProcessFS) {
+               /* Now copy out return params */
+               UpgradeSToWLock(&avc->lock,28);    /* keep out others for a while */
+               afs_ProcessFS(avc, &OutStatus, areq);
+               /* Keep last (max) size of file on server to see if
+                * we need to call afs_StoreMini to extend the file.
+                */
+               if (!moredata)
+                   maxStoredLength = OutStatus.Length;
+               ConvertWToSLock(&avc->lock);
+               doProcessFS = 0;
+           }
+
            if (code) {
                for (j++; j<=high; j++)
                    if ( dcList[j] )