From c3338a100dd9948d7c30c7b50f6cebf95fd6801e Mon Sep 17 00:00:00 2001
From: Susant Palai <spalai@redhat.com>
Date: Fri, 11 Sep 2015 08:52:44 -0400
Subject: [PATCH 328/330] dht/cluster: Avoid crash if local is NULL
This patch addresses crash handling if local is NULL. In addition to that,
we were not unwinding if no lock is taken in dht_linkfile_create_cbk(create/mknod).
This patch handles that also.
BUG: 1259750
Change-Id: I3f3dca5e88fba255e4c499f64c390da144a56590
Signed-off-by: Susant Palai <spalai@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/57617
Reviewed-by: Nithya Balachandran <nbalacha@redhat.com>
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
Tested-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
---
xlators/cluster/dht/src/dht-common.c | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index 1d27fba..7f4ae48 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -5033,12 +5033,15 @@ dht_mknod_linkfile_create_cbk (call_frame_t *frame, void *cookie,
goto err;
}
- if (op_ret == -1)
+ if (op_ret == -1) {
+ local->op_errno = op_errno;
goto err;
+ }
conf = this->private;
if (!conf) {
local->op_errno = EINVAL;
+ op_errno = EINVAL;
goto err;
}
@@ -5056,8 +5059,13 @@ dht_mknod_linkfile_create_cbk (call_frame_t *frame, void *cookie,
return 0;
err:
- if (local->lock.locks)
+ if (local && local->lock.locks) {
local->refresh_layout_unlock (frame, this, -1);
+ } else {
+ DHT_STACK_UNWIND (mknod, frame, -1,
+ op_errno, NULL, NULL, NULL,
+ NULL, NULL);
+ }
return 0;
}
@@ -5850,6 +5858,7 @@ dht_create_linkfile_create_cbk (call_frame_t *frame, void *cookie,
conf = this->private;
if (!conf) {
local->op_errno = EINVAL;
+ op_errno = EINVAL;
goto err;
}
@@ -5867,8 +5876,13 @@ dht_create_linkfile_create_cbk (call_frame_t *frame, void *cookie,
return 0;
err:
- if (local->lock.locks)
+ if (local && local->lock.locks) {
local->refresh_layout_unlock (frame, this, -1);
+ } else {
+ DHT_STACK_UNWIND (create, frame, -1,
+ op_errno, NULL, NULL, NULL,
+ NULL, NULL, NULL);
+ }
return 0;
}
--
1.7.1