int
osi_VM_FlushVCache(struct vcache *avc, int *slept)
{
- struct inode *ip = AFSTOI(avc);
+ struct inode *ip = AFSTOV(avc);
- if (VREFCOUNT(avc) != 0)
+ if (VREFCOUNT(avc) > 1)
return EBUSY;
if (avc->opens != 0)
void
osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync)
{
- struct inode *ip = AFSTOI(avc);
+ struct inode *ip = AFSTOV(avc);
#if defined(AFS_LINUX26_ENV)
invalidate_inode_pages(ip->i_mapping);
void
osi_VM_StoreAllSegments(struct vcache *avc)
{
- struct inode *ip = AFSTOI(avc);
+ struct inode *ip = AFSTOV(avc);
+
+ if (!avc->states & CPageWrite)
+ avc->states |= CPageWrite;
+ else
+ return; /* someone already writing */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,5)
/* filemap_fdatasync() only exported in 2.4.5 and above */
AFS_GLOCK();
ObtainWriteLock(&avc->lock, 121);
#endif
+ avc->states &= ~CPageWrite;
}
/* Purge VM for a file when its callback is revoked.
osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
- struct inode *ip = AFSTOI(avc);
+ struct inode *ip = AFSTOV(avc);
truncate_inode_pages(&ip->i_data, 0);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15)
- struct inode *ip = AFSTOI(avc);
+ struct inode *ip = AFSTOV(avc);
truncate_inode_pages(ip, 0);
#else
- invalidate_inode_pages(AFSTOI(avc));
+ invalidate_inode_pages(AFSTOV(avc));
#endif
}
osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
- struct inode *ip = AFSTOI(avc);
+ struct inode *ip = AFSTOV(avc);
truncate_inode_pages(&ip->i_data, alen);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15)
- struct inode *ip = AFSTOI(avc);
+ struct inode *ip = AFSTOV(avc);
truncate_inode_pages(ip, alen);
#else
- invalidate_inode_pages(AFSTOI(avc));
+ invalidate_inode_pages(AFSTOV(avc));
#endif
}