diff options
author | Kotresh HR <khiremat@redhat.com> | 2019-06-24 13:06:49 +0530 |
---|---|---|
committer | Rinku Kothiya <rkothiya@redhat.com> | 2019-08-19 11:27:14 +0000 |
commit | 8d2aebf93baed6f8555cd02545d6f95da59cc7f3 (patch) | |
tree | 1ea84070457dea886fd46d33e3fd69812ff5eb02 /rpc/xdr | |
parent | 8b7ceb3934f8e2dbcbabe5d1c0244c2bacda92c3 (diff) |
ctime: Set mdata xattr on legacy files
Problem:
The files which were created before ctime enabled would not
have "trusted.glusterfs.mdata"(stores time attributes) xattr.
Upon fops which modifies either ctime or mtime, the xattr
gets created with latest ctime, mtime and atime, which is
incorrect. It should update only the corresponding time
attribute and rest from backend
Solution:
Creating xattr with values from brick is not possible as
each brick of replica set would have different times.
So create the xattr upon successful lookup if the xattr
is not created
Note To Reviewers:
The time attributes used to set xattr is got from successful
lookup. Instead of sending the whole iatt over the wire via
setxattr, a structure called mdata_iatt is sent. The mdata_iatt
contains only time attributes.
Backport of:
> Patch: https://review.gluster.org/22936
> Change-Id: I5e535631ddef04195361ae0364336410a2895dd4
> BUG: 1593542
> Signed-off-by: Kotresh HR <khiremat@redhat.com>
Change-Id: I5e535631ddef04195361ae0364336410a2895dd4
updates: bz#1739430
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Diffstat (limited to 'rpc/xdr')
-rw-r--r-- | rpc/xdr/src/glusterfs-fops.x | 1 | ||||
-rw-r--r-- | rpc/xdr/src/glusterfs3.h | 59 | ||||
-rw-r--r-- | rpc/xdr/src/glusterfs4-xdr.x | 12 | ||||
-rw-r--r-- | rpc/xdr/src/libgfxdr.sym | 3 |
4 files changed, 74 insertions, 1 deletions
diff --git a/rpc/xdr/src/glusterfs-fops.x b/rpc/xdr/src/glusterfs-fops.x index bacf07735f4..651f8def0ba 100644 --- a/rpc/xdr/src/glusterfs-fops.x +++ b/rpc/xdr/src/glusterfs-fops.x @@ -245,5 +245,6 @@ enum gf_dict_data_type_t { GF_DATA_TYPE_PTR, GF_DATA_TYPE_GFUUID, GF_DATA_TYPE_IATT, + GF_DATA_TYPE_MDATA, GF_DATA_TYPE_MAX }; diff --git a/rpc/xdr/src/glusterfs3.h b/rpc/xdr/src/glusterfs3.h index 5521f4d4eca..86b3a4c0e5d 100644 --- a/rpc/xdr/src/glusterfs3.h +++ b/rpc/xdr/src/glusterfs3.h @@ -585,6 +585,34 @@ out: } static inline void +gfx_mdata_iatt_to_mdata_iatt(struct gfx_mdata_iatt *gf_mdata_iatt, + struct mdata_iatt *mdata_iatt) +{ + if (!mdata_iatt || !gf_mdata_iatt) + return; + mdata_iatt->ia_atime = gf_mdata_iatt->ia_atime; + mdata_iatt->ia_atime_nsec = gf_mdata_iatt->ia_atime_nsec; + mdata_iatt->ia_mtime = gf_mdata_iatt->ia_mtime; + mdata_iatt->ia_mtime_nsec = gf_mdata_iatt->ia_mtime_nsec; + mdata_iatt->ia_ctime = gf_mdata_iatt->ia_ctime; + mdata_iatt->ia_ctime_nsec = gf_mdata_iatt->ia_ctime_nsec; +} + +static inline void +gfx_mdata_iatt_from_mdata_iatt(struct gfx_mdata_iatt *gf_mdata_iatt, + struct mdata_iatt *mdata_iatt) +{ + if (!mdata_iatt || !gf_mdata_iatt) + return; + gf_mdata_iatt->ia_atime = mdata_iatt->ia_atime; + gf_mdata_iatt->ia_atime_nsec = mdata_iatt->ia_atime_nsec; + gf_mdata_iatt->ia_mtime = mdata_iatt->ia_mtime; + gf_mdata_iatt->ia_mtime_nsec = mdata_iatt->ia_mtime_nsec; + gf_mdata_iatt->ia_ctime = mdata_iatt->ia_ctime; + gf_mdata_iatt->ia_ctime_nsec = mdata_iatt->ia_ctime_nsec; +} + +static inline void gfx_stat_to_iattx(struct gfx_iattx *gf_stat, struct iatt *iatt) { if (!iatt || !gf_stat) @@ -721,6 +749,12 @@ dict_to_xdr(dict_t *this, gfx_dict *dict) gfx_stat_from_iattx(&xpair->value.gfx_value_u.iatt, (struct iatt *)dpair->value->data); break; + case GF_DATA_TYPE_MDATA: + index++; + gfx_mdata_iatt_from_mdata_iatt( + &xpair->value.gfx_value_u.mdata_iatt, + (struct mdata_iatt *)dpair->value->data); + break; case GF_DATA_TYPE_GFUUID: index++; memcpy(&xpair->value.gfx_value_u.uuid, dpair->value->data, @@ -787,6 +821,7 @@ xdr_to_dict(gfx_dict *dict, dict_t **to) dict_t *this = NULL; unsigned char *uuid = NULL; struct iatt *iatt = NULL; + struct mdata_iatt *mdata_iatt = NULL; if (!to || !dict) goto out; @@ -854,6 +889,30 @@ xdr_to_dict(gfx_dict *dict, dict_t **to) gfx_stat_to_iattx(&xpair->value.gfx_value_u.iatt, iatt); ret = dict_set_iatt(this, key, iatt, false); break; + case GF_DATA_TYPE_MDATA: + mdata_iatt = GF_CALLOC(1, sizeof(struct mdata_iatt), + gf_common_mt_char); + if (!mdata_iatt) { + errno = ENOMEM; + gf_msg(THIS->name, GF_LOG_ERROR, ENOMEM, LG_MSG_NO_MEMORY, + "failed to allocate memory. key: %s", key); + ret = -1; + goto out; + } + gfx_mdata_iatt_to_mdata_iatt( + &xpair->value.gfx_value_u.mdata_iatt, mdata_iatt); + ret = dict_set_mdata(this, key, mdata_iatt, false); + if (ret != 0) { + GF_FREE(mdata_iatt); + gf_msg(THIS->name, GF_LOG_ERROR, ENOMEM, + LG_MSG_DICT_SET_FAILED, + "failed to set the key (%s)" + " into dict", + key); + ret = -1; + goto out; + } + break; case GF_DATA_TYPE_PTR: case GF_DATA_TYPE_STR_OLD: value = GF_MALLOC(xpair->value.gfx_value_u.other.other_len + 1, diff --git a/rpc/xdr/src/glusterfs4-xdr.x b/rpc/xdr/src/glusterfs4-xdr.x index 6d13aafc9eb..30597850e23 100644 --- a/rpc/xdr/src/glusterfs4-xdr.x +++ b/rpc/xdr/src/glusterfs4-xdr.x @@ -46,6 +46,16 @@ struct gfx_iattx { unsigned int mode; /* type of file and rwx mode */ }; +struct gfx_mdata_iatt { + hyper ia_atime; /* last access time */ + hyper ia_mtime; /* last modification time */ + hyper ia_ctime; /* last status change time */ + + unsigned int ia_atime_nsec; + unsigned int ia_mtime_nsec; + unsigned int ia_ctime_nsec; +}; + union gfx_value switch (gf_dict_data_type_t type) { case GF_DATA_TYPE_INT: hyper value_int; @@ -62,6 +72,8 @@ union gfx_value switch (gf_dict_data_type_t type) { case GF_DATA_TYPE_PTR: case GF_DATA_TYPE_STR_OLD: opaque other<>; + case GF_DATA_TYPE_MDATA: + gfx_mdata_iatt mdata_iatt; }; /* AUTH */ diff --git a/rpc/xdr/src/libgfxdr.sym b/rpc/xdr/src/libgfxdr.sym index 22cdf30bfda..dd4ac8562bc 100644 --- a/rpc/xdr/src/libgfxdr.sym +++ b/rpc/xdr/src/libgfxdr.sym @@ -251,6 +251,7 @@ xdr_to_write3args xdr_vector_round_up xdr_gfx_read_rsp xdr_gfx_iattx +xdr_gfx_mdata_iatt xdr_gfx_value xdr_gfx_dict_pair xdr_gfx_dict @@ -344,4 +345,4 @@ xdr_compound_req_v2 xdr_gfx_compound_req xdr_compound_rsp_v2 xdr_gfx_compound_rsp -xdr_gfx_copy_file_range_req
\ No newline at end of file +xdr_gfx_copy_file_range_req |