diff options
author | Amar Tumballi <amarts@redhat.com> | 2018-09-17 14:25:16 +0530 |
---|---|---|
committer | N Balachandran <nbalacha@redhat.com> | 2018-09-19 04:26:55 +0000 |
commit | d4770602e044424ff5a4a7ac666bf5a90490ec9b (patch) | |
tree | 74a424315103ea3cf6fe983895867ceca7fa6059 /xlators/cluster/dht/src/dht-common.c | |
parent | 1e02ab9eb3af7b6ce49b154e6b9070d01a8bbb67 (diff) |
dht: utilize the framework to pass-through xlator tasks
Also fixes the issue caused due to not converting back the fn function
to after getting its address. We wanted the value of the field, not
the address of the pt_fop field.
With this patch, DHT will always be started in pass-through
mode if the number of subvols is just 1.
Fixes some tests to make sure DHT is in full config (ie, subvols > 1).
- increased timeout of brick-mux test as it was bordering on 300 seconds.
- Also change the volume type to supported 'replica 3' from 'replica 2'.
- also no DHT tests should assume presence of DHT when there is
just 1 brick in volume
Credits: Nithya B <nbalacha@redhat.com>
fixes: #405
Change-Id: I8e55239ce58d6ac6ae1901e2e384be1ecbd33d6e
Signed-off-by: Amar Tumballi <amarts@redhat.com>
Diffstat (limited to 'xlators/cluster/dht/src/dht-common.c')
-rw-r--r-- | xlators/cluster/dht/src/dht-common.c | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index f43a10bec2f..4ca54a1f5c0 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -11030,3 +11030,135 @@ dht_remove_stale_linkto_cbk(int ret, call_frame_t *sync_frame, void *data) DHT_STACK_DESTROY(sync_frame); return 0; } + +int +dht_pt_mkdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, inode_t *inode, struct iatt *stbuf, + struct iatt *preparent, struct iatt *postparent, dict_t *xdata) +{ + dht_local_t *local = NULL; + + local = frame->local; + + if (!op_ret) { + dht_layout_set(this, inode, local->layout); + } + + DHT_STACK_UNWIND(mkdir, frame, op_ret, op_errno, inode, stbuf, preparent, + postparent, NULL); + + return 0; +} + +int32_t +dht_pt_mkdir(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, + mode_t umask, dict_t *xdata) +{ + dht_layout_t *layout = NULL; + dht_conf_t *conf = NULL; + dht_local_t *local = NULL; + bool free_xdata = false; + int ret = 0; + int op_errno = 0; + int32_t *disk_layout_p = NULL; + + conf = this->private; + + local = dht_local_init(frame, loc, NULL, GF_FOP_MKDIR); + if (!local) { + op_errno = ENOMEM; + goto err; + } + + layout = dht_layout_new(this, conf->subvolume_cnt); + if (!layout) + goto wind; + + local->layout = layout; + + if (!xdata) { + xdata = dict_new(); + if (!xdata) + goto wind; + free_xdata = true; + } + + /*Set the xlator or the following will crash*/ + layout->list[0].xlator = conf->subvolumes[0]; + + dht_selfheal_layout_new_directory(frame, loc, layout); + + dht_disk_layout_extract(this, layout, 0, &disk_layout_p); + + ret = dict_set_bin(xdata, conf->xattr_name, disk_layout_p, 4 * 4); + if (ret) { + gf_msg("dht", GF_LOG_DEBUG, EINVAL, DHT_MSG_DICT_SET_FAILED, + "dht layout dict set failed"); + } +wind: + STACK_WIND(frame, dht_pt_mkdir_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->mkdir, loc, mode, umask, xdata); + if (free_xdata) + dict_unref(xdata); + return 0; + +err: + op_errno = local ? local->op_errno : op_errno; + DHT_STACK_UNWIND(mkdir, frame, -1, op_errno, NULL, NULL, NULL, NULL, NULL); + + return 0; +} + +static int +dht_pt_getxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, dict_t *xattr, dict_t *xdata) +{ + dht_conf_t *conf = NULL; + + conf = this->private; + dict_del(xattr, conf->xattr_name); + + if (frame->root->pid >= 0) { + GF_REMOVE_INTERNAL_XATTR("trusted.glusterfs.quota*", xattr); + GF_REMOVE_INTERNAL_XATTR("trusted.pgfid*", xattr); + } + + DHT_STACK_UNWIND(getxattr, frame, op_ret, op_errno, xattr, xdata); + return 0; +} + +int +dht_pt_getxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, + const char *key, dict_t *xdata) +{ + STACK_WIND(frame, dht_pt_getxattr_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->getxattr, loc, key, xdata); + return 0; +} + +static int +dht_pt_fgetxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, dict_t *xattr, dict_t *xdata) +{ + dht_conf_t *conf = NULL; + + conf = this->private; + dict_del(xattr, conf->xattr_name); + + if (frame->root->pid >= 0) { + GF_REMOVE_INTERNAL_XATTR("trusted.glusterfs.quota*", xattr); + GF_REMOVE_INTERNAL_XATTR("trusted.pgfid*", xattr); + } + + DHT_STACK_UNWIND(fgetxattr, frame, op_ret, op_errno, xattr, xdata); + return 0; +} + +int +dht_pt_fgetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, const char *key, + dict_t *xdata) +{ + STACK_WIND(frame, dht_pt_fgetxattr_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->fgetxattr, fd, key, xdata); + return 0; +} |