summaryrefslogtreecommitdiffstats
path: root/extras/quota/xattr_analysis.py
diff options
context:
space:
mode:
authorSanoj Unnikrishnan <sunnikri@redhat.com>2017-06-29 15:39:35 +0530
committerRaghavendra G <rgowdapp@redhat.com>2017-06-30 08:39:05 +0000
commit50d72373fadf1174918e754e31bae3806aa4c214 (patch)
tree7bbd7c860e5694a6b7315ab4dbfefd54ff3a0f79 /extras/quota/xattr_analysis.py
parent292b4e42fdc023e307fde35e189285040d4b9cdd (diff)
Scripts to identify quota accouting issues
The patch contains 2 scripts: log_accounting.sh does a du -h on the FS hierarchy and a quota list on the hierarchy and interleaves the two output. We can then identify which directory(s) in FS has caused the accounting to go bad and try to investigate what fops happened on those directories. We can also limit the set of directories on which we need to set dirty xattr to correct accounting. xattr_analysis.py reads all the xattr of a brick and dumps it a human readable form to ease debugging. Change-Id: I2155561d10c08dc3ab9e8b09dbd258f0592b4d33 BUG: 1466188 Signed-off-by: Sanoj Unnikrishnan <sunnikri@redhat.com> Reviewed-on: https://review.gluster.org/17649 CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'extras/quota/xattr_analysis.py')
-rwxr-xr-xextras/quota/xattr_analysis.py72
1 files changed, 72 insertions, 0 deletions
diff --git a/extras/quota/xattr_analysis.py b/extras/quota/xattr_analysis.py
new file mode 100755
index 00000000000..d3d1a74170b
--- /dev/null
+++ b/extras/quota/xattr_analysis.py
@@ -0,0 +1,72 @@
+#!/usr/bin/python
+# Below script has to purpose
+# 1. Display xattr of entire FS tree in a human readable form
+# 2. Display all the directory where contri and size mismatch.
+# (If there are any directory with contri and size mismatch that are not dirty
+# then that highlights a propogation issue)
+# The script takes only one input LOG _FILE generated from the command,
+# find <brick_path> | xargs getfattr -d -m. -e hex > log_gluster_xattr
+
+import re
+import subprocess
+import sys
+from hurry.filesize import size
+
+if len(sys.argv) < 2:
+ sys.exit('Usage: %s log_gluster_xattr \n'
+ 'to genereate log_gluster_xattr use: \n'
+ 'find <brick_path> | xargs getfattr -d -m. -e hex > log_gluster_xattr'
+ % sys.argv[0])
+LOG_FILE=sys.argv[1]
+
+def get_quota_xattr_brick():
+ out = subprocess.check_output (["/usr/bin/cat", LOG_FILE])
+ pairs = out.splitlines()
+
+ xdict = {}
+ mismatch_size = [('====contri_size===', '====size====')]
+ for xattr in pairs:
+ k = xattr.split("=")[0]
+ if re.search("# file:",k):
+ print xdict
+ filename=k
+ print "=====" + filename + "======="
+ xdict = {}
+ elif k is "":
+ pass
+ else:
+ print xattr
+ v = xattr.split("=")[1]
+ if re.search("contri",k):
+ if len(v) == 34:
+ # for files size is obtained in iatt, file count should be 1, dir count=0
+ xdict['contri_file_count'] = int(v[18:34], 16)
+ xdict['contri_dir_count'] = 0
+ else:
+ xdict['contri_size'] = size(int(v[2:18], 16))
+ xdict['contri_file_count'] = int(v[18:34], 16)
+ xdict['contri_dir_count'] = int(v[34:], 16)
+ elif re.search("size",k):
+ xdict['size'] = size(int(v[2:18], 16))
+ xdict['file_count'] = int(v[18:34], 16)
+ xdict['dir_count'] = int(v[34:], 16)
+ elif re.search("dirty",k):
+ if v == '0x3000':
+ xdict['dirty'] = False
+ elif v == '0x3100':
+ xdict['dirty'] = True
+ elif re.search("limit_objects",k):
+ xdict['limit_objects'] = int(v[2:18], 16)
+ elif re.search("limit_set",k):
+ xdict['limit_set'] = size(int(v[2:18], 16))
+
+ if 'size' in xdict and 'contri_size' in xdict and xdict['size'] != xdict['contri_size']:
+ mismatch_size.append((xdict['contri_size'], xdict['size'], filename))
+
+ for values in mismatch_size:
+ print values
+
+
+if __name__ == '__main__':
+ get_quota_xattr_brick()
+