Skip to content

Commit 9b3b2e0

Browse files
python linter: string comment extras/quota/quota_fsck.py
This series aim to reduce the python linter build logs. This commit changes unassigned strings to comments. Signed-off-by: Thales Antunes de Oliveira Barretto <[email protected]> # extras/quota/quota_fsck.py | 106 ++++++++++++++++++++++----------------------- # 1 file changed, 51 insertions(+), 55 deletions(-) # extras/quota/quota_fsck.py | 106 ++++++++++++++++++++++----------------------- # 1 file changed, 51 insertions(+), 55 deletions(-)
1 parent cdbed3b commit 9b3b2e0

File tree

1 file changed

+51
-55
lines changed

1 file changed

+51
-55
lines changed

extras/quota/quota_fsck.py

Lines changed: 51 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
#!/usr/bin/python3
2-
# The following script enables, Detecting, Reporting and Fixing
3-
# anomalies in quota accounting. Run this script with -h option
4-
# for further details.
2+
"""Extras quota/quota-fsck.
53
4+
The following script enables, Detecting, Reporting and Fixing
5+
anomalies in quota accounting. Run this script with -h option
6+
for further details.
67
"""
7-
Copyright (c) 2018 Red Hat, Inc. <http://www.redhat.com>
8-
This file is part of GlusterFS.
98

10-
This file is licensed to you under your choice of the GNU Lesser
11-
General Public License, version 3 or any later version (LGPLv3 or
12-
later), or the GNU General Public License, version 2 (GPLv2), in all
13-
cases as published by the Free Software Foundation.
14-
"""
9+
# Copyright (c) 2018 Red Hat, Inc. <http://www.redhat.com>
10+
# This file is part of GlusterFS.
11+
#
12+
# This file is licensed to you under your choice of the GNU Lesser
13+
# General Public License, version 3 or any later version (LGPLv3 or
14+
# later), or the GNU General Public License, version 2 (GPLv2), in all
15+
# cases as published by the Free Software Foundation.
16+
1517
from __future__ import print_function
1618

1719
import argparse
@@ -86,34 +88,34 @@ def size_differs_lot(s1, s2):
8688

8789

8890
def fix_hardlink_accounting(curr_dict, accounted_dict, curr_size):
91+
"""Fix hardlink accounting.
92+
93+
Hard links are messy.. we have to account them for their parent
94+
directory. But, stop accounting at the most common ancestor.
95+
Eg:
96+
say we have 3 hardlinks : /d1/d2/h1, /d1/d3/h2 and /d1/h3
97+
98+
suppose we encounter the hard links h1 first , then h2 and then h3.
99+
while accounting for h1, we account the size until root(d2->d1->/)
100+
while accounting for h2, we need to account only till d3. (as d1
101+
and / are accounted for this inode).
102+
while accounting for h3 we should not account at all.. as all
103+
its ancestors are already accounted for same inode.
104+
105+
curr_dict : dict of hardlinks that were seen and
106+
accounted by the current iteration.
107+
accounted_dict : dict of hardlinks that has already been
108+
accounted for.
109+
110+
size : size of the object as accounted by the
111+
curr_iteration.
112+
113+
Return vale:
114+
curr_size : size reduced by hardlink sizes for those
115+
hardlinks that has already been accounted
116+
in current subtree.
117+
Also delete the duplicate link from curr_dict.
89118
"""
90-
Hard links are messy.. we have to account them for their parent
91-
directory. But, stop accounting at the most common ancestor.
92-
Eg:
93-
say we have 3 hardlinks : /d1/d2/h1, /d1/d3/h2 and /d1/h3
94-
95-
suppose we encounter the hard links h1 first , then h2 and then h3.
96-
while accounting for h1, we account the size until root(d2->d1->/)
97-
while accounting for h2, we need to account only till d3. (as d1
98-
and / are accounted for this inode).
99-
while accounting for h3 we should not account at all.. as all
100-
its ancestors are already accounted for same inode.
101-
102-
curr_dict : dict of hardlinks that were seen and
103-
accounted by the current iteration.
104-
accounted_dict : dict of hardlinks that has already been
105-
accounted for.
106-
107-
size : size of the object as accounted by the
108-
curr_iteration.
109-
110-
Return vale:
111-
curr_size : size reduced by hardlink sizes for those
112-
hardlinks that has already been accounted
113-
in current subtree.
114-
Also delete the duplicate link from curr_dict.
115-
"""
116-
117119
dual_accounted_links = set(curr_dict.keys()) & set(accounted_dict.keys())
118120
for link in dual_accounted_links:
119121
curr_size = curr_size - curr_dict[link]
@@ -144,24 +146,18 @@ def get_quota_xattr_brick(dpath):
144146
"-d", "-m.", "-e", "hex", dpath])
145147
pairs = out.splitlines()
146148

147-
"""
148-
Sample output to be parsed:
149-
[root@dhcp35-100 mnt]# getfattr -d -m. -e hex /export/b1/B0/d14/d13/
150-
# file: export/b1/B0/d14/d13/
151-
security.selinux=0x756e636f6e66696e65645f753a6f626a6563745f723a7573725f743a733000
152-
trusted.gfid=0xbae5e0d2d05043de9fd851d91ecf63e8
153-
trusted.glusterfs.dht=0x000000010000000000000000ffffffff
154-
trusted.glusterfs.dht.mds=0x00000000
155-
trusted.glusterfs.quota.6a7675a3-b85a-40c5-830b-de9229d702ce.contri.39=0x00000000000000000000000000000000000000000000000e
156-
trusted.glusterfs.quota.dirty=0x3000
157-
trusted.glusterfs.quota.size.39=0x00000000000000000000000000000000000000000000000e
158-
"""
159-
160-
"""
161-
xattr_dict dictionary holds quota related xattrs
162-
eg:
163-
"""
164-
149+
# Sample output to be parsed:
150+
# [root@dhcp35-100 mnt]# getfattr -d -m. -e hex /export/b1/B0/d14/d13/
151+
# # file: export/b1/B0/d14/d13/
152+
# security.selinux=0x756e636f6e66696e65645f753a6f626a6563745f723a7573725f743a733000
153+
# trusted.gfid=0xbae5e0d2d05043de9fd851d91ecf63e8
154+
# trusted.glusterfs.dht=0x000000010000000000000000ffffffff
155+
# trusted.glusterfs.dht.mds=0x00000000
156+
# trusted.glusterfs.quota.6a7675a3-b85a-40c5-830b-de9229d702ce.contri.39=0x00000000000000000000000000000000000000000000000e
157+
# trusted.glusterfs.quota.dirty=0x3000
158+
# trusted.glusterfs.quota.size.39=0x00000000000000000000000000000000000000000000000e
159+
160+
# xattr_dict dictionary holds quota related xattrs
165161
xattr_dict = {}
166162
xattr_dict['parents'] = {}
167163

0 commit comments

Comments
 (0)