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