diff --git a/xlators/features/read-only/src/read-only.h b/xlators/features/read-only/src/read-only.h index d74053a2a..9ad4a6c79 100644 --- a/xlators/features/read-only/src/read-only.h +++ b/xlators/features/read-only/src/read-only.h @@ -24,13 +24,14 @@ typedef struct { } worm_reten_state_t; 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; - time_t start_time; + 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; + time_t start_time; + gf_boolean_t delete_retained; } read_only_priv_t; #endif diff --git a/xlators/features/read-only/src/worm.c b/xlators/features/read-only/src/worm.c index db128b751..0f26e1eec 100644 --- a/xlators/features/read-only/src/worm.c +++ b/xlators/features/read-only/src/worm.c @@ -91,7 +91,7 @@ worm_unlink(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, if (is_readonly_or_worm_enabled(frame, this)) { goto out; } - if (!priv->worm_file || (frame->root->pid < 0)) { + if (!priv->worm_file || (frame->root->pid < 0) || priv->delete_retained) { op_errno = 0; goto out; } @@ -514,6 +514,7 @@ init(xlator_t *this) GF_OPTION_INIT("retention-mode", priv->reten_mode, str, out); GF_OPTION_INIT("worm-files-deletable", priv->worm_files_deletable, bool, out); + GF_OPTION_INIT("delete-retained", priv->delete_retained, bool, out); ret = 0; out: @@ -539,6 +540,7 @@ reconfigure(xlator_t *this, dict_t *options) out); GF_OPTION_RECONF("worm-files-deletable", priv->worm_files_deletable, options, bool, out); + GF_OPTION_RECONF("delete-retained", priv->delete-retained, options, bool, out); ret = 0; out: gf_log(this->name, GF_LOG_DEBUG, "returning %d", ret); @@ -632,5 +634,11 @@ struct volume_options options[] = { .op_version = {GD_OP_VERSION_3_8_0}, .flags = OPT_FLAG_SETTABLE, .description = "Auto commit period for the files."}, + {.key = {"delete-retained"}, + .type = GF_OPTION_TYPE_BOOL, + .default_value = "off", + .op_version = {GD_OP_VERSION_5_4}, + .flags = OPT_FLAG_SETTABLE, + .description = "When \"on\", one can delete files in WORMed/Retain mode"}, {.key = {NULL}}, }; diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c index fa260253a..dc02d0ca2 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c @@ -2762,6 +2762,13 @@ struct volopt_map_entry glusterd_volopt_map[] = { .validate_fn = validate_worm_period, .op_version = GD_OP_VERSION_3_8_0, }, + { + .key = "features.delete-retained", + .voltype = "features/worm", + .option = "delete-retained", + .validate_fn = validate_boolean, + .op_version = GD_OP_VERSION_5_4, + }, {.key = "storage.linux-aio", .voltype = "storage/posix", .op_version = 1}, {.key = "storage.batch-fsync-mode", .voltype = "storage/posix",