From e64dd0a358e7a7b4c0da86a6b17adf6f125c00d5 Mon Sep 17 00:00:00 2001 From: Atin Mukherjee Date: Wed, 30 Apr 2014 11:12:40 +0530 Subject: glusterd : barrier enable/disable should fail if already enabled/disabled In barrier notify function, if we fail to set the barrier option execution goes to default_notify which returns 0 and command returns success. Fix : We need not call the default_notify function when handling GF_EVENT_TRANSLATOR_OP in barrier xlator's notify. Change-Id: Ia2c361b43cca7791c29829d69dcd6fc7923102f6 BUG: 1092841 Signed-off-by: Atin Mukherjee Reviewed-on: http://review.gluster.org/7609 Reviewed-by: Krishnan Parthasarathi Tested-by: Gluster Build System Reviewed-by: Sachin Pandit Reviewed-by: Kaushal M --- tests/bugs/bug-1092841.t | 24 ++++++++++++++++++++++++ xlators/features/barrier/src/barrier.c | 12 +++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 tests/bugs/bug-1092841.t diff --git a/tests/bugs/bug-1092841.t b/tests/bugs/bug-1092841.t new file mode 100644 index 0000000000..6740c318d9 --- /dev/null +++ b/tests/bugs/bug-1092841.t @@ -0,0 +1,24 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; + +TEST glusterd; +TEST pidof glusterd; +TEST $CLI volume info; + +TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2}; + +TEST $CLI volume start $V0; + +TEST $CLI volume barrier $V0 enable; + +TEST ! $CLI volume barrier $V0 enable; + +TEST $CLI volume barrier $V0 disable; + +TEST ! $CLI volume barrier $V0 disable; + +cleanup diff --git a/xlators/features/barrier/src/barrier.c b/xlators/features/barrier/src/barrier.c index a6867f6f45..74973499d5 100644 --- a/xlators/features/barrier/src/barrier.c +++ b/xlators/features/barrier/src/barrier.c @@ -351,8 +351,13 @@ notify (xlator_t *this, int event, void *data, ...) case GF_EVENT_TRANSLATOR_OP: { dict = data; - GF_OPTION_RECONF ("barrier", barrier_enabled, dict, - bool, out); + barrier_enabled = dict_get_str_boolean (dict, "barrier", -1); + + if (barrier_enabled == -1) { + gf_log (this->name, GF_LOG_ERROR, "Could not fetch " + " barrier key from the dictionary."); + goto out; + } LOCK (&priv->lock); { @@ -388,7 +393,8 @@ unlock: if (!list_empty (&queue)) barrier_dequeue_all (this, &queue); - // missing break is intentional + + break; } default: { -- cgit