summaryrefslogtreecommitdiffstats
path: root/extras/hook-scripts/add-brick
diff options
context:
space:
mode:
authorvmallika <vmallika@redhat.com>2015-12-29 17:35:30 +0530
committerAtin Mukherjee <amukherj@redhat.com>2016-02-08 19:58:56 -0800
commit6608b5cc1f9d01261b767c3abae212c6222e6ba6 (patch)
tree2cb801b4d770f71ef765936ed665ef701a0a7cae /extras/hook-scripts/add-brick
parentfac8038a9fa80e16b557d91b9e2fec271cfda5fa (diff)
quota: fix quota hook script for add-brick
Hook script should not call any CLI commands as this can cause parallel operation problem, so remove quota list command from the script Change-Id: I76a364133403371b172e063abd5f742075b20a2f BUG: 1294637 Signed-off-by: vmallika <vmallika@redhat.com> Reviewed-on: http://review.gluster.org/13110 Smoke: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Diffstat (limited to 'extras/hook-scripts/add-brick')
-rwxr-xr-xextras/hook-scripts/add-brick/post/disabled-quota-root-xattr-heal.sh51
1 files changed, 25 insertions, 26 deletions
diff --git a/extras/hook-scripts/add-brick/post/disabled-quota-root-xattr-heal.sh b/extras/hook-scripts/add-brick/post/disabled-quota-root-xattr-heal.sh
index 9e72464d161..5f143334358 100755
--- a/extras/hook-scripts/add-brick/post/disabled-quota-root-xattr-heal.sh
+++ b/extras/hook-scripts/add-brick/post/disabled-quota-root-xattr-heal.sh
@@ -21,7 +21,6 @@ VOLUME_OP=
GLUSTERD_WORKDIR=
ENABLED_NAME="S28Quota-root-xattr-heal.sh"
-
cleanup_mountpoint ()
{
umount -f $MOUNT_DIR;
@@ -37,6 +36,17 @@ cleanup_mountpoint ()
fi
}
+disable_and_exit ()
+{
+ if [ -e "$ENABLED_STATE" ]
+ then
+ unlink $ENABLED_STATE;
+ exit $?
+ fi
+
+ exit 0
+}
+
##------------------------------------------
## Parse the arguments
##------------------------------------------
@@ -73,20 +83,12 @@ done
ENABLED_STATE="$GLUSTERD_WORKDIR/hooks/$VERSION/$VOLUME_OP/post/$ENABLED_NAME"
-
-FLAG=`gluster volume quota $VOL_NAME list / 2>&1 | grep \
- '\(No quota configured on volume\)\|\(Limit not set\)'`;
-if ! [ -z $FLAG ]
+## Is quota enabled?
+FLAG=`grep "^features.quota=" $GLUSTERD_WORKDIR/vols/$VOL_NAME/info \
+ | awk -F'=' '{print $NF}'`;
+if [ "$FLAG" != "on" ]
then
- ls $ENABLED_STATE;
- RET=$?
- if [ 0 -eq $RET ]
- then
- unlink $ENABLED_STATE;
- exit $?
- fi
-
- exit $RET;
+ disable_and_exit
fi
## -----------------------------------
@@ -102,16 +104,22 @@ fi
## ------------------
## Getfattr the value
## ------------------
-VALUE=`getfattr -n "$QUOTA_CONFIG_XATTR" -e hex --absolute-names $MOUNT_DIR \
- 2>&1 | grep $QUOTA_CONFIG_XATTR | awk -F'=' '{print $2}'`
+VALUE=$(getfattr -n $QUOTA_CONFIG_XATTR -e hex --absolute-names $MOUNT_DIR 2>&1)
RET=$?
if [ 0 -ne $RET ]
then
## Clean up and exit
cleanup_mountpoint;
+ echo $VALUE | grep -iq "No such attribute"
+ if [ 0 -eq $? ]; then
+ disable_and_exit
+ fi
+
exit $RET;
fi
+
+VALUE=$(echo $VALUE | grep $QUOTA_CONFIG_XATTR | awk -F'=' '{print $NF}')
## ------------------
## ---------
@@ -129,13 +137,4 @@ fi
## ---------
cleanup_mountpoint;
-
-## Disable
-ls $ENABLED_STATE;
-RET=$?
-if [ 0 -eq $RET ]
-then
- unlink $ENABLED_STATE;
- exit $?
-fi
-exit $?
+disable_and_exit;