]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
DEVEL15-windows-afsd-20080222
authorJeffrey Altman <jaltman@secure-endpoints.com>
Sat, 23 Feb 2008 00:17:34 +0000 (00:17 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Sat, 23 Feb 2008 00:17:34 +0000 (00:17 +0000)
LICENSE MIT

1. Change RxEnableHotThread default to 'on'

2. Add a 'hash' value to the cm_fid_t structure in order to speed up cm_FidCmp().
   Add cm_SetFid() for use in constructing a fid complete with the hash.

3. Redefine the BUF_HASH and BUF_FILEHASH in terms of the cm_fid_t hash which
   has a better distribution

4. Modify cm_ConsiderPrefetch to evaluate the amount of data in the most recent
   read request instead of the next chunkSize.  cm_chunkSize can be dozens or
   hundreds of buffers.  As a result too much time is spent performing the
   evaluation.

5. Fix the usage of cm_scache_t bufCreateLock.  The purpose of this lock is
   to prevent the creation of new buffers while a truncation is being performed.
   All references to bufCreateLock have been removed except in two places:
   i.  a write-lock surrounding the function that calls buf_Truncate()
   ii. a read-lock within buf_GetNewLocked() that actually allocates new
       buffers

6. Modify the CM_CONFIG_DATA_MAGIC value to include a CM_CONFIG_DATA_VERSION
   number which value be used to force the replacement of the cache file
   contents when incompatible changes are made between releases.

7. CM_SCACHESYNC_ASYNCSTORE should not be ordered by cm_SyncOpCheckContinue

8. Avoid calls to multi_Rx if nconns == 0

9. Modify smb_WriteData to perform background writes based upon the crossing
   of buf_blockSize boundaries instead of cm_chunkSize boundaries.  This will
   slow down writes from the SMB interface but will avoid the risk of
   the CIFS client disconnecting from the AFS client SMB server.

(cherry picked from commit dcef8fa4adc4c2cdc166494979d77d91c40c1f06)

21 files changed:
src/WINNT/afsd/afsd_init.c
src/WINNT/afsd/cm_access.c
src/WINNT/afsd/cm_btree.c
src/WINNT/afsd/cm_buf.c
src/WINNT/afsd/cm_buf.h
src/WINNT/afsd/cm_callback.c
src/WINNT/afsd/cm_dcache.c
src/WINNT/afsd/cm_dcache.h
src/WINNT/afsd/cm_dir.c
src/WINNT/afsd/cm_freelance.c
src/WINNT/afsd/cm_ioctl.c
src/WINNT/afsd/cm_memmap.h
src/WINNT/afsd/cm_scache.c
src/WINNT/afsd/cm_scache.h
src/WINNT/afsd/cm_server.c
src/WINNT/afsd/cm_vnodeops.c
src/WINNT/afsd/cm_volume.c
src/WINNT/afsd/rawops.c
src/WINNT/afsd/smb.c
src/WINNT/afsd/smb.h
src/WINNT/afsd/smb3.c

index f7b0bba87812334bbc67142e2a57fba17cd427d7..2d2d7869bfa5831486bc7af526ae8a93a8fa7331 100644 (file)
@@ -1056,7 +1056,7 @@ int afsd_InitCM(char **reasonP)
     dwValue = 0;
     code = RegQueryValueEx(parmKey, "RxEnableHotThread", NULL, NULL,
                             (BYTE *) &dwValue, &dummyLen);
-     if (code == ERROR_SUCCESS && dwValue != 0) {
+     if (code != ERROR_SUCCESS || dwValue != 0) {
          rx_EnableHotThread();
          afsi_log("RX Hot Thread is enabled");
      }
@@ -1355,10 +1355,7 @@ int afsd_InitDaemons(char **reasonP)
 
     /* compute the root fid */
     if (!cm_freelanceEnabled) {
-        cm_data.rootFid.cell = cm_data.rootCellp->cellID;
-        cm_data.rootFid.volume = cm_GetROVolumeID(cm_data.rootVolumep);
-        cm_data.rootFid.vnode = 1;
-        cm_data.rootFid.unique = 1;
+        cm_SetFid(&cm_data.rootFid, cm_data.rootCellp->cellID, cm_GetROVolumeID(cm_data.rootVolumep), 1, 1);
     }
     else
         cm_FakeRootFid(&cm_data.rootFid);
index daf633b0bcdcd144f9654b3f2c5820398907796f..055186885eba07b092cd0b0d97e2aa18309b1b42 100644 (file)
@@ -54,10 +54,7 @@ int cm_HaveAccessRights(struct cm_scache *scp, struct cm_user *userp, afs_uint32
         aclScp = scp;
         cm_HoldSCache(scp);
     } else {
-        tfid.cell = scp->fid.cell;
-        tfid.volume = scp->fid.volume;
-        tfid.vnode = scp->parentVnode;
-        tfid.unique = scp->parentUnique;
+        cm_SetFid(&tfid, scp->fid.cell, scp->fid.volume, scp->parentVnode, scp->parentUnique);
         aclScp = cm_FindSCache(&tfid);
         if (!aclScp) 
             return 0;
@@ -175,10 +172,7 @@ long cm_GetAccessRights(struct cm_scache *scp, struct cm_user *userp,
            cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
     } else {
         /* not a dir, use parent dir's acl */
-        tfid.cell = scp->fid.cell;
-        tfid.volume = scp->fid.volume;
-        tfid.vnode = scp->parentVnode;
-        tfid.unique = scp->parentUnique;
+        cm_SetFid(&tfid, scp->fid.cell, scp->fid.volume, scp->parentVnode, scp->parentUnique);
         lock_ReleaseMutex(&scp->mx);
         code = cm_GetSCache(&tfid, &aclScp, userp, reqp);
         if (code) {
index b3ad945a430308ac2ce68ff685f3ab9579384a34..fc39c69e44ce420892d11761890a7df353a986f7 100644 (file)
@@ -1667,10 +1667,7 @@ long cm_BPlusDirCreateEntry(cm_dirOp_t * op, char *entry, cm_fid_t * cfid)
 
     lock_AssertWrite(&op->scp->dirlock);
 
-    data.fid.cell = cfid->cell;
-    data.fid.volume = cfid->volume;
-    data.fid.vnode = cfid->vnode;
-    data.fid.unique = cfid->unique;
+    cm_SetFid(&data.fid, cfid->cell, cfid->volume, cfid->vnode, cfid->unique);
     data.longname = NULL;
 
     QueryPerformanceCounter(&start);
@@ -1857,10 +1854,7 @@ int cm_BPlusDirFoo(struct cm_scache *scp, struct cm_dirEntry *dep,
     dataT  data;
     char   shortName[13];
 
-    data.fid.cell = scp->fid.cell;
-    data.fid.volume = scp->fid.volume;
-    data.fid.vnode = ntohl(dep->fid.vnode);
-    data.fid.unique = ntohl(dep->fid.unique);
+    cm_SetFid(&data.fid, scp->fid.cell, scp->fid.volume, ntohl(dep->fid.vnode), ntohl(dep->fid.unique));
     data.longname = NULL;
 
     /* the Write lock is held in cm_BPlusDirBuildTree() */
index dc7b4aefc91227323c740b7b3d5974cba9dfc02d..bd3bbc0eda66637529ec18e1484673f20f4c2598 100644 (file)
@@ -750,9 +750,9 @@ void buf_Recycle(cm_buf_t *bp)
  */
 long buf_GetNewLocked(struct cm_scache *scp, osi_hyper_t *offsetp, cm_buf_t **bufpp)
 {
-    cm_buf_t *bp;              /* buffer we're dealing with */
+    cm_buf_t *bp;      /* buffer we're dealing with */
     cm_buf_t *nextBp;  /* next buffer in file hash chain */
-    long i;                    /* temp */
+    afs_uint32 i;      /* temp */
     cm_req_t req;
 
     cm_InitReq(&req);  /* just in case */
@@ -763,6 +763,7 @@ long buf_GetNewLocked(struct cm_scache *scp, osi_hyper_t *offsetp, cm_buf_t **bu
 
     while(1) {
       retry:
+        lock_ObtainRead(&scp->bufCreateLock);
         lock_ObtainWrite(&buf_globalLock);
         /* check to see if we lost the race */
         if (scp) {
@@ -781,6 +782,7 @@ long buf_GetNewLocked(struct cm_scache *scp, osi_hyper_t *offsetp, cm_buf_t **bu
        if (!cm_data.buf_freeListEndp)
        {
            lock_ReleaseWrite(&buf_globalLock);
+            lock_ReleaseRead(&scp->bufCreateLock);
            osi_Log0(afsd_logp, "buf_GetNewLocked: Free Buffer List is empty - sleeping 200ms");
            Sleep(200);
            goto retry;
@@ -913,6 +915,7 @@ long buf_GetNewLocked(struct cm_scache *scp, osi_hyper_t *offsetp, cm_buf_t **bu
             bp->refCount = 1;
                         
             lock_ReleaseWrite(&buf_globalLock);
+            lock_ReleaseRead(&scp->bufCreateLock);
             *bufpp = bp;
 
 #ifdef TESTING
@@ -921,6 +924,7 @@ long buf_GetNewLocked(struct cm_scache *scp, osi_hyper_t *offsetp, cm_buf_t **bu
             return 0;
         } /* for all buffers in lru queue */
         lock_ReleaseWrite(&buf_globalLock);
+        lock_ReleaseRead(&scp->bufCreateLock);
        osi_Log0(afsd_logp, "buf_GetNewLocked: Free Buffer List has no buffers with a zero refcount - sleeping 100ms");
        Sleep(100);             /* give some time for a buffer to be freed */
     }  /* while loop over everything */
@@ -1557,7 +1561,7 @@ long buf_FlushCleanPages(cm_scache_t *scp, cm_user_t *userp, cm_req_t *reqp)
 long buf_ForceDataVersion(cm_scache_t * scp, afs_uint64 fromVersion, afs_uint64 toVersion)
 {
     cm_buf_t * bp;
-    unsigned int i;
+    afs_uint32 i;
     int found = 0;
 
     lock_AssertMutex(&scp->mx);
@@ -1588,7 +1592,7 @@ long buf_CleanVnode(struct cm_scache *scp, cm_user_t *userp, cm_req_t *reqp)
     long wasDirty = 0;
     cm_buf_t *bp;              /* buffer we're hacking on */
     cm_buf_t *nbp;             /* next one */
-    long i;
+    afs_uint32 i;
 
     i = BUF_FILEHASH(&scp->fid);
 
index 1c9b46f780054d667d9aaeb2009c32a753ee3c87..3dd4ba733013063f1f87fc5f7c02f464b75201d6 100644 (file)
 extern int buf_cacheType;
 
 /* force it to be signed so that mod comes out positive or 0 */
-#define BUF_HASH(fidp,offsetp) ((((fidp)->vnode+((fidp)->unique << 5)  \
-                               +(fidp)->volume+(fidp)->cell            \
-                               +((offsetp)->LowPart / cm_data.buf_blockSize))  \
-                                 & 0x7fffffff)                         \
+#define BUF_HASH(fidp,offsetp) ((((fidp)->hash \
+                               +(offsetp)->LowPart) / cm_data.buf_blockSize)   \
                                   % cm_data.buf_hashSize)
 
 /* another hash fn */
-#define BUF_FILEHASH(fidp) ((((fidp)->vnode+((fidp)->unique << 5)      \
-                               +(fidp)->volume+(fidp)->cell)           \
-                                 & 0x7fffffff)                         \
-                                  % cm_data.buf_hashSize)
+#define BUF_FILEHASH(fidp) ((fidp)->hash % cm_data.buf_hashSize)
 
 /* backup over pointer to the buffer */
 #define BUF_OVERTOBUF(op) ((cm_buf_t *)(((char *)op) - ((long)(&((cm_buf_t *)0)->over))))
@@ -67,12 +62,12 @@ typedef struct cm_buf {
                                 */
     struct cm_buf *dirtyp;     /* next in the dirty list */
     osi_mutex_t mx;            /* mutex protecting structure except refcount */
-    unsigned long refCount;    /* reference count (buf_globalLock) */
+    afs_int32 refCount;                /* reference count (buf_globalLock) */
     long idCounter;            /* counter for softrefs; bumped at each recycle */
     long dirtyCounter;         /* bumped at each dirty->clean transition */
     osi_hyper_t offset;                /* offset */
     cm_fid_t fid;              /* file ID */
-    long flags;                        /* flags we're using */
+    afs_uint32 flags;          /* flags we're using */
     char *datap;               /* data in this buffer */
     unsigned long error;       /* last error code, if CM_BUF_ERROR is set */
     cm_user_t *userp;          /* user who wrote to the buffer last */
index 0d2b00bb3bca2c37cde6fddba0ccda3987395b05..418dbb09d14a46e3cdeb482e644dedf63d57e737 100644 (file)
@@ -143,10 +143,7 @@ void cm_CallbackNotifyChange(cm_scache_t *scp)
         cm_fid_t tfid;
         cm_scache_t *dscp;
 
-        tfid.cell = scp->fid.cell;
-        tfid.volume = scp->fid.volume;
-        tfid.vnode = scp->parentVnode;
-        tfid.unique = scp->parentUnique;
+        cm_SetFid(&tfid, scp->fid.cell, scp->fid.volume, scp->parentVnode, scp->parentUnique);
         dscp = cm_FindSCache(&tfid);
 #ifndef AFSIFS
         if ( dscp &&
index 229288b863791b8dde4377f48a14ea17df093ec4..aa94fa56ba2333ad8ada39c6f50a456d9076ddf6 100644 (file)
@@ -697,9 +697,7 @@ cm_BkgPrefetch(cm_scache_t *scp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, af
             mxheld = 0;
         }
 
-        lock_ObtainRead(&scp->bufCreateLock);
         code = buf_Get(scp, &offset, &bp);
-        lock_ReleaseRead(&scp->bufCreateLock);
         if (code)
             break;
 
@@ -737,7 +735,7 @@ cm_BkgPrefetch(cm_scache_t *scp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, af
 /* a read was issued to offsetp, and we have to determine whether we should
  * do a prefetch of the next chunk.
  */
-void cm_ConsiderPrefetch(cm_scache_t *scp, osi_hyper_t *offsetp,
+void cm_ConsiderPrefetch(cm_scache_t *scp, osi_hyper_t *offsetp, afs_uint32 count,
                          cm_user_t *userp, cm_req_t *reqp)
 {
     long code;
@@ -750,7 +748,7 @@ void cm_ConsiderPrefetch(cm_scache_t *scp, osi_hyper_t *offsetp,
     readBase.LowPart += (cm_chunkSize-1);
     readBase.LowPart &= (-cm_chunkSize);
 
-    readLength = ConvertLongToLargeInteger(cm_chunkSize);
+    readLength = ConvertLongToLargeInteger(count);
 
     lock_ObtainMutex(&scp->mx);
     if ((scp->flags & CM_SCACHEFLAG_PREFETCHING)
@@ -1092,9 +1090,7 @@ long cm_SetupFetchBIOD(cm_scache_t *scp, osi_hyper_t *offsetp,
         if (LargeIntegerGreaterThanOrEqualTo(pageBase, fileSize)) 
             break;
 
-        lock_ObtainRead(&scp->bufCreateLock);
         code = buf_Get(scp, &pageBase, &tbp);
-        lock_ReleaseRead(&scp->bufCreateLock);
         if (code) {
             //lock_ReleaseMutex(&cm_bufGetMutex);
             lock_ObtainMutex(&scp->mx);
index 0fe4b1ad445fd78586ec9ae0fc1abecfa003ab3c..8cde66da68f1efc04b4408932f1483b6b39f648d 100644 (file)
@@ -50,7 +50,8 @@ extern afs_int32 cm_BkgStore(cm_scache_t *scp, afs_uint32 p1, afs_uint32 p2, afs
        struct cm_user *userp);
 
 extern void cm_ConsiderPrefetch(cm_scache_t *scp, osi_hyper_t *offsetp,
-       cm_user_t *userp, cm_req_t *reqp);
+                                afs_uint32 count, 
+                                cm_user_t *userp, cm_req_t *reqp);
 
 extern long cm_ValidateDCache(void);
 
index 0933b65b4cc825b4f09886b205bc3c3218f74051..be961d5e8b21bc014207a0dfa3d1479ae2d8704f 100644 (file)
@@ -1559,10 +1559,7 @@ cm_DirGetPage(cm_dirOp_t * op,
             goto _has_buffer;
         }
 
-        lock_ObtainRead(&op->scp->bufCreateLock);
         code = buf_Get(op->scp, &bufferOffset, &bufferp);
-        lock_ReleaseRead(&op->scp->bufCreateLock);
-
         if (code) {
             osi_Log1(afsd_logp, "    buf_Get returned code 0x%x", code);
             bufferp = NULL;
index 628edfc015649de83d24d4d1a603ef16da1f87b9..656d3633d51cf17c480bf14445d4e13f3b1546a6 100644 (file)
@@ -357,10 +357,10 @@ void cm_InitFakeRootDir() {
 
 int cm_FakeRootFid(cm_fid_t *fidp)
 {
-    fidp->cell = AFS_FAKE_ROOT_CELL_ID;            /* root cell */
-    fidp->volume = AFS_FAKE_ROOT_VOL_ID;           /* root.afs ? */
-    fidp->vnode = 0x1;
-    fidp->unique = 0x1;
+    cm_SetFid(fidp, 
+              AFS_FAKE_ROOT_CELL_ID,            /* root cell */
+              AFS_FAKE_ROOT_VOL_ID,            /* root.afs ? */
+              1, 1);
     return 0;
 }
   
@@ -395,10 +395,7 @@ int cm_reInitLocalMountPoints() {
 
     osi_Log0(afsd_logp,"Invalidating local mount point scp...  ");
 
-    aFid.cell = AFS_FAKE_ROOT_CELL_ID;
-    aFid.volume=AFS_FAKE_ROOT_VOL_ID;
-    aFid.unique=0x1;
-    aFid.vnode=0x2;
+    cm_SetFid(&aFid, AFS_FAKE_ROOT_CELL_ID, AFS_FAKE_ROOT_VOL_ID, 1, 2);
 
     lock_ObtainWrite(&cm_scacheLock);
     lock_ObtainMutex(&cm_Freelance_Lock);  /* always scache then freelance lock */
@@ -434,7 +431,7 @@ int cm_reInitLocalMountPoints() {
                 }
             }
         }
-        aFid.vnode = aFid.vnode + 1;
+        cm_SetFid(&aFid, AFS_FAKE_ROOT_CELL_ID, AFS_FAKE_ROOT_VOL_ID, aFid.vnode + 1, 2);
     }
     lock_ReleaseWrite(&cm_scacheLock);
     osi_Log0(afsd_logp,"\tall old scp cleared!");
@@ -1106,10 +1103,8 @@ long cm_FreelanceAddMount(char *filename, char *cellname, char *volume, int rw,
     lock_ReleaseMutex(&cm_Freelance_Lock);
 
     /* cm_reInitLocalMountPoints(); */
-    if (fidp) {
-        fidp->unique = 1;
-        fidp->vnode = cm_noLocalMountPoints + 1;   /* vnode value of last mt pt */
-    }
+    if (fidp)
+        cm_SetFid(fidp, fidp->cell, fidp->volume, cm_noLocalMountPoints + 1, 1);
     cm_noteLocalMountPointChange();
     return 0;
 }
@@ -1322,10 +1317,8 @@ long cm_FreelanceAddSymlink(char *filename, char *destination, cm_fid_t *fidp)
     lock_ReleaseMutex(&cm_Freelance_Lock);
 
     /* cm_reInitLocalMountPoints(); */
-    if (fidp) {
-        fidp->unique = 1;
-        fidp->vnode = cm_noLocalMountPoints + 1;   /* vnode value of last mt pt */
-    }
+    if (fidp)
+        cm_SetFid(fidp, fidp->cell, fidp->volume, cm_noLocalMountPoints + 1, 1);
     cm_noteLocalMountPointChange();
     return 0;
 }
index b078ee295a3315af4e116f358e8c4cb462a25b01..f9a9b3c0cf5206d93d5ffe5e1adb51ba4b3bfdfb 100644 (file)
@@ -71,14 +71,12 @@ long cm_CleanFile(cm_scache_t *scp, cm_user_t *userp, cm_req_t *reqp)
 {
     long code;
 
-    lock_ObtainWrite(&scp->bufCreateLock);
     code = buf_CleanVnode(scp, userp, reqp);
         
     lock_ObtainMutex(&scp->mx);
     cm_DiscardSCache(scp);
     lock_ReleaseMutex(&scp->mx);
 
-    lock_ReleaseWrite(&scp->bufCreateLock);
     osi_Log2(afsd_logp,"cm_CleanFile scp 0x%x returns error: [%x]",scp, code);
     return code;
 }
@@ -94,7 +92,6 @@ long cm_FlushFile(cm_scache_t *scp, cm_user_t *userp, cm_req_t *reqp)
     }
 #endif
 
-    lock_ObtainWrite(&scp->bufCreateLock);
     code = buf_FlushCleanPages(scp, userp, reqp);
         
     lock_ObtainMutex(&scp->mx);
@@ -102,7 +99,6 @@ long cm_FlushFile(cm_scache_t *scp, cm_user_t *userp, cm_req_t *reqp)
 
     lock_ReleaseMutex(&scp->mx);
 
-    lock_ReleaseWrite(&scp->bufCreateLock);
     osi_Log2(afsd_logp,"cm_FlushFile scp 0x%x returns error: [%x]",scp, code);
     return code;
 }
index 21c9a571bafe072ebcda0f91bd0e0765ed94892a..de2271006d61d85f662e5a664701d9f8cd3e8f5b 100644 (file)
@@ -10,7 +10,8 @@
 #ifndef CM_MEMMAP_H
 #define CM_MEMMAP_H 1
 
-#define CM_CONFIG_DATA_MAGIC            ('A' | 'F'<<8 | 'S'<<16 | 'D'<<24)
+#define CM_CONFIG_DATA_VERSION  1
+#define CM_CONFIG_DATA_MAGIC            ('A' | 'F'<<8 | 'S'<<16 | CM_CONFIG_DATA_VERSION<<24)
 
 typedef struct cm_config_data {
     afs_uint32          size;
index 16e7980c121e7ccb9857649c9dfeae73ec7816b6..be33820e2763b69be5c927379e6a315bd6c6aec7 100644 (file)
@@ -180,6 +180,7 @@ long cm_RecycleSCache(cm_scache_t *scp, afs_int32 flags)
     scp->fid.volume = 0;
     scp->fid.unique = 0;
     scp->fid.cell = 0;
+    scp->fid.hash = 0;
 
     /* remove from dnlc */
     cm_dnlcPurgedp(scp);
@@ -337,10 +338,21 @@ cm_scache_t *cm_GetNewSCache(void)
     return scp;
 }       
 
+void cm_SetFid(cm_fid_t *fidp, afs_uint32 cell, afs_uint32 volume, afs_uint32 vnode, afs_uint32 unique)
+{
+    fidp->cell = cell;
+    fidp->volume = volume;
+    fidp->vnode = vnode;
+    fidp->unique = unique;
+    fidp->hash = ((cell & 0xF) << 28) | ((volume & 0x3F) << 22) | ((vnode & 0x7FF) << 11) | (unique & 0x7FF);
+}
+
 /* like strcmp, only for fids */
 int cm_FidCmp(cm_fid_t *ap, cm_fid_t *bp)
 {
-    if (ap->vnode != bp->vnode) 
+    if (ap->hash != bp->hash)
+        return 1;
+    if (ap->vnode != bp->vnode)
         return 1;
     if (ap->volume != bp->volume) 
         return 1;
@@ -880,9 +892,7 @@ cm_scache_t * cm_FindSCacheParent(cm_scache_t * scp)
     cm_scache_t * pscp = NULL;
 
     lock_ObtainWrite(&cm_scacheLock);
-    parent_fid = scp->fid;
-    parent_fid.vnode = scp->parentVnode;
-    parent_fid.unique = scp->parentUnique;
+    cm_SetFid(&parent_fid, scp->fid.cell, scp->fid.volume, scp->parentVnode, scp->parentUnique);
 
     if (cm_FidCmp(&scp->fid, &parent_fid)) {
        i = CM_SCACHE_HASH(&parent_fid);
@@ -903,6 +913,10 @@ void cm_SyncOpAddToWaitQueue(cm_scache_t * scp, afs_int32 flags, cm_buf_t * bufp
 {
     cm_scache_waiter_t * w;
 
+    /* Do not use the queue for asynchronous store operations */
+    if (flags == CM_SCACHESYNC_ASYNCSTORE)
+        return;
+
     lock_ObtainWrite(&cm_scacheLock);
     if (cm_allFreeWaiters == NULL) {
         w = malloc(sizeof(*w));
@@ -929,6 +943,10 @@ int cm_SyncOpCheckContinue(cm_scache_t * scp, afs_int32 flags, cm_buf_t * bufp)
     cm_scache_waiter_t * w;
     int this_is_me;
 
+    /* Do not use the queue for asynchronous store operations */
+    if (flags == CM_SCACHESYNC_ASYNCSTORE)
+        return 1;
+
     osi_Log0(afsd_logp, "cm_SyncOpCheckContinue checking for continuation");
 
     lock_ObtainRead(&cm_scacheLock);
index 97b55059ff8c9a094841418d9b972c01cc22d02a..110e314f94b29da0b34e27fd5ac8bed677a66ea4 100644 (file)
 #define MOUNTPOINTLEN   1024    /* max path length for symlink; same as AFSPATHMAX */
 
 typedef struct cm_fid {
-       unsigned long cell;
-        unsigned long volume;
-        unsigned long vnode;
-        unsigned long unique;
+    afs_uint32 cell;
+    afs_uint32 volume;
+    afs_uint32 vnode;
+    afs_uint32 unique;
+    afs_uint32 hash;
 } cm_fid_t;
 
+
 /* Key used for byte range locking.  Each unique key identifies a
    unique client per cm_scache_t for the purpose of locking. */
 typedef afs_uint64 cm_key_t;
@@ -99,7 +101,7 @@ typedef struct cm_scache {
                                          * write-locked to prevent buffers from
                                         * being created during a truncate op, etc.
                                         */
-    afs_uint32 refCount;               /* reference count; cm_scacheLock */
+    afs_int32 refCount;                        /* reference count; cm_scacheLock */
     osi_queueData_t *bufReadsp;                /* queue of buffers being read */
     osi_queueData_t *bufWritesp;       /* queue of buffers being written */
 
@@ -347,6 +349,8 @@ extern cm_scache_t *cm_GetNewSCache(void);
 
 extern int cm_FidCmp(cm_fid_t *, cm_fid_t *);
 
+extern void cm_SetFid(cm_fid_t *, afs_uint32 cell, afs_uint32 volume, afs_uint32 vnode, afs_uint32 unique);
+
 extern long cm_SyncOp(cm_scache_t *, struct cm_buf *, struct cm_user *,
        struct cm_req *, afs_uint32, afs_uint32);
 
index 600c60bd6742cdde6607b37efb259ff0530d27e9..2a2d52f63e14fdf40709e59b3b922a9a3e47e364 100644 (file)
@@ -343,14 +343,15 @@ void cm_CheckServers(afs_uint32 flags, cm_cell_t *cellp)
         }
         lock_ReleaseWrite(&cm_serverLock);
 
-        /* Perform the multi call */
-        start = time(NULL);
-        multi_Rx(rxconns,nconns)
-        {
-            multi_RXAFS_GetCapabilities(&caps[multi_i]);
-            results[multi_i]=multi_error;
-        } multi_End;
-
+        if (nconns) {
+            /* Perform the multi call */
+            start = time(NULL);
+            multi_Rx(rxconns,nconns)
+            {
+                multi_RXAFS_GetCapabilities(&caps[multi_i]);
+                results[multi_i]=multi_error;
+            } multi_End;
+        }
 
         /* Process results of servers that support RXAFS_GetCapabilities */
         for (i=0; i<nconns; i++) {
@@ -479,18 +480,19 @@ void cm_CheckServers(afs_uint32 flags, cm_cell_t *cellp)
         }
         nconns = j;
 
-        /* Perform the multi call */
-        start = time(NULL);
-        multi_Rx(rxconns,nconns)
-        {
-            secs = usecs = 0;
-            multi_RXAFS_GetTime(&secs, &usecs);
-            end = time(NULL);
-            results[multi_i]=multi_error;
-            if ((start == end) && !multi_error)
-                deltas[multi_i] = end - secs;
-        } multi_End;
-
+        if (nconns) {
+            /* Perform the multi call */
+            start = time(NULL);
+            multi_Rx(rxconns,nconns)
+            {
+                secs = usecs = 0;
+                multi_RXAFS_GetTime(&secs, &usecs);
+                end = time(NULL);
+                results[multi_i]=multi_error;
+                if ((start == end) && !multi_error)
+                    deltas[multi_i] = end - secs;
+            } multi_End;
+        }
 
         /* Process Results of servers that only support RXAFS_GetTime */
         for (i=0; i<nconns; i++) {
@@ -637,14 +639,15 @@ void cm_CheckServers(afs_uint32 flags, cm_cell_t *cellp)
         }
         lock_ReleaseWrite(&cm_serverLock);
 
-        /* Perform the multi call */
-        start = time(NULL);
-        multi_Rx(rxconns,nconns)
-        {
-            multi_VL_ProbeServer();
-            results[multi_i]=multi_error;
-        } multi_End;
-
+        if (nconns) {
+            /* Perform the multi call */
+            start = time(NULL);
+            multi_Rx(rxconns,nconns)
+            {
+                multi_VL_ProbeServer();
+                results[multi_i]=multi_error;
+            } multi_End;
+        }
 
         /* Process results of servers that support RXAFS_GetCapabilities */
         for (i=0; i<nconns; i++) {
index bea15dfbefb8338f866fee72d5659b739dcb5e6d..c8c592f09cd83ff6326520f74ea3f421f255bcfa 100644 (file)
@@ -496,9 +496,7 @@ long cm_CheckNTDelete(cm_scache_t *dscp, cm_scache_t *scp, cm_user_t *userp,
         return code;
 
     thyper.HighPart = 0; thyper.LowPart = 0;
-    lock_ObtainRead(&scp->bufCreateLock);
     code = buf_Get(scp, &thyper, &bufferp);
-    lock_ReleaseRead(&scp->bufCreateLock);
     if (code)
         return code;
 
@@ -732,9 +730,7 @@ long cm_ApplyDir(cm_scache_t *scp, cm_DirFuncp_t funcp, void *parmp,
                 bufferp = NULL;
             }
 
-            lock_ObtainRead(&scp->bufCreateLock);
             code = buf_Get(scp, &thyper, &bufferp);
-            lock_ReleaseRead(&scp->bufCreateLock);
             if (code) {
                 /* if buf_Get() fails we do not have a buffer object to lock */
                 bufferp = NULL;
@@ -977,10 +973,8 @@ long cm_ReadMountPoint(cm_scache_t *scp, cm_user_t *userp, cm_req_t *reqp)
     /* otherwise, we have to read it in */
     lock_ReleaseMutex(&scp->mx);
 
-    lock_ObtainRead(&scp->bufCreateLock);
     thyper.LowPart = thyper.HighPart = 0;
     code = buf_Get(scp, &thyper, &bufp);
-    lock_ReleaseRead(&scp->bufCreateLock);
 
     lock_ObtainMutex(&scp->mx);
     if (code)
@@ -1123,6 +1117,8 @@ long cm_FollowMountPoint(cm_scache_t *scp, cm_scache_t *dscp, cm_user_t *userp,
     lock_ObtainMutex(&scp->mx);
         
     if (code == 0) {
+        afs_uint32 cell, volume, vnode, unique;
+
         /* save the parent of the volume root for this is the 
          * place where the volume is mounted and we must remember 
          * this in the volume structure rather than just in the 
@@ -1133,7 +1129,7 @@ long cm_FollowMountPoint(cm_scache_t *scp, cm_scache_t *dscp, cm_user_t *userp,
         volp->dotdotFid = dscp->fid;
         lock_ReleaseMutex(&volp->mx);
 
-        scp->mountRootFid.cell = cellp->cellID;
+        cell = cellp->cellID;
         
         /* if the mt pt originates in a .backup volume (not a .readonly)
          * and FollowBackupPath is active, and if there is a .backup
@@ -1158,15 +1154,14 @@ long cm_FollowMountPoint(cm_scache_t *scp, cm_scache_t *dscp, cm_user_t *userp,
             targetType = ROVOL;
         }
         if (targetType == ROVOL)
-            scp->mountRootFid.volume = volp->ro.ID;
+            volume = volp->ro.ID;
         else if (targetType == BACKVOL)
-            scp->mountRootFid.volume = volp->bk.ID;
+            volume = volp->bk.ID;
         else
-            scp->mountRootFid.volume = volp->rw.ID;
+            volume = volp->rw.ID;
 
         /* the rest of the fid is a magic number */
-        scp->mountRootFid.vnode = 1;
-        scp->mountRootFid.unique = 1;
+        cm_SetFid(&scp->mountRootFid, cell, volume, 1, 1);
         scp->mountRootGen = cm_data.mountRootGen;
 
         tfid = scp->mountRootFid;
@@ -1431,6 +1426,7 @@ long cm_EvaluateVolumeReference(char * namep, long flags, cm_user_t * userp,
     cm_cell_t *   cellp = NULL;
     cm_volume_t * volp = NULL;
     cm_fid_t      fid;
+    afs_uint32    volume;
     int           volType;
     int           mountType = RWVOL;
 
@@ -1497,18 +1493,15 @@ long cm_EvaluateVolumeReference(char * namep, long flags, cm_user_t * userp,
     if (code != 0)
         goto _exit_cleanup;
 
-    fid.cell = cellp->cellID;
-
     if (volType == BACKVOL)
-        fid.volume = volp->bk.ID;
+        volume = volp->bk.ID;
     else if (volType == ROVOL ||
              (volType == RWVOL && mountType == ROVOL && volp->ro.ID != 0))
-        fid.volume = volp->ro.ID;
+        volume = volp->ro.ID;
     else
-        fid.volume = volp->rw.ID;
+        volume = volp->rw.ID;
 
-    fid.vnode = 1;
-    fid.unique = 1;
+    cm_SetFid(&fid, cellp->cellID, volume, 1, 1);
 
     code = cm_GetSCache(&fid, outpScpp, userp, reqp);
 
@@ -1700,9 +1693,7 @@ long cm_HandleLink(cm_scache_t *linkScp, cm_user_t *userp, cm_req_t *reqp)
         /* read the link data */
         lock_ReleaseMutex(&linkScp->mx);
         thyper.LowPart = thyper.HighPart = 0;
-        lock_ObtainRead(&linkScp->bufCreateLock);
         code = buf_Get(linkScp, &thyper, &bufp);
-        lock_ReleaseRead(&linkScp->bufCreateLock);
         lock_ObtainMutex(&linkScp->mx);
         if (code) 
             return code;
@@ -2261,10 +2252,7 @@ long cm_TryBulkProc(cm_scache_t *scp, cm_dirEntry_t *dep, void *rockp,
     if (strcmp(dep->name, ".") == 0 || strcmp(dep->name, "..") == 0)
         return 0;
 
-    tfid.cell = scp->fid.cell;
-    tfid.volume = scp->fid.volume;
-    tfid.vnode = ntohl(dep->fid.vnode);
-    tfid.unique = ntohl(dep->fid.unique);
+    cm_SetFid(&tfid, scp->fid.cell, scp->fid.volume, ntohl(dep->fid.vnode), ntohl(dep->fid.unique));
     tscp = cm_FindSCache(&tfid);
     if (tscp) {
         if (lock_TryMutex(&tscp->mx)) {
@@ -2406,10 +2394,7 @@ cm_TryBulkStat(cm_scache_t *dscp, osi_hyper_t *offsetp, cm_user_t *userp,
         /* otherwise, we should do the merges */
         for (i = 0; i<filesThisCall; i++) {
             j = filex + i;
-            tfid.cell = dscp->fid.cell;
-            tfid.volume = bb.fids[j].Volume;
-            tfid.vnode = bb.fids[j].Vnode;
-            tfid.unique = bb.fids[j].Unique;
+            cm_SetFid(&tfid, dscp->fid.cell, bb.fids[j].Volume, bb.fids[j].Vnode, bb.fids[j].Unique);
             code = cm_GetSCache(&tfid, &scp, userp, reqp);
             if (code != 0) 
                 continue;
@@ -2767,10 +2752,7 @@ long cm_Create(cm_scache_t *dscp, char *namep, long flags, cm_attr_t *attrp,
      * info.
      */
     if (code == 0) {
-        newFid.cell = dscp->fid.cell;
-        newFid.volume = dscp->fid.volume;
-        newFid.vnode = newAFSFid.Vnode;
-        newFid.unique = newAFSFid.Unique;
+        cm_SetFid(&newFid, dscp->fid.cell, dscp->fid.volume, newAFSFid.Vnode, newAFSFid.Unique);
         code = cm_GetSCache(&newFid, &scp, userp, reqp);
         if (code == 0) {
             lock_ObtainMutex(&scp->mx);
@@ -2806,9 +2788,7 @@ long cm_FSync(cm_scache_t *scp, cm_user_t *userp, cm_req_t *reqp)
 {
     long code;
 
-    lock_ObtainWrite(&scp->bufCreateLock);
     code = buf_CleanVnode(scp, userp, reqp);
-    lock_ReleaseWrite(&scp->bufCreateLock);
     if (code == 0) {
         lock_ObtainMutex(&scp->mx);
 
@@ -2927,10 +2907,7 @@ long cm_MakeDir(cm_scache_t *dscp, char *namep, long flags, cm_attr_t *attrp,
      * info.
      */
     if (code == 0) {
-        newFid.cell = dscp->fid.cell;
-        newFid.volume = dscp->fid.volume;
-        newFid.vnode = newAFSFid.Vnode;
-        newFid.unique = newAFSFid.Unique;
+        cm_SetFid(&newFid, dscp->fid.cell, dscp->fid.volume, newAFSFid.Vnode, newAFSFid.Unique);
         code = cm_GetSCache(&newFid, &scp, userp, reqp);
         if (code == 0) {
             lock_ObtainMutex(&scp->mx);
@@ -3115,10 +3092,7 @@ long cm_SymLink(cm_scache_t *dscp, char *namep, char *contentsp, long flags,
 
     if (code == 0) {
         if (cm_CheckDirOpForSingleChange(&dirop)) {
-            newFid.cell = dscp->fid.cell;
-            newFid.volume = dscp->fid.volume;
-            newFid.vnode = newAFSFid.Vnode;
-            newFid.unique = newAFSFid.Unique;
+            cm_SetFid(&newFid, dscp->fid.cell, dscp->fid.volume, newAFSFid.Vnode, newAFSFid.Unique);
 
             cm_DirCreateEntry(&dirop, namep, &newFid);
 #ifdef USE_BPLUS
@@ -3134,10 +3108,7 @@ long cm_SymLink(cm_scache_t *dscp, char *namep, char *contentsp, long flags,
      * info.
      */
     if (code == 0) {
-        newFid.cell = dscp->fid.cell;
-        newFid.volume = dscp->fid.volume;
-        newFid.vnode = newAFSFid.Vnode;
-        newFid.unique = newAFSFid.Unique;
+        cm_SetFid(&newFid, dscp->fid.cell, dscp->fid.volume, newAFSFid.Vnode, newAFSFid.Unique);
         code = cm_GetSCache(&newFid, &scp, userp, reqp);
         if (code == 0) {
             lock_ObtainMutex(&scp->mx);
index 3dc6beb1ba3067c39d2e3f29a24d64d8202b8ba4..d4dfd5aefba3c2603130d092e61eed7380ceb6dd 100644 (file)
@@ -755,6 +755,7 @@ long cm_GetVolumeByName(struct cm_cell *cellp, char *volumeNamep,
            volp->dotdotFid.volume = 0;
            volp->dotdotFid.unique = 0;
            volp->dotdotFid.vnode = 0;
+            volp->dotdotFid.hash = 0;
        } else {
            volp = &cm_data.volumeBaseAddress[cm_data.currentVolumes++];
            memset(volp, 0, sizeof(cm_volume_t));
@@ -1569,10 +1570,7 @@ cm_VolumeRenewROCallbacks(void)
             cm_fid_t      fid;
             cm_scache_t * scp;
 
-            fid.cell = volp->cellp->cellID;
-            fid.volume = volp->ro.ID;
-            fid.vnode = 1;
-            fid.unique = 1;
+            cm_SetFid(&fid, volp->cellp->cellID, volp->ro.ID, 1, 1);
 
             cm_InitReq(&req);
 
index 21b77d82deb100217b9b676a1a1a5bb5328fea78..48ff81dc579ec05540396219ea0830d0684c5a88 100644 (file)
@@ -84,9 +84,7 @@ long ReadData(cm_scache_t *scp, osi_hyper_t offset, long count, char *op,
             }
             lock_ReleaseMutex(&scp->mx);
 
-            lock_ObtainRead(&scp->bufCreateLock);
             code = buf_Get(scp, &thyper, &bufferp);
-            lock_ReleaseRead(&scp->bufCreateLock);
 
             lock_ObtainMutex(&scp->mx);
             if (code) goto done;
@@ -142,7 +140,7 @@ long ReadData(cm_scache_t *scp, osi_hyper_t offset, long count, char *op,
         buf_Release(bufferp);
 
     if (code == 0 && sequential)
-        cm_ConsiderPrefetch(scp, &lastByte, userp, &req);
+        cm_ConsiderPrefetch(scp, &lastByte, *readp, userp, &req);
 
     return code;
 }       
@@ -161,7 +159,7 @@ long WriteData(cm_scache_t *scp, osi_hyper_t offset, long count, char *op,
     osi_hyper_t bufferOffset;
     afs_uint32 bufIndex;       /* index in buffer where our data is */
     int doWriteBack;
-    osi_hyper_t writeBackOffset;       /* offset of region to write back when
+    osi_hyper_t writeBackOffset;/* offset of region to write back when
     * I/O is done */
     DWORD filter = 0;
     cm_req_t req;
@@ -247,9 +245,7 @@ long WriteData(cm_scache_t *scp, osi_hyper_t offset, long count, char *op,
             }  
             lock_ReleaseMutex(&scp->mx);
 
-            lock_ObtainRead(&scp->bufCreateLock);
             code = buf_Get(scp, &thyper, &bufferp);
-            lock_ReleaseRead(&scp->bufCreateLock);
 
             lock_ObtainMutex(&bufferp->mx);
             lock_ObtainMutex(&scp->mx);
index 9951987dac347f4bd927ccdc07f474d0fc971817..b9972471f98e1d3796ce979a4d0a221e1711ed78 100644 (file)
@@ -4406,9 +4406,7 @@ long smb_ReceiveCoreSearchDir(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *ou
                 bufferp = NULL;
             }  
             lock_ReleaseMutex(&scp->mx);
-            lock_ObtainRead(&scp->bufCreateLock);
             code = buf_Get(scp, &thyper, &bufferp);
-            lock_ReleaseRead(&scp->bufCreateLock);
             lock_ObtainMutex(&dsp->mx);
 
             /* now, if we're doing a star match, do bulk fetching of all of 
@@ -4541,10 +4539,7 @@ long smb_ReceiveCoreSearchDir(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *ou
             if (!(dsp->attribute & SMB_ATTR_DIRECTORY))  /* no directories */
             {
                 /* We have already done the cm_TryBulkStat above */
-                fid.cell = scp->fid.cell;
-                fid.volume = scp->fid.volume;
-                fid.vnode = ntohl(dep->fid.vnode);
-                fid.unique = ntohl(dep->fid.unique);
+                cm_SetFid(&fid, scp->fid.cell, scp->fid.volume, ntohl(dep->fid.vnode), ntohl(dep->fid.unique));
                 fileType = cm_FindFileType(&fid);
                 osi_Log2(smb_logp, "smb_ReceiveCoreSearchDir: file %s "
                          "has filetype %d", osi_LogSaveString(smb_logp, dep->name),
@@ -4582,10 +4577,7 @@ long smb_ReceiveCoreSearchDir(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *ou
             curPatchp = malloc(sizeof(*curPatchp));
             osi_QAdd((osi_queue_t **) &dirListPatchesp, &curPatchp->q);
             curPatchp->dptr = op;
-            curPatchp->fid.cell = scp->fid.cell;
-            curPatchp->fid.volume = scp->fid.volume;
-            curPatchp->fid.vnode = ntohl(dep->fid.vnode);
-            curPatchp->fid.unique = ntohl(dep->fid.unique);
+            cm_SetFid(&curPatchp->fid, scp->fid.cell, scp->fid.volume, ntohl(dep->fid.vnode), ntohl(dep->fid.unique));
 
             /* do hidden attribute here since name won't be around when applying
              * dir list patches
@@ -6396,9 +6388,7 @@ long smb_ReadData(smb_fid_t *fidp, osi_hyper_t *offsetp, long count, char *op,
             }
             lock_ReleaseMutex(&scp->mx);
 
-            lock_ObtainRead(&scp->bufCreateLock);
             code = buf_Get(scp, &thyper, &bufferp);
-            lock_ReleaseRead(&scp->bufCreateLock);
 
             lock_ObtainMutex(&scp->mx);
             if (code) goto done;
@@ -6458,7 +6448,7 @@ long smb_ReadData(smb_fid_t *fidp, osi_hyper_t *offsetp, long count, char *op,
         buf_Release(bufferp);
 
     if (code == 0 && sequential)
-        cm_ConsiderPrefetch(scp, &lastByte, userp, &req);
+        cm_ConsiderPrefetch(scp, &lastByte, *readp, userp, &req);
 
     cm_ReleaseSCache(scp);
 
@@ -6476,18 +6466,18 @@ long smb_WriteData(smb_fid_t *fidp, osi_hyper_t *offsetp, long count, char *op,
        cm_user_t *userp, long *writtenp, int dosflag)
 #endif /* !DJGPP */
 {
-    osi_hyper_t offset;
+    osi_hyper_t offset = *offsetp;
     long code = 0;
     long written = 0;
     cm_scache_t *scp;
     osi_hyper_t fileLength;    /* file's length at start of write */
     osi_hyper_t minLength;     /* don't read past this */
     afs_uint32 nbytes;         /* # of bytes to transfer this iteration */
-    cm_buf_t *bufferp;
+    cm_buf_t *bufferp = NULL;
     osi_hyper_t thyper;                /* hyper tmp variable */
     osi_hyper_t bufferOffset;
     afs_uint32 bufIndex;               /* index in buffer where our data is */
-    int doWriteBack;
+    int doWriteBack = 0;
     osi_hyper_t writeBackOffset;/* offset of region to write back when
                                  * I/O is done */
     DWORD filter = 0;
@@ -6500,10 +6490,6 @@ long smb_WriteData(smb_fid_t *fidp, osi_hyper_t *offsetp, long count, char *op,
 
     cm_InitReq(&req);
 
-    bufferp = NULL;
-    doWriteBack = 0;
-    offset = *offsetp;
-
     lock_ObtainMutex(&fidp->mx);
     /* make sure we have a writable FD */
     if (!(fidp->flags & SMB_FID_OPENWRITE)) {
@@ -6550,13 +6536,20 @@ long smb_WriteData(smb_fid_t *fidp, osi_hyper_t *offsetp, long count, char *op,
     /* now, if the new position (thyper) and the old (offset) are in
      * different storeback windows, remember to store back the previous
      * storeback window when we're done with the write.
+     *
+     * the purpose of this logic is to slow down the CIFS client 
+     * in order to avoid the client disconnecting during the CLOSE
+     * operation if there are too many dirty buffers left to write
+     * than can be accomplished during 45 seconds.  This used to be
+     * based upon cm_chunkSize but we desire cm_chunkSize to be large
+     * so that we can read larger amounts of data at a time.
      */
-    if ((thyper.LowPart & (-cm_chunkSize)) !=
-         (offset.LowPart & (-cm_chunkSize))) {
+    if ((thyper.LowPart & ~(cm_data.buf_blockSize-1)) !=
+         (offset.LowPart & ~(cm_data.buf_blockSize-1))) {
         /* they're different */
         doWriteBack = 1;
         writeBackOffset.HighPart = offset.HighPart;
-        writeBackOffset.LowPart = offset.LowPart & (-cm_chunkSize);
+        writeBackOffset.LowPart = offset.LowPart & ~(cm_data.buf_blockSize-1);
     }
         
     *writtenp = count;
@@ -6587,9 +6580,7 @@ long smb_WriteData(smb_fid_t *fidp, osi_hyper_t *offsetp, long count, char *op,
             }  
             lock_ReleaseMutex(&scp->mx);
 
-            lock_ObtainRead(&scp->bufCreateLock);
             code = buf_Get(scp, &thyper, &bufferp);
-            lock_ReleaseRead(&scp->bufCreateLock);
 
             lock_ObtainMutex(&bufferp->mx);
             lock_ObtainMutex(&scp->mx);
@@ -6711,6 +6702,7 @@ long smb_WriteData(smb_fid_t *fidp, osi_hyper_t *offsetp, long count, char *op,
 
     if (code == 0 && doWriteBack) {
         long code2;
+
         lock_ObtainMutex(&scp->mx);
         osi_Log1(smb_logp, "smb_WriteData fid %d calling cm_SyncOp ASYNCSTORE",
                   fidp->fid);
@@ -6719,7 +6711,8 @@ long smb_WriteData(smb_fid_t *fidp, osi_hyper_t *offsetp, long count, char *op,
                   fidp->fid, code2);
         lock_ReleaseMutex(&scp->mx);
         cm_QueueBKGRequest(scp, cm_BkgStore, writeBackOffset.LowPart,
-                            writeBackOffset.HighPart, cm_chunkSize, 0, userp);
+                            writeBackOffset.HighPart, 
+                            *writtenp & ~(cm_data.blockSize-1), 0, userp);
        /* cm_SyncOpDone is called at the completion of cm_BkgStore */
     }
 
@@ -7731,29 +7724,32 @@ void smb_DispatchPacket(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp,
 
         if (dp->procp) {
             /* we have a recognized operation */
+            char * opName = myCrt_Dispatch(inp->inCom);
 
             if (inp->inCom == 0x1d)
                 /* Raw Write */
                 code = smb_ReceiveCoreWriteRaw (vcp, inp, outp, rwcp);
             else {
-                osi_Log4(smb_logp,"Dispatch %s vcp 0x%p lana %d lsn %d",myCrt_Dispatch(inp->inCom),vcp,vcp->lana,vcp->lsn);
+                osi_Log4(smb_logp,"Dispatch %s vcp 0x%p lana %d lsn %d",opName,vcp,vcp->lana,vcp->lsn);
                 code = (*(dp->procp)) (vcp, inp, outp);
                 osi_Log4(smb_logp,"Dispatch return  code 0x%x vcp 0x%p lana %d lsn %d",code,vcp,vcp->lana,vcp->lsn);
 #ifdef LOG_PACKET
                 if ( code == CM_ERROR_BADSMB ||
                      code == CM_ERROR_BADOP )
-                smb_LogPacket(inp);
+                    smb_LogPacket(inp);
 #endif /* LOG_PACKET */
             }   
 
+            newTime = GetTickCount();
+            osi_Log2(smb_logp, "Dispatch %s duration %d ms", opName, newTime - oldTime);
+
             if (oldGen != sessionGen) {
-                newTime = GetTickCount();
 #ifndef DJGPP
                LogEvent(EVENTLOG_WARNING_TYPE, MSG_BAD_SMB_WRONG_SESSION, 
                         newTime - oldTime, ncbp->ncb_length);
 #endif /* !DJGPP */
-               osi_Log2(smb_logp, "Pkt straddled session startup, "
-                          "took %d ms, ncb length %d", newTime - oldTime, ncbp->ncb_length);
+               osi_Log3(smb_logp, "Request %s straddled session startup, "
+                          "took %d ms, ncb length %d", opName, newTime - oldTime, ncbp->ncb_length);
             }
         }
         else {
index dba2eadc6447786d1c3f8815233b29d4a8febd76..6fb61c81d6256077e7f3d4b4ac2cdf08a9b31b5e 100644 (file)
@@ -223,10 +223,10 @@ typedef struct myncb {
 typedef struct smb_vc {
     struct smb_vc *nextp;              /* not used */
     afs_uint32 magic;                  /* a magic value to detect bad entries */
-    unsigned long refCount;            /* the reference count */
-    long flags;                                /* the flags, if any; locked by mx */
+    afs_int32 refCount;                        /* the reference count */
+    afs_uint32 flags;                  /* the flags, if any; locked by mx */
     osi_mutex_t mx;                    /* the mutex */
-    long vcID;                         /* VC id */
+    afs_uint32 vcID;                   /* VC id */
     unsigned short lsn;                        /* the NCB LSN associated with this */
     unsigned short uidCounter;         /* session ID counter */
     unsigned short tidCounter;         /* tree ID counter */
@@ -259,7 +259,7 @@ typedef struct smb_vc {
 /* one per user session */
 typedef struct smb_user {
     struct smb_user *nextp;            /* next sibling */
-    unsigned long refCount;            /* ref count */
+    afs_int32 refCount;                        /* ref count */
     afs_uint32 flags;                  /* flags; locked by mx */
     osi_mutex_t mx;
     unsigned short userID;             /* the session identifier */
@@ -272,7 +272,7 @@ typedef struct smb_user {
 
 typedef struct smb_username {
     struct smb_username *nextp;                /* next sibling */
-    unsigned long refCount;            /* ref count */
+    afs_int32 refCount;                        /* ref count */
     long flags;                                /* flags; locked by mx */
     osi_mutex_t mx;
     struct cm_user *userp;             /* CM user structure */
@@ -303,7 +303,7 @@ typedef struct smb_username {
 /* one per tree-connect */
 typedef struct smb_tid {
     struct smb_tid *nextp;             /* next sibling */
-    unsigned long refCount;
+    afs_int32 refCount;
     afs_uint32 flags;                  /* protected by mx */
     osi_mutex_t mx;                    /* for non-tree-related stuff */
     unsigned short tid;                        /* the tid */
@@ -319,7 +319,7 @@ typedef struct smb_tid {
 /* one per process ID */
 typedef struct smb_pid {
     struct smb_pid *nextp;             /* next sibling */
-    unsigned long refCount;
+    afs_int32 refCount;
     long flags;
     osi_mutex_t mx;                    /* for non-tree-related stuff */
     unsigned short pid;                        /* the pid */
@@ -360,7 +360,7 @@ typedef struct smb_ioctl {
 /* one per file ID; these are really file descriptors */
 typedef struct smb_fid {
     osi_queue_t q;
-    unsigned long refCount;
+    afs_int32 refCount;
     afs_uint32 flags;                  /* protected by mx */
     osi_mutex_t mx;                    /* for non-tree-related stuff */
     unsigned short fid;                        /* the file ID */
@@ -452,7 +452,7 @@ typedef struct smb_fid {
 typedef struct smb_dirSearch {
     osi_queue_t q;                     /* queue of all outstanding cookies */
     osi_mutex_t mx;                    /* just in case the caller screws up */
-    unsigned long refCount;            /* reference count */
+    afs_int32 refCount;                        /* reference count */
     long cookie;                       /* value returned to the caller */
     struct cm_scache *scp;             /* vnode of the dir we're searching */
     time_t lastTime;                   /* last time we used this (osi_Time) */
index 95715deb9d2f9fcd73070225dc45f183e313017c..dca5c4b39e874cddabcfd7ad66ed9bfcecdc8156 100644 (file)
@@ -4608,10 +4608,7 @@ long smb_T2SearchDirSingle(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op
             curPatchp->flags = 0;
         }
 
-        curPatchp->fid.cell = targetscp->fid.cell;
-        curPatchp->fid.volume = targetscp->fid.volume;
-        curPatchp->fid.vnode = targetscp->fid.vnode;
-        curPatchp->fid.unique = targetscp->fid.unique;
+        cm_SetFid(&curPatchp->fid, targetscp->fid.cell, targetscp->fid.volume, targetscp->fid.vnode, targetscp->fid.unique);
 
         /* temp */
         dep = (cm_dirEntry_t *)malloc(sizeof(cm_dirEntry_t)+strlen(maskp));
@@ -5033,9 +5030,7 @@ long smb_ReceiveTran2SearchDir(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t
                 bufferp = NULL;
             }       
             lock_ReleaseMutex(&scp->mx);
-            lock_ObtainRead(&scp->bufCreateLock);
             code = buf_Get(scp, &thyper, &bufferp);
-            lock_ReleaseRead(&scp->bufCreateLock);
             lock_ObtainMutex(&dsp->mx);
 
             /* now, if we're doing a star match, do bulk fetching
@@ -5175,10 +5170,7 @@ long smb_ReceiveTran2SearchDir(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t
             if (!(dsp->attribute & SMB_ATTR_DIRECTORY))  /* no directories */
             {
                 /* We have already done the cm_TryBulkStat above */
-                fid.cell = scp->fid.cell;
-                fid.volume = scp->fid.volume;
-                fid.vnode = ntohl(dep->fid.vnode);
-                fid.unique = ntohl(dep->fid.unique);
+                cm_SetFid(&fid, scp->fid.cell, scp->fid.volume, ntohl(dep->fid.vnode), ntohl(dep->fid.unique));
                 fileType = cm_FindFileType(&fid);
                 /* osi_Log2(smb_logp, "smb_ReceiveTran2SearchDir: file %s "
                  * "has filetype %d", dep->name, fileType);
@@ -5295,10 +5287,7 @@ long smb_ReceiveTran2SearchDir(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t
                 else    
                     curPatchp->flags = 0;
 
-                curPatchp->fid.cell = scp->fid.cell;
-                curPatchp->fid.volume = scp->fid.volume;
-                curPatchp->fid.vnode = ntohl(dep->fid.vnode);
-                curPatchp->fid.unique = ntohl(dep->fid.unique);
+                cm_SetFid(&curPatchp->fid, scp->fid.cell, scp->fid.volume, ntohl(dep->fid.vnode), ntohl(dep->fid.unique));
 
                 /* temp */
                 curPatchp->dep = dep;