#include <afsconfig.h>
#include "afs/param.h"
-RCSID
- ("$Header$");
#include "afs/sysincludes.h" /* Standard vendor system headers */
#include "afsincludes.h" /* Afs-based standard headers */
extern char afs_zeros[AFS_ZEROS];
-afs_int32 maxIHint;
-afs_int32 nihints; /* # of above actually in-use */
-afs_int32 usedihint;
-
-
/* Imported variables */
extern afs_rwlock_t afs_xdcache;
extern unsigned char *afs_indexFlags;
/* Forward declarations */
void afs_PrefetchChunk(struct vcache *avc, struct dcache *adc,
- struct AFS_UCRED *acred, struct vrequest *areq);
+ afs_ucred_t *acred, struct vrequest *areq);
int
-afs_MemRead(register struct vcache *avc, struct uio *auio,
- struct AFS_UCRED *acred, daddr_t albn, struct buf **abpp,
+afs_MemRead(struct vcache *avc, struct uio *auio,
+ afs_ucred_t *acred, daddr_t albn, struct buf **abpp,
int noLock)
{
afs_size_t totalLength;
afs_Trace4(afs_iclSetp, CM_TRACE_READ, ICL_TYPE_POINTER, avc,
ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(filePos), ICL_TYPE_INT32,
totalLength, ICL_TYPE_OFFSET,
- ICL_HANDLE_OFFSET(avc->m.Length));
+ ICL_HANDLE_OFFSET(avc->f.m.Length));
error = 0;
transferLength = 0;
if (!noLock)
ObtainReadLock(&avc->lock);
#if defined(AFS_TEXT_ENV) && !defined(AFS_VM_RDWR_ENV)
if (avc->flushDV.high == AFS_MAXDV && avc->flushDV.low == AFS_MAXDV) {
- hset(avc->flushDV, avc->m.DataVersion);
+ hset(avc->flushDV, avc->f.m.DataVersion);
}
#endif
* Locks held:
* avc->lock(R)
*/
- if (filePos >= avc->m.Length) {
+ if (filePos >= avc->f.m.Length) {
if (len > AFS_ZEROS)
len = sizeof(afs_zeros); /* and in 0 buffer */
len = 0;
AFS_UIOMOVE(afs_zeros, trimlen, UIO_READ, tuiop, code);
}
- while (avc->m.Length > 0 && totalLength > 0) {
+ while (avc->f.m.Length > 0 && totalLength > 0) {
/* read all of the cached info */
- if (filePos >= avc->m.Length)
+ if (filePos >= avc->f.m.Length)
break; /* all done */
if (noLock) {
if (tdc) {
* 2 requests never return a null dcache entry, btw.
*/
if (!(tdc->dflags & DFFetching)
- && !hsame(avc->m.DataVersion, tdc->f.versionNo)) {
+ && !hsame(avc->f.m.DataVersion, tdc->f.versionNo)) {
/* have cache entry, it is not coming in now,
* and we'll need new data */
tagain:
tdc->mflags |= DFFetchReq;
bp = afs_BQueue(BOP_FETCH, avc, B_DONTWAIT, 0, acred,
(afs_size_t) filePos, (afs_size_t) 0,
- tdc);
+ tdc, (void *)0, (void *)0);
if (!bp) {
tdc->mflags &= ~DFFetchReq;
trybusy = 0; /* Avoid bkg daemon since they're too busy */
} else {
/* no longer fetching, verify data version
* (avoid new GetDCache call) */
- if (hsame(avc->m.DataVersion, tdc->f.versionNo)
+ if (hsame(avc->f.m.DataVersion, tdc->f.versionNo)
&& ((len = tdc->validPos - filePos) > 0)) {
offset = filePos - AFS_CHUNKTOBASE(tdc->f.chunk);
} else {
/* don't have current data, so get it below */
afs_Trace3(afs_iclSetp, CM_TRACE_VERSIONNO,
ICL_TYPE_INT64, ICL_HANDLE_OFFSET(filePos),
- ICL_TYPE_HYPER, &avc->m.DataVersion,
+ ICL_TYPE_HYPER, &avc->f.m.DataVersion,
ICL_TYPE_HYPER, &tdc->f.versionNo);
ReleaseReadLock(&tdc->lock);
afs_PutDCache(tdc);
len = AFS_CHUNKTOSIZE(tdc->f.chunk) - offset; /* bytes left in chunk addr space */
if (len > totalLength)
len = totalLength; /* and still within xfr request */
- tlen = avc->m.Length - offset; /* and still within file */
+ tlen = avc->f.m.Length - offset; /* and still within file */
if (len > tlen)
len = tlen;
if (len > AFS_ZEROS)
tuio.afsio_offset = offset;
#endif
- code = afs_MemReadUIO(tdc->f.inode, tuiop);
+ code = afs_MemReadUIO(&tdc->f.inode, tuiop);
if (code) {
error = code;
*/
void
afs_PrefetchChunk(struct vcache *avc, struct dcache *adc,
- struct AFS_UCRED *acred, struct vrequest *areq)
+ afs_ucred_t *acred, struct vrequest *areq)
{
- register struct dcache *tdc;
+ struct dcache *tdc;
afs_size_t offset;
afs_size_t j1, j2; /* junk vbls for GetDCache to trash */
offset = AFS_CHUNKTOBASE(offset); /* base of next chunk */
ObtainReadLock(&adc->lock);
ObtainSharedLock(&adc->mflock, 662);
- if (offset < avc->m.Length && !(adc->mflags & DFNextStarted)
+ if (offset < avc->f.m.Length && !(adc->mflags & DFNextStarted)
&& !afs_BBusy()) {
struct brequest *bp;
ReleaseReadLock(&adc->lock);
tdc = afs_GetDCache(avc, offset, areq, &j1, &j2, 2); /* type 2 never returns 0 */
-#ifdef AFS_DISCON_ENV
/*
* In disconnected mode, type 2 can return 0 because it doesn't
* make any sense to allocate a dcache we can never fill
*/
if (tdc == NULL)
return;
-#endif /* AFS_DISCON_ENV */
ObtainSharedLock(&tdc->mflock, 651);
if (!(tdc->mflags & DFFetchReq)) {
* since we don't want to wait for it to finish before doing so ourselves.
*/
bp = afs_BQueue(BOP_FETCH, avc, B_DONTWAIT, 0, acred,
- (afs_size_t) offset, (afs_size_t) 1, tdc);
+ (afs_size_t) offset, (afs_size_t) 1, tdc,
+ (void *)0, (void *)0);
if (!bp) {
/* Bkg table full; just abort non-important prefetching to avoid deadlocks */
tdc->mflags &= ~DFFetchReq;
}
int
-afs_UFSRead(register struct vcache *avc, struct uio *auio,
- struct AFS_UCRED *acred, daddr_t albn, struct buf **abpp,
+afs_UFSRead(struct vcache *avc, struct uio *auio,
+ afs_ucred_t *acred, daddr_t albn, struct buf **abpp,
int noLock)
{
afs_size_t totalLength;
afs_Trace4(afs_iclSetp, CM_TRACE_READ, ICL_TYPE_POINTER, avc,
ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(filePos), ICL_TYPE_INT32,
totalLength, ICL_TYPE_OFFSET,
- ICL_HANDLE_OFFSET(avc->m.Length));
+ ICL_HANDLE_OFFSET(avc->f.m.Length));
error = 0;
transferLength = 0;
if (!noLock)
ObtainReadLock(&avc->lock);
#if defined(AFS_TEXT_ENV) && !defined(AFS_VM_RDWR_ENV)
if (avc->flushDV.high == AFS_MAXDV && avc->flushDV.low == AFS_MAXDV) {
- hset(avc->flushDV, avc->m.DataVersion);
+ hset(avc->flushDV, avc->f.m.DataVersion);
}
#endif
- if (filePos >= avc->m.Length) {
+ if (filePos >= avc->f.m.Length) {
if (len > AFS_ZEROS)
len = sizeof(afs_zeros); /* and in 0 buffer */
len = 0;
AFS_UIOMOVE(afs_zeros, trimlen, UIO_READ, tuiop, code);
}
- while (avc->m.Length > 0 && totalLength > 0) {
+ while (avc->f.m.Length > 0 && totalLength > 0) {
/* read all of the cached info */
- if (filePos >= avc->m.Length)
+ if (filePos >= avc->f.m.Length)
break; /* all done */
if (noLock) {
if (tdc) {
afs_PutDCache(tdc); /* before reusing tdc */
}
tdc = afs_GetDCache(avc, filePos, &treq, &offset, &len, 2);
-#ifdef AFS_DISCON_ENV
if (!tdc) {
- printf("Network down in afs_read");
error = ENETDOWN;
break;
}
-#endif /* AFS_DISCON_ENV */
ObtainReadLock(&tdc->lock);
/* now, first try to start transfer, if we'll need the data. If
* data already coming, we don't need to do this, obviously. Type
* 2 requests never return a null dcache entry, btw. */
if (!(tdc->dflags & DFFetching)
- && !hsame(avc->m.DataVersion, tdc->f.versionNo)) {
+ && !hsame(avc->f.m.DataVersion, tdc->f.versionNo)) {
/* have cache entry, it is not coming in now, and we'll need new data */
tagain:
if (trybusy && !afs_BBusy()) {
tdc->mflags |= DFFetchReq;
bp = afs_BQueue(BOP_FETCH, avc, B_DONTWAIT, 0, acred,
(afs_size_t) filePos, (afs_size_t) 0,
- tdc);
+ tdc, (void *)0, (void *)0);
if (!bp) {
/* Bkg table full; retry deadlocks */
tdc->mflags &= ~DFFetchReq;
} else {
/* no longer fetching, verify data version (avoid new
* GetDCache call) */
- if (hsame(avc->m.DataVersion, tdc->f.versionNo)
+ if (hsame(avc->f.m.DataVersion, tdc->f.versionNo)
&& ((len = tdc->validPos - filePos) > 0)) {
offset = filePos - AFS_CHUNKTOBASE(tdc->f.chunk);
} else {
/* don't have current data, so get it below */
afs_Trace3(afs_iclSetp, CM_TRACE_VERSIONNO,
ICL_TYPE_INT64, ICL_HANDLE_OFFSET(filePos),
- ICL_TYPE_HYPER, &avc->m.DataVersion,
+ ICL_TYPE_HYPER, &avc->f.m.DataVersion,
ICL_TYPE_HYPER, &tdc->f.versionNo);
ReleaseReadLock(&tdc->lock);
afs_PutDCache(tdc);
len = AFS_CHUNKTOSIZE(tdc->f.chunk) - offset; /* bytes left in chunk addr space */
if (len > totalLength)
len = totalLength; /* and still within xfr request */
- tlen = avc->m.Length - offset; /* and still within file */
+ tlen = avc->f.m.Length - offset; /* and still within file */
if (len > tlen)
len = tlen;
if (len > AFS_ZEROS)
}
} else {
/* get the data from the file */
-#ifdef IHINT
- if (tfile = tdc->ihint) {
- if (tdc->f.inode != tfile->inum) {
- afs_warn("afs_UFSRead: %x hint mismatch tdc %d inum %d\n",
- tdc, tdc->f.inode, tfile->inum);
- osi_UFSClose(tfile);
- tdc->ihint = tfile = 0;
- nihints--;
- }
- }
- if (tfile != 0) {
- usedihint++;
- } else
-#endif /* IHINT */
-
- tfile = (struct osi_file *)osi_UFSOpen(tdc->f.inode);
+ tfile = (struct osi_file *)osi_UFSOpen(&tdc->f.inode);
#ifdef AFS_DARWIN80_ENV
trimlen = len;
tuiop = afsio_darwin_partialcopy(auio, trimlen);
code);
AFS_VOP_RWUNLOCK(tfile->vnode, VRWLOCK_READ);
AFS_GLOCK();
-#elif defined(AFS_OSF_ENV)
- tuio.uio_rw = UIO_READ;
- AFS_GUNLOCK();
- VOP_READ(tfile->vnode, &tuio, 0, afs_osi_credp, code);
- AFS_GLOCK();
#elif defined(AFS_HPUX100_ENV)
AFS_GUNLOCK();
code = VOP_RDWR(tfile->vnode, &tuio, UIO_READ, 0, afs_osi_credp);
code = VOP_READ(tfile->vnode, &tuio, 0, afs_osi_credp);
VOP_UNLOCK(tfile->vnode, 0);
AFS_GLOCK();
-#elif defined(AFS_FBSD50_ENV)
+#elif defined(AFS_FBSD_ENV)
AFS_GUNLOCK();
VOP_LOCK(tfile->vnode, LK_EXCLUSIVE, curthread);
code = VOP_READ(tfile->vnode, &tuio, 0, afs_osi_credp);
VOP_UNLOCK(tfile->vnode, 0, curthread);
AFS_GLOCK();
+#elif defined(AFS_NBSD_ENV)
+ AFS_GUNLOCK();
+ VOP_LOCK(tfile->vnode, LK_EXCLUSIVE);
+ code = VOP_READ(tfile->vnode, &tuio, 0, afs_osi_credp);
+ VOP_UNLOCK(tfile->vnode, 0);
+ AFS_GLOCK();
+
#elif defined(AFS_XBSD_ENV)
AFS_GUNLOCK();
VOP_LOCK(tfile->vnode, LK_EXCLUSIVE, curproc);
#else
code = VOP_RDWR(tfile->vnode, &tuio, UIO_READ, 0, afs_osi_credp);
#endif
-
-#ifdef IHINT
- if (!tdc->ihint && nihints < maxIHint) {
- tdc->ihint = tfile;
- nihints++;
- } else
-#endif /* IHINT */
- osi_UFSClose(tfile);
+ osi_UFSClose(tfile);
if (code) {
error = code;