14f8ab
From 90254e4ae9455fa0a126f83700978a9314eb79ea Mon Sep 17 00:00:00 2001
14f8ab
From: Anuradha Talur <atalur@commvault.com>
14f8ab
Date: Thu, 29 Nov 2018 12:54:21 -0800
14f8ab
Subject: [PATCH 153/169] features/cloudsync : Added some new functions
14f8ab
14f8ab
This patch contains the following changes:
14f8ab
1) Store ID info will now be stored in the inode ctx
14f8ab
2) Added new readv type where read is made directly
14f8ab
   from the remote store. This choice is made by
14f8ab
   volume set operation.
14f8ab
3) cs_forget() was missing. Added it.
14f8ab
14f8ab
backport of:https://review.gluster.org/#/c/glusterfs/+/21757/
14f8ab
14f8ab
> Change-Id: Ie3232b3d7ffb5313a03f011b0553b19793eedfa2
14f8ab
> fixes: bz#1642168
14f8ab
> Signed-off-by: Anuradha Talur <atalur@commvault.com>
14f8ab
14f8ab
Change-Id: I089e5a8c93049cf6bfabf011673796e38e78d7ee
14f8ab
Signed-off-by: Susant Palai <spalai@redhat.com>
14f8ab
Reviewed-on: https://code.engineering.redhat.com/gerrit/172192
14f8ab
Tested-by: RHGS Build Bot <nigelb@redhat.com>
14f8ab
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
14f8ab
---
14f8ab
 xlators/features/cloudsync/src/cloudsync-common.c  |  16 +
14f8ab
 xlators/features/cloudsync/src/cloudsync-common.h  |  35 ++
14f8ab
 xlators/features/cloudsync/src/cloudsync-fops-c.py |  12 +-
14f8ab
 .../features/cloudsync/src/cloudsync-mem-types.h   |   1 +
14f8ab
 xlators/features/cloudsync/src/cloudsync.c         | 600 ++++++++++++++++++---
14f8ab
 xlators/features/cloudsync/src/cloudsync.h         |  20 +
14f8ab
 xlators/mgmt/glusterd/src/glusterd-volume-set.c    |   7 +-
14f8ab
 7 files changed, 597 insertions(+), 94 deletions(-)
14f8ab
14f8ab
diff --git a/xlators/features/cloudsync/src/cloudsync-common.c b/xlators/features/cloudsync/src/cloudsync-common.c
14f8ab
index aee1f06..445a31b 100644
14f8ab
--- a/xlators/features/cloudsync/src/cloudsync-common.c
14f8ab
+++ b/xlators/features/cloudsync/src/cloudsync-common.c
14f8ab
@@ -11,6 +11,20 @@
14f8ab
 #include "cloudsync-common.h"
14f8ab
 
14f8ab
 void
14f8ab
+cs_xattrinfo_wipe(cs_local_t *local)
14f8ab
+{
14f8ab
+    if (local->xattrinfo.lxattr) {
14f8ab
+        if (local->xattrinfo.lxattr->file_path)
14f8ab
+            GF_FREE(local->xattrinfo.lxattr->file_path);
14f8ab
+
14f8ab
+        if (local->xattrinfo.lxattr->volname)
14f8ab
+            GF_FREE(local->xattrinfo.lxattr->volname);
14f8ab
+
14f8ab
+        GF_FREE(local->xattrinfo.lxattr);
14f8ab
+    }
14f8ab
+}
14f8ab
+
14f8ab
+void
14f8ab
 cs_local_wipe(xlator_t *this, cs_local_t *local)
14f8ab
 {
14f8ab
     if (!local)
14f8ab
@@ -40,5 +54,7 @@ cs_local_wipe(xlator_t *this, cs_local_t *local)
14f8ab
     if (local->remotepath)
14f8ab
         GF_FREE(local->remotepath);
14f8ab
 
14f8ab
+    cs_xattrinfo_wipe(local);
14f8ab
+
14f8ab
     mem_put(local);
14f8ab
 }
14f8ab
diff --git a/xlators/features/cloudsync/src/cloudsync-common.h b/xlators/features/cloudsync/src/cloudsync-common.h
14f8ab
index 7b3520c..11d2334 100644
14f8ab
--- a/xlators/features/cloudsync/src/cloudsync-common.h
14f8ab
+++ b/xlators/features/cloudsync/src/cloudsync-common.h
14f8ab
@@ -14,9 +14,23 @@
14f8ab
 #include <glusterfs/call-stub.h>
14f8ab
 #include <glusterfs/xlator.h>
14f8ab
 #include <glusterfs/syncop.h>
14f8ab
+#include <glusterfs/compat-errno.h>
14f8ab
 #include "cloudsync-mem-types.h"
14f8ab
 #include "cloudsync-messages.h"
14f8ab
 
14f8ab
+typedef struct cs_loc_xattr {
14f8ab
+    char *file_path;
14f8ab
+    uuid_t uuid;
14f8ab
+    uuid_t gfid;
14f8ab
+    char *volname;
14f8ab
+} cs_loc_xattr_t;
14f8ab
+
14f8ab
+typedef struct cs_size_xattr {
14f8ab
+    uint64_t size;
14f8ab
+    uint64_t blksize;
14f8ab
+    uint64_t blocks;
14f8ab
+} cs_size_xattr_t;
14f8ab
+
14f8ab
 typedef struct cs_local {
14f8ab
     loc_t loc;
14f8ab
     fd_t *fd;
14f8ab
@@ -34,10 +48,25 @@ typedef struct cs_local {
14f8ab
     int call_cnt;
14f8ab
     inode_t *inode;
14f8ab
     char *remotepath;
14f8ab
+
14f8ab
+    struct {
14f8ab
+        /* offset, flags and size are the information needed
14f8ab
+         * by read fop for remote read operation. These will be
14f8ab
+         * populated in cloudsync read fop, before being passed
14f8ab
+         * on to the plugin performing remote read.
14f8ab
+         */
14f8ab
+        off_t offset;
14f8ab
+        uint32_t flags;
14f8ab
+        size_t size;
14f8ab
+        cs_loc_xattr_t *lxattr;
14f8ab
+    } xattrinfo;
14f8ab
+
14f8ab
 } cs_local_t;
14f8ab
 
14f8ab
 typedef int (*fop_download_t)(call_frame_t *frame, void *config);
14f8ab
 
14f8ab
+typedef int (*fop_remote_read_t)(call_frame_t *, void *);
14f8ab
+
14f8ab
 typedef void *(*store_init)(xlator_t *this);
14f8ab
 
14f8ab
 typedef int (*store_reconfigure)(xlator_t *this, dict_t *options);
14f8ab
@@ -48,6 +77,7 @@ struct cs_remote_stores {
14f8ab
     char *name;                    /* store name */
14f8ab
     void *config;                  /* store related information */
14f8ab
     fop_download_t dlfop;          /* store specific download function */
14f8ab
+    fop_remote_read_t rdfop;       /* store specific read function */
14f8ab
     store_init init;               /* store init to initialize store config */
14f8ab
     store_reconfigure reconfigure; /* reconfigure store config */
14f8ab
     store_fini fini;
14f8ab
@@ -59,11 +89,15 @@ typedef struct cs_private {
14f8ab
     struct cs_remote_stores *stores;
14f8ab
     gf_boolean_t abortdl;
14f8ab
     pthread_spinlock_t lock;
14f8ab
+    gf_boolean_t remote_read;
14f8ab
 } cs_private_t;
14f8ab
 
14f8ab
 void
14f8ab
 cs_local_wipe(xlator_t *this, cs_local_t *local);
14f8ab
 
14f8ab
+void
14f8ab
+cs_xattrinfo_wipe(cs_local_t *local);
14f8ab
+
14f8ab
 #define CS_STACK_UNWIND(fop, frame, params...)                                 \
14f8ab
     do {                                                                       \
14f8ab
         cs_local_t *__local = NULL;                                            \
14f8ab
@@ -90,6 +124,7 @@ cs_local_wipe(xlator_t *this, cs_local_t *local);
14f8ab
 
14f8ab
 typedef struct store_methods {
14f8ab
     int (*fop_download)(call_frame_t *frame, void *config);
14f8ab
+    int (*fop_remote_read)(call_frame_t *, void *);
14f8ab
     /* return type should be the store config */
14f8ab
     void *(*fop_init)(xlator_t *this);
14f8ab
     int (*fop_reconfigure)(xlator_t *this, dict_t *options);
14f8ab
diff --git a/xlators/features/cloudsync/src/cloudsync-fops-c.py b/xlators/features/cloudsync/src/cloudsync-fops-c.py
14f8ab
index 3122bd3..a7a2201 100755
14f8ab
--- a/xlators/features/cloudsync/src/cloudsync-fops-c.py
14f8ab
+++ b/xlators/features/cloudsync/src/cloudsync-fops-c.py
14f8ab
@@ -137,15 +137,15 @@ cs_@NAME@_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
14f8ab
                         } else {
14f8ab
                                 __cs_inode_ctx_update (this, fd->inode, val);
14f8ab
                                 gf_msg (this->name, GF_LOG_INFO, 0, 0,
14f8ab
-                                        " state = %ld", val);
14f8ab
+                                        " state = %" PRIu64, val);
14f8ab
 
14f8ab
                                 if (local->call_cnt == 1 &&
14f8ab
                                     (val == GF_CS_REMOTE ||
14f8ab
                                      val == GF_CS_DOWNLOADING))  {
14f8ab
                                         gf_msg (this->name, GF_LOG_INFO, 0,
14f8ab
                                                 0, " will repair and download "
14f8ab
-                                                "the file, current state : %ld",
14f8ab
-                                                val);
14f8ab
+                                                "the file, current state : %"
14f8ab
+                                                PRIu64, val);
14f8ab
                                         goto repair;
14f8ab
                                 } else {
14f8ab
                                         gf_msg (this->name, GF_LOG_ERROR, 0, 0,
14f8ab
@@ -274,7 +274,7 @@ fd_ops = ['readv', 'writev', 'flush', 'fsync', 'fsyncdir', 'ftruncate',
14f8ab
 # These are the current actual lists used to generate the code
14f8ab
 
14f8ab
 # The following list contains fops which are fd based that modifies data
14f8ab
-fd_data_modify_op_fop_template = ['readv', 'writev', 'flush', 'fsync',
14f8ab
+fd_data_modify_op_fop_template = ['writev', 'flush', 'fsync',
14f8ab
                                   'ftruncate', 'rchecksum', 'fallocate',
14f8ab
                                   'discard', 'zerofill', 'seek']
14f8ab
 
14f8ab
@@ -284,8 +284,8 @@ loc_stat_op_fop_template = ['lookup', 'stat', 'discover', 'access', 'setattr',
14f8ab
                             'getattr']
14f8ab
 
14f8ab
 # These fops need a separate implementation
14f8ab
-special_fops = ['readdirp', 'statfs', 'setxattr', 'unlink', 'getxattr',
14f8ab
-                'truncate', 'fstat']
14f8ab
+special_fops = ['statfs', 'setxattr', 'unlink', 'getxattr',
14f8ab
+                'truncate', 'fstat', 'readv']
14f8ab
 
14f8ab
 def gen_defaults():
14f8ab
     for name in ops:
14f8ab
diff --git a/xlators/features/cloudsync/src/cloudsync-mem-types.h b/xlators/features/cloudsync/src/cloudsync-mem-types.h
14f8ab
index 9e6837a..2203464 100644
14f8ab
--- a/xlators/features/cloudsync/src/cloudsync-mem-types.h
14f8ab
+++ b/xlators/features/cloudsync/src/cloudsync-mem-types.h
14f8ab
@@ -16,6 +16,7 @@ enum cs_mem_types_ {
14f8ab
     gf_cs_mt_cs_private_t = gf_common_mt_end + 1,
14f8ab
     gf_cs_mt_cs_remote_stores_t,
14f8ab
     gf_cs_mt_cs_inode_ctx_t,
14f8ab
+    gf_cs_mt_cs_lxattr_t,
14f8ab
     gf_cs_mt_end
14f8ab
 };
14f8ab
 #endif /* __CLOUDSYNC_MEM_TYPES_H__ */
14f8ab
diff --git a/xlators/features/cloudsync/src/cloudsync.c b/xlators/features/cloudsync/src/cloudsync.c
14f8ab
index fbdcdf7..2240fc3 100644
14f8ab
--- a/xlators/features/cloudsync/src/cloudsync.c
14f8ab
+++ b/xlators/features/cloudsync/src/cloudsync.c
14f8ab
@@ -16,6 +16,7 @@
14f8ab
 #include <glusterfs/call-stub.h>
14f8ab
 #include "cloudsync-autogen-fops.h"
14f8ab
 
14f8ab
+#include <string.h>
14f8ab
 #include <dlfcn.h>
14f8ab
 
14f8ab
 void
14f8ab
@@ -72,6 +73,8 @@ cs_init(xlator_t *this)
14f8ab
 
14f8ab
     this->private = priv;
14f8ab
 
14f8ab
+    GF_OPTION_INIT("cloudsync-remote-read", priv->remote_read, bool, out);
14f8ab
+
14f8ab
     /* temp workaround. Should be configurable through glusterd*/
14f8ab
     per_vol = _gf_true;
14f8ab
 
14f8ab
@@ -135,6 +138,18 @@ cs_init(xlator_t *this)
14f8ab
 
14f8ab
         (void)dlerror();
14f8ab
 
14f8ab
+        if (priv->remote_read) {
14f8ab
+            priv->stores->rdfop = store_methods->fop_remote_read;
14f8ab
+            if (!priv->stores->rdfop) {
14f8ab
+                gf_msg(this->name, GF_LOG_ERROR, 0, 0,
14f8ab
+                       "failed to get"
14f8ab
+                       " read fop %s",
14f8ab
+                       dlerror());
14f8ab
+                ret = -1;
14f8ab
+                goto out;
14f8ab
+            }
14f8ab
+        }
14f8ab
+
14f8ab
         priv->stores->dlfop = store_methods->fop_download;
14f8ab
         if (!priv->stores->dlfop) {
14f8ab
             gf_msg(this->name, GF_LOG_ERROR, 0, 0,
14f8ab
@@ -196,6 +211,22 @@ out:
14f8ab
     return ret;
14f8ab
 }
14f8ab
 
14f8ab
+int
14f8ab
+cs_forget(xlator_t *this, inode_t *inode)
14f8ab
+{
14f8ab
+    uint64_t ctx_int = 0;
14f8ab
+    cs_inode_ctx_t *ctx = NULL;
14f8ab
+
14f8ab
+    inode_ctx_del(inode, this, &ctx_int);
14f8ab
+    if (!ctx_int)
14f8ab
+        return 0;
14f8ab
+
14f8ab
+    ctx = (cs_inode_ctx_t *)(uintptr_t)ctx_int;
14f8ab
+
14f8ab
+    GF_FREE(ctx);
14f8ab
+    return 0;
14f8ab
+}
14f8ab
+
14f8ab
 void
14f8ab
 cs_fini(xlator_t *this)
14f8ab
 {
14f8ab
@@ -217,6 +248,9 @@ cs_reconfigure(xlator_t *this, dict_t *options)
14f8ab
         goto out;
14f8ab
     }
14f8ab
 
14f8ab
+    GF_OPTION_RECONF("cloudsync-remote-read", priv->remote_read, options, bool,
14f8ab
+                     out);
14f8ab
+
14f8ab
     /* needed only for per volume configuration*/
14f8ab
     ret = priv->stores->reconfigure(this, options);
14f8ab
 
14f8ab
@@ -242,59 +276,6 @@ out:
14f8ab
 }
14f8ab
 
14f8ab
 int32_t
14f8ab
-cs_readdirp_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
14f8ab
-                int32_t op_ret, int32_t op_errno, gf_dirent_t *entries,
14f8ab
-                dict_t *xdata)
14f8ab
-{
14f8ab
-    gf_dirent_t *tmp = NULL;
14f8ab
-    char *sxattr = NULL;
14f8ab
-    uint64_t ia_size = 0;
14f8ab
-    int ret = 0;
14f8ab
-
14f8ab
-    list_for_each_entry(tmp, &entries->list, list)
14f8ab
-    {
14f8ab
-        ret = dict_get_str(tmp->dict, GF_CS_OBJECT_SIZE, &sxattr);
14f8ab
-        if (ret) {
14f8ab
-            gf_msg_trace(this->name, 0, "size xattr found");
14f8ab
-            continue;
14f8ab
-        }
14f8ab
-
14f8ab
-        ia_size = atoll(sxattr);
14f8ab
-        tmp->d_stat.ia_size = ia_size;
14f8ab
-    }
14f8ab
-
14f8ab
-    STACK_UNWIND_STRICT(readdirp, frame, op_ret, op_errno, entries, xdata);
14f8ab
-    return 0;
14f8ab
-}
14f8ab
-
14f8ab
-int32_t
14f8ab
-cs_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
14f8ab
-            off_t off, dict_t *xdata)
14f8ab
-{
14f8ab
-    int ret = 0;
14f8ab
-    int op_errno = ENOMEM;
14f8ab
-
14f8ab
-    if (!xdata) {
14f8ab
-        xdata = dict_new();
14f8ab
-        if (!xdata) {
14f8ab
-            goto err;
14f8ab
-        }
14f8ab
-    }
14f8ab
-
14f8ab
-    ret = dict_set_int32(xdata, GF_CS_OBJECT_SIZE, 1);
14f8ab
-    if (ret) {
14f8ab
-        goto err;
14f8ab
-    }
14f8ab
-
14f8ab
-    STACK_WIND(frame, cs_readdirp_cbk, FIRST_CHILD(this),
14f8ab
-               FIRST_CHILD(this)->fops->readdirp, fd, size, off, xdata);
14f8ab
-    return 0;
14f8ab
-err:
14f8ab
-    STACK_UNWIND_STRICT(readdirp, frame, -1, op_errno, NULL, NULL);
14f8ab
-    return 0;
14f8ab
-}
14f8ab
-
14f8ab
-int32_t
14f8ab
 cs_truncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
14f8ab
                 int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
14f8ab
                 struct iatt *postbuf, dict_t *xdata)
14f8ab
@@ -305,7 +286,6 @@ cs_truncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
14f8ab
 
14f8ab
     local = frame->local;
14f8ab
 
14f8ab
-    /* Do we need lock here? */
14f8ab
     local->call_cnt++;
14f8ab
 
14f8ab
     if (op_ret == -1) {
14f8ab
@@ -320,13 +300,13 @@ cs_truncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
14f8ab
                 goto unwind;
14f8ab
             } else {
14f8ab
                 __cs_inode_ctx_update(this, local->loc.inode, val);
14f8ab
-                gf_msg(this->name, GF_LOG_INFO, 0, 0, " state = %ld", val);
14f8ab
+                gf_msg(this->name, GF_LOG_INFO, 0, 0, " state = %" PRIu64, val);
14f8ab
 
14f8ab
                 if (local->call_cnt == 1 &&
14f8ab
                     (val == GF_CS_REMOTE || val == GF_CS_DOWNLOADING)) {
14f8ab
                     gf_msg(this->name, GF_LOG_WARNING, 0, 0,
14f8ab
                            "will repair and download "
14f8ab
-                           "the file, current state : %ld",
14f8ab
+                           "the file, current state : %" PRIu64,
14f8ab
                            val);
14f8ab
                     goto repair;
14f8ab
                 } else {
14f8ab
@@ -665,7 +645,7 @@ cs_fstat_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
14f8ab
     if (op_ret == 0) {
14f8ab
         ret = dict_get_uint64(xdata, GF_CS_OBJECT_STATUS, &val;;
14f8ab
         if (!ret) {
14f8ab
-            gf_msg_debug(this->name, 0, "state %ld", val);
14f8ab
+            gf_msg_debug(this->name, 0, "state %" PRIu64, val);
14f8ab
             ret = __cs_inode_ctx_update(this, fd->inode, val);
14f8ab
             if (ret) {
14f8ab
                 gf_msg(this->name, GF_LOG_ERROR, 0, 0, "ctx update failed");
14f8ab
@@ -831,7 +811,7 @@ out:
14f8ab
     return 0;
14f8ab
 }
14f8ab
 
14f8ab
-void *
14f8ab
+int
14f8ab
 cs_download_task(void *arg)
14f8ab
 {
14f8ab
     call_frame_t *frame = NULL;
14f8ab
@@ -842,7 +822,6 @@ cs_download_task(void *arg)
14f8ab
     fd_t *fd = NULL;
14f8ab
     cs_local_t *local = NULL;
14f8ab
     dict_t *dict = NULL;
14f8ab
-    int *retval = NULL;
14f8ab
 
14f8ab
     frame = (call_frame_t *)arg;
14f8ab
 
14f8ab
@@ -850,13 +829,6 @@ cs_download_task(void *arg)
14f8ab
 
14f8ab
     priv = this->private;
14f8ab
 
14f8ab
-    retval = GF_CALLOC(1, sizeof(int), gf_common_mt_int);
14f8ab
-    if (!retval) {
14f8ab
-        gf_msg(this->name, GF_LOG_ERROR, 0, 0, "insufficient memory");
14f8ab
-        ret = -1;
14f8ab
-        goto out;
14f8ab
-    }
14f8ab
-
14f8ab
     if (!priv->stores) {
14f8ab
         gf_msg(this->name, GF_LOG_ERROR, 0, 0,
14f8ab
                "No remote store "
14f8ab
@@ -972,20 +944,13 @@ out:
14f8ab
         local->dlfd = NULL;
14f8ab
     }
14f8ab
 
14f8ab
-    if (retval) {
14f8ab
-        *retval = ret;
14f8ab
-        pthread_exit(retval);
14f8ab
-    } else {
14f8ab
-        pthread_exit(&ret;;
14f8ab
-    }
14f8ab
+    return ret;
14f8ab
 }
14f8ab
 
14f8ab
 int
14f8ab
 cs_download(call_frame_t *frame)
14f8ab
 {
14f8ab
-    int *retval = NULL;
14f8ab
     int ret = 0;
14f8ab
-    pthread_t dthread;
14f8ab
     cs_local_t *local = NULL;
14f8ab
     xlator_t *this = NULL;
14f8ab
 
14f8ab
@@ -1000,16 +965,406 @@ cs_download(call_frame_t *frame)
14f8ab
         goto out;
14f8ab
     }
14f8ab
 
14f8ab
-    ret = gf_thread_create(&dthread, NULL, &cs_download_task, (void *)frame,
14f8ab
-                           "downloadthread");
14f8ab
+    ret = cs_download_task((void *)frame);
14f8ab
+out:
14f8ab
+    return ret;
14f8ab
+}
14f8ab
 
14f8ab
-    pthread_join(dthread, (void **)&retval);
14f8ab
+int
14f8ab
+cs_set_xattr_req(call_frame_t *frame)
14f8ab
+{
14f8ab
+    cs_local_t *local = NULL;
14f8ab
+    GF_UNUSED int ret = 0;
14f8ab
+
14f8ab
+    local = frame->local;
14f8ab
+
14f8ab
+    /* When remote reads are performed (i.e. reads on remote store),
14f8ab
+     * there needs to be a way to associate a file on gluster volume
14f8ab
+     * with its correspnding file on the remote store. In order to do
14f8ab
+     * that, a unique key can be maintained as an xattr
14f8ab
+     * (GF_CS_XATTR_ARCHIVE_UUID)on the stub file on gluster bricks.
14f8ab
+     * This xattr should be provided to the plugin to
14f8ab
+     * perform the read fop on the correct file. This assumes that the file
14f8ab
+     * hierarchy and name need not be the same on remote store as that of
14f8ab
+     * the gluster volume.
14f8ab
+     */
14f8ab
+    ret = dict_set_str(local->xattr_req, GF_CS_XATTR_ARCHIVE_UUID, "1");
14f8ab
+
14f8ab
+    return 0;
14f8ab
+}
14f8ab
 
14f8ab
-    ret = *retval;
14f8ab
+int
14f8ab
+cs_update_xattrs(call_frame_t *frame, dict_t *xdata)
14f8ab
+{
14f8ab
+    cs_local_t *local = NULL;
14f8ab
+    xlator_t *this = NULL;
14f8ab
+    int size = -1;
14f8ab
+    GF_UNUSED int ret = 0;
14f8ab
+
14f8ab
+    local = frame->local;
14f8ab
+    this = frame->this;
14f8ab
+
14f8ab
+    local->xattrinfo.lxattr = GF_CALLOC(1, sizeof(cs_loc_xattr_t),
14f8ab
+                                        gf_cs_mt_cs_lxattr_t);
14f8ab
+    if (!local->xattrinfo.lxattr) {
14f8ab
+        local->op_ret = -1;
14f8ab
+        local->op_errno = ENOMEM;
14f8ab
+        goto err;
14f8ab
+    }
14f8ab
+
14f8ab
+    gf_uuid_copy(local->xattrinfo.lxattr->gfid, local->loc.gfid);
14f8ab
+
14f8ab
+    if (local->remotepath) {
14f8ab
+        local->xattrinfo.lxattr->file_path = gf_strdup(local->remotepath);
14f8ab
+        if (!local->xattrinfo.lxattr->file_path) {
14f8ab
+            local->op_ret = -1;
14f8ab
+            local->op_errno = ENOMEM;
14f8ab
+            goto err;
14f8ab
+        }
14f8ab
+    }
14f8ab
+
14f8ab
+    ret = dict_get_gfuuid(xdata, GF_CS_XATTR_ARCHIVE_UUID,
14f8ab
+                          &(local->xattrinfo.lxattr->uuid));
14f8ab
+
14f8ab
+    if (ret) {
14f8ab
+        gf_uuid_clear(local->xattrinfo.lxattr->uuid);
14f8ab
+    }
14f8ab
+    size = strlen(this->name) - strlen("-cloudsync") + 1;
14f8ab
+    local->xattrinfo.lxattr->volname = GF_CALLOC(1, size, gf_common_mt_char);
14f8ab
+    if (!local->xattrinfo.lxattr->volname) {
14f8ab
+        local->op_ret = -1;
14f8ab
+        local->op_errno = ENOMEM;
14f8ab
+        goto err;
14f8ab
+    }
14f8ab
+    strncpy(local->xattrinfo.lxattr->volname, this->name, size - 1);
14f8ab
+    local->xattrinfo.lxattr->volname[size - 1] = '\0';
14f8ab
+
14f8ab
+    return 0;
14f8ab
+err:
14f8ab
+    cs_xattrinfo_wipe(local);
14f8ab
+    return -1;
14f8ab
+}
14f8ab
+
14f8ab
+int
14f8ab
+cs_serve_readv(call_frame_t *frame, off_t offset, size_t size, uint32_t flags)
14f8ab
+{
14f8ab
+    xlator_t *this = NULL;
14f8ab
+    cs_private_t *priv = NULL;
14f8ab
+    int ret = -1;
14f8ab
+    fd_t *fd = NULL;
14f8ab
+    cs_local_t *local = NULL;
14f8ab
+
14f8ab
+    local = frame->local;
14f8ab
+    this = frame->this;
14f8ab
+    priv = this->private;
14f8ab
+
14f8ab
+    if (!local->remotepath) {
14f8ab
+        ret = -1;
14f8ab
+        gf_msg(this->name, GF_LOG_ERROR, 0, 0,
14f8ab
+               "remote path not"
14f8ab
+               " available. Check posix logs to resolve");
14f8ab
+        goto out;
14f8ab
+    }
14f8ab
+
14f8ab
+    if (!priv->stores) {
14f8ab
+        gf_msg(this->name, GF_LOG_ERROR, 0, 0,
14f8ab
+               "No remote store "
14f8ab
+               "plugins found");
14f8ab
+        ret = -1;
14f8ab
+        goto out;
14f8ab
+    }
14f8ab
+
14f8ab
+    if (local->fd) {
14f8ab
+        fd = fd_anonymous(local->fd->inode);
14f8ab
+    } else {
14f8ab
+        fd = fd_anonymous(local->loc.inode);
14f8ab
+    }
14f8ab
+
14f8ab
+    local->xattrinfo.size = size;
14f8ab
+    local->xattrinfo.offset = offset;
14f8ab
+    local->xattrinfo.flags = flags;
14f8ab
+
14f8ab
+    if (!fd) {
14f8ab
+        gf_msg("CS", GF_LOG_ERROR, 0, 0, "fd creation failed");
14f8ab
+        ret = -1;
14f8ab
+        goto out;
14f8ab
+    }
14f8ab
+
14f8ab
+    local->dlfd = fd;
14f8ab
+    local->dloffset = offset;
14f8ab
+
14f8ab
+    /*this calling method is for per volume setting */
14f8ab
+    ret = priv->stores->rdfop(frame, priv->stores->config);
14f8ab
+    if (ret) {
14f8ab
+        gf_msg(this->name, GF_LOG_ERROR, 0, 0,
14f8ab
+               "read failed"
14f8ab
+               ", remotepath: %s",
14f8ab
+               local->remotepath);
14f8ab
+        ret = -1;
14f8ab
+        goto out;
14f8ab
+    } else {
14f8ab
+        gf_msg(this->name, GF_LOG_INFO, 0, 0,
14f8ab
+               "read success, path"
14f8ab
+               " : %s",
14f8ab
+               local->remotepath);
14f8ab
+    }
14f8ab
 
14f8ab
 out:
14f8ab
-    if (retval)
14f8ab
-        GF_FREE(retval);
14f8ab
+    if (fd) {
14f8ab
+        fd_unref(fd);
14f8ab
+        local->dlfd = NULL;
14f8ab
+    }
14f8ab
+    return ret;
14f8ab
+}
14f8ab
+
14f8ab
+int32_t
14f8ab
+cs_readv_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
14f8ab
+             int32_t op_errno, struct iovec *vector, int32_t count,
14f8ab
+             struct iatt *stbuf, struct iobref *iobref, dict_t *xdata)
14f8ab
+{
14f8ab
+    cs_local_t *local = NULL;
14f8ab
+    int ret = 0;
14f8ab
+    uint64_t val = 0;
14f8ab
+    fd_t *fd = NULL;
14f8ab
+
14f8ab
+    local = frame->local;
14f8ab
+    fd = local->fd;
14f8ab
+
14f8ab
+    local->call_cnt++;
14f8ab
+
14f8ab
+    if (op_ret == -1) {
14f8ab
+        ret = dict_get_uint64(xdata, GF_CS_OBJECT_STATUS, &val;;
14f8ab
+        if (ret == 0) {
14f8ab
+            if (val == GF_CS_ERROR) {
14f8ab
+                gf_msg(this->name, GF_LOG_ERROR, 0, 0,
14f8ab
+                       "could not get file state, unwinding");
14f8ab
+                op_ret = -1;
14f8ab
+                op_errno = EIO;
14f8ab
+                goto unwind;
14f8ab
+            } else {
14f8ab
+                __cs_inode_ctx_update(this, fd->inode, val);
14f8ab
+                gf_msg(this->name, GF_LOG_INFO, 0, 0, " state = %" PRIu64, val);
14f8ab
+
14f8ab
+                if (local->call_cnt == 1 &&
14f8ab
+                    (val == GF_CS_REMOTE || val == GF_CS_DOWNLOADING)) {
14f8ab
+                    gf_msg(this->name, GF_LOG_INFO, 0, 0,
14f8ab
+                           " will read from remote : %" PRIu64, val);
14f8ab
+                    goto repair;
14f8ab
+                } else {
14f8ab
+                    gf_msg(this->name, GF_LOG_ERROR, 0, 0,
14f8ab
+                           "second readv, Unwinding");
14f8ab
+                    goto unwind;
14f8ab
+                }
14f8ab
+            }
14f8ab
+        } else {
14f8ab
+            gf_msg(this->name, GF_LOG_ERROR, 0, 0,
14f8ab
+                   "file state "
14f8ab
+                   "could not be figured, unwinding");
14f8ab
+            goto unwind;
14f8ab
+        }
14f8ab
+    } else {
14f8ab
+        /* successful readv => file is local */
14f8ab
+        __cs_inode_ctx_update(this, fd->inode, GF_CS_LOCAL);
14f8ab
+        gf_msg(this->name, GF_LOG_INFO, 0, 0,
14f8ab
+               "state : GF_CS_LOCAL"
14f8ab
+               ", readv successful");
14f8ab
+
14f8ab
+        goto unwind;
14f8ab
+    }
14f8ab
+
14f8ab
+repair:
14f8ab
+    ret = locate_and_execute(frame);
14f8ab
+    if (ret) {
14f8ab
+        goto unwind;
14f8ab
+    }
14f8ab
+
14f8ab
+    return 0;
14f8ab
+
14f8ab
+unwind:
14f8ab
+    CS_STACK_UNWIND(readv, frame, op_ret, op_errno, vector, count, stbuf,
14f8ab
+                    iobref, xdata);
14f8ab
+
14f8ab
+    return 0;
14f8ab
+}
14f8ab
+
14f8ab
+int32_t
14f8ab
+cs_resume_readv(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
14f8ab
+                off_t offset, uint32_t flags, dict_t *xdata)
14f8ab
+{
14f8ab
+    int ret = 0;
14f8ab
+
14f8ab
+    ret = cs_resume_postprocess(this, frame, fd->inode);
14f8ab
+    if (ret) {
14f8ab
+        goto unwind;
14f8ab
+    }
14f8ab
+
14f8ab
+    cs_inodelk_unlock(frame);
14f8ab
+
14f8ab
+    STACK_WIND(frame, cs_readv_cbk, FIRST_CHILD(this),
14f8ab
+               FIRST_CHILD(this)->fops->readv, fd, size, offset, flags, xdata);
14f8ab
+
14f8ab
+    return 0;
14f8ab
+
14f8ab
+unwind:
14f8ab
+    cs_inodelk_unlock(frame);
14f8ab
+
14f8ab
+    cs_common_cbk(frame);
14f8ab
+
14f8ab
+    return 0;
14f8ab
+}
14f8ab
+
14f8ab
+int32_t
14f8ab
+cs_resume_remote_readv(call_frame_t *frame, xlator_t *this, fd_t *fd,
14f8ab
+                       size_t size, off_t offset, uint32_t flags, dict_t *xdata)
14f8ab
+{
14f8ab
+    int ret = 0;
14f8ab
+    cs_local_t *local = NULL;
14f8ab
+    gf_cs_obj_state state = -1;
14f8ab
+    cs_inode_ctx_t *ctx = NULL;
14f8ab
+
14f8ab
+    cs_inodelk_unlock(frame);
14f8ab
+
14f8ab
+    local = frame->local;
14f8ab
+    if (!local) {
14f8ab
+        ret = -1;
14f8ab
+        goto unwind;
14f8ab
+    }
14f8ab
+
14f8ab
+    __cs_inode_ctx_get(this, fd->inode, &ctx;;
14f8ab
+
14f8ab
+    state = __cs_get_file_state(this, fd->inode, ctx);
14f8ab
+    if (state == GF_CS_ERROR) {
14f8ab
+        gf_msg(this->name, GF_LOG_ERROR, 0, 0,
14f8ab
+               "status is GF_CS_ERROR."
14f8ab
+               " Aborting readv");
14f8ab
+        local->op_ret = -1;
14f8ab
+        local->op_errno = EREMOTE;
14f8ab
+        ret = -1;
14f8ab
+        goto unwind;
14f8ab
+    }
14f8ab
+
14f8ab
+    /* Serve readv from remote store only if it is remote. */
14f8ab
+    gf_msg_debug(this->name, 0, "status of file %s is %d",
14f8ab
+                 local->remotepath ? local->remotepath : "", state);
14f8ab
+
14f8ab
+    /* We will reach this condition if local inode ctx had REMOTE
14f8ab
+     * state when the control was in cs_readv but after stat
14f8ab
+     * we got an updated state saying that the file is LOCAL.
14f8ab
+     */
14f8ab
+    if (state == GF_CS_LOCAL) {
14f8ab
+        STACK_WIND(frame, cs_readv_cbk, FIRST_CHILD(this),
14f8ab
+                   FIRST_CHILD(this)->fops->readv, fd, size, offset, flags,
14f8ab
+                   xdata);
14f8ab
+    } else if (state == GF_CS_REMOTE) {
14f8ab
+        ret = cs_resume_remote_readv_postprocess(this, frame, fd->inode, offset,
14f8ab
+                                                 size, flags);
14f8ab
+        /* Failed to submit the remote readv fop to plugin */
14f8ab
+        if (ret) {
14f8ab
+            local->op_ret = -1;
14f8ab
+            local->op_errno = EREMOTE;
14f8ab
+            goto unwind;
14f8ab
+        }
14f8ab
+        /* When the file is in any other intermediate state,
14f8ab
+         * we should not perform remote reads.
14f8ab
+         */
14f8ab
+    } else {
14f8ab
+        local->op_ret = -1;
14f8ab
+        local->op_errno = EINVAL;
14f8ab
+        goto unwind;
14f8ab
+    }
14f8ab
+
14f8ab
+    return 0;
14f8ab
+
14f8ab
+unwind:
14f8ab
+    cs_common_cbk(frame);
14f8ab
+
14f8ab
+    return 0;
14f8ab
+}
14f8ab
+
14f8ab
+int32_t
14f8ab
+cs_readv(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
14f8ab
+         off_t offset, uint32_t flags, dict_t *xdata)
14f8ab
+{
14f8ab
+    int op_errno = -1;
14f8ab
+    cs_local_t *local = NULL;
14f8ab
+    int ret = 0;
14f8ab
+    cs_inode_ctx_t *ctx = NULL;
14f8ab
+    gf_cs_obj_state state = -1;
14f8ab
+    cs_private_t *priv = NULL;
14f8ab
+
14f8ab
+    VALIDATE_OR_GOTO(frame, err);
14f8ab
+    VALIDATE_OR_GOTO(this, err);
14f8ab
+    VALIDATE_OR_GOTO(fd, err);
14f8ab
+
14f8ab
+    priv = this->private;
14f8ab
+
14f8ab
+    local = cs_local_init(this, frame, NULL, fd, GF_FOP_READ);
14f8ab
+    if (!local) {
14f8ab
+        gf_msg(this->name, GF_LOG_ERROR, 0, 0, "local init failed");
14f8ab
+        op_errno = ENOMEM;
14f8ab
+        goto err;
14f8ab
+    }
14f8ab
+
14f8ab
+    __cs_inode_ctx_get(this, fd->inode, &ctx;;
14f8ab
+
14f8ab
+    if (ctx)
14f8ab
+        state = __cs_get_file_state(this, fd->inode, ctx);
14f8ab
+    else
14f8ab
+        state = GF_CS_LOCAL;
14f8ab
+
14f8ab
+    local->xattr_req = xdata ? dict_ref(xdata) : (xdata = dict_new());
14f8ab
+
14f8ab
+    ret = dict_set_uint32(local->xattr_req, GF_CS_OBJECT_STATUS, 1);
14f8ab
+    if (ret) {
14f8ab
+        gf_msg(this->name, GF_LOG_ERROR, 0, 0,
14f8ab
+               "dict_set failed key:"
14f8ab
+               " %s",
14f8ab
+               GF_CS_OBJECT_STATUS);
14f8ab
+        goto err;
14f8ab
+    }
14f8ab
+
14f8ab
+    if (priv->remote_read) {
14f8ab
+        local->stub = fop_readv_stub(frame, cs_resume_remote_readv, fd, size,
14f8ab
+                                     offset, flags, xdata);
14f8ab
+    } else {
14f8ab
+        local->stub = fop_readv_stub(frame, cs_resume_readv, fd, size, offset,
14f8ab
+                                     flags, xdata);
14f8ab
+    }
14f8ab
+    if (!local->stub) {
14f8ab
+        gf_msg(this->name, GF_LOG_ERROR, 0, 0, "insufficient memory");
14f8ab
+        op_errno = ENOMEM;
14f8ab
+        goto err;
14f8ab
+    }
14f8ab
+
14f8ab
+    if (state == GF_CS_LOCAL) {
14f8ab
+        STACK_WIND(frame, cs_readv_cbk, FIRST_CHILD(this),
14f8ab
+                   FIRST_CHILD(this)->fops->readv, fd, size, offset, flags,
14f8ab
+                   xdata);
14f8ab
+    } else {
14f8ab
+        local->call_cnt++;
14f8ab
+        ret = locate_and_execute(frame);
14f8ab
+        if (ret) {
14f8ab
+            op_errno = ENOMEM;
14f8ab
+            goto err;
14f8ab
+        }
14f8ab
+    }
14f8ab
+
14f8ab
+    return 0;
14f8ab
+
14f8ab
+err:
14f8ab
+    CS_STACK_UNWIND(readv, frame, -1, op_errno, NULL, -1, NULL, NULL, NULL);
14f8ab
+
14f8ab
+    return 0;
14f8ab
+}
14f8ab
+
14f8ab
+int
14f8ab
+cs_resume_remote_readv_postprocess(xlator_t *this, call_frame_t *frame,
14f8ab
+                                   inode_t *inode, off_t offset, size_t size,
14f8ab
+                                   uint32_t flags)
14f8ab
+{
14f8ab
+    int ret = 0;
14f8ab
+
14f8ab
+    ret = cs_serve_readv(frame, offset, size, flags);
14f8ab
 
14f8ab
     return ret;
14f8ab
 }
14f8ab
@@ -1059,7 +1414,7 @@ cs_stat_check_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,
14f8ab
                 goto err;
14f8ab
             } else {
14f8ab
                 ret = __cs_inode_ctx_update(this, inode, val);
14f8ab
-                gf_msg_debug(this->name, 0, "status : %lu", val);
14f8ab
+                gf_msg_debug(this->name, 0, "status : %" PRIu64, val);
14f8ab
                 if (ret) {
14f8ab
                     gf_msg(this->name, GF_LOG_ERROR, 0, 0, "ctx update failed");
14f8ab
                     local->op_ret = -1;
14f8ab
@@ -1087,6 +1442,10 @@ cs_stat_check_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,
14f8ab
             gf_msg_debug(this->name, 0, "NULL filepath");
14f8ab
         }
14f8ab
 
14f8ab
+        ret = cs_update_xattrs(frame, xdata);
14f8ab
+        if (ret)
14f8ab
+            goto err;
14f8ab
+
14f8ab
         local->op_ret = 0;
14f8ab
         local->xattr_rsp = dict_ref(xdata);
14f8ab
         memcpy(&local->stbuf, stbuf, sizeof(struct iatt));
14f8ab
@@ -1121,6 +1480,8 @@ cs_do_stat_check(call_frame_t *main_frame)
14f8ab
         goto err;
14f8ab
     }
14f8ab
 
14f8ab
+    cs_set_xattr_req(main_frame);
14f8ab
+
14f8ab
     if (local->fd) {
14f8ab
         STACK_WIND(main_frame, cs_stat_check_cbk, FIRST_CHILD(this),
14f8ab
                    FIRST_CHILD(this)->fops->fstat, local->fd, local->xattr_req);
14f8ab
@@ -1177,6 +1538,10 @@ cs_common_cbk(call_frame_t *frame)
14f8ab
                             NULL, NULL, NULL);
14f8ab
             break;
14f8ab
 
14f8ab
+        case GF_FOP_TRUNCATE:
14f8ab
+            CS_STACK_UNWIND(truncate, frame, local->op_ret, local->op_errno,
14f8ab
+                            NULL, NULL, NULL);
14f8ab
+            break;
14f8ab
         default:
14f8ab
             break;
14f8ab
     }
14f8ab
@@ -1427,7 +1792,7 @@ __cs_inode_ctx_get(xlator_t *this, inode_t *inode, cs_inode_ctx_t **ctx)
14f8ab
     if (ret)
14f8ab
         *ctx = NULL;
14f8ab
     else
14f8ab
-        *ctx = (cs_inode_ctx_t *)ctxint;
14f8ab
+        *ctx = (cs_inode_ctx_t *)(uintptr_t)ctxint;
14f8ab
 
14f8ab
     return;
14f8ab
 }
14f8ab
@@ -1452,7 +1817,7 @@ __cs_inode_ctx_update(xlator_t *this, inode_t *inode, uint64_t val)
14f8ab
 
14f8ab
             ctx->state = val;
14f8ab
 
14f8ab
-            ctxint = (uint64_t)ctx;
14f8ab
+            ctxint = (uint64_t)(uintptr_t)ctx;
14f8ab
 
14f8ab
             ret = __inode_ctx_set(inode, this, &ctxint);
14f8ab
             if (ret) {
14f8ab
@@ -1460,7 +1825,7 @@ __cs_inode_ctx_update(xlator_t *this, inode_t *inode, uint64_t val)
14f8ab
                 goto out;
14f8ab
             }
14f8ab
         } else {
14f8ab
-            ctx = (cs_inode_ctx_t *)ctxint;
14f8ab
+            ctx = (cs_inode_ctx_t *)(uintptr_t)ctxint;
14f8ab
 
14f8ab
             ctx->state = val;
14f8ab
         }
14f8ab
@@ -1483,7 +1848,7 @@ cs_inode_ctx_reset(xlator_t *this, inode_t *inode)
14f8ab
         return 0;
14f8ab
     }
14f8ab
 
14f8ab
-    ctx = (cs_inode_ctx_t *)ctxint;
14f8ab
+    ctx = (cs_inode_ctx_t *)(uintptr_t)ctxint;
14f8ab
 
14f8ab
     GF_FREE(ctx);
14f8ab
     return 0;
14f8ab
@@ -1532,6 +1897,57 @@ cs_resume_postprocess(xlator_t *this, call_frame_t *frame, inode_t *inode)
14f8ab
 out:
14f8ab
     return ret;
14f8ab
 }
14f8ab
+
14f8ab
+int32_t
14f8ab
+__cs_get_dict_str(char **str, dict_t *xattr, const char *name, int *errnum)
14f8ab
+{
14f8ab
+    data_t *data = NULL;
14f8ab
+    int ret = -1;
14f8ab
+
14f8ab
+    assert(str != NULL);
14f8ab
+
14f8ab
+    data = dict_get(xattr, (char *)name);
14f8ab
+    if (!data) {
14f8ab
+        *errnum = ENODATA;
14f8ab
+        goto out;
14f8ab
+    }
14f8ab
+
14f8ab
+    *str = GF_CALLOC(data->len + 1, sizeof(char), gf_common_mt_char);
14f8ab
+    if (!(*str)) {
14f8ab
+        *errnum = ENOMEM;
14f8ab
+        goto out;
14f8ab
+    }
14f8ab
+
14f8ab
+    memcpy(*str, data->data, sizeof(char) * (data->len));
14f8ab
+    return 0;
14f8ab
+
14f8ab
+out:
14f8ab
+    return ret;
14f8ab
+}
14f8ab
+
14f8ab
+int32_t
14f8ab
+__cs_get_dict_uuid(uuid_t uuid, dict_t *xattr, const char *name, int *errnum)
14f8ab
+{
14f8ab
+    data_t *data = NULL;
14f8ab
+    int ret = -1;
14f8ab
+
14f8ab
+    assert(uuid != NULL);
14f8ab
+
14f8ab
+    data = dict_get(xattr, (char *)name);
14f8ab
+    if (!data) {
14f8ab
+        *errnum = ENODATA;
14f8ab
+        goto out;
14f8ab
+    }
14f8ab
+
14f8ab
+    assert(data->len == sizeof(uuid_t));
14f8ab
+
14f8ab
+    gf_uuid_copy(uuid, (unsigned char *)data->data);
14f8ab
+    return 0;
14f8ab
+
14f8ab
+out:
14f8ab
+    return ret;
14f8ab
+}
14f8ab
+
14f8ab
 int32_t
14f8ab
 cs_fdctx_to_dict(xlator_t *this, fd_t *fd, dict_t *dict)
14f8ab
 {
14f8ab
@@ -1606,7 +2022,6 @@ cs_notify(xlator_t *this, int event, void *data, ...)
14f8ab
 
14f8ab
 struct xlator_fops cs_fops = {
14f8ab
     .stat = cs_stat,
14f8ab
-    .readdirp = cs_readdirp,
14f8ab
     .truncate = cs_truncate,
14f8ab
     .seek = cs_seek,
14f8ab
     .statfs = cs_statfs,
14f8ab
@@ -1627,7 +2042,9 @@ struct xlator_fops cs_fops = {
14f8ab
     .zerofill = cs_zerofill,
14f8ab
 };
14f8ab
 
14f8ab
-struct xlator_cbks cs_cbks = {};
14f8ab
+struct xlator_cbks cs_cbks = {
14f8ab
+    .forget = cs_forget,
14f8ab
+};
14f8ab
 
14f8ab
 struct xlator_dumpops cs_dumpops = {
14f8ab
     .fdctx_to_dict = cs_fdctx_to_dict,
14f8ab
@@ -1647,6 +2064,15 @@ struct volume_options cs_options[] = {
14f8ab
     {.key = {"cloudsync-storetype"},
14f8ab
      .type = GF_OPTION_TYPE_STR,
14f8ab
      .description = "Defines which remote store is enabled"},
14f8ab
+    {.key = {"cloudsync-remote-read"},
14f8ab
+     .type = GF_OPTION_TYPE_BOOL,
14f8ab
+     .description = "Defines a remote read fop when on"},
14f8ab
+    {.key = {"cloudsync-store-id"},
14f8ab
+     .type = GF_OPTION_TYPE_STR,
14f8ab
+     .description = "Defines a volume wide store id"},
14f8ab
+    {.key = {"cloudsync-product-id"},
14f8ab
+     .type = GF_OPTION_TYPE_STR,
14f8ab
+     .description = "Defines a volume wide product id"},
14f8ab
     {.key = {NULL}},
14f8ab
 };
14f8ab
 
14f8ab
diff --git a/xlators/features/cloudsync/src/cloudsync.h b/xlators/features/cloudsync/src/cloudsync.h
14f8ab
index dbdb207..0cb800a 100644
14f8ab
--- a/xlators/features/cloudsync/src/cloudsync.h
14f8ab
+++ b/xlators/features/cloudsync/src/cloudsync.h
14f8ab
@@ -19,6 +19,7 @@
14f8ab
 #include "cloudsync-common.h"
14f8ab
 #include "cloudsync-autogen-fops.h"
14f8ab
 
14f8ab
+#define ALIGN_SIZE 4096
14f8ab
 #define CS_LOCK_DOMAIN "cs.protect.file.stat"
14f8ab
 typedef struct cs_dlstore {
14f8ab
     off_t off;
14f8ab
@@ -29,6 +30,7 @@ typedef struct cs_dlstore {
14f8ab
 } cs_dlstore;
14f8ab
 
14f8ab
 typedef struct cs_inode_ctx {
14f8ab
+    cs_loc_xattr_t locxattr;
14f8ab
     gf_cs_obj_state state;
14f8ab
 } cs_inode_ctx_t;
14f8ab
 
14f8ab
@@ -100,4 +102,22 @@ cs_truncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
14f8ab
 int32_t
14f8ab
 cs_resume_truncate(call_frame_t *frame, xlator_t *this, loc_t *loc,
14f8ab
                    off_t offset, dict_t *xattr_req);
14f8ab
+
14f8ab
+int32_t
14f8ab
+cs_readv_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
14f8ab
+             int32_t op_errno, struct iovec *vector, int32_t count,
14f8ab
+             struct iatt *stbuf, struct iobref *iobref, dict_t *xdata);
14f8ab
+int32_t
14f8ab
+cs_resume_readv(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
14f8ab
+                off_t offset, uint32_t flags, dict_t *xdata);
14f8ab
+int32_t
14f8ab
+cs_readv(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
14f8ab
+         off_t offset, uint32_t flags, dict_t *xdata);
14f8ab
+
14f8ab
+int
14f8ab
+cs_resume_remote_readv_postprocess(xlator_t *this, call_frame_t *frame,
14f8ab
+                                   inode_t *inode, off_t offset, size_t size,
14f8ab
+                                   uint32_t flags);
14f8ab
+int
14f8ab
+cs_serve_readv(call_frame_t *frame, off_t offset, size_t size, uint32_t flags);
14f8ab
 #endif /* __CLOUDSYNC_H__ */
14f8ab
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
14f8ab
index 4b32fb6..73abf37 100644
14f8ab
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
14f8ab
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
14f8ab
@@ -3693,7 +3693,7 @@ struct volopt_map_entry glusterd_volopt_map[] = {
14f8ab
      .op_version = GD_OP_VERSION_5_0,
14f8ab
      .description = "enable/disable noatime option with ctime enabled.",
14f8ab
      .flags = VOLOPT_FLAG_CLIENT_OPT | VOLOPT_FLAG_XLATOR_OPT},
14f8ab
-    {.key = "feature.cloudsync-storetype",
14f8ab
+    {.key = "features.cloudsync-storetype",
14f8ab
      .voltype = "features/cloudsync",
14f8ab
      .op_version = GD_OP_VERSION_5_0,
14f8ab
      .flags = VOLOPT_FLAG_CLIENT_OPT},
14f8ab
@@ -3721,4 +3721,9 @@ struct volopt_map_entry glusterd_volopt_map[] = {
14f8ab
      .validate_fn = validate_boolean,
14f8ab
      .description = "option to enforce mandatory lock on a file",
14f8ab
      .flags = VOLOPT_FLAG_XLATOR_OPT},
14f8ab
+    {.key = "features.cloudsync-remote-read",
14f8ab
+     .voltype = "features/cloudsync",
14f8ab
+     .value = "off",
14f8ab
+     .op_version = GD_OP_VERSION_6_0,
14f8ab
+     .flags = VOLOPT_FLAG_CLIENT_OPT},
14f8ab
     {.key = NULL}};
14f8ab
-- 
14f8ab
1.8.3.1
14f8ab