Module Name:    src
Committed By:   manu
Date:           Tue Jan 13 16:39:51 UTC 2015

Modified Files:
        src/sys/fs/puffs: puffs_vnops.c

Log Message:
Make sure reads on empty files reach PUFFS filesystems

Sending a read through the page cache will get the operation
short-circuited. This is a problem with some filesystems that
expect to receive the read operation in order to update atime.

We fix that by bypassing the page cache when reading a file
wich a size known to be zero.


To generate a diff of this commit:
cvs rdiff -u -r1.198 -r1.199 src/sys/fs/puffs/puffs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/puffs/puffs_vnops.c
diff -u src/sys/fs/puffs/puffs_vnops.c:1.198 src/sys/fs/puffs/puffs_vnops.c:1.199
--- src/sys/fs/puffs/puffs_vnops.c:1.198	Tue Nov  4 09:14:42 2014
+++ src/sys/fs/puffs/puffs_vnops.c	Tue Jan 13 16:39:51 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: puffs_vnops.c,v 1.198 2014/11/04 09:14:42 manu Exp $	*/
+/*	$NetBSD: puffs_vnops.c,v 1.199 2015/01/13 16:39:51 manu Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006, 2007  Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.198 2014/11/04 09:14:42 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.199 2015/01/13 16:39:51 manu Exp $");
 
 #include <sys/param.h>
 #include <sys/buf.h>
@@ -2279,9 +2279,17 @@ puffs_vnop_read(void *v)
 	if (uio->uio_offset < 0)
 		return EFBIG;
 
+	/*
+	 * On the case of reading empty files and (vp->v_size != 0) below:
+	 * some filesystems (hint: FUSE and distributed filesystems) still
+	 * expect to get the READ in order to update atime. Reading through
+	 * the case filters empty files, therefore we prefer to bypass the
+	 * cache here.
+	 */
 	if (vp->v_type == VREG &&
 	    PUFFS_USE_PAGECACHE(pmp) &&
-	    !(pn->pn_stat & PNODE_RDIRECT)) {
+	    !(pn->pn_stat & PNODE_RDIRECT) &&
+	    (vp->v_size != 0)) {
 		const int advice = IO_ADV_DECODE(ap->a_ioflag);
 
 		while (uio->uio_resid > 0) {

Reply via email to