Windows: Update Bulk I/O Descriptor
authorJeffrey Altman <jaltman@your-file-system.com>
Thu, 3 Jan 2013 19:11:31 +0000 (14:11 -0500)
committerJeffrey Altman <jaltman@your-file-system.com>
Thu, 31 Jan 2013 19:31:30 +0000 (11:31 -0800)
Update the cm_bulkIO_t and associated functions such that
the 'reserved' field is no longer a boolean indicated whether
or not buffers have been reserved but instead becomes a count
of the number of buffers that have been reserved.

buf_TryReserveBuffers is modified to return an afs_uint64
count of the number of buffers reserved instead of a boolean.

cm_SetupStoreBIOD, cm_SetupFetchBIOD, and cm_ReleaseBIOD altered
to store the reserved buffer count and use it when freeing the
BIOD.

Prior to this change it was not possible to reserve a count other
than the number of buffers it takes to store one chunkSize of data.

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

src/WINNT/afsd/cm_buf.c
src/WINNT/afsd/cm_buf.h
src/WINNT/afsd/cm_dcache.c
src/WINNT/afsd/cm_dcache.h

index cc7072b..bea6608 100644 (file)
@@ -1877,20 +1877,21 @@ void buf_ReserveBuffers(afs_uint64 nbuffers)
     lock_ReleaseWrite(&buf_globalLock);
 }
 
-int buf_TryReserveBuffers(afs_uint64 nbuffers)
+afs_uint64
+buf_TryReserveBuffers(afs_uint64 nbuffers)
 {
-    int code;
+    afs_uint64 reserved;
 
     lock_ObtainWrite(&buf_globalLock);
     if (cm_data.buf_reservedBufs + nbuffers > cm_data.buf_maxReservedBufs) {
-        code = 0;
+        reserved = 0;
     }
     else {
         cm_data.buf_reservedBufs += nbuffers;
-        code = 1;
+        reserved = nbuffers;
     }
     lock_ReleaseWrite(&buf_globalLock);
-    return code;
+    return reserved;
 }
 
 /* called without global lock held, releases reservation held by
index 09801b5..02dcbe7 100644 (file)
@@ -189,7 +189,7 @@ extern long buf_CleanAndReset(void);
 
 extern void buf_ReserveBuffers(afs_uint64);
 
-extern int buf_TryReserveBuffers(afs_uint64);
+extern afs_uint64 buf_TryReserveBuffers(afs_uint64);
 
 extern void buf_UnreserveBuffers(afs_uint64);
 
index a3ad77a..8eaef82 100644 (file)
@@ -1026,7 +1026,8 @@ long cm_SetupStoreBIOD(cm_scache_t *scp, osi_hyper_t *inOffsetp, long inSize,
 
     /* reserve a chunk's worth of buffers */
     lock_ReleaseWrite(&scp->rw);
-    buf_ReserveBuffers(cm_chunkSize / cm_data.buf_blockSize);
+    biop->reserved = (cm_chunkSize / cm_data.buf_blockSize);
+    buf_ReserveBuffers(biop->reserved);
     lock_ObtainWrite(&scp->rw);
 
     bufp = NULL;
@@ -1074,8 +1075,6 @@ long cm_SetupStoreBIOD(cm_scache_t *scp, osi_hyper_t *inOffsetp, long inSize,
         }
     }
 
-    biop->reserved = 1;
-
     /* if we get here, if bufp is null, we didn't find any dirty buffers
      * that weren't already being stored back, so we just quit now.
      */
@@ -1485,7 +1484,7 @@ void cm_ReleaseBIOD(cm_bulkIO_t *biop, int isStore, long code, int scp_locked)
 
     /* Give back reserved buffers */
     if (biop->reserved)
-        buf_UnreserveBuffers(cm_chunkSize / cm_data.buf_blockSize);
+        buf_UnreserveBuffers(biop->reserved);
 
     if (isStore)
         flags = CM_SCACHESYNC_STOREDATA;
index 5fea183..8cf0ec4 100644 (file)
@@ -16,11 +16,14 @@ typedef struct cm_bulkIO {
     struct cm_user *userp;              /* the user of the request */
     struct cm_req *reqp;                /* the request ptr */
     osi_hyper_t offset;                        /* offset of buffers */
-    long length;                       /* # of bytes to be transferred */
-    int reserved;                      /* did we reserve multiple buffers? */
-
-    /* all of these buffers are held */
-    osi_queueData_t *bufListp; /* list of buffers involved in I/O */
+    afs_uint32 length;                 /* # of bytes to be transferred */
+    afs_uint64 reserved;               /* # of reserved buffers? */
+
+    /*
+     * all of these buffers are held.
+     * the lowest offset buffer is at the end of the list.
+     */
+    osi_queueData_t *bufListp;         /* list of buffers involved in I/O */
     osi_queueData_t *bufListEndp;      /* list of buffers involved in I/O */
 } cm_bulkIO_t;