diff options
Diffstat (limited to 'extras')
-rwxr-xr-x | extras/quota/quota_fsck.py | 30 | ||||
-rwxr-xr-x | extras/quota/xattr_analysis.py | 12 |
2 files changed, 21 insertions, 21 deletions
diff --git a/extras/quota/quota_fsck.py b/extras/quota/quota_fsck.py index e2bb580dd5d..2803c6ec7c6 100755 --- a/extras/quota/quota_fsck.py +++ b/extras/quota/quota_fsck.py @@ -52,16 +52,16 @@ epilog_msg=''' def print_msg(log_type, path, xattr_dict = {}, stbuf = "", dir_size = None): if log_type == QUOTA_VERBOSE: - print('%-24s %-60s\nxattr_values: %s\n%s\n' % {"Verbose", path , xattr_dict, stbuf}) + print('%-24s %-60s\nxattr_values: %s\n%s\n' % {"Verbose", path, xattr_dict, stbuf}) elif log_type == QUOTA_META_ABSENT: - print('%-24s %-60s\n%s\n' % {"Quota-Meta Absent", path , xattr_dict}) + print('%-24s %-60s\n%s\n' % {"Quota-Meta Absent", path, xattr_dict}) elif log_type == QUOTA_SIZE_MISMATCH: print("mismatch") if dir_size is not None: - print('%24s %60s %12s %12s' % {"Size Mismatch", path , xattr_dict['contri_size'], + print('%24s %60s %12s %12s' % {"Size Mismatch", path, xattr_dict['contri_size'], dir_size}) else: - print('%-24s %-60s %-12i %-12i' % {"Size Mismatch", path , xattr_dict['contri_size'], + print('%-24s %-60s %-12i %-12i' % {"Size Mismatch", path, xattr_dict['contri_size'], stbuf.st_size}) def size_differs_lot(s1, s2): @@ -158,18 +158,18 @@ def get_quota_xattr_brick(dpath): for xattr in pairs: xattr_key = xattr.split("=")[0] - if re.search("# file:",xattr_key): + if re.search("# file:", xattr_key): # skip the file comment continue elif xattr_key is "": # skip any empty lines continue - elif not re.search("quota",xattr_key): + elif not re.search("quota", xattr_key): # skip all non quota xattr. continue xattr_value = xattr.split("=")[1] - if re.search("contri",xattr_key): + if re.search("contri", xattr_key): xattr_version = xattr_key.split(".")[5] if 'version' not in xattr_dict: @@ -197,18 +197,18 @@ def get_quota_xattr_brick(dpath): contri_dict['contri_file_count'] = int(xattr_value[18:34], 16) contri_dict['contri_dir_count'] = int(xattr_value[34:], 16) - elif re.search("size",xattr_key): + elif re.search("size", xattr_key): xattr_dict['size'] = int(xattr_value[2:18], 16) xattr_dict['file_count'] = int(xattr_value[18:34], 16) xattr_dict['dir_count'] = int(xattr_value[34:], 16) - elif re.search("dirty",xattr_key): + elif re.search("dirty", xattr_key): if xattr_value == IS_CLEAN: xattr_dict['dirty'] = False elif xattr_value == IS_DIRTY: xattr_dict['dirty'] = True - elif re.search("limit_objects",xattr_key): + elif re.search("limit_objects", xattr_key): xattr_dict['limit_objects'] = int(xattr_value[2:18], 16) - elif re.search("limit_set",xattr_key): + elif re.search("limit_set", xattr_key): xattr_dict['limit_set'] = int(xattr_value[2:18], 16) return xattr_dict @@ -232,7 +232,7 @@ def verify_file_xattr(path, stbuf = None): print_msg(QUOTA_META_ABSENT, path, xattr_dict, stbuf) fix_xattr(path, False) return - elif size_differs_lot(contri_dict['contri_size'] , stbuf.st_size): + elif size_differs_lot(contri_dict['contri_size'], stbuf.st_size): print_msg(QUOTA_SIZE_MISMATCH, path, xattr_dict, stbuf) fix_xattr(path, False) return @@ -257,7 +257,7 @@ def verify_dir_xattr(path, dir_size): fix_xattr(path, True) return elif size_differs_lot(dir_size, xattr_dict['size']) or \ - size_differs_lot(contri_dict['contri_size'] , xattr_dict['size']): + size_differs_lot(contri_dict['contri_size'], xattr_dict['size']): print_msg(QUOTA_SIZE_MISMATCH, path, xattr_dict, stbuf, dir_size) fix_xattr(path, True) return @@ -347,7 +347,7 @@ if __name__ == '__main__': disk space exists if redirecting to file] ''' ) - parser.add_argument('--fix-issues',metavar='mount_path', dest='mnt', action='store', + parser.add_argument('--fix-issues', metavar='mount_path', dest='mnt', action='store', help=''' fix accounting issues where the xattr values disagree with stat sizes reported by gluster. A mount is also @@ -355,7 +355,7 @@ if __name__ == '__main__': [CAUTION: This will directly modify backend xattr] ''' ) - parser.add_argument('--sub-dir',metavar='sub_dir', dest='sub_dir', action='store', + parser.add_argument('--sub-dir', metavar='sub_dir', dest='sub_dir', action='store', help=''' limit the crawling and accounting verification/correction to a specific subdirectory. diff --git a/extras/quota/xattr_analysis.py b/extras/quota/xattr_analysis.py index 9a178e058c2..a68eb341e19 100755 --- a/extras/quota/xattr_analysis.py +++ b/extras/quota/xattr_analysis.py @@ -28,7 +28,7 @@ def get_quota_xattr_brick(): mismatch_size = [('====contri_size===', '====size====')] for xattr in pairs: k = xattr.split("=")[0] - if re.search("# file:",k): + if re.search("# file:", k): print(xdict) filename=k print("=====" + filename + "=======") @@ -38,7 +38,7 @@ def get_quota_xattr_brick(): else: print(xattr) v = xattr.split("=")[1] - if re.search("contri",k): + 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) @@ -47,18 +47,18 @@ def get_quota_xattr_brick(): 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): + 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): + elif re.search("dirty", k): if v == '0x3000': xdict['dirty'] = False elif v == '0x3100': xdict['dirty'] = True - elif re.search("limit_objects",k): + elif re.search("limit_objects", k): xdict['limit_objects'] = int(v[2:18], 16) - elif re.search("limit_set",k): + 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']: |