summaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
authorAnand V. Avati <avati@amp.gluster.com>2009-05-07 15:02:09 +0530
committerAnand V. Avati <avati@amp.gluster.com>2009-05-07 15:12:09 +0530
commitadb56cb5e0f0d718764b25f1b37397be720f8750 (patch)
treef7c4cd5f7ae77ae2487f6943735316166aa0c78f /extras
parentbabc4dfb08504e41a35cf06e8c297a19c87ac397 (diff)
backend-xattr-sanitize.sh: script added to extras/
Run the script as: sh$ ./backend-xattr-sanitize.sh /data/export0 and it will remove all the known stale xattrs on the backend files and dirs
Diffstat (limited to 'extras')
-rw-r--r--extras/Makefile.am2
-rwxr-xr-xextras/backend-xattr-sanitize.sh66
2 files changed, 67 insertions, 1 deletions
diff --git a/extras/Makefile.am b/extras/Makefile.am
index d95880c..9be3973 100644
--- a/extras/Makefile.am
+++ b/extras/Makefile.am
@@ -5,7 +5,7 @@ EditorMode_DATA = glusterfs-mode.el glusterfs.vim
SUBDIRS = init.d benchmarking
-EXTRA_DIST = specgen.scm MacOSX/Portfile glusterfs-mode.el glusterfs.vim migrate-unify-to-distribute.sh
+EXTRA_DIST = specgen.scm MacOSX/Portfile glusterfs-mode.el glusterfs.vim migrate-unify-to-distribute.sh backend-xattr-sanitize.sh
CLEANFILES =
diff --git a/extras/backend-xattr-sanitize.sh b/extras/backend-xattr-sanitize.sh
new file mode 100755
index 0000000..3967654
--- /dev/null
+++ b/extras/backend-xattr-sanitize.sh
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+# Each entry in the array below is a regular expression to match stale keys
+
+xs=("trusted.glusterfs.createtime"
+ "trusted.glusterfs.version"
+ "trusted.glusterfs.afr.data-pending"
+ "trusted.glusterfs.afr.metadata-pending"
+ "trusted.glusterfs.afr.entry-pending")
+
+absolute_path()
+{
+ local dir=$(dirname "$1");
+ local base=$(basename "$1");
+ cd "$dir";
+ echo $(pwd)/"$base";
+ cd - >/dev/null;
+}
+
+
+cleanup()
+{
+ sanitizee=$(absolute_path "$1");
+
+ stale_keys=$(
+ for pattern in ${xs[@]}; do
+ getfattr -d -m "$pattern" "$sanitizee" 2>/dev/null |
+ grep = | cut -f1 -d=;
+ done
+ )
+
+ if [ -z "$stale_keys" ]; then
+ return;
+ fi
+
+ for key in $stale_keys; do
+ echo "REMOVEXATTR ($key) $sanitizee";
+ setfattr -x "$key" "$sanitizee";
+ done
+}
+
+
+crawl()
+{
+ this_script=$(absolute_path "$0");
+
+ export sanitize=yes;
+ find "$1" -exec "$this_script" {} \;
+}
+
+
+main()
+{
+ if [ -z "$1" ]; then
+ echo "Usage: $0 <export-dir>"
+ return 1
+ fi
+
+ if [ "$sanitize" = "yes" ]; then
+ cleanup "$@";
+ else
+ crawl "$@";
+ fi
+}
+
+main "$@"