summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix-helpers.c
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2018-04-02 08:31:25 -0400
committerAmar Tumballi <amarts@redhat.com>2018-05-06 07:09:08 +0530
commitf8fe0771f0b450713595a7d298ed5a758cf2ce3e (patch)
tree8066610f5d3343c5f71b52c9159a701e7450c7a3 /xlators/storage/posix/src/posix-helpers.c
parent9a854a98af69c1b7e06aa01dff7ea3271ebd574c (diff)
posix/ctime: posix hook to set ctime xattr in relevant fops
This patch uses the ctime posix APIs to set consistent time across replica on disk. It also stores the time attributes in the inode context. Credits: Rafi KC <rkavunga@redhat.com> Updates: #208 Change-Id: I1a8d74d1e251f1d6d142f066fc99258025c0bcdd Signed-off-by: Kotresh HR <khiremat@redhat.com>
Diffstat (limited to 'xlators/storage/posix/src/posix-helpers.c')
-rw-r--r--xlators/storage/posix/src/posix-helpers.c44
1 files changed, 42 insertions, 2 deletions
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index 6a34e38..75fb045 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -104,6 +104,44 @@ out:
}
int
+posix_handle_mdata_xattr (call_frame_t *frame, const char *name, int *op_errno)
+{
+ int i = 0;
+ int ret = 0;
+ int pid = 1;
+ static const char * const internal_xattr[] = { GF_XATTR_MDATA_KEY,
+ NULL
+ };
+ if (frame && frame->root) {
+ pid = frame->root->pid;
+ }
+
+ if (!name || pid < GF_CLIENT_PID_MAX) {
+ /* No need to do anything here */
+ ret = 0;
+ goto out;
+ }
+
+ for (i = 0; internal_xattr[i]; i++) {
+ if (fnmatch (internal_xattr[i] , name, FNM_PERIOD) == 0) {
+ ret = -1;
+ if (op_errno) {
+ *op_errno = ENOATTR;
+ }
+
+ gf_msg_debug ("posix", ENOATTR,
+ "Ignoring the key %s as an internal "
+ "xattrs.", name);
+ goto out;
+ }
+ }
+
+ ret = 0;
+out:
+ return ret;
+}
+
+int
posix_handle_georep_xattrs (call_frame_t *frame, const char *name,
int *op_errno, gf_boolean_t is_getxattr)
{
@@ -1297,8 +1335,8 @@ out:
}
int
-posix_fhandle_pair (xlator_t *this, int fd,
- char *key, data_t *value, int flags, struct iatt *stbuf)
+posix_fhandle_pair (call_frame_t *frame, xlator_t *this, int fd, char *key,
+ data_t *value, int flags, struct iatt *stbuf, fd_t *_fd)
{
int sys_ret = -1;
int ret = 0;
@@ -1344,6 +1382,8 @@ posix_fhandle_pair (xlator_t *this, int fd,
}
goto out;
+ } else if (_fd) {
+ posix_set_ctime (frame, this, NULL, fd, _fd->inode, NULL);
}
out: