linux-dont-flush-writes-on-exec-20080326
[openafs.git] / src / afs / LINUX / osi_vnodeops.c
index 93bba1c..ded2fa7 100644 (file)
@@ -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);
@@ -661,6 +667,10 @@ struct file_operations afs_file_fops = {
 #if defined(AFS_LINUX26_ENV) && defined(STRUCT_FILE_OPERATIONS_HAS_SENDFILE)
   .sendfile =   generic_file_sendfile,
 #endif
+#if defined(AFS_LINUX26_ENV) && defined(STRUCT_FILE_OPERATIONS_HAS_SPLICE)
+  .splice_write = generic_file_splice_write,
+  .splice_read = generic_file_splice_read,
+#endif
   .release =   afs_linux_release,
   .fsync =     afs_linux_fsync,
   .lock =      afs_linux_lock,
@@ -966,6 +976,7 @@ afs_linux_create(struct inode *dip, struct dentry *dp, int mode)
 
        afs_getattr(vcp, &vattr, credp);
        afs_fill_inode(ip, &vattr);
+       insert_inode_hash(ip);
        dp->d_op = &afs_dentry_operations;
        dp->d_time = hgetlo(VTOAFS(dip)->m.DataVersion);
        d_instantiate(dp, ip);
@@ -1014,6 +1025,8 @@ afs_linux_lookup(struct inode *dip, struct dentry *dp)
        ip = AFSTOV(vcp);
        afs_getattr(vcp, &vattr, credp);
        afs_fill_inode(ip, &vattr);
+       if (hlist_unhashed(&ip->i_hash))
+           insert_inode_hash(ip);
     }
     dp->d_op = &afs_dentry_operations;
     dp->d_time = hgetlo(VTOAFS(dip)->m.DataVersion);
@@ -1876,5 +1889,4 @@ afs_fill_inode(struct inode *ip, struct vattr *vattr)
 #endif
     }
 
-    /* insert_inode_hash(ip);  -- this would make iget() work (if we used it) */
 }