From 40f476f40b37cc8fcc83618094d357ee643442d8 Mon Sep 17 00:00:00 2001 From: Csaba Henk Date: Wed, 3 Apr 2019 14:23:06 +0200 Subject: fuse: rate limit reading from fuse device upon receiving EPERM Fixes: bz#1644322 Change-Id: I53e8fa362cd8c7d04fb1c4abb606a9abb642c592 Signed-off-by: Csaba Henk --- glusterfsd/src/glusterfsd.c | 28 ++++++++++++++++++++++++++++ glusterfsd/src/glusterfsd.h | 3 ++- 2 files changed, 30 insertions(+), 1 deletion(-) (limited to 'glusterfsd') diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index cf6d9a7215c..968b97c2eac 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -276,6 +276,9 @@ static struct argp_option gf_options[] = { "attribute, dentry and page-cache. " "Disable this only if same files/directories are not accessed across " "two different mounts concurrently [default: \"on\"]"}, + {"fuse-dev-eperm-ratelimit-ns", ARGP_FUSE_DEV_EPERM_RATELIMIT_NS_KEY, + "OPTIONS", OPTION_HIDDEN, + "rate limit reading from fuse device upon EPERM failure"}, {"brick-mux", ARGP_BRICK_MUX_KEY, 0, 0, "Enable brick mux. "}, {0, 0, 0, 0, "Miscellaneous Options:"}, { @@ -707,6 +710,16 @@ set_fuse_mount_options(glusterfs_ctx_t *ctx, dict_t *options) goto err; } } + if (cmd_args->fuse_dev_eperm_ratelimit_ns) { + ret = dict_set_uint32(options, "fuse-dev-eperm-ratelimit-ns", + cmd_args->fuse_dev_eperm_ratelimit_ns); + if (ret < 0) { + gf_msg("glusterfsd", GF_LOG_ERROR, 0, glusterfsd_msg_4, + "failed to set dict value for key " + "fuse-dev-eperm-ratelimit-ns"); + goto err; + } + } ret = 0; err: @@ -1536,6 +1549,21 @@ parse_opts(int key, char *arg, struct argp_state *state) argp_failure(state, -1, 0, "Invalid value for global threading \"%s\"", arg); break; + + case ARGP_FUSE_DEV_EPERM_RATELIMIT_NS_KEY: + if (gf_string2uint32(arg, &cmd_args->fuse_dev_eperm_ratelimit_ns)) { + argp_failure(state, -1, 0, + "Non-numerical value for " + "'fuse-dev-eperm-ratelimit-ns' option %s", + arg); + } else if (cmd_args->fuse_dev_eperm_ratelimit_ns > 1000000000) { + argp_failure(state, -1, 0, + "Invalid 'fuse-dev-eperm-ratelimit-ns' value %s. " + "Valid range: [\"0, 1000000000\"]", + arg); + } + + break; } return 0; } diff --git a/glusterfsd/src/glusterfsd.h b/glusterfsd/src/glusterfsd.h index dc7d995e778..8a7c034ce40 100644 --- a/glusterfsd/src/glusterfsd.h +++ b/glusterfsd/src/glusterfsd.h @@ -112,7 +112,8 @@ enum argp_option_keys { ARGP_FUSE_LRU_LIMIT_KEY = 190, ARGP_FUSE_AUTO_INVAL_KEY = 191, ARGP_GLOBAL_THREADING_KEY = 192, - ARGP_BRICK_MUX_KEY = 193 + ARGP_BRICK_MUX_KEY = 193, + ARGP_FUSE_DEV_EPERM_RATELIMIT_NS_KEY = 194, }; struct _gfd_vol_top_priv { -- cgit