summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2015-09-24 15:42:14 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2015-10-26 05:57:47 -0700
commit8216ecb871c8d74edcc46b7f13d1e1879be25de1 (patch)
tree519409ac6c4ccae4f0d4cdaef7f679bc0cfe2dbe
parent6188b5fcebc56b3d8af1956beeec9988f3e8f268 (diff)
features/shard: Support geo-rep for sharded volume
Approach: Shard xlator on slave side is by passed for all the fops to geo-rep mount. So each shard on master is considered as a separate file for geo-rep and it syncs them separately on to slave. The extended attribute in which shard maintains the size is also synced from master and shard on slave doesn't calculate by itself. Pre-requisites: 1. If master is sharded volume, slave also should be sharded. 2. Slave's shard configurations should be same as master. 3. Geo-rep config of xattr sync should not be disabled. All other dependant patches: 1. http://review.gluster.org/#/c/12205/ 2. http://review.gluster.org/#/c/12206/ 3. http://review.gluster.org/#/c/12225/ 4. http://review.gluster.org/#/c/12226/ Change-Id: I474220d69fa030b1e06a4fa0868c34fabe02efcf BUG: 1265148 Signed-off-by: Kotresh HR <khiremat@redhat.com> Reviewed-on: http://review.gluster.org/12228 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Krutika Dhananjay <kdhananj@redhat.com> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
-rw-r--r--xlators/features/shard/src/shard.c104
-rw-r--r--xlators/mount/fuse/src/fuse-helpers.c4
2 files changed, 74 insertions, 34 deletions
diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c
index f5ac76d974a..a99eaf92bc1 100644
--- a/xlators/features/shard/src/shard.c
+++ b/xlators/features/shard/src/shard.c
@@ -27,6 +27,17 @@ __is_shard_dir (uuid_t gfid)
return _gf_false;
}
+static gf_boolean_t
+__is_gsyncd_on_shard_dir (call_frame_t *frame, loc_t *loc)
+{
+ if (frame->root->pid == GF_CLIENT_PID_GSYNCD &&
+ (__is_shard_dir (loc->pargfid) ||
+ (loc->parent && __is_shard_dir(loc->parent->gfid))))
+ return _gf_true;
+
+ return _gf_false;
+}
+
void
shard_make_block_bname (int block_num, uuid_t gfid, char *buf, size_t len)
{
@@ -753,7 +764,8 @@ shard_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
* and store them in the stbuf appropriately.
*/
- if (dict_get (xdata, GF_XATTR_SHARD_FILE_SIZE))
+ if (dict_get (xdata, GF_XATTR_SHARD_FILE_SIZE) &&
+ frame->root->pid != GF_CLIENT_PID_GSYNCD)
shard_modify_size_and_block_count (buf, xdata);
unwind:
@@ -771,7 +783,9 @@ shard_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc,
uint64_t block_size = 0;
shard_local_t *local = NULL;
- SHARD_ENTRY_FOP_CHECK (loc, op_errno, err);
+ if (frame->root->pid != GF_CLIENT_PID_GSYNCD) {
+ SHARD_ENTRY_FOP_CHECK (loc, op_errno, err);
+ }
local = mem_get0 (this->local_pool);
if (!local)
@@ -797,15 +811,18 @@ shard_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc,
}
}
- ret = dict_set_uint64 (local->xattr_req, GF_XATTR_SHARD_FILE_SIZE,
- 8 * 4);
- if (ret) {
- gf_msg (this->name, GF_LOG_WARNING, 0,
- SHARD_MSG_DICT_SET_FAILED, "Failed to set dict value: "
- "key:%s for path %s.", GF_XATTR_SHARD_FILE_SIZE,
- loc->path);
- goto err;
+ if (frame->root->pid != GF_CLIENT_PID_GSYNCD) {
+ ret = dict_set_uint64 (local->xattr_req,
+ GF_XATTR_SHARD_FILE_SIZE, 8 * 4);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ SHARD_MSG_DICT_SET_FAILED,
+ "Failed to set dict value: key:%s for path %s.",
+ GF_XATTR_SHARD_FILE_SIZE, loc->path);
+ goto err;
+ }
}
+
if ((xattr_req) && (dict_get (xattr_req, GF_CONTENT_KEY)))
dict_del (xattr_req, GF_CONTENT_KEY);
@@ -1005,7 +1022,7 @@ shard_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
goto err;
}
- if (!block_size) {
+ if (!block_size || frame->root->pid == GF_CLIENT_PID_GSYNCD) {
STACK_WIND (frame, default_stat_cbk, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->stat, loc, xdata);
return 0;
@@ -1059,7 +1076,7 @@ shard_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
goto err;
}
- if (!block_size) {
+ if (!block_size || frame->root->pid == GF_CLIENT_PID_GSYNCD) {
STACK_WIND (frame, default_fstat_cbk, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->fstat, fd, xdata);
return 0;
@@ -1769,7 +1786,7 @@ shard_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
goto err;
}
- if (!block_size) {
+ if (!block_size || frame->root->pid == GF_CLIENT_PID_GSYNCD) {
STACK_WIND (frame, default_truncate_cbk, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->truncate, loc, offset,
xdata);
@@ -1819,7 +1836,7 @@ shard_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
goto err;
}
- if (!block_size) {
+ if (!block_size || frame->root->pid == GF_CLIENT_PID_GSYNCD) {
STACK_WIND (frame, default_ftruncate_cbk, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->ftruncate, fd, offset,
xdata);
@@ -1893,8 +1910,9 @@ shard_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
goto err;
frame->local = local;
-
- SHARD_INODE_CREATE_INIT (this, local, xdata, loc, err);
+ if (!__is_gsyncd_on_shard_dir (frame, loc)) {
+ SHARD_INODE_CREATE_INIT (this, local, xdata, loc, err);
+ }
STACK_WIND (frame, shard_mknod_cbk, FIRST_CHILD (this),
FIRST_CHILD(this)->fops->mknod, loc, mode, rdev, umask,
@@ -2331,7 +2349,7 @@ shard_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag,
goto err;
}
- if (!block_size) {
+ if (!block_size || frame->root->pid == GF_CLIENT_PID_GSYNCD) {
STACK_WIND (frame, default_unlink_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->unlink, loc, xflag, xdata);
return 0;
@@ -2554,7 +2572,8 @@ shard_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
* a. the src file is not sharded and dst doesn't exist, OR
* b. the src and dst both exist but are not sharded.
*/
- if ((!block_size) && (!dst_block_size)) {
+ if (((!block_size) && (!dst_block_size)) ||
+ frame->root->pid == GF_CLIENT_PID_GSYNCD) {
STACK_WIND (frame, default_rename_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->rename, oldloc, newloc,
xdata);
@@ -2641,7 +2660,9 @@ shard_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
frame->local = local;
- SHARD_INODE_CREATE_INIT (this, local, xdata, loc, err);
+ if (!__is_gsyncd_on_shard_dir (frame, loc)) {
+ SHARD_INODE_CREATE_INIT (this, local, xdata, loc, err);
+ }
STACK_WIND (frame, shard_create_cbk, FIRST_CHILD (this),
FIRST_CHILD(this)->fops->create, loc, flags, mode, umask,
@@ -3201,7 +3222,7 @@ shard_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
goto err;
}
- if (!block_size) {
+ if (!block_size || frame->root->pid == GF_CLIENT_PID_GSYNCD) {
/* block_size = 0 means that the file was created before
* sharding was enabled on the volume.
*/
@@ -3646,7 +3667,7 @@ shard_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
goto out;
}
- if (!block_size) {
+ if (!block_size || frame->root->pid == GF_CLIENT_PID_GSYNCD) {
/* block_size = 0 means that the file was created before
* sharding was enabled on the volume.
*/
@@ -3830,7 +3851,8 @@ shard_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (IA_ISDIR (entry->d_stat.ia_type))
continue;
- if (dict_get (entry->dict, GF_XATTR_SHARD_FILE_SIZE))
+ if (dict_get (entry->dict, GF_XATTR_SHARD_FILE_SIZE) &&
+ frame->root->pid != GF_CLIENT_PID_GSYNCD)
shard_modify_size_and_block_count (&entry->d_stat,
entry->dict);
@@ -3951,9 +3973,12 @@ shard_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
{
int op_errno = EINVAL;
- GF_IF_NATIVE_XATTR_GOTO (SHARD_XATTR_PREFIX"*", name, op_errno, out);
+ if (frame->root->pid != GF_CLIENT_PID_GSYNCD) {
+ GF_IF_NATIVE_XATTR_GOTO (SHARD_XATTR_PREFIX"*",
+ name, op_errno, out);
+ }
- if (xdata) {
+ if (xdata && (frame->root->pid != GF_CLIENT_PID_GSYNCD)) {
dict_del (xdata, GF_XATTR_SHARD_BLOCK_SIZE);
dict_del (xdata, GF_XATTR_SHARD_FILE_SIZE);
}
@@ -3974,9 +3999,12 @@ shard_fremovexattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
{
int op_errno = EINVAL;
- GF_IF_NATIVE_XATTR_GOTO (SHARD_XATTR_PREFIX"*", name, op_errno, out);
+ if (frame->root->pid != GF_CLIENT_PID_GSYNCD) {
+ GF_IF_NATIVE_XATTR_GOTO (SHARD_XATTR_PREFIX"*",
+ name, op_errno, out);
+ }
- if (xdata) {
+ if (xdata && (frame->root->pid != GF_CLIENT_PID_GSYNCD)) {
dict_del (xdata, GF_XATTR_SHARD_BLOCK_SIZE);
dict_del (xdata, GF_XATTR_SHARD_FILE_SIZE);
}
@@ -3999,7 +4027,7 @@ shard_fgetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (op_ret < 0)
goto unwind;
- if (dict) {
+ if (dict && (frame->root->pid != GF_CLIENT_PID_GSYNCD)) {
dict_del (dict, GF_XATTR_SHARD_BLOCK_SIZE);
dict_del (dict, GF_XATTR_SHARD_FILE_SIZE);
}
@@ -4015,7 +4043,8 @@ shard_fgetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
{
int op_errno = EINVAL;
- if ((name) && (!strncmp (name, SHARD_XATTR_PREFIX,
+ if ((frame->root->pid != GF_CLIENT_PID_GSYNCD) &&
+ (name) && (!strncmp (name, SHARD_XATTR_PREFIX,
strlen (SHARD_XATTR_PREFIX)))) {
op_errno = ENODATA;
goto out;
@@ -4039,7 +4068,7 @@ shard_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (op_ret < 0)
goto unwind;
- if (dict) {
+ if (dict && (frame->root->pid != GF_CLIENT_PID_GSYNCD)) {
dict_del (dict, GF_XATTR_SHARD_BLOCK_SIZE);
dict_del (dict, GF_XATTR_SHARD_FILE_SIZE);
}
@@ -4055,7 +4084,8 @@ shard_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
{
int op_errno = EINVAL;
- if ((name) && (!strncmp (name, SHARD_XATTR_PREFIX,
+ if ((frame->root->pid != GF_CLIENT_PID_GSYNCD) &&
+ (name) && (!strncmp (name, SHARD_XATTR_PREFIX,
strlen (SHARD_XATTR_PREFIX)))) {
op_errno = ENODATA;
goto out;
@@ -4076,7 +4106,10 @@ shard_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict,
{
int op_errno = EINVAL;
- GF_IF_INTERNAL_XATTR_GOTO (SHARD_XATTR_PREFIX"*", dict, op_errno, out);
+ if (frame->root->pid != GF_CLIENT_PID_GSYNCD) {
+ GF_IF_INTERNAL_XATTR_GOTO (SHARD_XATTR_PREFIX"*", dict,
+ op_errno, out);
+ }
STACK_WIND_TAIL (frame, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->fsetxattr, fd, dict, flags,
@@ -4094,7 +4127,10 @@ shard_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
{
int op_errno = EINVAL;
- GF_IF_INTERNAL_XATTR_GOTO (SHARD_XATTR_PREFIX"*", dict, op_errno, out);
+ if (frame->root->pid != GF_CLIENT_PID_GSYNCD) {
+ GF_IF_INTERNAL_XATTR_GOTO (SHARD_XATTR_PREFIX"*", dict,
+ op_errno, out);
+ }
STACK_WIND_TAIL (frame, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->setxattr, loc, dict, flags,
@@ -4191,7 +4227,7 @@ shard_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
goto err;
}
- if (!block_size) {
+ if (!block_size || frame->root->pid == GF_CLIENT_PID_GSYNCD) {
STACK_WIND (frame, default_setattr_cbk, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->setattr, loc, stbuf,
valid, xdata);
@@ -4250,7 +4286,7 @@ shard_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
goto err;
}
- if (!block_size) {
+ if (!block_size || frame->root->pid == GF_CLIENT_PID_GSYNCD) {
STACK_WIND (frame, default_fsetattr_cbk, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->fsetattr, fd, stbuf,
valid, xdata);
diff --git a/xlators/mount/fuse/src/fuse-helpers.c b/xlators/mount/fuse/src/fuse-helpers.c
index 22aa9b486d1..0f8abf03d32 100644
--- a/xlators/mount/fuse/src/fuse-helpers.c
+++ b/xlators/mount/fuse/src/fuse-helpers.c
@@ -638,6 +638,10 @@ fuse_ignore_xattr_set (fuse_private_t *priv, char *key)
|| (fnmatch ("system.posix_acl_access",
key, FNM_PERIOD) == 0)
|| (fnmatch ("glusterfs.gfid.newfile",
+ key, FNM_PERIOD) == 0)
+ || (fnmatch ("*.glusterfs.shard.block-size",
+ key, FNM_PERIOD) == 0)
+ || (fnmatch ("*.glusterfs.shard.file-size",
key, FNM_PERIOD) == 0)))
ret = -1;