From f5e8415f163c5436d0a8264ea9490ab0c10c6b79 Mon Sep 17 00:00:00 2001 From: Chas Williams Date: Wed, 26 Mar 2008 04:17:18 +0000 Subject: [PATCH] DEVEL15-linux-dont-flush-writes-on-exec-20080326 LICENSE IPL10 FIXES 17509 because of when fds are NULL'd in file_table this should work except when one process has the same file open for read and for write in different FDs; otherwise, the last write fd to close collects the error. (cherry picked from commit 1cf6c12a075cb0705cd8680291d78d215d4fe996) --- src/afs/LINUX/osi_vnodeops.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index 674b857c26..8c953fd40f 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -582,18 +582,24 @@ afs_linux_flush(struct file *fp) #endif { struct vrequest treq; - struct vcache *vcp = VTOAFS(FILE_INODE(fp)); - cred_t *credp = crref(); + struct vcache *vcp; + cred_t *credp; int code; AFS_GLOCK(); + if (fp->f_flags | O_RDONLY) /* readers dont flush */ + return 0; + + credp = crref(); + vcp = VTOAFS(FILE_INODE(fp)); + code = afs_InitReq(&treq, credp); if (code) goto out; ObtainSharedLock(&vcp->lock, 535); - if (vcp->execsOrWriters > 0) { + if ((vcp->execsOrWriters > 0) && (file_count(fp) == 1)) { UpgradeSToWLock(&vcp->lock, 536); code = afs_StoreAllSegments(vcp, &treq, AFS_SYNC | AFS_LASTSTORE); ConvertWToSLock(&vcp->lock);