From 1da6a7525eb83f429c6f6ef2bba58c0adf3f64aa Mon Sep 17 00:00:00 2001 From: vmallika Date: Wed, 10 Feb 2016 16:27:05 +0530 Subject: quota: heal object-limit on a root dir of a newly added brick This is a backport of http://review.gluster.org/13422 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 > Reviewed-on: http://review.gluster.org/13422 > Smoke: Gluster Build System > CentOS-regression: Gluster Build System > NetBSD-regression: NetBSD Build System > Reviewed-by: Atin Mukherjee Change-Id: I47412b4da35c0f5d28106020daf32212d267cb9e BUG: 1312954 Signed-off-by: vmallika Reviewed-on: http://review.gluster.org/13551 Smoke: Gluster Build System CentOS-regression: Gluster Build System NetBSD-regression: NetBSD Build System Reviewed-by: Atin Mukherjee --- .../post/disabled-quota-root-xattr-heal.sh | 61 ++++++++++------------ 1 file 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; -- cgit