summaryrefslogtreecommitdiffstats
path: root/xlators/features/read-only
diff options
context:
space:
mode:
authorVishal Pandey <vishpandey2014@gmail.com>2017-11-02 19:16:26 +0530
committerAmar Tumballi <amarts@redhat.com>2017-11-20 11:41:27 +0000
commitdbd94d5bee93ca9ad4f485147b90b4ccf8a3b61e (patch)
treea45e286ae34fd2f6e03bbebf64455467a9a43fc1 /xlators/features/read-only
parentc810ea1e2ba5c15b11808e2bd378e95c428b7f96 (diff)
features/worm: new config option to manage deletion of Worm files.
Add a new configuration option worm-files-deletable to file-level Worm in order to control behaviour of Worm files upon deletion. Steps to Test: 1. Add all the configuration options to a volume to activate file-level-worm 2. Option features.worm-files-deletable is set to 1 by default. 3. Create a new file and wait for the retention time to expire. 4. After retention time expires, do an truncate, rename, unlink, link or write to send the file in Worm state. 5. After that do `rm -f filename`. 6. The file is successfully removed. 7. Repeat from step 2 by setting features.worm-files-deletable 0. This time deletion should not be successful. Change-Id: Ibc89861ee296e065330b93a9f9606be5da40af31 BUG: 1508898 Signed-off-by: Vishal Pandey <vishpandey2014@gmail.com>
Diffstat (limited to 'xlators/features/read-only')
-rw-r--r--xlators/features/read-only/src/read-only.h1
-rw-r--r--xlators/features/read-only/src/worm-helper.c2
-rw-r--r--xlators/features/read-only/src/worm.c10
3 files changed, 12 insertions, 1 deletions
diff --git a/xlators/features/read-only/src/read-only.h b/xlators/features/read-only/src/read-only.h
index d0263e74179..aae625f5eaf 100644
--- a/xlators/features/read-only/src/read-only.h
+++ b/xlators/features/read-only/src/read-only.h
@@ -28,6 +28,7 @@ typedef struct {
typedef struct {
gf_boolean_t readonly_or_worm_enabled;
gf_boolean_t worm_file;
+ gf_boolean_t worm_files_deletable;
uint64_t reten_period;
uint64_t com_period;
char *reten_mode;
diff --git a/xlators/features/read-only/src/worm-helper.c b/xlators/features/read-only/src/worm-helper.c
index 425e48123b1..0770f9d77c4 100644
--- a/xlators/features/read-only/src/worm-helper.c
+++ b/xlators/features/read-only/src/worm-helper.c
@@ -379,7 +379,7 @@ gf_worm_state_transition (xlator_t *this, gf_boolean_t fop_with_fd,
&reten_state, &stbuf);
}
if (reten_state.worm && !reten_state.retain &&
- op == GF_FOP_UNLINK) {
+ priv->worm_files_deletable && op == GF_FOP_UNLINK) {
op_errno = 0;
goto out;
}
diff --git a/xlators/features/read-only/src/worm.c b/xlators/features/read-only/src/worm.c
index a1474b6bc27..cbe7df8e798 100644
--- a/xlators/features/read-only/src/worm.c
+++ b/xlators/features/read-only/src/worm.c
@@ -542,6 +542,8 @@ init (xlator_t *this)
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 ("worm-files-deletable", priv->worm_files_deletable,
+ bool, out);
this->private = priv;
ret = 0;
@@ -569,6 +571,8 @@ reconfigure (xlator_t *this, dict_t *options)
out);
GF_OPTION_RECONF ("auto-commit-period", priv->com_period, options,
uint64, out);
+ GF_OPTION_RECONF ("worm-files-deletable", priv->worm_files_deletable,
+ options, bool, out);
ret = 0;
out:
gf_log (this->name, GF_LOG_DEBUG, "returning %d", ret);
@@ -632,6 +636,12 @@ struct volume_options options[] = {
.description = "When \"on\", activates the file level worm. "
"It is turned \"off\" by default."
},
+ { .key = {"worm-files-deletable"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "on",
+ .description = "When \"off\", doesn't allow the Worm files"
+ "to be deleted. It is turned \"on\" by default."
+ },
{ .key = {"default-retention-period"},
.type = GF_OPTION_TYPE_TIME,
.default_value = "120",