summaryrefslogtreecommitdiffstats
path: root/xlators/experimental/jbr-server/src/gen-fops.py
diff options
context:
space:
mode:
authorAvra Sengupta <asengupt@redhat.com>2016-05-10 12:13:18 +0530
committerJeff Darcy <jdarcy@redhat.com>2016-05-25 11:52:44 -0700
commitf8f16595d8dd8c8a869630bb77b7fd1b42b97e08 (patch)
tree8f8d7ff3739a16155331f0411501f94d8849513d /xlators/experimental/jbr-server/src/gen-fops.py
parentfb57ac1acb228301edb98f2fe7cf93471363eb4a (diff)
jbr: Making fop functions more modular to reuse more code
Putting bigger chunks of re-usable code like leader checks and init into functions thereby reducing the size of the 'fop' call. Introduced 'perform_local_op' in the 'fop' call, where regular functions as of now just call dispatch, but fops like 'lk' can do their fop specific operations. Introduced selective_generate to allow certain functions for a particular fop to be generated. The rest of the functions can be customised and added in jbr.c Change-Id: I3754ed68983e763329e14a2faef911428e36e4f0 BUG: 1336328 Signed-off-by: Avra Sengupta <asengupt@redhat.com> Reviewed-on: http://review.gluster.org/14355 Smoke: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Diffstat (limited to 'xlators/experimental/jbr-server/src/gen-fops.py')
-rwxr-xr-xxlators/experimental/jbr-server/src/gen-fops.py52
1 files changed, 46 insertions, 6 deletions
diff --git a/xlators/experimental/jbr-server/src/gen-fops.py b/xlators/experimental/jbr-server/src/gen-fops.py
index 64cbe4f760e..36bf1e35d27 100755
--- a/xlators/experimental/jbr-server/src/gen-fops.py
+++ b/xlators/experimental/jbr-server/src/gen-fops.py
@@ -78,7 +78,7 @@ fop_table = {
"getxattr": "read",
# "inodelk": "read",
"link": "write",
-# "lk": "read",
+# "lk": "write",
# "lookup": "read",
"mkdir": "write",
"mknod": "write",
@@ -103,6 +103,13 @@ fop_table = {
"xattrop": "write",
}
+# Mention those fops in the selective_generate table, for which
+# only a few common functions will be generated, and mention those
+# functions. Rest of the functions can be customized
+selective_generate = {
+# "lk": "fop,dispatch,call_dispatch",
+}
+
# Stolen from gen_fdl.py
def gen_server (templates):
fops_done = []
@@ -110,15 +117,48 @@ def gen_server (templates):
info = fop_table[name].split(",")
kind = info[0]
flags = info[1:]
+
+ # generate all functions for the fops in fop_table
+ # except for the ones in selective_generate for which
+ # generate only the functions mentioned in the
+ # selective_generate table
+ gen_funcs = "fop,complete,continue,fan-in,dispatch, \
+ call_dispatch,perform_local_op"
+ if name in selective_generate:
+ gen_funcs = selective_generate[name].split(",")
+
if ("fsync" in flags) or ("queue" in flags):
flags.append("need_fd")
for fname in flags:
print "#define JBR_CG_%s" % fname.upper()
- print generate(templates[kind+"-complete"],name,cbk_subs)
- print generate(templates[kind+"-continue"],name,fop_subs)
- print generate(templates[kind+"-fan-in"],name,cbk_subs)
- print generate(templates[kind+"-dispatch"],name,fop_subs)
- print generate(templates[kind+"-fop"],name,fop_subs)
+
+ if 'complete' in gen_funcs:
+ print generate(templates[kind+"-complete"],
+ name,cbk_subs)
+
+ if 'continue' in gen_funcs:
+ print generate(templates[kind+"-continue"],
+ name,fop_subs)
+
+ if 'fan-in' in gen_funcs:
+ print generate(templates[kind+"-fan-in"],
+ name,cbk_subs)
+
+ if 'dispatch' in gen_funcs:
+ print generate(templates[kind+"-dispatch"],
+ name,fop_subs)
+
+ if 'call_dispatch' in gen_funcs:
+ print generate(templates[kind+"-call_dispatch"],
+ name,fop_subs)
+
+ if 'perform_local_op' in gen_funcs:
+ print generate(templates[kind+"-perform_local_op"],
+ name, fop_subs)
+
+ if 'fop' in gen_funcs:
+ print generate(templates[kind+"-fop"],name,fop_subs)
+
for fname in flags:
print "#undef JBR_CG_%s" % fname.upper()
fops_done.append(name)