Windows: cm_FindVolumeByFID
authorJeffrey Altman <jaltman@your-file-system.com>
Fri, 15 Nov 2013 23:32:37 +0000 (17:32 -0600)
committerJeffrey Altman <jaltman@your-file-system.com>
Sat, 16 Nov 2013 00:59:06 +0000 (16:59 -0800)
cm_GetVolumeByFID() does not query the vldb if the volume group
is not known to the cache manager.   cm_FindVolumeByFID() is to
be used in cases where the volume group data must be known for the
operation to successfully complete.

Change-Id: I9bb3bd13f14dea534952495b00a3348aafd2d591
Reviewed-on: http://gerrit.openafs.org/10465
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

src/WINNT/afsd/cm_access.c
src/WINNT/afsd/cm_buf.c
src/WINNT/afsd/cm_conn.c
src/WINNT/afsd/cm_vnodeops.c
src/WINNT/afsd/cm_volume.c
src/WINNT/afsd/cm_volume.h
src/WINNT/afsrdr/user/RDRFunction.c

index ed29a48..b63632b 100644 (file)
@@ -43,7 +43,7 @@ int cm_HaveAccessRights(struct cm_scache *scp, struct cm_user *userp, cm_req_t *
     int didLock;
     long trights;
     int release = 0;    /* Used to avoid a call to cm_HoldSCache in the directory case */
-    cm_volume_t *volp = cm_GetVolumeByFID(&scp->fid);
+    cm_volume_t *volp = cm_FindVolumeByFID(&scp->fid, userp, reqp);
 
     didLock = 0;
     if (scp->fileType == CM_SCACHETYPE_DIRECTORY ||
@@ -160,7 +160,7 @@ long cm_GetAccessRights(struct cm_scache *scp, struct cm_user *userp,
     cm_fid_t tfid;
     cm_scache_t *aclScp = NULL;
     int got_cb = 0;
-    cm_volume_t * volp = cm_GetVolumeByFID(&scp->fid);
+    cm_volume_t * volp = cm_FindVolumeByFID(&scp->fid, userp, reqp);
 
     /* pretty easy: just force a pass through the fetch status code */
 
index e6b3872..37c8e80 100644 (file)
@@ -236,7 +236,7 @@ buf_Sync(int quitOnShutdown)
             afs_uint32 dirty;
             cm_volume_t * volp;
 
-            volp = cm_GetVolumeByFID(&bp->fid);
+           volp = cm_FindVolumeByFID(&bp->fid, bp->userp, &req);
             switch (cm_GetVolumeStatus(volp, bp->fid.volume)) {
             case vl_online:
             case vl_unknown:
@@ -277,7 +277,7 @@ buf_Sync(int quitOnShutdown)
                 char volstr[VL_MAXNAMELEN+12]="";
                 char *ext = "";
 
-                volp = cm_GetVolumeByFID(&bp->fid);
+               volp = cm_GetVolumeByFID(&bp->fid);
                 if (volp) {
                     cellp = volp->cellp;
                     if (bp->fid.volume == volp->vol[RWVOL].ID)
index bb10393..06bb811 100644 (file)
@@ -941,7 +941,7 @@ cm_Analyze(cm_conn_t *connp,
             if (!fidp) { /* vldb */
                 retry = 1;
             } else { /* file */
-                cm_volume_t *volp = cm_GetVolumeByFID(fidp);
+               cm_volume_t *volp = cm_FindVolumeByFID(fidp, userp, reqp);
                 if (volp) {
                     if (fidp->volume == cm_GetROVolumeID(volp))
                         retry = 1;
index 5a2bf67..d031b10 100644 (file)
@@ -2762,7 +2762,7 @@ cm_IsSpaceAvailable(cm_fid_t * fidp, osi_hyper_t *sizep, cm_user_t *userp, cm_re
         goto _done;
     }
 
-    volp = cm_GetVolumeByFID(fidp);
+    volp = cm_FindVolumeByFID(fidp, userp, reqp);
     if (!volp) {
         spaceAvail = 0;
         goto _done;
index 8aeece1..8eca1ca 100644 (file)
@@ -795,6 +795,24 @@ cm_volume_t *cm_GetVolumeByFID(cm_fid_t *fidp)
     return volp;
 }
 
+cm_volume_t *cm_FindVolumeByFID(cm_fid_t *fidp, cm_user_t *userp, cm_req_t *reqp)
+{
+    cm_volume_t *volp = NULL;
+    cm_cell_t   *cellp;
+    long         code;
+
+    cellp = cm_FindCellByID(fidp->cell, CM_FLAG_NOPROBE);
+    if (!cellp) {
+       return NULL;
+    }
+
+    code = cm_FindVolumeByID(cellp, fidp->volume, userp, reqp, CM_GETVOL_FLAG_CREATE, &volp);
+    if (code)
+       return NULL;
+
+    return volp;
+}
+
 long cm_FindVolumeByID(cm_cell_t *cellp, afs_uint32 volumeID, cm_user_t *userp,
                       cm_req_t *reqp, afs_uint32 flags, cm_volume_t **outVolpp)
 {
index 8c43076..b104c4d 100644 (file)
@@ -81,6 +81,9 @@ extern long cm_FindVolumeByID(struct cm_cell *cellp, afs_uint32 volumeID,
                              cm_user_t *userp, cm_req_t *reqp,
                              afs_uint32 flags, cm_volume_t **outVolpp);
 
+extern cm_volume_t *cm_FindVolumeByFID(cm_fid_t *fidp,
+                                      cm_user_t *userp, cm_req_t *reqp);
+
 #define CM_GETVOL_FLAG_CREATE               1
 #define CM_GETVOL_FLAG_NO_LRU_UPDATE        2
 #define CM_GETVOL_FLAG_NO_RESET                    4
index cb62204..b87f7c5 100644 (file)
@@ -5918,11 +5918,12 @@ RDR_GetVolumeInfo( IN cm_user_t     *userp,
         if ( pResultCB->CellLength )
             pResultCB->CellLength--;
     } else {
-        volp = cm_GetVolumeByFID(&scp->fid);
-        if (!volp) {
+       volp = cm_FindVolumeByFID(&scp->fid, userp, &req);
+       if (!volp) {
             code = CM_ERROR_NOSUCHVOLUME;
             goto _done;
         }
+
         volType = cm_VolumeType(volp, scp->fid.volume);
 
         if (cm_volumeInfoReadOnlyFlag && (volType == ROVOL || volType == BACKVOL))
@@ -6152,8 +6153,8 @@ RDR_GetVolumeSizeInfo( IN cm_user_t     *userp,
         pResultCB->TotalAllocationUnits.QuadPart = 100;
         pResultCB->AvailableAllocationUnits.QuadPart = 0;
     } else {
-        volp = cm_GetVolumeByFID(&scp->fid);
-        if (!volp) {
+       volp = cm_FindVolumeByFID(&scp->fid, userp, &req);
+       if (!volp) {
             code = CM_ERROR_NOSUCHVOLUME;
             goto _done;
         }