summaryrefslogtreecommitdiffstats
path: root/xlators/features
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2018-12-02 15:35:09 +0530
committerAmar Tumballi <amarts@redhat.com>2018-12-17 17:19:00 +0000
commitc228f0c2d94c028619088c07b66f88488f7c3335 (patch)
treec312f100b984ae36ec2d4e865194743a47f44769 /xlators/features
parentbdcb2d8497d77ff28cb031ae3992eb7ea0c90486 (diff)
Don't depend on string options to be valid always
updates bz#1650403 Change-Id: Ib5a11e691599ce4bd93c1ed5aca6060592893961 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Diffstat (limited to 'xlators/features')
-rw-r--r--xlators/features/read-only/src/read-only.h2
-rw-r--r--xlators/features/read-only/src/worm-helper.c5
-rw-r--r--xlators/features/read-only/src/worm.c17
3 files changed, 17 insertions, 7 deletions
diff --git a/xlators/features/read-only/src/read-only.h b/xlators/features/read-only/src/read-only.h
index 7cd09d37bc8..b959d2a44fb 100644
--- a/xlators/features/read-only/src/read-only.h
+++ b/xlators/features/read-only/src/read-only.h
@@ -29,7 +29,7 @@ typedef struct {
gf_boolean_t worm_files_deletable;
uint64_t reten_period;
uint64_t com_period;
- char *reten_mode;
+ int reten_mode;
time_t start_time;
} read_only_priv_t;
diff --git a/xlators/features/read-only/src/worm-helper.c b/xlators/features/read-only/src/worm-helper.c
index 2cf6ba5d438..25fbd4aa748 100644
--- a/xlators/features/read-only/src/worm-helper.c
+++ b/xlators/features/read-only/src/worm-helper.c
@@ -84,10 +84,7 @@ worm_set_state(xlator_t *this, gf_boolean_t fop_with_fd, void *file_ptr,
retention_state->worm = 1;
retention_state->retain = 1;
retention_state->legal_hold = 0;
- if (strcmp(priv->reten_mode, "relax") == 0)
- retention_state->ret_mode = 0;
- else
- retention_state->ret_mode = 1;
+ retention_state->ret_mode = priv->reten_mode;
retention_state->ret_period = priv->reten_period;
retention_state->auto_commit_period = priv->com_period;
if (fop_with_fd)
diff --git a/xlators/features/read-only/src/worm.c b/xlators/features/read-only/src/worm.c
index 8bbea21e6d3..24196f83931 100644
--- a/xlators/features/read-only/src/worm.c
+++ b/xlators/features/read-only/src/worm.c
@@ -475,11 +475,21 @@ worm_create(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
return 0;
}
+static void
+set_reten_mode(read_only_priv_t *priv, char *reten_mode)
+{
+ if (strcmp(reten_mode, "relax") == 0)
+ priv->reten_mode = 0;
+ else
+ priv->reten_mode = 1;
+}
+
int32_t
init(xlator_t *this)
{
int ret = -1;
read_only_priv_t *priv = NULL;
+ char *reten_mode = NULL;
if (!this->children || this->children->next) {
gf_log(this->name, GF_LOG_ERROR,
@@ -511,7 +521,8 @@ init(xlator_t *this)
GF_OPTION_INIT("worm-file-level", priv->worm_file, bool, out);
GF_OPTION_INIT("default-retention-period", priv->reten_period, uint64, out);
GF_OPTION_INIT("auto-commit-period", priv->com_period, uint64, out);
- GF_OPTION_INIT("retention-mode", priv->reten_mode, str, out);
+ GF_OPTION_INIT("retention-mode", reten_mode, str, out);
+ set_reten_mode(priv, reten_mode);
GF_OPTION_INIT("worm-files-deletable", priv->worm_files_deletable, bool,
out);
@@ -524,6 +535,7 @@ int
reconfigure(xlator_t *this, dict_t *options)
{
read_only_priv_t *priv = NULL;
+ char *reten_mode = NULL;
int ret = -1;
priv = this->private;
@@ -534,7 +546,8 @@ reconfigure(xlator_t *this, dict_t *options)
GF_OPTION_RECONF("worm-file-level", priv->worm_file, options, bool, out);
GF_OPTION_RECONF("default-retention-period", priv->reten_period, options,
uint64, out);
- GF_OPTION_RECONF("retention-mode", priv->reten_mode, options, str, out);
+ GF_OPTION_RECONF("retention-mode", reten_mode, options, str, out);
+ set_reten_mode(priv, reten_mode);
GF_OPTION_RECONF("auto-commit-period", priv->com_period, options, uint64,
out);
GF_OPTION_RECONF("worm-files-deletable", priv->worm_files_deletable,