#endif
int
-osi_Active(register struct vcache *avc)
+osi_Active(struct vcache *avc)
{
AFS_STATCNT(osi_Active);
-#if defined(AFS_AIX_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SUN5_ENV) || (AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) || (AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
if ((avc->opens > 0) || (avc->f.states & CMAPPED))
return 1; /* XXX: Warning, verify this XXX */
#elif defined(AFS_SGI_ENV)
us, of course).
*/
void
-osi_FlushPages(register struct vcache *avc, AFS_UCRED *credp)
+osi_FlushPages(struct vcache *avc, afs_ucred_t *credp)
{
-#ifdef AFS_FBSD70_ENV
- int vfslocked;
-#endif
afs_hyper_t origDV;
#if defined(AFS_CACHE_BYPASS)
- /* The optimization to check DV under read lock below is identical a
- * change in CITI cache bypass work. The problem CITI found in 1999
- * was that this code and background daemon doing prefetching competed
- * for the vcache entry shared lock. It's not clear to me from the
+ /* The optimization to check DV under read lock below is identical a
+ * change in CITI cache bypass work. The problem CITI found in 1999
+ * was that this code and background daemon doing prefetching competed
+ * for the vcache entry shared lock. It's not clear to me from the
* tech report, but it looks like CITI fixed the general prefetch code
* path as a bonus when experimenting on prefetch for cache bypass, see
* citi-tr-01-3.
*/
-#endif
+#endif
+ if (vType(avc) == VDIR) {
+ /* not applicable to directories; they're never mapped or stored in
+ * pages */
+ return;
+ }
ObtainReadLock(&avc->lock);
/* If we've already purged this version, or if we're the ones
* writing this version, don't flush it (could lose the
ReleaseWriteLock(&avc->lock);
return;
}
- if (hiszero(avc->mapDV)) {
- hset(avc->mapDV, avc->f.m.DataVersion);
- ReleaseWriteLock(&avc->lock);
- return;
- }
+
+ /* At this point, you might think that we can skip trying to flush pages
+ * if mapDV is zero, since a file with a zero DV will not have any data in
+ * it. However, some platforms (notably Linux 2.6.22+) will keep a page
+ * full of zeroes around for an empty file. So play it safe and always
+ * flush pages. */
AFS_STATCNT(osi_FlushPages);
hset(origDV, avc->f.m.DataVersion);
ICL_TYPE_INT32, origDV.low, ICL_TYPE_INT32, avc->f.m.Length);
ReleaseWriteLock(&avc->lock);
-#ifdef AFS_FBSD70_ENV
- vfslocked = VFS_LOCK_GIANT(AFSTOV(avc)->v_mount);
-#endif
-#ifndef AFS_FBSD70_ENV
AFS_GUNLOCK();
-#endif
osi_VM_FlushPages(avc, credp);
-#ifndef AFS_FBSD70_ENV
AFS_GLOCK();
-#endif
-#ifdef AFS_FBSD70_ENV
- VFS_UNLOCK_GIANT(vfslocked);
-#endif
ObtainWriteLock(&avc->lock, 88);
/* do this last, and to original version, since stores may occur
* it is written to the file system. */
void
-osi_FlushText_really(register struct vcache *vp)
+osi_FlushText_really(struct vcache *vp)
{
afs_hyper_t fdv; /* version before which we'll flush */
if (hcmp(vp->f.m.DataVersion, vp->flushDV) <= 0)
return;
- MObtainWriteLock(&afs_ftf, 317);
+ ObtainWriteLock(&afs_ftf, 317);
hset(fdv, vp->f.m.DataVersion);
/* why this disgusting code below?
xrele(vp);
if (vp->v.v_flag & VTEXT) { /* still has a text object? */
- MReleaseWriteLock(&afs_ftf);
+ ReleaseWriteLock(&afs_ftf);
return;
}
}
/* finally, record that we've done it */
hset(vp->flushDV, fdv);
- MReleaseWriteLock(&afs_ftf);
+ ReleaseWriteLock(&afs_ftf);
}
#endif /* AFS_TEXT_ENV */
-/* ? is it moderately likely that there are dirty VM pages associated with
- * this vnode?
- *
- * Prereqs: avc must be write-locked
- *
- * System Dependencies: - *must* support each type of system for which
- * memory mapped files are supported, even if all
- * it does is return TRUE;
- *
- * NB: this routine should err on the side of caution for ProcessFS to work
- * correctly (or at least, not to introduce worse bugs than already exist)
- */
-#ifdef notdef
-int
-osi_VMDirty_p(struct vcache *avc)
-{
- int dirtyPages;
-
- if (avc->execsOrWriters <= 0)
- return 0; /* can't be many dirty pages here, I guess */
-
-#if defined (AFS_AIX32_ENV)
-#ifdef notdef
- /* because of the level of hardware involvment with VM and all the
- * warnings about "This routine must be called at VMM interrupt
- * level", I thought it would be safest to disable interrupts while
- * looking at the software page fault table. */
-
- /* convert vm handle into index into array: I think that stoinio is
- * always zero... Look into this XXX */
-#define VMHASH(handle) ( \
- ( ((handle) & ~vmker.stoinio) \
- ^ ((((handle) & ~vmker.stoinio) & vmker.stoimask) << vmker.stoihash) \
- ) & 0x000fffff)
-
- if (avc->segid) {
- unsigned int pagef, pri, index, next;
-
- index = VMHASH(avc->segid);
- if (scb_valid(index)) { /* could almost be an ASSERT */
-
- pri = disable_ints();
- for (pagef = scb_sidlist(index); pagef >= 0; pagef = next) {
- next = pft_sidfwd(pagef);
- if (pft_modbit(pagef)) { /* has page frame been modified? */
- enable_ints(pri);
- return 1;
- }
- }
- enable_ints(pri);
- }
- }
-#undef VMHASH
-#endif
-#endif /* AFS_AIX32_ENV */
-
-#if defined (AFS_SUN5_ENV)
- if (avc->f.states & CMAPPED) {
- struct page *pg;
- for (pg = avc->v.v_s.v_Pages; pg; pg = pg->p_vpnext) {
- if (pg->p_mod) {
- return 1;
- }
- }
- }
-#endif
- return 0;
-}
-#endif /* notdef */
-
-
/*
* Solaris osi_ReleaseVM should not drop and re-obtain the vcache entry lock.
* This leads to bad races when osi_ReleaseVM() is called from
* Locking: the vcache entry lock is held. It is dropped and re-obtained.
*/
void
-osi_ReleaseVM(struct vcache *avc, AFS_UCRED *acred)
+osi_ReleaseVM(struct vcache *avc, afs_ucred_t *acred)
{
#ifdef AFS_SUN5_ENV
AFS_GUNLOCK();