Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-6]: src Pull up following revision(s) (requested by manu in ticke...



details:   https://anonhg.NetBSD.org/src/rev/737d0bf02316
branches:  netbsd-6
changeset: 776911:737d0bf02316
user:      martin <martin%NetBSD.org@localhost>
date:      Fri Feb 27 20:21:02 2015 +0000

description:
Pull up following revision(s) (requested by manu in ticket #1260):
        lib/libpuffs/puffs.3: revision 1,55,1.60
        sys/fs/puffs/puffs_msgif.h: revision 1.84
        lib/libperfuse/ops.c: revision 1.83
        sys/fs/puffs/puffs_sys.h: revision 1.89
        sys/fs/puffs/puffs_vfsops.c: revision 1.116
        lib/libperfuse/perfuse.c: revision 1.36
        sys/fs/puffs/puffs_vnops.c: revision 1.200-1.202

Use more markup. New sentence, new line. Bump date for previous.

Add PUFFS_KFLAG_NOFLUSH_META to prevent sending metadata flush to FUSE
FUSE filesystems do not expect to get metadata updates for [amc]time
and size, they updates the value on their own after operations.

The PUFFS PUFFS_KFLAG_NOFLUSH_META option prevents regular metadata cache
flushes to the filesystem , and libperfuse uses it to match Linux FUSE
behavior.

While there, fix a bug in SETATTR: do not update kernel metadata cache
from SETATTR reply when the request is asynchronous, as we do not have
the reply yet.

Update file size after write without metadata flush
If we do not use metadata flush, we must make sure the size is updated
in the filesystem after a write, otherwise the next GETATTR will get us
a stale value and the file will be truncated.

diffstat:

 lib/libperfuse/ops.c        |   4 ++-
 lib/libperfuse/perfuse.c    |  11 +++++++-
 lib/libpuffs/puffs.3        |  13 ++++++---
 sys/fs/puffs/puffs_msgif.h  |   5 ++-
 sys/fs/puffs/puffs_sys.h    |   4 ++-
 sys/fs/puffs/puffs_vfsops.c |   5 ++-
 sys/fs/puffs/puffs_vnops.c  |  60 +++++++++++++++++++++++++++++++-------------
 7 files changed, 73 insertions(+), 29 deletions(-)

diffs (260 lines):

diff -r 5a4323f901dc -r 737d0bf02316 lib/libperfuse/ops.c
--- a/lib/libperfuse/ops.c      Mon Feb 23 07:00:57 2015 +0000
+++ b/lib/libperfuse/ops.c      Fri Feb 27 20:21:02 2015 +0000
@@ -1,4 +1,4 @@
-/*  $NetBSD: ops.c,v 1.50.2.20 2015/01/16 19:42:54 martin Exp $ */
+/*  $NetBSD: ops.c,v 1.50.2.21 2015/02/27 20:21:02 martin Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -1818,6 +1818,7 @@
                fsi->valid |= FUSE_FATTR_LOCKOWNER;
        }
 
+#ifndef PUFFS_KFLAG_NOFLUSH_META
        /*
         * ftruncate() sends only va_size, and metadata cache
         * flush adds va_atime and va_mtime. Some FUSE
@@ -1846,6 +1847,7 @@
         */
        if (fsi->valid == FUSE_FATTR_ATIME)
                fsi->valid &= ~FUSE_FATTR_ATIME;
+#endif /* PUFFS_KFLAG_NOFLUSH_META */
                    
        /*
         * If nothing remain, discard the operation.
diff -r 5a4323f901dc -r 737d0bf02316 lib/libperfuse/perfuse.c
--- a/lib/libperfuse/perfuse.c  Mon Feb 23 07:00:57 2015 +0000
+++ b/lib/libperfuse/perfuse.c  Fri Feb 27 20:21:02 2015 +0000
@@ -1,4 +1,4 @@
-/*  $NetBSD: perfuse.c,v 1.25.2.5 2014/11/03 19:37:58 msaitoh Exp $ */
+/*  $NetBSD: perfuse.c,v 1.25.2.6 2015/02/27 20:21:02 martin Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -536,6 +536,15 @@
        puffs_flags |= PUFFS_FLAG_IAONDEMAND;
 #endif
 
+       /*
+        * FUSE filesystem do not expect [amc]time and size
+        * updates to be sent by the kernel, they do the
+        * updates on their own after other operations.
+        */
+#ifdef PUFFS_KFLAG_NOFLUSH_META
+       puffs_flags |= PUFFS_KFLAG_NOFLUSH_META;
+#endif
+
        if (perfuse_diagflags & PDF_PUFFS)
                puffs_flags |= PUFFS_FLAG_OPDUMP;
 
diff -r 5a4323f901dc -r 737d0bf02316 lib/libpuffs/puffs.3
--- a/lib/libpuffs/puffs.3      Mon Feb 23 07:00:57 2015 +0000
+++ b/lib/libpuffs/puffs.3      Fri Feb 27 20:21:02 2015 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: puffs.3,v 1.49.2.3 2012/09/13 20:20:16 riz Exp $
+.\"    $NetBSD: puffs.3,v 1.49.2.4 2015/02/27 20:21:02 martin Exp $
 .\"
 .\" Copyright (c) 2006, 2007, 2008 Antti Kantee.  All rights reserved.
 .\"
@@ -23,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd April 18, 2012
+.Dd August 10, 2012
 .Dt PUFFS 3
 .Os
 .Sh NAME
@@ -259,8 +259,13 @@
 and
 .Fn puffs_node_setattr .
 .It Dv PUFFS_KFLAG_CACHE_DOTDOT
-Never send lookups for .. to the filesystem. Parent vnodes are all
-kept active until their children are reclaimed.
+Never send lookups for
+.Dq ..
+to the filesystem.
+Parent vnodes are all kept active until their children are reclaimed.
+.It Dv PUFFS_KFLAG_NOFLUSH_META
+Do not send metadata cache flushes for time and size to the filesystem,
+which should take care of updating the values on its own.
 .It Dv PUFFS_FLAG_OPDUMP
 This option makes the framework dump a textual representation of
 each operation before executing it.
diff -r 5a4323f901dc -r 737d0bf02316 sys/fs/puffs/puffs_msgif.h
--- a/sys/fs/puffs/puffs_msgif.h        Mon Feb 23 07:00:57 2015 +0000
+++ b/sys/fs/puffs/puffs_msgif.h        Fri Feb 27 20:21:02 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: puffs_msgif.h,v 1.77.8.3 2014/11/03 19:18:09 msaitoh Exp $     */
+/*     $NetBSD: puffs_msgif.h,v 1.77.8.4 2015/02/27 20:21:02 martin Exp $      */
 
 /*
  * Copyright (c) 2005, 2006, 2007  Antti Kantee.  All Rights Reserved.
@@ -162,7 +162,8 @@
 #define PUFFS_KFLAG_NOCACHE_ATTR       0x040   /* no attrib cache (unused) */
 #define PUFFS_KFLAG_CACHE_FS_TTL       0x080   /* cache use TTL from FS    */
 #define PUFFS_KFLAG_CACHE_DOTDOT       0x100   /* don't send lookup for .. */
-#define PUFFS_KFLAG_MASK               0x1bf
+#define PUFFS_KFLAG_NOFLUSH_META       0x200   /* don't flush metadata cache*/
+#define PUFFS_KFLAG_MASK               0x3bf
 
 #define PUFFS_FHFLAG_DYNAMIC           0x01
 #define PUFFS_FHFLAG_NFSV2             0x02
diff -r 5a4323f901dc -r 737d0bf02316 sys/fs/puffs/puffs_sys.h
--- a/sys/fs/puffs/puffs_sys.h  Mon Feb 23 07:00:57 2015 +0000
+++ b/sys/fs/puffs/puffs_sys.h  Fri Feb 27 20:21:02 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: puffs_sys.h,v 1.78.8.3 2014/11/03 19:18:09 msaitoh Exp $       */
+/*     $NetBSD: puffs_sys.h,v 1.78.8.4 2015/02/27 20:21:02 martin Exp $        */
 
 /*
  * Copyright (c) 2005, 2006  Antti Kantee.  All Rights Reserved.
@@ -94,6 +94,8 @@
     ((pmp)->pmp_flags & PUFFS_KFLAG_CACHE_FS_TTL)
 #define PUFFS_USE_DOTDOTCACHE(pmp)     \
     ((pmp)->pmp_flags & PUFFS_KFLAG_CACHE_DOTDOT)
+#define PUFFS_USE_METAFLUSH(pmp)       \
+    (((pmp)->pmp_flags & PUFFS_KFLAG_NOFLUSH_META) == 0)
 
 #define PUFFS_WCACHEINFO(pmp)  0
 
diff -r 5a4323f901dc -r 737d0bf02316 sys/fs/puffs/puffs_vfsops.c
--- a/sys/fs/puffs/puffs_vfsops.c       Mon Feb 23 07:00:57 2015 +0000
+++ b/sys/fs/puffs/puffs_vfsops.c       Fri Feb 27 20:21:02 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: puffs_vfsops.c,v 1.100.8.3 2014/04/21 10:14:17 bouyer Exp $    */
+/*     $NetBSD: puffs_vfsops.c,v 1.100.8.4 2015/02/27 20:21:02 martin Exp $    */
 
 /*
  * Copyright (c) 2005, 2006  Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: puffs_vfsops.c,v 1.100.8.3 2014/04/21 10:14:17 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_vfsops.c,v 1.100.8.4 2015/02/27 20:21:02 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -127,6 +127,7 @@
                goto out;
        }
 
+printf("args->pa_flags = 0x%x\n", args->pa_flags);
        if ((args->pa_flags & ~PUFFS_KFLAG_MASK) != 0) {
                printf("puffs_mount: invalid KFLAGs 0x%x\n", args->pa_flags);
                error = EINVAL;
diff -r 5a4323f901dc -r 737d0bf02316 sys/fs/puffs/puffs_vnops.c
--- a/sys/fs/puffs/puffs_vnops.c        Mon Feb 23 07:00:57 2015 +0000
+++ b/sys/fs/puffs/puffs_vnops.c        Fri Feb 27 20:21:02 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: puffs_vnops.c,v 1.163.2.11 2015/01/16 19:44:53 martin Exp $    */
+/*     $NetBSD: puffs_vnops.c,v 1.163.2.12 2015/02/27 20:21:02 martin 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.163.2.11 2015/01/16 19:44:53 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.163.2.12 2015/02/27 20:21:02 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/buf.h>
@@ -985,6 +985,8 @@
          struct timespec *va_ttl, struct timespec *cn_ttl, int flags)
 {
        struct puffs_node *pn = VPTOPP(vp);
+       struct puffs_mount *pmp = MPTOPUFFSMP(vp->v_mount);
+       int use_metacache;
 
        if (TTL_VALID(cn_ttl)) {
                pn->pn_cn_timeout = TTL_TO_TIMEOUT(cn_ttl);
@@ -1008,17 +1010,21 @@
                (void) memcpy(vap, rvap, sizeof(struct vattr));
                vap->va_fsid = vp->v_mount->mnt_stat.f_fsidx.__fsid_val[0];
 
-               if (pn->pn_stat & PNODE_METACACHE_ATIME)
-                       vap->va_atime = pn->pn_mc_atime;
-               if (pn->pn_stat & PNODE_METACACHE_CTIME)
-                       vap->va_ctime = pn->pn_mc_ctime;
-               if (pn->pn_stat & PNODE_METACACHE_MTIME)
-                       vap->va_mtime = pn->pn_mc_mtime;
-               if (pn->pn_stat & PNODE_METACACHE_SIZE)
-                       vap->va_size = pn->pn_mc_size;
+               if (PUFFS_USE_METAFLUSH(pmp)) {
+                       if (pn->pn_stat & PNODE_METACACHE_ATIME)
+                               vap->va_atime = pn->pn_mc_atime;
+                       if (pn->pn_stat & PNODE_METACACHE_CTIME)
+                               vap->va_ctime = pn->pn_mc_ctime;
+                       if (pn->pn_stat & PNODE_METACACHE_MTIME)
+                               vap->va_mtime = pn->pn_mc_mtime;
+                       if (pn->pn_stat & PNODE_METACACHE_SIZE)
+                               vap->va_size = pn->pn_mc_size;
+               }
        }
 
-       if (!(pn->pn_stat & PNODE_METACACHE_SIZE) && (flags & SETATTR_CHSIZE)) {
+       use_metacache = PUFFS_USE_METAFLUSH(pmp) &&
+                       (pn->pn_stat & PNODE_METACACHE_SIZE);
+       if (!use_metacache && (flags & SETATTR_CHSIZE)) {
                if (rvap->va_size != VNOVAL
                    && vp->v_type != VBLK && vp->v_type != VCHR) {
                        uvm_vnp_setsize(vp, rvap->va_size);
@@ -1186,7 +1192,7 @@
         * parameters, treat them as information overriding metacache
         * information.
         */
-       if (pn->pn_stat & PNODE_METACACHE_MASK) {
+       if (PUFFS_USE_METAFLUSH(pmp) && pn->pn_stat & PNODE_METACACHE_MASK) {
                if ((pn->pn_stat & PNODE_METACACHE_ATIME)
                    && vap->va_atime.tv_sec == VNOVAL)
                        vap->va_atime = pn->pn_mc_atime;
@@ -1219,14 +1225,15 @@
                puffs_msg_setfaf(park_setattr);
 
        puffs_msg_enqueue(pmp, park_setattr);
-       if ((flags & SETATTR_ASYNC) == 0)
+       if ((flags & SETATTR_ASYNC) == 0) {
                error = puffs_msg_wait2(pmp, park_setattr, vp->v_data, NULL);
 
-       if ((error == 0) && PUFFS_USE_FS_TTL(pmp)) {
-               struct timespec *va_ttl = &setattr_msg->pvnr_va_ttl;
-               struct vattr *rvap = &setattr_msg->pvnr_va;
-
-               update_va(vp, NULL, rvap, va_ttl, NULL, flags);
+               if ((error == 0) && PUFFS_USE_FS_TTL(pmp)) {
+                       struct timespec *va_ttl = &setattr_msg->pvnr_va_ttl;
+                       struct vattr *rvap = &setattr_msg->pvnr_va;
+
+                       update_va(vp, NULL, rvap, va_ttl, NULL, flags);
+               }
        }
 
        PUFFS_MSG_RELEASE(setattr);
@@ -2526,6 +2533,23 @@
        uflags |= PUFFS_UPDATEMTIME;
        puffs_updatenode(VPTOPP(vp), uflags, vp->v_size);
 
+       /*
+        * If we do not use meta flush, we need to update the
+        * filesystem now, otherwise we will get a stale value
+        * on the next GETATTR
+        */
+       if (!PUFFS_USE_METAFLUSH(pmp) && (uflags & PUFFS_UPDATESIZE)) {
+               struct vattr va;
+               int ret;
+
+               vattr_null(&va);
+               va.va_size = vp->v_size;
+               ret = dosetattr(vp, &va, FSCRED, 0);
+               if (ret) {
+                       DPRINTF(("dosetattr set size to %jd failed: %d\n",
+                           (intmax_t)vp->v_size, ret));
+               }
+       }
        mutex_exit(&pn->pn_sizemtx);
        return error;
 }



Home | Main Index | Thread Index | Old Index