Source-Changes-HG archive

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

[src/trunk]: src/sys/fs/puffs Add a oflags input field to open requests so th...



details:   https://anonhg.NetBSD.org/src/rev/35a675961c6d
branches:  trunk
changeset: 331612:35a675961c6d
user:      manu <manu%NetBSD.org@localhost>
date:      Sat Aug 16 16:19:41 2014 +0000

description:
Add a oflags input field to open requests so that the filesystem can pass
back information about the file. Implement PUFFS_OPEN_IO_DIRECT, which
will force direct IO (bypassing page cache) for the file.

diffstat:

 sys/fs/puffs/puffs_msgif.h |   6 +++++-
 sys/fs/puffs/puffs_sys.h   |   4 +++-
 sys/fs/puffs/puffs_vnops.c |  20 ++++++++++++++++----
 3 files changed, 24 insertions(+), 6 deletions(-)

diffs (114 lines):

diff -r 4aae3cb8a714 -r 35a675961c6d sys/fs/puffs/puffs_msgif.h
--- a/sys/fs/puffs/puffs_msgif.h        Sat Aug 16 15:34:33 2014 +0000
+++ b/sys/fs/puffs/puffs_msgif.h        Sat Aug 16 16:19:41 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: puffs_msgif.h,v 1.80 2012/08/10 16:49:35 manu Exp $    */
+/*     $NetBSD: puffs_msgif.h,v 1.81 2014/08/16 16:19:41 manu Exp $    */
 
 /*
  * Copyright (c) 2005, 2006, 2007  Antti Kantee.  All Rights Reserved.
@@ -339,6 +339,9 @@
 
 #define PUFFS_EXTATTRCTL_HASNODE       0x01
 #define PUFFS_EXTATTRCTL_HASATTRNAME   0x02
+
+#define        PUFFS_OPEN_IO_DIRECT    0x01
+
 struct puffs_vfsmsg_extattrctl {
        struct puffs_req        pvfsr_pr;
 
@@ -399,6 +402,7 @@
 
        struct puffs_kcred      pvnr_cred;              /* OUT  */
        int                     pvnr_mode;              /* OUT  */
+       int                     pvnr_oflags;            /* IN   */
 };
 
 struct puffs_vnmsg_close {
diff -r 4aae3cb8a714 -r 35a675961c6d sys/fs/puffs/puffs_sys.h
--- a/sys/fs/puffs/puffs_sys.h  Sat Aug 16 15:34:33 2014 +0000
+++ b/sys/fs/puffs/puffs_sys.h  Sat Aug 16 16:19:41 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: puffs_sys.h,v 1.84 2013/10/17 21:03:27 christos Exp $  */
+/*     $NetBSD: puffs_sys.h,v 1.85 2014/08/16 16:19:41 manu Exp $      */
 
 /*
  * Copyright (c) 2005, 2006  Antti Kantee.  All Rights Reserved.
@@ -197,6 +197,8 @@
 #define PNODE_FAF      0x004   /* issue all operations as FAF          */
 #define PNODE_DOINACT  0x008   /* if inactive-on-demand, call inactive */
 #define PNODE_SOPEXP   0x100   /* Node reclaim postponed in sop thread */
+#define PNODE_RDIRECT  0x200   /* bypass page cache on read            */
+#define PNODE_WDIRECT  0x400   /* bypass page cache on write           */
 
 #define PNODE_METACACHE_ATIME  0x10    /* cache atime metadata */
 #define PNODE_METACACHE_CTIME  0x20    /* cache atime metadata */
diff -r 4aae3cb8a714 -r 35a675961c6d sys/fs/puffs/puffs_vnops.c
--- a/sys/fs/puffs/puffs_vnops.c        Sat Aug 16 15:34:33 2014 +0000
+++ b/sys/fs/puffs/puffs_vnops.c        Sat Aug 16 16:19:41 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: puffs_vnops.c,v 1.182 2014/07/25 08:20:52 dholland Exp $       */
+/*     $NetBSD: puffs_vnops.c,v 1.183 2014/08/16 16:19:41 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.182 2014/07/25 08:20:52 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.183 2014/08/16 16:19:41 manu Exp $");
 
 #include <sys/param.h>
 #include <sys/buf.h>
@@ -893,6 +893,7 @@
        PUFFS_MSG_VARS(vn, open);
        struct vnode *vp = ap->a_vp;
        struct puffs_mount *pmp = MPTOPUFFSMP(vp->v_mount);
+       struct puffs_node *pn = VPTOPP(vp);
        int mode = ap->a_mode;
        int error;
 
@@ -913,6 +914,12 @@
        PUFFS_MSG_ENQUEUEWAIT2(pmp, park_open, vp->v_data, NULL, error);
        error = checkerr(pmp, error, __func__);
 
+       if (open_msg->pvnr_oflags & PUFFS_OPEN_IO_DIRECT) {
+               if (mode & FREAD)
+                       pn->pn_stat |= PNODE_RDIRECT;
+               if (mode & FWRITE)
+                       pn->pn_stat |= PNODE_WDIRECT;
+       }
  out:
        DPRINTF(("puffs_open: returning %d\n", error));
        PUFFS_MSG_RELEASE(open);
@@ -2181,6 +2188,7 @@
        } */ *ap = v;
        PUFFS_MSG_VARS(vn, read);
        struct vnode *vp = ap->a_vp;
+       struct puffs_node *pn = VPTOPP(vp);
        struct puffs_mount *pmp = MPTOPUFFSMP(vp->v_mount);
        struct uio *uio = ap->a_uio;
        size_t tomove, argsize;
@@ -2196,7 +2204,9 @@
        if (uio->uio_offset < 0)
                return EINVAL;
 
-       if (vp->v_type == VREG && PUFFS_USE_PAGECACHE(pmp)) {
+       if (vp->v_type == VREG &&
+           PUFFS_USE_PAGECACHE(pmp) &&
+           !(pn->pn_stat & PNODE_RDIRECT)) {
                const int advice = IO_ADV_DECODE(ap->a_ioflag);
 
                while (uio->uio_resid > 0) {
@@ -2301,7 +2311,9 @@
 
        mutex_enter(&pn->pn_sizemtx);
 
-       if (vp->v_type == VREG && PUFFS_USE_PAGECACHE(pmp)) {
+       if (vp->v_type == VREG && 
+           PUFFS_USE_PAGECACHE(pmp) &&
+           !(pn->pn_stat & PNODE_WDIRECT)) {
                ubcflags = UBC_WRITE | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp);
 
                /*



Home | Main Index | Thread Index | Old Index