From f4ad9c9eb7f062198189801ddc8cfd958bb413d9 Mon Sep 17 00:00:00 2001 From: N Balachandran Date: Mon, 13 Feb 2017 16:49:06 +0530 Subject: cluster/dht Fix error assignment in dht_*xattr2 functions Corrected the op_errno assignments and NULL checks in the dht_sexattr2 and dht_removexattr2 functions. Earlier, they unwound with the default EINVAL op_errno if the file had been deleted. > Change-Id: Iaf837a473d769cea40132487a966c7f452990071 > BUG: 1421653 > Signed-off-by: N Balachandran > Reviewed-on: https://review.gluster.org/16610 > Smoke: Gluster Build System > NetBSD-regression: NetBSD Build System > CentOS-regression: Gluster Build System > Reviewed-by: MOHIT AGRAWAL > Reviewed-by: Shyamsundar Ranganathan (cherry picked from commit 028626a86ea409f908783b9007c02877f20be43e) Signed-off-by: N Balachandran Change-Id: Id2e91df47bcd734dda18700fb075608c1627a608 BUG: 1424915 Reviewed-on: https://review.gluster.org/16678 Tested-by: N Balachandran Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Shyamsundar Ranganathan --- xlators/cluster/dht/src/dht-common.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'xlators/cluster/dht/src') diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index a9714b02b79..c3b1a541507 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -3929,6 +3929,7 @@ dht_setxattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret) goto err; local = frame->local; + op_errno = local->op_errno; if (we_are_not_migrating (ret)) { /* This dht xlator is not migrating the file. Unwind and @@ -3943,7 +3944,6 @@ dht_setxattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret) if (subvol == NULL) goto err; - op_errno = local->op_errno; local->call_cnt = 2; /* This is the second attempt */ @@ -4351,10 +4351,11 @@ dht_removexattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame, dht_local_t *local = NULL; int op_errno = EINVAL; - if (!frame || !frame->local || !subvol) + if (!frame || !frame->local) goto err; local = frame->local; + op_errno = local->op_errno; local->call_cnt = 2; /* This is the second attempt */ @@ -4369,6 +4370,9 @@ dht_removexattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame, return 0; } + if (subvol == NULL) + goto err; + if (local->fop == GF_FOP_REMOVEXATTR) { STACK_WIND (frame, dht_file_removexattr_cbk, subvol, subvol->fops->removexattr, &local->loc, -- cgit From 2b65e69bf7adcd6176c24ef1439bd06aa445deae Mon Sep 17 00:00:00 2001 From: Krutika Dhananjay Date: Thu, 2 Mar 2017 15:27:54 +0530 Subject: cluster/dht: Fix crash in "nuke-dir" feature Backport of: https://review.gluster.org/16829 My patch at https://review.gluster.org/16419 is resulting in core dumps everytime I run tests/features/nuke.t. Turns out dht, upon successfully "nuking" a directory, which was initiated through a setxattr, unwinds the operation with rmdir fop signature, resulting in readdir-ahead casting a struct iatt (preparent) to dict_t, leading to a crash. Change-Id: Ib970b3198185a6c641092b00e115a672cb3f9111 BUG: 1428743 Signed-off-by: Krutika Dhananjay Reviewed-on: https://review.gluster.org/16840 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System Reviewed-by: Raghavendra G CentOS-regression: Gluster Build System Reviewed-by: Niels de Vos --- xlators/cluster/dht/src/dht-common.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'xlators/cluster/dht/src') diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index c3b1a541507..74a2aa78ca7 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -3967,6 +3967,15 @@ err: return 0; } +int +dht_nuke_dir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct iatt *preparent, + struct iatt *postparent, dict_t *xdata) +{ + STACK_UNWIND_STRICT (setxattr, frame, op_ret, op_errno, NULL); + return 0; +} + int dht_nuke_dir (call_frame_t *frame, xlator_t *this, loc_t *loc, data_t *tmp) { @@ -3998,7 +4007,7 @@ dht_nuke_dir (call_frame_t *frame, xlator_t *this, loc_t *loc, data_t *tmp) * obscure the fact that we came in via this path instead of a genuine * rmdir. That makes debugging just a tiny bit easier. */ - STACK_WIND (frame, default_rmdir_cbk, this, this->fops->rmdir, + STACK_WIND (frame, dht_nuke_dir_cbk, this, this->fops->rmdir, loc, 1, NULL); return 0; -- cgit