summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2018-05-05 00:05:09 -0400
committerAmar Tumballi <amarts@redhat.com>2018-05-06 07:09:19 +0530
commit17e3f617086da785a3678d7cfa8f68ebd1497023 (patch)
tree8694053a2076c9445b113ff48c57ffb4578b2ef0
parent99cba93daadd29967d26621d1deee842d94483a8 (diff)
glusterd/ctime: Provide option to enable/disable ctime feature
Updates: #208 Change-Id: If6f52b9b1b5b823ad64faeed662e96ceb848c54c Signed-off-by: Kotresh HR <khiremat@redhat.com>
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-set.c5
-rw-r--r--xlators/storage/posix/src/posix-common.c16
-rw-r--r--xlators/storage/posix/src/posix-helpers.c9
-rw-r--r--xlators/storage/posix/src/posix-metadata.c24
-rw-r--r--xlators/storage/posix/src/posix-metadata.h2
-rw-r--r--xlators/storage/posix/src/posix.h1
6 files changed, 41 insertions, 16 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
index d603d1b..0f4df92 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
@@ -2995,6 +2995,11 @@ struct volopt_map_entry glusterd_volopt_map[] = {
.voltype = "storage/posix",
.op_version = GD_OP_VERSION_4_0_0,
},
+ { .option = "ctime",
+ .key = "storage.ctime",
+ .voltype = "storage/posix",
+ .op_version = GD_OP_VERSION_4_1_0,
+ },
{ .key = "storage.bd-aio",
.voltype = "storage/bd",
.op_version = 3
diff --git a/xlators/storage/posix/src/posix-common.c b/xlators/storage/posix/src/posix-common.c
index bcaad27..c175345 100644
--- a/xlators/storage/posix/src/posix-common.c
+++ b/xlators/storage/posix/src/posix-common.c
@@ -390,6 +390,9 @@ posix_reconfigure (xlator_t *this, dict_t *options)
GF_OPTION_RECONF ("fips-mode-rchecksum", priv->fips_mode_rchecksum,
options, bool, out);
+
+ GF_OPTION_RECONF ("ctime", priv->ctime, options, bool, out);
+
ret = 0;
out:
return ret;
@@ -1082,6 +1085,8 @@ posix_init (xlator_t *this)
GF_OPTION_INIT ("fips-mode-rchecksum", _private->fips_mode_rchecksum,
bool, out);
+
+ GF_OPTION_INIT ("ctime", _private->ctime, bool, out);
out:
if (ret) {
if (_private) {
@@ -1383,5 +1388,16 @@ struct volume_options options[] = {
.description = "If enabled, posix_rchecksum uses the FIPS compliant"
"SHA256 checksum. MD5 otherwise."
},
+ { .key = {"ctime"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "off",
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
+ .op_version = { GD_OP_VERSION_4_1_0 },
+ .tags = { "ctime" },
+ .description = "When this option is enabled, time attributes (ctime,mtime,atime) "
+ "are stored in xattr to keep it consistent across replica and "
+ "distribute set. The time attributes stored at the backend are "
+ "not considered "
+ },
{ .key = {NULL} }
};
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index 75fb045..0ca9169 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -644,6 +644,9 @@ posix_fdstat (xlator_t *this, inode_t *inode, int fd, struct iatt *stbuf_p)
int ret = 0;
struct stat fstatbuf = {0, };
struct iatt stbuf = {0, };
+ struct posix_private *priv = NULL;
+
+ priv = this->private;
ret = sys_fstat (fd, &fstatbuf);
if (ret == -1)
@@ -654,7 +657,7 @@ posix_fdstat (xlator_t *this, inode_t *inode, int fd, struct iatt *stbuf_p)
iatt_from_stat (&stbuf, &fstatbuf);
- if (inode && is_ctime_enabled()) {
+ if (inode && priv->ctime) {
ret = posix_get_mdata_xattr (this, NULL, fd, inode, &stbuf);
if (ret) {
gf_msg (this->name, GF_LOG_WARNING, errno,
@@ -736,7 +739,7 @@ posix_istat (xlator_t *this, inode_t *inode, uuid_t gfid, const char *basename,
iatt_from_stat (&stbuf, &lstatbuf);
- if (inode && is_ctime_enabled()) {
+ if (inode && priv->ctime) {
ret = posix_get_mdata_xattr (this, real_path, -1, inode,
&stbuf);
if (ret) {
@@ -804,7 +807,7 @@ posix_pstat (xlator_t *this, inode_t *inode, uuid_t gfid, const char *path,
iatt_from_stat (&stbuf, &lstatbuf);
- if (inode && is_ctime_enabled()) {
+ if (inode && priv->ctime) {
if (!inode_locked) {
ret = posix_get_mdata_xattr (this, path, -1, inode, &stbuf);
} else {
diff --git a/xlators/storage/posix/src/posix-metadata.c b/xlators/storage/posix/src/posix-metadata.c
index 90030ff..fda8fb5 100644
--- a/xlators/storage/posix/src/posix-metadata.c
+++ b/xlators/storage/posix/src/posix-metadata.c
@@ -487,7 +487,11 @@ posix_update_utime_in_mdata (xlator_t *this, const char *real_path, int fd,
#endif
posix_mdata_flag_t flag = {0, };
- if (inode && is_ctime_enabled()) {
+ struct posix_private *priv = NULL;
+
+ priv = this->private;
+
+ if (inode && priv->ctime) {
if ((valid & GF_SET_ATTR_ATIME) == GF_SET_ATTR_ATIME) {
tv.tv_sec = stbuf->ia_atime;
SET_TIMESPEC_NSEC_OR_TIMEVAL_USEC(tv, stbuf->ia_atime_nsec);
@@ -522,14 +526,6 @@ posix_update_utime_in_mdata (xlator_t *this, const char *real_path, int fd,
return;
}
-gf_boolean_t
-is_ctime_enabled () {
- /* TODO: This gets implemented once glusterd changes are in place to
- * * enable and disable ctime feature
- * */
- return _gf_false;
-}
-
static void
posix_get_mdata_flag (uint64_t flags, posix_mdata_flag_t *flag)
{
@@ -572,8 +568,11 @@ posix_set_ctime (call_frame_t *frame, xlator_t *this, const char* real_path,
{
posix_mdata_flag_t flag = {0,};
int ret = 0;
+ struct posix_private *priv = NULL;
+
+ priv = this->private;
- if (inode && is_ctime_enabled()) {
+ if (inode && priv->ctime) {
(void) posix_get_mdata_flag (frame->root->flags, &flag);
ret = posix_set_mdata_xattr (this, real_path, fd, inode,
&frame->root->ctime, stbuf, &flag);
@@ -598,8 +597,11 @@ posix_set_parent_ctime (call_frame_t *frame, xlator_t *this,
{
posix_mdata_flag_t flag = {0,};
int ret = 0;
+ struct posix_private *priv = NULL;
+
+ priv = this->private;
- if (inode && is_ctime_enabled()) {
+ if (inode && priv->ctime) {
(void) posix_get_parent_mdata_flag (frame->root->flags, &flag);
ret = posix_set_mdata_xattr (this, real_path, fd, inode,
&frame->root->ctime, stbuf, &flag);
diff --git a/xlators/storage/posix/src/posix-metadata.h b/xlators/storage/posix/src/posix-metadata.h
index 48744fd..fbd79f6 100644
--- a/xlators/storage/posix/src/posix-metadata.h
+++ b/xlators/storage/posix/src/posix-metadata.h
@@ -48,7 +48,5 @@ void
posix_set_parent_ctime (call_frame_t *frame, xlator_t *this,
const char* real_path, int fd, inode_t *inode,
struct iatt *stbuf);
-gf_boolean_t
-is_ctime_enabled();
#endif /* _POSIX_METADATA_H */
diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h
index b5172a2..db525ad 100644
--- a/xlators/storage/posix/src/posix.h
+++ b/xlators/storage/posix/src/posix.h
@@ -262,6 +262,7 @@ struct posix_private {
uint32_t max_hardlinks;
gf_boolean_t fips_mode_rchecksum;
+ gf_boolean_t ctime;
};
typedef struct {