From: Chas Williams Date: Wed, 26 Mar 2008 04:16:51 +0000 (+0000) Subject: linux-dont-flush-writes-on-exec-20080326 X-Git-Tag: openafs-devel-1_5_61~1169 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=1cf6c12a075cb0705cd8680291d78d215d4fe996;hp=3f8be40525ae84980f1519e60f4b9f73bd4cc676 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. --- diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index 16ef9d6..ded2fa7 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);