]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
windows-afsd-20080222
authorJeffrey Altman <jaltman@secure-endpoints.com>
Sat, 23 Feb 2008 00:15:22 +0000 (00:15 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Sat, 23 Feb 2008 00:15:22 +0000 (00:15 +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.

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 afe0caa19144af325269f9a8a897fca30c44be53..fb21e5f1c5bd600eead7a3de9b3c855d17b3238b 100644 (file)
@@ -1054,7 +1054,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");
      }
@@ -1351,10 +1351,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 a69d087f0c87bc56a67e8d8249d53cf46449ebae..11f6f0af82ab1b83fe2d247ccc766de581724d58 100644 (file)
@@ -50,10 +50,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;
@@ -171,10 +168,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 16c663d137864e8474c97b0ce346573ec849da2c..33961393abffbae5ed937926154b7a8dee3876b8 100644 (file)
@@ -704,9 +704,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 */
@@ -717,6 +717,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) {
@@ -735,6 +736,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;
@@ -867,6 +869,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
@@ -875,6 +878,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 */
@@ -1507,7 +1511,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);
@@ -1538,7 +1542,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 d604cf18e62f4643e9ae9ccb911a215abceb3621..63e99039ec52097d68a08939b5873c5f8745598e 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 6c4b447d7e28aacc2953ec362ba565b9a719b597..4a076a39d9399d1318294ad2a706bcee9e5e9ac4 100644 (file)
@@ -139,10 +139,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 8fe7dbee85609295558558a0b878d76fa0801aef..3243e3804235fafd7d6177598e3b66914a663d5f 100644 (file)
@@ -695,9 +695,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;
 
@@ -735,7 +733,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;
@@ -748,7 +746,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)
@@ -1090,9 +1088,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 a3e69fe7c8af8f31f31485b13cd16a85f4b17af5..d501255ebb4c83f7c990dd39300e07b5cfd3d616 100644 (file)
@@ -1557,10 +1557,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 78e7dcc91ee0d6b799c83ec36eb679f875f9c0bc..e52ebd46646b1c22240cdbe47f379d8e7aef240c 100644 (file)
@@ -343,10 +343,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;
 }
   
@@ -381,10 +381,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 */
@@ -420,7 +417,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!");
@@ -1072,10 +1069,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;
 }
@@ -1278,10 +1273,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 16a480c9204df3dd1af2037bfefa71626753b10e..13e49fb397d83ba6e58d78eef639e0ac89ced206 100644 (file)
@@ -62,14 +62,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;
 }
@@ -85,7 +83,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);
@@ -93,7 +90,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 1a4d394fabad5da15bbe28139d9c089cdbda33fe..036394f202bcf8f409c47bd6ca6030643fc9af5d 100644 (file)
@@ -178,6 +178,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);
@@ -335,10 +336,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;
@@ -878,9 +890,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);
@@ -901,6 +911,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));
@@ -927,6 +941,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 f353b5d367a59b7c5fdda06860835cd65c054b2d..74337841ce2c5f571e0c6587825e3ab63673fa47 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;
@@ -95,7 +97,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 */
 
@@ -343,6 +345,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 27bcfa49e7af7d90e3cff85863e65af32c46bdb2..fce5e6e7ad5e248ca173da5db46ca58ce156f783 100644 (file)
@@ -339,14 +339,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++) {
@@ -475,18 +476,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++) {
@@ -633,14 +635,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 318886b71775743cd60b9f6f4fb1ed5d65886efa..ebdae21293b96453fb4220eb5320e478620a3b94 100644 (file)
@@ -494,9 +494,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;
 
@@ -730,9 +728,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;
@@ -975,10 +971,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)
@@ -1121,6 +1115,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 
@@ -1131,7 +1127,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
@@ -1156,15 +1152,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;
@@ -1429,6 +1424,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;
 
@@ -1495,18 +1491,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);
 
@@ -1698,9 +1691,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;
@@ -2259,10 +2250,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)) {
@@ -2404,10 +2392,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;
@@ -2765,10 +2750,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);
@@ -2804,9 +2786,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);
 
@@ -2925,10 +2905,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);
@@ -3113,10 +3090,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
@@ -3132,10 +3106,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 9d396d8fdab7655ef039eb7cc5462ee9dcc76642..669ab495880590ce3778c3f29506bbe5141416e1 100644 (file)
@@ -751,6 +751,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));
@@ -1565,10 +1566,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 0a6b07efed657500ec7461b063ac9d5e4d55672b..ac342a4622c92f01e8327776082c44316b5765ec 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 1796ad0db2b04dff17af868bba8a687dc3d1460f..93996f89fe8d63db11a32ceed21baec2fb9c8f47 100644 (file)
@@ -4126,9 +4126,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 
@@ -4261,10 +4259,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),
@@ -4302,10 +4297,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
@@ -6111,9 +6103,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;
@@ -6168,7 +6158,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);
 
@@ -6181,18 +6171,18 @@ long smb_ReadData(smb_fid_t *fidp, osi_hyper_t *offsetp, long count, char *op,
 long smb_WriteData(smb_fid_t *fidp, osi_hyper_t *offsetp, long count, char *op,
        cm_user_t *userp, long *writtenp)
 {
-    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;
@@ -6205,10 +6195,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)) {
@@ -6255,13 +6241,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;
@@ -6292,9 +6285,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);
@@ -6411,6 +6402,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);
@@ -6419,7 +6411,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 */
     }
 
@@ -7392,27 +7385,30 @@ 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();
                LogEvent(EVENTLOG_WARNING_TYPE, MSG_BAD_SMB_WRONG_SESSION, 
                         newTime - oldTime, ncbp->ncb_length);
-               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 aa74dca4604d45ef30d954432de87552a7b95694..72ae0a9c250d6693642a3b9785c2c136c1cc7ccd 100644 (file)
@@ -210,10 +210,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 */
@@ -246,7 +246,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 */
@@ -259,7 +259,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 */
@@ -290,7 +290,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 */
@@ -306,7 +306,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 */
@@ -347,7 +347,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 */
@@ -439,7 +439,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 41ed6fd9079d2812f677c3d3cbb2d6ee77f74809..4dfa3c387304649650b67139abdb2e45e7010424 100644 (file)
@@ -4602,10 +4602,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));
@@ -5027,9 +5024,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
@@ -5169,10 +5164,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);
@@ -5289,10 +5281,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;