From 06e92a2ee437c1a81c815129b1d188af0b4fa84e Mon Sep 17 00:00:00 2001 From: Kotresh HR Date: Mon, 24 Jun 2019 13:06:49 +0530 Subject: 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. Change-Id: I5e535631ddef04195361ae0364336410a2895dd4 fixes: bz#1593542 Signed-off-by: Kotresh HR --- libglusterfs/src/glusterfs/iatt.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'libglusterfs/src/glusterfs/iatt.h') diff --git a/libglusterfs/src/glusterfs/iatt.h b/libglusterfs/src/glusterfs/iatt.h index bee7a0afa7..f03d68b02f 100644 --- a/libglusterfs/src/glusterfs/iatt.h +++ b/libglusterfs/src/glusterfs/iatt.h @@ -92,6 +92,15 @@ struct old_iatt { uint32_t ia_ctime_nsec; }; +struct mdata_iatt { + int64_t ia_atime; /* last access time */ + int64_t ia_mtime; /* last modification time */ + int64_t ia_ctime; /* last status change time */ + uint32_t ia_atime_nsec; + uint32_t ia_mtime_nsec; + uint32_t ia_ctime_nsec; +}; + /* 64-bit mask for valid members in struct iatt. */ #define IATT_TYPE 0x0000000000000001U #define IATT_MODE 0x0000000000000002U @@ -313,6 +322,17 @@ st_mode_from_ia(ia_prot_t prot, ia_type_t type) return st_mode; } +static inline void +iatt_to_mdata(struct mdata_iatt *mdata, struct iatt *iatt) +{ + mdata->ia_atime = iatt->ia_atime; + mdata->ia_atime_nsec = iatt->ia_atime_nsec; + mdata->ia_mtime = iatt->ia_mtime; + mdata->ia_mtime_nsec = iatt->ia_mtime_nsec; + mdata->ia_ctime = iatt->ia_ctime; + mdata->ia_ctime_nsec = iatt->ia_ctime_nsec; +} + static inline int iatt_from_stat(struct iatt *iatt, struct stat *stat) { -- cgit