From 4ebe6c4df3415bfad6cb5bc29a9aa2eb53fdb6c3 Mon Sep 17 00:00:00 2001 From: vmallika Date: Tue, 29 Dec 2015 17:35:30 +0530 Subject: quota: fix quota hook script for add-brick This is a backport of http://review.gluster.org/#/c/13110/ 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 Change-Id: I9f2850e53c2ce69b33a82acec3fc739bc5bf54e5 BUG: 1296040 Signed-off-by: vmallika Reviewed-on: http://review.gluster.org/13182 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Atin Mukherjee --- .../post/disabled-quota-root-xattr-heal.sh | 51 +++++++++++----------- 1 file changed, 25 insertions(+), 26 deletions(-) (limited to 'extras') 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; -- cgit