From 81b32ab6e1c950577d0f2779db67283303e3e705 Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Thu, 27 Mar 2014 06:35:34 -0700 Subject: fuse: allow xlators to request for direct-io-mode on virtual files Translators like meta, create virtual files with dynamic content generated only at the time of open(). Therefore the file size returned in lookup or stat is 0 (just like files in /proc). However the VFS does not read beyond the size, and if the size is 0, no READ ever reaches gluster for that file -- unless direct-io-mode is enabled. This patch allows translators to return "direct-io-mode" flag for such 0-byte virtual files in xdata of open_cbk/create_cbk. Change-Id: I3fe3312cd96baa4eecfe1247ab7255b4f455f049 BUG: 1089216 Signed-off-by: Anand Avati Reviewed-on: http://review.gluster.org/7506 Tested-by: Gluster Build System Reviewed-by: Pranith Kumar Karampuri --- xlators/mount/fuse/src/fuse-bridge.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'xlators/mount/fuse/src') diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index d9055468e..cbf256e8b 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -869,6 +869,16 @@ out: return ret; } + +gf_boolean_t +direct_io_mode (dict_t *xdata) +{ + if (xdata && dict_get (xdata, "direct-io-mode")) + return _gf_true; + return _gf_false; +} + + static int fuse_fd_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, fd_t *fd, dict_t *xdata) @@ -892,7 +902,8 @@ fuse_fd_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (!IA_ISDIR (fd->inode->ia_type)) { if (((priv->direct_io_mode == 2) && ((state->flags & O_ACCMODE) != O_RDONLY)) - || (priv->direct_io_mode == 1)) + || (priv->direct_io_mode == 1) + || (direct_io_mode (xdata))) foo.open_flags |= FOPEN_DIRECT_IO; #ifdef GF_DARWIN_HOST_OS /* In Linux: by default, buffer cache @@ -1840,7 +1851,8 @@ fuse_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (((priv->direct_io_mode == 2) && ((state->flags & O_ACCMODE) != O_RDONLY)) - || (priv->direct_io_mode == 1)) + || (priv->direct_io_mode == 1) + || direct_io_mode (xdata)) foo.open_flags |= FOPEN_DIRECT_IO; gf_log ("glusterfs-fuse", GF_LOG_TRACE, -- cgit