libafs: Avoid duplicate afs_Analyze in bulk stat
authorAndrew Deason <adeason@sinenomine.net>
Fri, 22 Jul 2011 21:09:52 +0000 (16:09 -0500)
committerDerrick Brashear <shadow@dementix.org>
Sat, 13 Aug 2011 02:56:06 +0000 (19:56 -0700)
In afs_DoBulkStat, we can call afs_Analyze multiple times for the same
set of connection objects. Since afs_Analyze puts its reference to the
given afs_conn and rx_connection structures, calling it more than once
can cause the reference counts on those objects to be lower than they
should be.

Instead of making another afs_Analyze call, just alter the error code
inside the normal do/while afs_Analyze loop, so the 'loop' afs_Analyze
call gets the appropriate error code from the first bulk stat'd entry.

Reviewed-on: http://gerrit.openafs.org/5086
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
(cherry picked from commit ef28bc08c18e750f6100535665d5258a317a0a2b)

Change-Id: Id367ea7e8d3735d1b88475ad771bd23e3d013df2
Reviewed-on: http://gerrit.openafs.org/5236
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>

src/afs/VNOPS/afs_vnop_lookup.c

index d99f016..1b076c0 100644 (file)
@@ -565,7 +565,6 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp)
     struct volume *volp = 0;   /* volume ptr */
     struct VenusFid dotdot;
     int flagIndex = 0;         /* First file with bulk fetch flag set */
-    int inlinebulk = 0;                /* Did we use InlineBulk RPC or not? */
     struct rx_connection *rxconn;
     XSTATS_DECLS;
 #ifdef AFS_DARWIN80_ENV
@@ -820,14 +819,16 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp)
                                           &cbParm, &volSync);
                if (code == RXGEN_OPCODE) {
                    tcp->srvr->server->flags |= SNO_INLINEBULK;
-                   inlinebulk = 0;
                    code =
                        RXAFS_BulkStatus(rxconn, &fidParm, &statParm,
                                         &cbParm, &volSync);
-               } else
-                   inlinebulk = 1;
+               } else if (!code) {
+                   /* The InlineBulkStatus call itself succeeded, but we
+                    * may have failed to stat the first entry. Use the error
+                    * from the first entry for processing. */
+                   code = (&statsp[0])->errorCode;
+               }
            } else {
-               inlinebulk = 0;
                code =
                    RXAFS_BulkStatus(rxconn, &fidParm, &statParm, &cbParm,
                                     &volSync);
@@ -1075,16 +1076,6 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp)
     if (volp)
        afs_PutVolume(volp, READ_LOCK);
 
-    /* If we did the InlineBulk RPC pull out the return code */
-    if (inlinebulk && code == 0) {
-       if ((&statsp[0])->errorCode) {
-           afs_Analyze(tcp, rxconn, (&statsp[0])->errorCode, &adp->fid, areqp,
-                       AFS_STATS_FS_RPCIDX_BULKSTATUS, SHARED_LOCK, NULL);
-           code = (&statsp[0])->errorCode;
-       }
-    } else {
-       code = 0;
-    }
   done2:
     osi_FreeLargeSpace((char *)fidsp);
     osi_Free((char *)statsp, AFSCBMAX * sizeof(AFSFetchStatus));