#include <afsconfig.h>
#include "afs/param.h"
-RCSID
- ("$Header$");
#include "afs/sysincludes.h" /*Standard vendor system headers */
#include "afsincludes.h" /*AFS-based standard headers */
afs_int32 afs_discardDCCount; /*!< Count of elts in discardDCList */
struct dcache *afs_freeDSList; /*!< Free list for disk slots */
struct dcache *afs_Initial_freeDSList; /*!< Initial list for above */
-#if defined(LINUX_USE_FH)
-struct fid cacheitems_fh;
-int cacheitems_fh_type;
-#else
-ino_t cacheInode; /*!< Inode for CacheItems file */
-#endif
+afs_dcache_id_t cacheInode; /*!< Inode for CacheItems file */
struct osi_file *afs_cacheInodep = 0; /*!< file for CacheItems inode */
struct afs_q afs_DLRU; /*!< dcache LRU */
afs_int32 afs_dhashsize = 1024;
afs_size_t *);
struct afs_cacheOps afs_UfsCacheOps = {
-#if defined(LINUX_USE_FH)
- osi_UFSOpen_fh,
-#else
osi_UFSOpen,
-#endif
osi_UFSTruncate,
afs_osi_Read,
afs_osi_Write,
/*
* Truncate the element to reclaim its space
*/
-#if defined(LINUX_USE_FH)
- tfile = afs_CFileOpen(&tdc->f.fh, tdc->f.fh_type);
-#else
- tfile = afs_CFileOpen(tdc->f.inode);
-#endif
+ tfile = afs_CFileOpen(&tdc->f.inode);
afs_CFileTruncate(tfile, 0);
afs_CFileClose(tfile);
afs_AdjustSize(tdc, 0);
/*
- * afs_UFSCacheStoreProc
- *
- * Description:
- * Called upon store.
- *
- * Parameters:
- * acall : Ptr to the Rx call structure involved.
- * afile : Ptr to the related file descriptor.
- * alen : Size of the file in bytes.
- * avc : Ptr to the vcache entry.
- * shouldWake : is it "safe" to return early from close() ?
- * abytesToXferP : Set to the number of bytes to xfer.
- * NOTE: This parameter is only used if AFS_NOSTATS
- * is not defined.
- * abytesXferredP : Set to the number of bytes actually xferred.
- * NOTE: This parameter is only used if AFS_NOSTATS
- * is not defined.
- *
- * Environment:
- * Nothing interesting.
- */
-static int
-afs_UFSCacheStoreProc(register struct rx_call *acall, struct osi_file *afile,
- register afs_int32 alen, struct vcache *avc,
- int *shouldWake, afs_size_t * abytesToXferP,
- afs_size_t * abytesXferredP)
-{
- afs_int32 code, got;
- register char *tbuffer;
- register int tlen;
-
- AFS_STATCNT(UFS_CacheStoreProc);
-
-#ifndef AFS_NOSTATS
- /*
- * In this case, alen is *always* the amount of data we'll be trying
- * to ship here.
- */
- (*abytesToXferP) = alen;
- (*abytesXferredP) = 0;
-#endif /* AFS_NOSTATS */
-
- afs_Trace4(afs_iclSetp, CM_TRACE_STOREPROC, ICL_TYPE_POINTER, avc,
- ICL_TYPE_FID, &(avc->f.fid), ICL_TYPE_OFFSET,
- ICL_HANDLE_OFFSET(avc->f.m.Length), ICL_TYPE_INT32, alen);
- tbuffer = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
- while (alen > 0) {
- tlen = (alen > AFS_LRALLOCSIZ ? AFS_LRALLOCSIZ : alen);
- got = afs_osi_Read(afile, -1, tbuffer, tlen);
- if ((got < 0)
-#if defined(KERNEL_HAVE_UERROR)
- || (got != tlen && getuerror())
-#endif
- ) {
- osi_FreeLargeSpace(tbuffer);
- return EIO;
- }
- afs_Trace2(afs_iclSetp, CM_TRACE_STOREPROC2, ICL_TYPE_OFFSET,
- ICL_HANDLE_OFFSET(*tbuffer), ICL_TYPE_INT32, got);
- RX_AFS_GUNLOCK();
- code = rx_Write(acall, tbuffer, got); /* writing 0 bytes will
- * push a short packet. Is that really what we want, just because the
- * data didn't come back from the disk yet? Let's try it and see. */
- RX_AFS_GLOCK();
-#ifndef AFS_NOSTATS
- (*abytesXferredP) += code;
-#endif /* AFS_NOSTATS */
- if (code != got) {
- code = rx_Error(acall);
- osi_FreeLargeSpace(tbuffer);
- return code ? code : -33;
- }
- alen -= got;
- /*
- * If file has been locked on server, we can allow the store
- * to continue.
- */
- if (shouldWake && *shouldWake && (rx_GetRemoteStatus(acall) & 1)) {
- *shouldWake = 0; /* only do this once */
- afs_wakeup(avc);
- }
- }
- afs_Trace4(afs_iclSetp, CM_TRACE_STOREPROC, ICL_TYPE_POINTER, avc,
- ICL_TYPE_FID, &(avc->f.fid), ICL_TYPE_OFFSET,
- ICL_HANDLE_OFFSET(avc->f.m.Length), ICL_TYPE_INT32, alen);
- osi_FreeLargeSpace(tbuffer);
- return 0;
-
-} /* afs_UFSCacheStoreProc */
-
-
-/*
- * afs_UFSCacheFetchProc
- *
- * Description:
- * Routine called on fetch; also tells people waiting for data
- * that more has arrived.
- *
- * Parameters:
- * acall : Ptr to the Rx call structure.
- * afile : File descriptor for the cache file.
- * abase : Base offset to fetch.
- * adc : Ptr to the dcache entry for the file, write-locked.
- * avc : Ptr to the vcache entry for the file.
- * abytesToXferP : Set to the number of bytes to xfer.
- * NOTE: This parameter is only used if AFS_NOSTATS
- * is not defined.
- * abytesXferredP : Set to the number of bytes actually xferred.
- * NOTE: This parameter is only used if AFS_NOSTATS
- * is not defined.
- *
- * Environment:
- * Nothing interesting.
- */
-
-static int
-afs_UFSCacheFetchProc(register struct rx_call *acall, struct osi_file *afile,
- afs_size_t abase, struct dcache *adc,
- struct vcache *avc, afs_size_t * abytesToXferP,
- afs_size_t * abytesXferredP, afs_int32 lengthFound)
-{
- afs_int32 length;
- register afs_int32 code;
- register char *tbuffer;
- register int tlen;
- int moredata = 0;
-
- AFS_STATCNT(UFS_CacheFetchProc);
- osi_Assert(WriteLocked(&adc->lock));
- afile->offset = 0; /* Each time start from the beginning */
- length = lengthFound;
-#ifndef AFS_NOSTATS
- (*abytesToXferP) = 0;
- (*abytesXferredP) = 0;
-#endif /* AFS_NOSTATS */
- tbuffer = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
- adc->validPos = abase;
- do {
- if (moredata) {
- RX_AFS_GUNLOCK();
- code = rx_Read(acall, (char *)&length, sizeof(afs_int32));
- RX_AFS_GLOCK();
- length = ntohl(length);
- if (code != sizeof(afs_int32)) {
- osi_FreeLargeSpace(tbuffer);
- code = rx_Error(acall);
- return (code ? code : -1); /* try to return code, not -1 */
- }
- }
- /*
- * The fetch protocol is extended for the AFS/DFS translator
- * to allow multiple blocks of data, each with its own length,
- * to be returned. As long as the top bit is set, there are more
- * blocks expected.
- *
- * We do not do this for AFS file servers because they sometimes
- * return large negative numbers as the transfer size.
- */
- if (avc->f.states & CForeign) {
- moredata = length & 0x80000000;
- length &= ~0x80000000;
- } else {
- moredata = 0;
- }
-#ifndef AFS_NOSTATS
- (*abytesToXferP) += length;
-#endif /* AFS_NOSTATS */
- while (length > 0) {
- tlen = (length > AFS_LRALLOCSIZ ? AFS_LRALLOCSIZ : length);
-#ifdef RX_KERNEL_TRACE
- afs_Trace1(afs_iclSetp, CM_TRACE_TIMESTAMP, ICL_TYPE_STRING,
- "before rx_Read");
-#endif
- RX_AFS_GUNLOCK();
- code = rx_Read(acall, tbuffer, tlen);
- RX_AFS_GLOCK();
-#ifdef RX_KERNEL_TRACE
- afs_Trace1(afs_iclSetp, CM_TRACE_TIMESTAMP, ICL_TYPE_STRING,
- "after rx_Read");
-#endif
-#ifndef AFS_NOSTATS
- (*abytesXferredP) += code;
-#endif /* AFS_NOSTATS */
- if (code != tlen) {
- osi_FreeLargeSpace(tbuffer);
- afs_Trace3(afs_iclSetp, CM_TRACE_FETCH64READ,
- ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, code,
- ICL_TYPE_INT32, length);
- return -34;
- }
- code = afs_osi_Write(afile, -1, tbuffer, tlen);
- if (code != tlen) {
- osi_FreeLargeSpace(tbuffer);
- return EIO;
- }
- abase += tlen;
- length -= tlen;
- adc->validPos = abase;
- if (afs_osi_Wakeup(&adc->validPos) == 0)
- afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAKE, ICL_TYPE_STRING,
- __FILE__, ICL_TYPE_INT32, __LINE__,
- ICL_TYPE_POINTER, adc, ICL_TYPE_INT32,
- adc->dflags);
- }
- } while (moredata);
- osi_FreeLargeSpace(tbuffer);
- return 0;
-
-} /* afs_UFSCacheFetchProc */
-
/*!
* Get a fresh dcache from the free or discarded list.
*
afs_stats_cmperf.cacheBlocksDiscarded = afs_blocksDiscarded;
if (lock & 2) {
/* Truncate the chunk so zeroes get filled properly */
-#if defined(LINUX_USE_FH)
- file = afs_CFileOpen(&tdc->f.fh, tdc->f.fh_type);
-#else
- file = afs_CFileOpen(tdc->f.inode);
-#endif
+ file = afs_CFileOpen(&tdc->f.inode);
afs_CFileTruncate(file, 0);
afs_CFileClose(file);
afs_AdjustSize(tdc, 0);
if (doReallyAdjustSize || overWriteWholeChunk) {
/* no data in file to read at this position */
UpgradeSToWLock(&tdc->lock, 607);
-
-#if defined(LINUX_USE_FH)
- file = afs_CFileOpen(&tdc->f.fh, tdc->f.fh_type);
-#else
- file = afs_CFileOpen(tdc->f.inode);
-#endif
+ file = afs_CFileOpen(&tdc->f.inode);
afs_CFileTruncate(file, 0);
afs_CFileClose(file);
afs_AdjustSize(tdc, 0);
* fetch the whole file.
*/
DZap(tdc); /* pages in cache may be old */
-#if defined(LINUX_USE_FH)
- file = afs_CFileOpen(&tdc->f.fh, tdc->f.fh_type);
-#else
- file = afs_CFileOpen(tdc->f.inode);
-#endif
+ file = afs_CFileOpen(&tdc->f.inode);
afs_RemoveVCB(&avc->f.fid);
tdc->f.states |= DWriting;
tdc->dflags |= DFFetching;
tc = afs_Conn(&avc->f.fid, areq, SHARED_LOCK);
if (tc) {
- afs_int32 length_hi, length, bytes;
+#ifdef AFS_64BIT_CLIENT
+ afs_int32 length_hi;
+#endif
+ afs_int32 length, bytes;
#ifndef AFS_NOSTATS
numFetchLoops++;
if (fromReplica)
*/
osi_Assert(!setLocks || slowPass);
}
- tdc->f.states &= ~(DRO|DBackup|DRW);
- afs_DCMoveBucket(tdc, 0, 0);
tdc = NULL;
goto done;
}
tdc->f.fid.Fid.Volume = 0;
tdc->f.chunk = -1;
hones(tdc->f.versionNo);
- tdc->f.inode = aslot;
+ tdc->f.inode.mem = aslot;
tdc->dflags |= DFEntryMod;
tdc->refCount = 1;
tdc->index = aslot;
afs_InitCacheFile(char *afile, ino_t ainode)
{
register afs_int32 code;
-#if defined(AFS_LINUX22_ENV)
- struct dentry *filevp;
-#else
- struct vnode *filevp;
-#endif
afs_int32 index;
int fileIsBad;
struct osi_file *tfile;
struct osi_stat tstat;
register struct dcache *tdc;
-#if defined(LINUX_USE_FH)
- int max_len = sizeof(struct fid);
-#endif
AFS_STATCNT(afs_InitCacheFile);
index = afs_stats_cmperf.cacheNumEntries;
ObtainWriteLock(&tdc->lock, 621);
MObtainWriteLock(&afs_xdcache, 622);
if (afile) {
- code = gop_lookupname(afile, AFS_UIOSYS, 0, &filevp);
+ code = afs_LookupInodeByPath(afile, &tdc->f.inode.ufs, NULL);
if (code) {
ReleaseWriteLock(&afs_xdcache);
ReleaseWriteLock(&tdc->lock);
afs_PutDCache(tdc);
return code;
}
- /*
- * We have a VN_HOLD on filevp. Get the useful info out and
- * return. We make use of the fact that the cache is in the
- * UFS file system, and just record the inode number.
- */
-#ifdef AFS_LINUX22_ENV
-#if defined(LINUX_USE_FH)
- tdc->f.fh_type = osi_get_fh(filevp, &tdc->f.fh, &max_len);
+ } else {
+ /* Add any other 'complex' inode types here ... */
+#if defined(UKERNEL) || !defined(LINUX_USE_FH)
+ tdc->f.inode.ufs = ainode;
#else
- tdc->f.inode = VTOI(filevp->d_inode)->i_number;
- dput(filevp);
+ osi_Panic("Can't init cache with inode numbers when complex inodes are "
+ "in use\n");
#endif
-#else
- tdc->f.inode = afs_vnodeToInumber(filevp);
- AFS_RELE(filevp);
-#endif /* AFS_LINUX22_ENV */
- } else {
- tdc->f.inode = ainode;
}
fileIsBad = 0;
if ((tdc->f.states & DWriting) || tdc->f.fid.Fid.Volume == 0)
fileIsBad = 1;
-#if defined(LINUX_USE_FH)
- tfile = osi_UFSOpen_fh(&tdc->f.fh, tdc->f.fh_type);
-#else
- tfile = osi_UFSOpen(tdc->f.inode);
-#endif
+ tfile = osi_UFSOpen(&tdc->f.inode);
code = afs_osi_Stat(tfile, &tstat);
if (code)
osi_Panic("initcachefile stat");
struct osi_file *tfile_src, *tfile_dst;
struct VenusFid shadow_fid;
char *data;
- int lock_held = 0;
/* Is this a dir? */
if (vType(avc) != VDIR)
}
/* Open the files. */
- tfile_src = afs_CFileOpen(adc->f.inode);
- tfile_dst = afs_CFileOpen(new_dc->f.inode);
+ tfile_src = afs_CFileOpen(&adc->f.inode);
+ tfile_dst = afs_CFileOpen(&new_dc->f.inode);
/* And now copy dir dcache data into this dcache,
* 4k at a time.