summaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
authorvmallika <vmallika@redhat.com>2016-02-10 16:27:05 +0530
committerAtin Mukherjee <amukherj@redhat.com>2016-02-27 21:30:40 -0800
commit15602865865386672bcb996dab8259d25b684900 (patch)
tree907b68180a68072fb054937b1163cb7d690641fc /extras
parent18612a7b2e005d76529f8c2a6149a6506f6daae6 (diff)
quota: heal object-limit on a root dir of a newly added brick
When a new brick is added, xattr trusted.glusterfs.quota.limit-objects is not healed on a root directory. This patch will fix the problem Change-Id: I776609ebf4d7822c541b6262e63d465ea3a86db4 BUG: 1306220 Signed-off-by: vmallika <vmallika@redhat.com> Reviewed-on: http://review.gluster.org/13422 Smoke: Gluster Build System <jenkins@build.gluster.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
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;