summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix-handle.c
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2018-04-23 04:22:09 -0400
committerAmar Tumballi <amarts@redhat.com>2018-05-06 07:06:53 +0530
commit9a854a98af69c1b7e06aa01dff7ea3271ebd574c (patch)
tree1a1de97e4938ba6bd7cda63cb903727680a186bf /xlators/storage/posix/src/posix-handle.c
parent3e24848f1e568ed3307683a9786f33d1ee15209b (diff)
posix/ctime: posix hooks to get consistent time xattr
This patch uses the ctime posix APIs to get consistent time across replica. The time attributes are got from from inode context or from on disk if not found and merged with iatt to be returned. Credits: Rafi KC <rkavunga@redhat.com> Updates: #208 Change-Id: Id737038ce52468f1f5ebc8a42cbf9c6ffbd63850 Signed-off-by: Kotresh HR <khiremat@redhat.com>
Diffstat (limited to 'xlators/storage/posix/src/posix-handle.c')
-rw-r--r--xlators/storage/posix/src/posix-handle.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/xlators/storage/posix/src/posix-handle.c b/xlators/storage/posix/src/posix-handle.c
index a3a8ea464d3..0bb4c055a3c 100644
--- a/xlators/storage/posix/src/posix-handle.c
+++ b/xlators/storage/posix/src/posix-handle.c
@@ -23,6 +23,7 @@
#include "xlator.h"
#include "syscall.h"
#include "posix-messages.h"
+#include "posix-metadata.h"
#include "compat-errno.h"
@@ -36,7 +37,7 @@ posix_resolve (xlator_t *this, inode_table_t *itable, inode_t *parent,
inode_t *inode = NULL;
int ret = -1;
- ret = posix_istat (this, parent->gfid, bname, iabuf);
+ ret = posix_istat (this, NULL, parent->gfid, bname, iabuf);
if (ret < 0) {
gf_log (this->name, GF_LOG_WARNING, "gfid: %s, bname: %s "
"failed", uuid_utoa (parent->gfid), bname);
@@ -53,6 +54,19 @@ posix_resolve (xlator_t *this, inode_table_t *itable, inode_t *parent,
}
}
+ /* posix_istat wouldn't have fetched posix_mdata_t i.e.,
+ * time attributes as inode is passed as NULL, hence get
+ * here once you got the inode
+ */
+ ret = posix_get_mdata_xattr (this, NULL, -1, inode, iabuf);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_WARNING, errno,
+ P_MSG_GETMDATA_FAILED,
+ "posix get mdata failed on gfid:%s",
+ uuid_utoa (inode->gfid));
+ goto out;
+ }
+
/* Linking an inode here, can cause a race in posix_acl.
Parent inode gets linked here, but before
it reaches posix_acl_readdirp_cbk, create/lookup can
@@ -939,8 +953,10 @@ posix_handle_unset (xlator_t *this, uuid_t gfid, const char *basename)
return -1;
}
- ret = posix_istat (this, gfid, basename, &stat);
-
+ /* stat is being used only for gfid, so passing a NULL inode
+ * doesn't fetch time attributes which is fine
+ */
+ ret = posix_istat (this, NULL, gfid, basename, &stat);
if (ret == -1) {
gf_msg (this->name, GF_LOG_WARNING, errno,
P_MSG_HANDLE_DELETE, "%s", path);