]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE14-linux-dont-flush-writes-on-exec-20080326
authorChas Williams <chas@cmf.nrl.navy.mil>
Wed, 26 Mar 2008 04:17:32 +0000 (04:17 +0000)
committerDerrick Brashear <shadow@dementia.org>
Wed, 26 Mar 2008 04:17:32 +0000 (04:17 +0000)
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

index dfc8b581df24c2e8827e9fa76927dec98432cf99..39569462788315243a01d59f1be471a8ca60c98b 100644 (file)
@@ -564,18 +564,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);