diff options
author | Rajesh Amaravathi <rajesh@redhat.com> | 2011-12-13 12:58:25 +0530 |
---|---|---|
committer | Vijay Bellur <vijay@gluster.com> | 2011-12-25 21:41:12 -0800 |
commit | 4511ed196f94f639846b899e6b58f5f6af3fa668 (patch) | |
tree | 422f8cf09d66ed7a971c71c89f692d36a0fa8f03 /extras | |
parent | 31fa06932952f0cb706653aa7d0450646009eb07 (diff) |
extras: clean up a brick's gfid xattr
* extras/clear_xattrs.sh: This script enables a brick from a
deleted volume(stale brick) to be used in a new volume by
clearing all the trusted.gfid xattr from the brick tree.
* One should run this script on all machines which have
stale bricks if one wants to re-use the same bricks
for a new volume.
NOTE: This script *SHOULD BE RUN ONLY AFTER STOPPING A VOLUME*,
thereby ensuring that no replace-brick or rebalance operations
are on-going.
Change-Id: I35a4a2784fe502749184b87299b1a043b8e48e90
BUG: 765572
Signed-off-by: Rajesh Amaravathi <rajesh@redhat.com>
Reviewed-on: http://review.gluster.com/781
Reviewed-by: Amar Tumballi <amar@gluster.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'extras')
-rwxr-xr-x | extras/clear_xattrs.sh | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/extras/clear_xattrs.sh b/extras/clear_xattrs.sh new file mode 100755 index 000000000..bdce5b895 --- /dev/null +++ b/extras/clear_xattrs.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# Clear the trusted.gfid xattr in the brick tree + +# This script must be run only on a stopped brick/volume +# Stop the volume to make sure no rebalance/replace-brick +# operations are on-going + +# Not much error checking +remove_xattrs () +{ + find "$1" -exec setfattr -h -x "trusted.gfid" '{}' \; > /dev/null 2>&1; + find "$1" -exec setfattr -h -x "trusted.glusterfs.volume-id" '{}' \; > /dev/null 2>&1; +} + +main () +{ + if [ -z "$1" ]; then + echo "Please specify the brick path(s)"; + exit 1; + fi + + which getfattr > /dev/null 2>&1; + if [ $? -ne 0 ]; then + echo "attr package missing"; + exit 1; + fi + + which setfattr > /dev/null 2>&1; + if [ $? -ne 0 ]; then + echo "attr package missing"; + exit 1; + fi + + for brick in "$@"; + do + echo "xattr clean-up in progress: $brick"; + remove_xattrs "$brick"; + echo "$brick ready to be used as a glusterfs brick"; + done; +} + +main "$@";
\ No newline at end of file |