diff options
author | Kotresh HR <khiremat@redhat.com> | 2018-09-03 09:07:58 -0400 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-09-25 17:20:47 +0000 |
commit | 89636be4c73b12de2e11c75d8e59527bb243f147 (patch) | |
tree | afae0f98352fc524054f9e6fae438c1e3faa80f1 /xlators/features/utime/src/utime.c | |
parent | c006434c4f6d5762e826bd2ecc414b6d332d66c9 (diff) |
ctime: Provide noatime option
Most of the applications are {c|m}time dependant
and very few are atime dependant. So provide noatime
option to not update atime when ctime feature is
enabled.
Also this option has to be enabled with ctime
feature to avoid unnecessary self heal. Since
AFR/EC reads data from single subvolume, atime
is only updated in one subvolume triggering self
heal.
updates: bz#1593538
Change-Id: I085fb33c882296545345f5df194cde7b6cbc337e
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Diffstat (limited to 'xlators/features/utime/src/utime.c')
-rw-r--r-- | xlators/features/utime/src/utime.c | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/xlators/features/utime/src/utime.c b/xlators/features/utime/src/utime.c index 7671904b717..418e4c4a0d5 100644 --- a/xlators/features/utime/src/utime.c +++ b/xlators/features/utime/src/utime.c @@ -9,6 +9,8 @@ */ #include "utime.h" +#include "utime-messages.h" +#include "utime-mem-types.h" int32_t gf_utime_invalidate(xlator_t *this, inode_t *inode) @@ -120,21 +122,57 @@ gf_utime_priv(xlator_t *this) } int32_t +mem_acct_init(xlator_t *this) +{ + if (xlator_mem_acct_init(this, utime_mt_end + 1) != 0) { + gf_msg(this->name, GF_LOG_ERROR, ENOMEM, UTIME_MSG_NO_MEMORY, + "Memory accounting initialization failed."); + return -1; + } + return 0; +} + +int32_t init(xlator_t *this) { + utime_priv_t *utime = NULL; + + utime = GF_MALLOC(sizeof(*utime), utime_mt_utime_t); + if (utime == NULL) { + gf_msg(this->name, GF_LOG_ERROR, ENOMEM, UTIME_MSG_NO_MEMORY, + "Failed to allocate private memory."); + return -1; + } + memset(utime, 0, sizeof(*utime)); + + this->private = utime; + GF_OPTION_INIT("noatime", utime->noatime, bool, err); + return 0; +err: + return -1; } void fini(xlator_t *this) { + utime_priv_t *utime = NULL; + + utime = this->private; + GF_FREE(utime); return; } int32_t -reconfigure(xlator_t *this, dict_t *dict) +reconfigure(xlator_t *this, dict_t *options) { + utime_priv_t *utime = this->private; + + GF_OPTION_RECONF("noatime", utime->noatime, options, bool, err); + return 0; +err: + return -1; } int @@ -180,3 +218,15 @@ struct xlator_dumpops dumpops = { .priv_to_dict = gf_utime_priv_to_dict, .priv = gf_utime_priv, }; + +struct volume_options options[] = { + {.key = {"noatime"}, + .type = GF_OPTION_TYPE_BOOL, + .default_value = "on", + .op_version = {GD_OP_VERSION_5_0}, + .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC, + .tags = {"ctime"}, + .description = "Enable/Disable atime updation when ctime feature is " + "enabled. When noatime is on, atime is not updated with " + "ctime feature enabled and vice versa."}, + {.key = {NULL}}}; |