summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnand Avati <avati@gluster.com>2010-04-05 13:35:45 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-04-08 03:08:00 -0700
commit9c2bc1bc61af888192bde18170b113b4f6f8b4ca (patch)
tree99f130177a265b40266f75f675f4536b795365c6
parent7cb8982cbbe8298cd1bdd35055f7d3818f4a136f (diff)
fuse: change behavior of direct io mode.
If bigwrites are available, then disable direct io mode only by default (previously direct io mode was disabled in any case). Added new command line option to force enabling of direct io mode Signed-off-by: Anand V. Avati <avati@blackhole.gluster.com> Signed-off-by: Raghavendra G <raghavendra@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 801 (Direct io-mode support and related changes in caching translators.) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=801
-rw-r--r--glusterfsd/src/glusterfsd.c26
-rw-r--r--glusterfsd/src/glusterfsd.h3
-rw-r--r--xlators/mount/fuse/src/fuse-bridge.c13
3 files changed, 27 insertions, 15 deletions
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c
index e27bf1949..867cdf78e 100644
--- a/glusterfsd/src/glusterfsd.c
+++ b/glusterfsd/src/glusterfsd.c
@@ -152,6 +152,8 @@ static struct argp_option gf_options[] = {
{"disable-direct-io-mode", ARGP_DISABLE_DIRECT_IO_MODE_KEY, 0, 0,
"Disable direct I/O mode in fuse kernel module"
" [default if big writes are supported]"},
+ {"enable-direct-io-mode", ARGP_ENABLE_DIRECT_IO_MODE_KEY, 0, 0,
+ "Force direct I/O mode in fuse kernel module"},
{"entry-timeout", ARGP_ENTRY_TIMEOUT_KEY, "SECONDS", 0,
"Set entry timeout to SECONDS in fuse kernel module [default: 1]"},
{"attribute-timeout", ARGP_ATTRIBUTE_TIMEOUT_KEY, "SECONDS", 0,
@@ -338,7 +340,7 @@ _add_fuse_mount (xlator_t *graph)
/* On Darwin machines, O_APPEND is not handled,
* which may corrupt the data
*/
- if (cmd_args->fuse_direct_io_mode_flag == _gf_true) {
+ if (cmd_args->fuse_direct_io_mode_flag == 1) {
gf_log ("glusterfs", GF_LOG_DEBUG,
"'direct-io-mode' in fuse causes data corruption "
"if O_APPEND is used. disabling 'direct-io-mode'");
@@ -350,12 +352,18 @@ _add_fuse_mount (xlator_t *graph)
cmd_args->non_local);
#else /* ! DARWIN HOST OS */
- if (cmd_args->fuse_direct_io_mode_flag == _gf_true) {
- ret = dict_set_static_ptr (top->options, ZR_DIRECT_IO_OPT,
- "enable");
- } else {
+ switch (cmd_args->fuse_direct_io_mode_flag) {
+ case 0: /* disable */
ret = dict_set_static_ptr (top->options, ZR_DIRECT_IO_OPT,
"disable");
+ break;
+ case 1: /* enable */
+ ret = dict_set_static_ptr (top->options, ZR_DIRECT_IO_OPT,
+ "enable");
+ break;
+ case 2: /* default */
+ default:
+ break;
}
#endif /* GF_DARWIN_HOST_OS */
@@ -924,7 +932,11 @@ parse_opts (int key, char *arg, struct argp_state *state)
break;
case ARGP_DISABLE_DIRECT_IO_MODE_KEY:
- cmd_args->fuse_direct_io_mode_flag = _gf_false;
+ cmd_args->fuse_direct_io_mode_flag = 0;
+ break;
+
+ case ARGP_ENABLE_DIRECT_IO_MODE_KEY:
+ cmd_args->fuse_direct_io_mode_flag = 1;
break;
case ARGP_ENTRY_TIMEOUT_KEY:
@@ -1187,7 +1199,7 @@ main (int argc, char *argv[])
/* parsing command line arguments */
cmd_args->log_level = DEFAULT_LOG_LEVEL;
- cmd_args->fuse_direct_io_mode_flag = _gf_true;
+ cmd_args->fuse_direct_io_mode_flag = 2;
cmd_args->fuse_attribute_timeout = -1;
INIT_LIST_HEAD (&cmd_args->xlator_options);
diff --git a/glusterfsd/src/glusterfsd.h b/glusterfsd/src/glusterfsd.h
index 77028c706..f3ee2ed3f 100644
--- a/glusterfsd/src/glusterfsd.h
+++ b/glusterfsd/src/glusterfsd.h
@@ -67,8 +67,9 @@ enum argp_option_keys {
ARGP_ATTRIBUTE_TIMEOUT_KEY = 136,
ARGP_VOLUME_NAME_KEY = 137,
ARGP_XLATOR_OPTION_KEY = 138,
+ ARGP_ENABLE_DIRECT_IO_MODE_KEY = 139,
#ifdef GF_DARWIN_HOST_OS
- ARGP_NON_LOCAL_KEY = 139,
+ ARGP_NON_LOCAL_KEY = 140,
#endif /* DARWIN */
ARGP_VOLFILE_ID_KEY = 143,
ARGP_VOLFILE_CHECK_KEY = 144,
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c
index b33607076..ada09f5b8 100644
--- a/xlators/mount/fuse/src/fuse-bridge.c
+++ b/xlators/mount/fuse/src/fuse-bridge.c
@@ -835,8 +835,7 @@ fuse_fd_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
foo.open_flags = 0;
if (!IA_ISDIR (fd->inode->ia_type)) {
- if (((state->flags & O_ACCMODE) != O_RDONLY) &&
- priv->direct_io_mode)
+ if (priv->direct_io_mode)
foo.open_flags |= FOPEN_DIRECT_IO;
}
@@ -1650,8 +1649,7 @@ fuse_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (op_ret >= 0) {
foo.fh = (uintptr_t) fd;
- if (((state->flags & O_ACCMODE) != O_RDONLY) &&
- priv->direct_io_mode)
+ if (priv->direct_io_mode)
foo.open_flags |= FOPEN_DIRECT_IO;
gf_log ("glusterfs-fuse", GF_LOG_TRACE,
@@ -2922,8 +2920,9 @@ fuse_init (xlator_t *this, fuse_in_header_t *finh, void *msg)
fino.flags = FUSE_ASYNC_READ | FUSE_POSIX_LOCKS;
if (fini->minor >= 6 /* fuse_init_in has flags */ &&
fini->flags & FUSE_BIG_WRITES) {
- /* no need for direct I/O mode if big writes are supported */
- priv->direct_io_mode = 0;
+ /* no need for direct I/O mode by default if big writes are supported */
+ if (priv->direct_io_mode == 2)
+ priv->direct_io_mode = 0;
fino.flags |= FUSE_BIG_WRITES;
}
if (fini->minor >= 13) {
@@ -3423,7 +3422,7 @@ init (xlator_t *this_xl)
priv->entry_timeout = 1.0; /* default */
- priv->direct_io_mode = 1;
+ priv->direct_io_mode = 2;
ret = dict_get_str (options, ZR_DIRECT_IO_OPT, &value_string);
if (value_string) {
ret = gf_string2boolean (value_string, &priv->direct_io_mode);