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");
}
/* 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);
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;
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) {
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);
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() */
*/
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 */
while(1) {
retry:
+ lock_ObtainRead(&scp->bufCreateLock);
lock_ObtainWrite(&buf_globalLock);
/* check to see if we lost the race */
if (scp) {
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;
bp->refCount = 1;
lock_ReleaseWrite(&buf_globalLock);
+ lock_ReleaseRead(&scp->bufCreateLock);
*bufpp = bp;
#ifdef TESTING
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 */
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);
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);
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))))
*/
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 */
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 &&
mxheld = 0;
}
- lock_ObtainRead(&scp->bufCreateLock);
code = buf_Get(scp, &offset, &bp);
- lock_ReleaseRead(&scp->bufCreateLock);
if (code)
break;
/* 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;
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)
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);
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);
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;
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;
}
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 */
}
}
}
- 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!");
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;
}
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;
}
{
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;
}
}
#endif
- lock_ObtainWrite(&scp->bufCreateLock);
code = buf_FlushCleanPages(scp, userp, reqp);
lock_ObtainMutex(&scp->mx);
lock_ReleaseMutex(&scp->mx);
- lock_ReleaseWrite(&scp->bufCreateLock);
osi_Log2(afsd_logp,"cm_FlushFile scp 0x%x returns error: [%x]",scp, code);
return code;
}
#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;
scp->fid.volume = 0;
scp->fid.unique = 0;
scp->fid.cell = 0;
+ scp->fid.hash = 0;
/* remove from dnlc */
cm_dnlcPurgedp(scp);
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;
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);
{
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));
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);
#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;
* 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 */
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);
}
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++) {
}
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++) {
}
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++) {
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;
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;
/* 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)
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
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
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;
cm_cell_t * cellp = NULL;
cm_volume_t * volp = NULL;
cm_fid_t fid;
+ afs_uint32 volume;
int volType;
int mountType = RWVOL;
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);
/* 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;
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)) {
/* 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;
* 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);
{
long code;
- lock_ObtainWrite(&scp->bufCreateLock);
code = buf_CleanVnode(scp, userp, reqp);
- lock_ReleaseWrite(&scp->bufCreateLock);
if (code == 0) {
lock_ObtainMutex(&scp->mx);
* 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);
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
* 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);
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));
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);
}
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;
buf_Release(bufferp);
if (code == 0 && sequential)
- cm_ConsiderPrefetch(scp, &lastByte, userp, &req);
+ cm_ConsiderPrefetch(scp, &lastByte, *readp, userp, &req);
return code;
}
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;
}
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);
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
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),
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
}
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;
buf_Release(bufferp);
if (code == 0 && sequential)
- cm_ConsiderPrefetch(scp, &lastByte, userp, &req);
+ cm_ConsiderPrefetch(scp, &lastByte, *readp, userp, &req);
cm_ReleaseSCache(scp);
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;
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)) {
/* 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;
}
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);
if (code == 0 && doWriteBack) {
long code2;
+
lock_ObtainMutex(&scp->mx);
osi_Log1(smb_logp, "smb_WriteData fid %d calling cm_SyncOp ASYNCSTORE",
fidp->fid);
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 */
}
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 {
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 */
/* 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 */
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 */
/* 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 */
/* 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 */
/* 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 */
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) */
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));
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
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);
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;