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 <avati@redhat.com> Reviewed-on: http://review.gluster.org/7506 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
This commit is contained in:
parent
bac02a359f
commit
81b32ab6e1
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user