Source-Changes-HG archive

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

[src/trunk]: src/lib/libperfuse Use just introduced open2 PUFFS method and it...



details:   https://anonhg.NetBSD.org/src/rev/2b199cf0d6fe
branches:  trunk
changeset: 331615:2b199cf0d6fe
user:      manu <manu%NetBSD.org@localhost>
date:      Sat Aug 16 16:28:43 2014 +0000

description:
Use just introduced open2 PUFFS method and its PUFFS_OPEN_IO_DIRECT oflag
to implement FUSE's OPEN_IO_DIRECT, by which the filesystem tells the kernel
that read/write to the file should bypass the page cache.

Remove a warning about read beyond EOF which will now normally appear when
page cache is bypassed.

diffstat:

 lib/libperfuse/ops.c          |  20 ++++++++++++++------
 lib/libperfuse/perfuse.c      |   5 ++++-
 lib/libperfuse/perfuse_priv.h |   4 +++-
 3 files changed, 21 insertions(+), 8 deletions(-)

diffs (85 lines):

diff -r 4cd9dcdfd601 -r 2b199cf0d6fe lib/libperfuse/ops.c
--- a/lib/libperfuse/ops.c      Sat Aug 16 16:25:44 2014 +0000
+++ b/lib/libperfuse/ops.c      Sat Aug 16 16:28:43 2014 +0000
@@ -1,4 +1,4 @@
-/*  $NetBSD: ops.c,v 1.66 2014/08/10 03:22:33 manu Exp $ */
+/*  $NetBSD: ops.c,v 1.67 2014/08/16 16:28:43 manu Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -1338,6 +1338,13 @@
 perfuse_node_open(struct puffs_usermount *pu, puffs_cookie_t opc, int mode,
        const struct puffs_cred *pcr)
 {
+       return perfuse_node_open2(pu, opc, mode, pcr, NULL);
+}
+
+int
+perfuse_node_open2(struct puffs_usermount *pu, puffs_cookie_t opc, int mode,
+       const struct puffs_cred *pcr, int *oflags)
+{
        struct perfuse_state *ps;
        struct perfuse_node_data *pnd;
        perfuse_msg_t *pm;
@@ -1439,6 +1446,12 @@
         */
        perfuse_new_fh(opc, foo->fh, mode);
 
+       /*
+        * Set direct I/O if the filesystems forces it
+        */
+       if ((foo->open_flags & FUSE_FOPEN_DIRECT_IO) && (oflags != NULL))
+               *oflags |= PUFFS_OPEN_IO_DIRECT;
+
 #ifdef PERFUSE_DEBUG
        if (perfuse_diagflags & (PDF_FH|PDF_FILENAME))
                DPRINTF("%s: opc = %p, file = \"%s\", "
@@ -3031,11 +3044,6 @@
        if (vap->va_type == VDIR)
                return EISDIR;
 
-       if ((u_quad_t)offset + *resid > vap->va_size)
-               DWARNX("%s %p read %lld@%zu beyond EOF %" PRIu64 "\n",
-                      __func__, (void *)opc, (long long)offset,
-                      *resid, vap->va_size);
-
        do {
                size_t max_read;
 
diff -r 4cd9dcdfd601 -r 2b199cf0d6fe lib/libperfuse/perfuse.c
--- a/lib/libperfuse/perfuse.c  Sat Aug 16 16:25:44 2014 +0000
+++ b/lib/libperfuse/perfuse.c  Sat Aug 16 16:28:43 2014 +0000
@@ -1,4 +1,4 @@
-/*  $NetBSD: perfuse.c,v 1.31 2012/09/10 13:56:18 manu Exp $ */
+/*  $NetBSD: perfuse.c,v 1.32 2014/08/16 16:28:43 manu Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -503,6 +503,9 @@
 #ifdef PUFFS_SETATTR_FAF
        PUFFSOP_SET(pops, perfuse, node, write2);
 #endif /* PUFFS_SETATTR_FAF */
+#ifdef PUFFS_OPEN_IO_DIRECT 
+       PUFFSOP_SET(pops, perfuse, node, open2);
+#endif /* PUFFS_OPEN_IO_DIRECT */
 
        /*
         * PUFFS_KFLAG_NOCACHE_NAME is required so that we can see changes
diff -r 4cd9dcdfd601 -r 2b199cf0d6fe lib/libperfuse/perfuse_priv.h
--- a/lib/libperfuse/perfuse_priv.h     Sat Aug 16 16:25:44 2014 +0000
+++ b/lib/libperfuse/perfuse_priv.h     Sat Aug 16 16:28:43 2014 +0000
@@ -1,4 +1,4 @@
-/*  $NetBSD: perfuse_priv.h,v 1.32 2014/08/10 03:22:33 manu Exp $ */
+/*  $NetBSD: perfuse_priv.h,v 1.33 2014/08/16 16:28:43 manu Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -262,6 +262,8 @@
     uint8_t *, off_t, size_t *, const struct puffs_cred *, int);
 int perfuse_node_write2(struct puffs_usermount *, puffs_cookie_t,
     uint8_t *, off_t, size_t *, const struct puffs_cred *, int, int);
+int perfuse_node_open2(struct puffs_usermount *,
+    puffs_cookie_t, int, const struct puffs_cred *, int *);
 void perfuse_cache_write(struct puffs_usermount *,
     puffs_cookie_t, size_t, struct puffs_cacherun *);
 int perfuse_node_getextattr(struct puffs_usermount *, puffs_cookie_t,



Home | Main Index | Thread Index | Old Index