linux-execsorwrites-at-close-20030328

FIXES 1215

fixes bad interaction with openmosix

comment from derrick: i'm still not sure what's going on here.

====================
This delta was composed from multiple commits as part of the CVS->Git migration.
The checkin message with each commit was inconsistent.
The following are the additional commit messages.
====================
FIXES 1215

fixes bad interaction with openmosix
somehow diff screwed up the first time and applied one hunk wrong.

comment from derrick: i'm still not sure what's going on here.
This commit is contained in:
Onime Ehimika Ohireime 2003-03-28 17:41:04 +00:00 committed by Derrick Brashear
parent 73b4283116
commit 20e15449ae

View File

@ -431,6 +431,7 @@ void afs_linux_vma_close(struct vm_area_struct *vmap)
{
struct vcache *vcp;
cred_t *credp;
int need_unlock = 0;
if (!vmap->vm_file)
return;
@ -445,24 +446,38 @@ void afs_linux_vma_close(struct vm_area_struct *vmap)
ICL_TYPE_INT32, vcp->mapcnt,
ICL_TYPE_INT32, vcp->opens,
ICL_TYPE_INT32, vcp->execsOrWriters);
ObtainWriteLock(&vcp->lock, 532);
if ((&vcp->lock)->excl_locked == 0 || (&vcp->lock)->pid_writer == MyPidxx) {
ObtainWriteLock(&vcp->lock, 532);
need_unlock = 1;
} else
printk("AFS_VMA_CLOSE(%d): Skipping Already locked vcp=%p vmap=%p\n", MyPidxx, &vcp, &vmap);
if (vcp->mapcnt) {
vcp->mapcnt--;
ReleaseWriteLock(&vcp->lock);
if (need_unlock)
ReleaseWriteLock(&vcp->lock);
if (!vcp->mapcnt) {
credp = crref();
(void) afs_close(vcp, vmap->vm_file->f_flags, credp);
/* only decrement the execsOrWriters flag if this is not a writable
* file. */
if (! (vmap->vm_file->f_flags & (FWRITE | FTRUNC)))
if(need_unlock && vcp->execsOrWriters < 2) {
credp = crref();
(void) afs_close(vcp, vmap->vm_file->f_flags, credp);
/* only decrement the execsOrWriters flag if this is not a
writable file. */
if (! (vmap->vm_file->f_flags & (FWRITE | FTRUNC)))
vcp->execsOrWriters--;
vcp->states &= ~CMAPPED;
crfree(credp);
} else if ((vmap->vm_file->f_flags & (FWRITE | FTRUNC)))
vcp->execsOrWriters--;
vcp->states &= ~CMAPPED;
crfree(credp);
/* If we did not have the lock */
if (!need_unlock) {
vcp->mapcnt++;
if (!vcp->execsOrWriters)
vcp->execsOrWriters = 1;
}
}
}
else {
ReleaseWriteLock(&vcp->lock);
if (need_unlock)
ReleaseWriteLock(&vcp->lock);
}
unlock_exit: