summaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
Diffstat (limited to 'extras')
-rwxr-xr-xextras/hook-scripts/add-brick/post/disabled-quota-root-xattr-heal.sh61
1 files changed, 28 insertions, 33 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 5f143334358..bde7249d429 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
@@ -11,7 +11,8 @@
## 4. Disable itself
##---------------------------------------------------------------------------
-QUOTA_CONFIG_XATTR="trusted.glusterfs.quota.limit-set";
+QUOTA_LIMIT_XATTR="trusted.glusterfs.quota.limit-set"
+QUOTA_OBJECT_LIMIT_XATTR="trusted.glusterfs.quota.limit-objects"
MOUNT_DIR=`mktemp -d -t ${0##*/}.XXXXXX`;
OPTSPEC="volname:,version:,gd-workdir:,volume-op:"
PROGNAME="Quota-xattr-heal-add-brick"
@@ -47,6 +48,26 @@ disable_and_exit ()
exit 0
}
+get_and_set_xattr ()
+{
+ XATTR=$1
+
+ VALUE=$(getfattr -n $XATTR -e hex --absolute-names $MOUNT_DIR 2>&1)
+ RET=$?
+ if [ 0 -eq $RET ]; then
+ VALUE=$(echo $VALUE | grep $XATTR | awk -F'=' '{print $NF}')
+ setfattr -n $XATTR -v $VALUE $MOUNT_DIR;
+ RET=$?
+ else
+ echo $VALUE | grep -iq "No such attribute"
+ if [ 0 -eq $? ]; then
+ RET=0
+ fi
+ fi
+
+ return $RET;
+}
+
##------------------------------------------
## Parse the arguments
##------------------------------------------
@@ -101,40 +122,14 @@ then
fi
## -----------------------------------
-## ------------------
-## Getfattr the value
-## ------------------
-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}')
-## ------------------
+RET1=$(get_and_set_xattr $QUOTA_LIMIT_XATTR)
+RET2=$(get_and_set_xattr $QUOTA_OBJECT_LIMIT_XATTR)
-## ---------
-## Set xattr
-## ---------
-setfattr -n "$QUOTA_CONFIG_XATTR" -v $VALUE $MOUNT_DIR;
-RET=$?
-if [ 0 -ne $RET ]
-then
- ## Clean up and exit
- cleanup_mountpoint;
+## Clean up and exit
+cleanup_mountpoint;
- exit $RET;
+if [ $RET1 -ne 0 -o $RET2 -ne 0 ]; then
+ exit 1
fi
-## ---------
-cleanup_mountpoint;
disable_and_exit;