summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authormohit84 <moagrawa@redhat.com>2021-02-24 18:17:18 +0530
committerGitHub <noreply@github.com>2021-02-24 18:17:18 +0530
commit80b65bc2ff4709f5a5d3dccaea24ccf9a3401337 (patch)
tree688c986616d25f09febbd2d02625a50f5ab42952 /xlators
parentd858f3bc135238f3809e488441f25bba0efd6bd7 (diff)
downloadglusterfs-80b65bc2ff4709f5a5d3dccaea24ccf9a3401337.tar.gz
glusterfs-80b65bc2ff4709f5a5d3dccaea24ccf9a3401337.tar.xz
glusterfs-80b65bc2ff4709f5a5d3dccaea24ccf9a3401337.zip
dht: Ongoing IO is failed during volume shrink operation (#2188)
In the commit (c878174) we have introduced a check to avoid stale layout issue.To avoid a stale layout issue dht has set a key along with layout at the time of wind a create fop and posix validates the parent layout based on the key value. If layout does not match it throw and error.In case of volume shrink layout has been changed by reabalance daemon and if layout does not matches dht is not able to wind a create fop successfully. Solution: To avoid the issue populate a key only while dht has wind a fop first time. After got an error in 2nd attempt dht takes a lock and then reattempt to wind a fop again. Fixes: #2187 Change-Id: Ie018386e7823a11eea415496bb226ca032453a55 Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/dht/src/dht-common.c41
1 files changed, 30 insertions, 11 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index d27670d796..da3bbc4f14 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -8521,15 +8521,32 @@ dht_create_wind_to_avail_subvol(call_frame_t *frame, xlator_t *this,
{
dht_local_t *local = NULL;
xlator_t *avail_subvol = NULL;
+ int lk_count = 0;
local = frame->local;
if (!dht_is_subvol_filled(this, subvol)) {
- gf_msg_debug(this->name, 0, "creating %s on %s", loc->path,
- subvol->name);
-
- dht_set_parent_layout_in_dict(loc, this, local);
-
+ lk_count = local->lock[0].layout.parent_layout.lk_count;
+ gf_msg_debug(this->name, 0, "creating %s on %s with lock_count %d",
+ loc->path, subvol->name, lk_count);
+ /*The function dht_set_parent_layout_in_dict sets the layout
+ in dictionary and posix_create validates a layout before
+ creating a file.In case if parent layout does not match
+ with disk layout posix xlator throw an error but in case
+ if volume is shrunk layout has been changed by rebalance daemon
+ so we need to call this function only while a function is calling
+ without taking any lock otherwise we would not able to populate a
+ layout on disk in case if layout has changed.
+ */
+ if (!lk_count) {
+ dht_set_parent_layout_in_dict(loc, this, local);
+ } else {
+ /* Delete a key to avoid layout validate if it was set by
+ previous STACK_WIND attempt when a lock was not taken
+ by dht_create
+ */
+ (void)dict_del_sizen(local->params, GF_PREOP_PARENT_KEY);
+ }
STACK_WIND_COOKIE(frame, dht_create_cbk, subvol, subvol,
subvol->fops->create, loc, flags, mode, umask, fd,
params);
@@ -8549,12 +8566,14 @@ dht_create_wind_to_avail_subvol(call_frame_t *frame, xlator_t *this,
goto out;
}
-
- gf_msg_debug(this->name, 0, "creating %s on %s", loc->path,
- subvol->name);
-
- dht_set_parent_layout_in_dict(loc, this, local);
-
+ lk_count = local->lock[0].layout.parent_layout.lk_count;
+ gf_msg_debug(this->name, 0, "creating %s on %s with lk_count %d",
+ loc->path, subvol->name, lk_count);
+ if (!lk_count) {
+ dht_set_parent_layout_in_dict(loc, this, local);
+ } else {
+ (void)dict_del_sizen(local->params, GF_PREOP_PARENT_KEY);
+ }
STACK_WIND_COOKIE(frame, dht_create_cbk, subvol, subvol,
subvol->fops->create, loc, flags, mode, umask, fd,
params);