summaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
authorvmallika <vmallika@redhat.com>2015-12-29 17:35:30 +0530
committerAtin Mukherjee <amukherj@redhat.com>2016-02-10 00:58:23 -0800
commit4ebe6c4df3415bfad6cb5bc29a9aa2eb53fdb6c3 (patch)
tree7c509b7cfcbe4e0acc02fc18f88bfa8f71d76671 /extras
parent68c97f53561da413c80e6e22d364d00cfb3c8196 (diff)
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 <vmallika@redhat.com> Change-Id: I9f2850e53c2ce69b33a82acec3fc739bc5bf54e5 BUG: 1296040 Signed-off-by: vmallika <vmallika@redhat.com> Reviewed-on: http://review.gluster.org/13182 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')
-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;