Delay calling afs_ProcessFS() and upgrading the shared vcache lock
authorNickolai Zeldovich <kolya@mit.edu>
Wed, 5 Jun 2002 16:56:09 +0000 (16:56 +0000)
committerNickolai Zeldovich <kolya@mit.edu>
Wed, 5 Jun 2002 16:56:09 +0000 (16:56 +0000)
until after the dcache locks have been released, to obey lock ordering
and avoid deadlock.

src/afs/afs_segments.c

index 4c1f958..ce95a08 100644 (file)
@@ -311,6 +311,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_size_t base, bytes;
        afs_uint32 nchunks;
        int nomore;
@@ -530,26 +532,13 @@ restart:
                      * one which has the writing bit turned on. */
                }
                if (!code) {
-                   struct AFSFetchStatus OutStatus;
                    struct AFSVolSync tsync;
                    RX_AFS_GUNLOCK();
                    code = EndRXAFS_StoreData(tcall, &OutStatus, &tsync);
                    RX_AFS_GLOCK();
                    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) {
                    RX_AFS_GUNLOCK();
@@ -593,6 +582,19 @@ restart:
                dclist[i] = NULL;
            }
 
+           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] ) {