Created
July 18, 2013 23:13
-
-
Save T0aD/6033887 to your computer and use it in GitHub Desktop.
Files used to reproduce crashes with GlusterFS configured with more than 6000 quotas.
If quotas > 6000, it will crash on 1060th
Basically the issue is in the volume file reading procedure, but Im not skilled enough to see where exactly.
Use: ./gen.py 10000 (generate 10.000 quotas and store them in pickle file)
./inject_quota.py <VOLNAME>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
import os | |
from gfsquota import * | |
import sys | |
try: | |
count = int(sys.argv[1]) | |
except: | |
count = 5000 | |
# path | |
def home(): | |
for a in range(4, 20): | |
for b in range(256): | |
for c in range(256): | |
path = "/%02x/%02x/%02x" % (a, b, c) | |
yield path | |
p = "/home" | |
#s = "gluster volume quota users limit-usage %s 100MB" | |
g = gfsq() | |
g.empty() | |
i = 0 | |
for h in home(): | |
if i > count: | |
break | |
i += 1 | |
f = "%s%s" % (p, h) | |
g.set(f, '50MB') | |
# print s % f | |
# os.system(s % f) | |
print 'saved %d records.' % i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
import pickle | |
import os | |
class gfsq(): | |
def __init__(self, name="./quotas.pickle"): | |
self.dbfile = name | |
self.db = self.load(name) | |
def empty(self): | |
self.db = {} | |
def count(self): | |
print 'found %d records' % len(self.db) | |
def __del__(self): | |
self.save() | |
def save(self): | |
p = open(self.dbfile, 'wb') | |
pickle.dump(self.db, p) | |
p.close() | |
def load(self, dbfile): | |
try: | |
p = open(dbfile, 'r') | |
db = pickle.load(p) | |
p.close() | |
except: | |
return {} | |
return db | |
def set(self, path, size): | |
self.db[path] = size | |
def rem(self, path): | |
if path in self.db: | |
del self.db[path] | |
def dump(self): | |
export = "" | |
for path in self.db: | |
export += ",%s:%s" % (path, self.db[path]) | |
return export[1:] | |
def pdump(self): | |
print self.dump() | |
def show(self): | |
for path in self.db: | |
print '%s:%s' % (path, self.db[path]) | |
if __name__ == "__main__": | |
gfsq = gfsq() | |
import sys | |
if hasattr(gfsq, sys.argv[1]): | |
func = getattr(gfsq, sys.argv[1]) | |
if len(sys.argv) == 3: | |
func(sys.argv[2]) | |
elif len(sys.argv) == 4: | |
func(sys.argv[2], sys.argv[3]) | |
else: | |
func() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
import sys | |
import gfsquota | |
import os | |
g = gfsquota.gfsq() | |
data = g.dump() | |
# Files where quotas seem to be stored: | |
### | |
targets = ("/var/lib/glusterd/nfs/nfs-server.vol", | |
"/var/lib/glusterd/vols/%s/info", | |
"/var/lib/glusterd/vols/%s/trusted-%s-fuse.vol", | |
"/var/lib/glusterd/vols/%s/%s-fuse.vol" | |
) | |
target_lines = ("option limit-set ", "features.limit-usage=") | |
vol = sys.argv[1] | |
for t in targets: | |
if t.count('%') == 2: | |
t %= (vol, vol) | |
elif t.count('%') == 1: | |
t %= vol | |
out = "%s.tmp" % t | |
i = open(t, 'r') | |
o = open(out, 'w') | |
for l in i: | |
line = l.strip() | |
for tl in target_lines: | |
if line.startswith(tl): | |
offset = l.find(tl) + len(tl) | |
# print l.rstrip() | |
l = l[:offset] + data + "\n" | |
# print l.rstrip() | |
continue | |
o.write(l) | |
i.close() | |
o.close() | |
os.rename(out, t) | |
print 'wrote', t | |
exit() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment