Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 May 2015 11:03:19 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r282960 - stable/10/sys/fs/fuse
Message-ID:  <201505151103.t4FB3JeS072113@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Fri May 15 11:03:19 2015
New Revision: 282960
URL: https://svnweb.freebsd.org/changeset/base/282960

Log:
  MFC r279536:
  
  Make fuse(4) respect FOPEN_DIRECT_IO.  This is required for correct
  operation of GlusterFS.
  
  PR:		192701
  Submitted by:	harsha at harshavardhana.net
  Reviewed by:	kib@
  Sponsored by:	The FreeBSD Foundation

Modified:
  stable/10/sys/fs/fuse/fuse_node.c
  stable/10/sys/fs/fuse/fuse_node.h
  stable/10/sys/fs/fuse/fuse_vnops.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/fs/fuse/fuse_node.c
==============================================================================
--- stable/10/sys/fs/fuse/fuse_node.c	Fri May 15 11:00:12 2015	(r282959)
+++ stable/10/sys/fs/fuse/fuse_node.c	Fri May 15 11:03:19 2015	(r282960)
@@ -273,8 +273,26 @@ fuse_vnode_open(struct vnode *vp, int32_
          * Funcation is called for every vnode open.
          * Merge fuse_open_flags it may be 0
          *
-         * XXXIP: Handle FOPEN_DIRECT_IO and FOPEN_KEEP_CACHE
+         * XXXIP: Handle FOPEN_KEEP_CACHE
          */
+        /*
+	  * Ideally speaking, direct io should be enabled on
+         * fd's but do not see of any way of providing that
+         * this implementation.
+
+         * Also cannot think of a reason why would two
+         * different fd's on same vnode would like
+         * have DIRECT_IO turned on and off. But linux
+         * based implementation works on an fd not an
+         * inode and provides such a feature.
+         *
+         * XXXIP: Handle fd based DIRECT_IO
+         */
+	if (fuse_open_flags & FOPEN_DIRECT_IO) {
+		VTOFUD(vp)->flag |= FN_DIRECTIO;
+	} else {
+	        VTOFUD(vp)->flag &= ~FN_DIRECTIO;
+	}
 
 	if (vnode_vtype(vp) == VREG) {
 		/* XXXIP prevent getattr, by using cached node size */

Modified: stable/10/sys/fs/fuse/fuse_node.h
==============================================================================
--- stable/10/sys/fs/fuse/fuse_node.h	Fri May 15 11:00:12 2015	(r282959)
+++ stable/10/sys/fs/fuse/fuse_node.h	Fri May 15 11:03:19 2015	(r282960)
@@ -67,6 +67,7 @@
 #define FN_FLUSHINPROG       0x00000040
 #define FN_FLUSHWANT         0x00000080
 #define FN_SIZECHANGE        0x00000100
+#define FN_DIRECTIO          0x00000200
 
 struct fuse_vnode_data {
     /** self **/

Modified: stable/10/sys/fs/fuse/fuse_vnops.c
==============================================================================
--- stable/10/sys/fs/fuse/fuse_vnops.c	Fri May 15 11:00:12 2015	(r282959)
+++ stable/10/sys/fs/fuse/fuse_vnops.c	Fri May 15 11:03:19 2015	(r282960)
@@ -1173,6 +1173,11 @@ fuse_vnop_read(struct vop_read_args *ap)
 	if (fuse_isdeadfs(vp)) {
 		return ENXIO;
 	}
+
+	if (VTOFUD(vp)->flag & FN_DIRECTIO) {
+		ioflag |= IO_DIRECT;
+	}
+
 	return fuse_io_dispatch(vp, uio, ioflag, cred);
 }
 
@@ -1712,6 +1717,10 @@ fuse_vnop_write(struct vop_write_args *a
 	}
 	fuse_vnode_refreshsize(vp, cred);
 
+	if (VTOFUD(vp)->flag & FN_DIRECTIO) {
+		ioflag |= IO_DIRECT;
+	}
+
 	return fuse_io_dispatch(vp, uio, ioflag, cred);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201505151103.t4FB3JeS072113>