Source-Changes-HG archive

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

[src/trunk]: src Add PUFFS_KFLAG_NOFLUSH_META to prevent sending metadata flu...



details:   https://anonhg.NetBSD.org/src/rev/b3293826daf3
branches:  trunk
changeset: 336175:b3293826daf3
user:      manu <manu%NetBSD.org@localhost>
date:      Sun Feb 15 20:21:29 2015 +0000

description:
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.

diffstat:

 lib/libperfuse/ops.c        |   4 +++-
 lib/libperfuse/perfuse.c    |  11 ++++++++++-
 lib/libpuffs/puffs.3        |   5 ++++-
 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  |  43 +++++++++++++++++++++++++------------------
 7 files changed, 51 insertions(+), 26 deletions(-)

diffs (221 lines):

diff -r a88e22f50ba0 -r b3293826daf3 lib/libperfuse/ops.c
--- a/lib/libperfuse/ops.c      Sun Feb 15 17:21:08 2015 +0000
+++ b/lib/libperfuse/ops.c      Sun Feb 15 20:21:29 2015 +0000
@@ -1,4 +1,4 @@
-/*  $NetBSD: ops.c,v 1.82 2015/01/13 16:51:30 manu Exp $ */
+/*  $NetBSD: ops.c,v 1.83 2015/02/15 20:21:29 manu Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -1828,6 +1828,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
@@ -1856,6 +1857,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 a88e22f50ba0 -r b3293826daf3 lib/libperfuse/perfuse.c
--- a/lib/libperfuse/perfuse.c  Sun Feb 15 17:21:08 2015 +0000
+++ b/lib/libperfuse/perfuse.c  Sun Feb 15 20:21:29 2015 +0000
@@ -1,4 +1,4 @@
-/*  $NetBSD: perfuse.c,v 1.35 2014/10/31 15:12:15 manu Exp $ */
+/*  $NetBSD: perfuse.c,v 1.36 2015/02/15 20:21:29 manu Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -539,6 +539,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 a88e22f50ba0 -r b3293826daf3 lib/libpuffs/puffs.3
--- a/lib/libpuffs/puffs.3      Sun Feb 15 17:21:08 2015 +0000
+++ b/lib/libpuffs/puffs.3      Sun Feb 15 20:21:29 2015 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: puffs.3,v 1.59 2014/03/18 18:20:38 riastradh Exp $
+.\"    $NetBSD: puffs.3,v 1.60 2015/02/15 20:21:29 manu Exp $
 .\"
 .\" Copyright (c) 2006, 2007, 2008 Antti Kantee.  All rights reserved.
 .\"
@@ -263,6 +263,9 @@
 .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 a88e22f50ba0 -r b3293826daf3 sys/fs/puffs/puffs_msgif.h
--- a/sys/fs/puffs/puffs_msgif.h        Sun Feb 15 17:21:08 2015 +0000
+++ b/sys/fs/puffs/puffs_msgif.h        Sun Feb 15 20:21:29 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: puffs_msgif.h,v 1.83 2014/10/31 14:20:54 manu Exp $    */
+/*     $NetBSD: puffs_msgif.h,v 1.84 2015/02/15 20:21:29 manu Exp $    */
 
 /*
  * Copyright (c) 2005, 2006, 2007  Antti Kantee.  All Rights Reserved.
@@ -163,7 +163,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 a88e22f50ba0 -r b3293826daf3 sys/fs/puffs/puffs_sys.h
--- a/sys/fs/puffs/puffs_sys.h  Sun Feb 15 17:21:08 2015 +0000
+++ b/sys/fs/puffs/puffs_sys.h  Sun Feb 15 20:21:29 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: puffs_sys.h,v 1.88 2014/10/05 20:40:46 apb Exp $       */
+/*     $NetBSD: puffs_sys.h,v 1.89 2015/02/15 20:21:29 manu Exp $      */
 
 /*
  * Copyright (c) 2005, 2006  Antti Kantee.  All Rights Reserved.
@@ -98,6 +98,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)  (__USE(pmp), 0)
 
diff -r a88e22f50ba0 -r b3293826daf3 sys/fs/puffs/puffs_vfsops.c
--- a/sys/fs/puffs/puffs_vfsops.c       Sun Feb 15 17:21:08 2015 +0000
+++ b/sys/fs/puffs/puffs_vfsops.c       Sun Feb 15 20:21:29 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: puffs_vfsops.c,v 1.115 2014/11/10 18:46:33 maxv Exp $  */
+/*     $NetBSD: puffs_vfsops.c,v 1.116 2015/02/15 20:21:29 manu 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.115 2014/11/10 18:46:33 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_vfsops.c,v 1.116 2015/02/15 20:21:29 manu Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -124,6 +124,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 a88e22f50ba0 -r b3293826daf3 sys/fs/puffs/puffs_vnops.c
--- a/sys/fs/puffs/puffs_vnops.c        Sun Feb 15 17:21:08 2015 +0000
+++ b/sys/fs/puffs/puffs_vnops.c        Sun Feb 15 20:21:29 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: puffs_vnops.c,v 1.199 2015/01/13 16:39:51 manu Exp $   */
+/*     $NetBSD: puffs_vnops.c,v 1.200 2015/02/15 20:21:29 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.199 2015/01/13 16:39:51 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.200 2015/02/15 20:21:29 manu Exp $");
 
 #include <sys/param.h>
 #include <sys/buf.h>
@@ -1000,6 +1000,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);
@@ -1023,17 +1025,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);
@@ -1201,7 +1207,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;
@@ -1234,14 +1240,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);



Home | Main Index | Thread Index | Old Index