summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2010-04-06 02:15:40 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-04-08 03:08:35 -0700
commit9daf76661fcaee2e607b371c91cb7600f51bf678 (patch)
tree045232c33b55e6be2f4cc8737837b5c967e30c62
parent286b913e6335d23796883e729e014b486817f38c (diff)
fuse: change behavior of direct io mode.
by default disable direct-io only for fds opened with O_RDONLY. (previously direct io mode was disabled in any case). Added new command line option to force enabling of direct io mode 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.c37
-rw-r--r--glusterfsd/src/glusterfsd.h3
-rw-r--r--xlators/mount/fuse/src/fuse-bridge.c12
3 files changed, 34 insertions, 18 deletions
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c
index d2c156321..60dbe6192 100644
--- a/glusterfsd/src/glusterfsd.c
+++ b/glusterfsd/src/glusterfsd.c
@@ -135,6 +135,8 @@ static struct argp_option gf_options[] = {
{0, 0, 0, 0, "Fuse options:"},
{"disable-direct-io-mode", ARGP_DISABLE_DIRECT_IO_MODE_KEY, 0, 0,
"Disable direct I/O mode in fuse kernel module"},
+ {"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,
@@ -321,7 +323,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'");
@@ -333,14 +335,19 @@ _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 {
- ret = dict_set_static_ptr (top->options, ZR_DIRECT_IO_OPT,
- "disable");
- }
-
+ 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 */
graph->parents = CALLOC (1, sizeof (xlator_list_t));
@@ -825,9 +832,13 @@ 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;
- break;
-
+ 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:
d = 0.0;
@@ -1064,7 +1075,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;
INIT_LIST_HEAD (&cmd_args->xlator_options);
diff --git a/glusterfsd/src/glusterfsd.h b/glusterfsd/src/glusterfsd.h
index 262783070..56b6d4ca1 100644
--- a/glusterfsd/src/glusterfsd.h
+++ b/glusterfsd/src/glusterfsd.h
@@ -62,12 +62,13 @@ enum argp_option_keys {
ARGP_RUN_ID_KEY = 'r',
ARGP_DEBUG_KEY = 133,
ARGP_DISABLE_DIRECT_IO_MODE_KEY = 134,
+ ARGP_ENABLE_DIRECT_IO_MODE_KEY = 139,
ARGP_ENTRY_TIMEOUT_KEY = 135,
ARGP_ATTRIBUTE_TIMEOUT_KEY = 136,
ARGP_VOLUME_NAME_KEY = 137,
ARGP_XLATOR_OPTION_KEY = 138,
#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 1dc710c96..8f6dabd0a 100644
--- a/xlators/mount/fuse/src/fuse-bridge.c
+++ b/xlators/mount/fuse/src/fuse-bridge.c
@@ -621,7 +621,9 @@ fuse_fd_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
fi.flags = state->flags;
if (!S_ISDIR (fd->inode->st_mode)) {
- if ((fi.flags & 3) && priv->direct_io_mode)
+ if (((priv->direct_io_mode == 2)
+ && ((state->flags & O_ACCMODE) != O_RDONLY))
+ || (priv->direct_io_mode == 1))
fi.direct_io = 1;
}
@@ -1327,7 +1329,9 @@ fuse_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (op_ret >= 0) {
fi.fh = (unsigned long) fd;
- if ((fi.flags & 3) && priv->direct_io_mode)
+ if (((priv->direct_io_mode == 2)
+ && ((state->flags & O_ACCMODE) != O_RDONLY))
+ || (priv->direct_io_mode == 1))
fi.direct_io = 1;
gf_log ("glusterfs-fuse", GF_LOG_TRACE,
@@ -2372,7 +2376,7 @@ fuse_setlk (fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi,
static void
fuse_init (void *data, struct fuse_conn_info *conn)
{
- return;
+
}
static void
@@ -2793,7 +2797,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);