diff options
author | Poornima G <pgurusid@redhat.com> | 2018-05-08 10:35:35 +0530 |
---|---|---|
committer | Poornima G <pgurusid@redhat.com> | 2018-05-17 09:17:41 +0000 |
commit | 7588be808db3fcfda337971990f02d2ebccba3d7 (patch) | |
tree | 68c90a095f2beb2cab151b9ec433af0fcdd342ee /extras/create_new_xlator | |
parent | c925962b91c67c8cd2391df7dd0251e0cbf66648 (diff) |
extras/create_new_xl : Fix the tool to accomodate the xl structure changes
Change-Id: I3524e62b0ed873c0763ca38f80fcd53b22ee79d1
fixes: bz#1577744
Signed-off-by: Poornima G <pgurusid@redhat.com>
Diffstat (limited to 'extras/create_new_xlator')
-rwxr-xr-x | extras/create_new_xlator/generate_xlator.py | 17 | ||||
-rw-r--r-- | extras/create_new_xlator/new-xlator-tmpl.c | 107 |
2 files changed, 100 insertions, 24 deletions
diff --git a/extras/create_new_xlator/generate_xlator.py b/extras/create_new_xlator/generate_xlator.py index 281afc2e0df..3af7ac48d54 100755 --- a/extras/create_new_xlator/generate_xlator.py +++ b/extras/create_new_xlator/generate_xlator.py @@ -93,8 +93,6 @@ def gen_xlator(): print(generate(fragments["FUNC_TEMPLATE"], dops, xlator_dumpops), file=xl) - print(fragments["XLATOR_METHODS"], file=xl) - #Generate fop table print("struct xlator_fops fops = {", file=xl) for fop in ops: @@ -113,6 +111,10 @@ def gen_xlator(): print(" .{0:20} = {1}_{2},".format(dops, fop_prefix, dops), file=xl) print("};", file=xl) + xlator_methods = fragments["XLATOR_METHODS"].replace("@XL_NAME@",xl_name) + xlator_methods = xlator_methods.replace("@FOP_PREFIX@",fop_prefix) + print(xlator_methods, file=xl) + xl.close() @@ -126,22 +128,21 @@ def gen_header_files(): h = open(src_dir_path+"/"+xl_name+".h", 'w+') print(COPYRIGHT, file=h) txt = fragments["HEADER_FMT"].replace("@HFL_NAME@", upname) - txt2 = fragments["INCLUDE_IN_HEADER_FILE"].replace("@XL_NAME@", xl_name) - txt = txt.replace("@INCLUDE_SECT@",txt2) + txt = txt.replace("@XL_NAME@", xl_name) print(txt, file=h) h.close() h = open(src_dir_path+"/"+xl_name+"-mem-types.h", 'w+') print(COPYRIGHT, file=h) - txt = fragments["HEADER_FMT"].replace("@HFL_NAME@", upname+"_MEM_TYPES") - txt = txt.replace("@INCLUDE_SECT@", '#include "mem-types.h"') + txt = fragments["MEM_HEADER_FMT"].replace("@HFL_NAME@", upname+"_MEM_TYPES") + txt = txt.replace("@FOP_PREFIX@", fop_prefix) print(txt, file=h) h.close() h = open(src_dir_path+"/"+xl_name+"-messages.h", 'w+') print(COPYRIGHT, file=h) - txt = fragments["HEADER_FMT"].replace("@HFL_NAME@", upname+"_MESSAGES") - txt = txt.replace("@INCLUDE_SECT@", '') + txt = fragments["MSG_HEADER_FMT"].replace("@HFL_NAME@", upname+"_MESSAGES") + txt = txt.replace("@FOP_PREFIX@", fop_prefix.upper()) print(txt, file=h) h.close() diff --git a/extras/create_new_xlator/new-xlator-tmpl.c b/extras/create_new_xlator/new-xlator-tmpl.c index ac08f3732a7..1f2f9c316a2 100644 --- a/extras/create_new_xlator/new-xlator-tmpl.c +++ b/extras/create_new_xlator/new-xlator-tmpl.c @@ -48,42 +48,117 @@ err: #pragma fragment INCLUDE_IN_SRC_FILE #include "@XL_NAME@.h" -#pragma fragment INCLUDE_IN_HEADER_FILE -#include "@XL_NAME@-mem-types.h" -#include "@XL_NAME@-messages.h" -#include "glusterfs.h" -#include "xlator.h" -#include "defaults.h" - #pragma fragment XLATOR_METHODS -int32_t -init (xlator_t *this) + +static int32_t +@FOP_PREFIX@_init (xlator_t *this) { return 0; } -void -fini (xlator_t *this) +static void +@FOP_PREFIX@_fini (xlator_t *this) { return; } -int32_t -reconfigure (xlator_t *this, dict_t *dict) +static int32_t +@FOP_PREFIX@_reconfigure (xlator_t *this, dict_t *dict) { return 0; } -int -notify (xlator_t *this, int event, void *data, ...) +static int +@FOP_PREFIX@_notify (xlator_t *this, int event, void *data, ...) { return default_notify (this, event, data); } +static int32_t +@FOP_PREFIX@_mem_acct_init (xlator_t *this) +{ + int ret = -1; + + ret = xlator_mem_acct_init (this, gf_@FOP_PREFIX@_mt_end + 1); + return ret; +} + +static int32_t +@FOP_PREFIX@_dump_metrics (xlator_t *this, int fd) +{ + return 0; +} + +struct volume_options @FOP_PREFIX@_options[] = { + /*{ .key = {""}, + .type = GF_OPTION_TYPE_BOOL, + .default_value = "", + .op_version = {GD_OP_VERSION_}, + .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT, + .tags = {""}, + .description = "" + }, + { .key = {NULL} }, + */ +}; + +xlator_api_t xlator_api = { + .init = @FOP_PREFIX@_init, + .fini = @FOP_PREFIX@_fini, + .notify = @FOP_PREFIX@_notify, + .reconfigure = @FOP_PREFIX@_reconfigure, + .mem_acct_init = @FOP_PREFIX@_mem_acct_init, + .dump_metrics = @FOP_PREFIX@_dump_metrics, + .op_version = {GD_OP_VERSION_}, + .dumpops = &@FOP_PREFIX@_dumpops, + .fops = &@FOP_PREFIX@_fops, + .cbks = &@FOP_PREFIX@_cbks, + .options = @FOP_PREFIX@_options, + .identifier = "@XL_NAME@", +}; #pragma fragment HEADER_FMT #ifndef __@HFL_NAME@_H__ #define __@HFL_NAME@_H__ -@INCLUDE_SECT@ +#include "@XL_NAME@-mem-types.h" +#include "@XL_NAME@-messages.h" +#include "glusterfs.h" +#include "xlator.h" +#include "defaults.h" + +#endif /* __@HFL_NAME@_H__ */ + +#pragma fragment MEM_HEADER_FMT +#ifndef __@HFL_NAME@_H__ +#define __@HFL_NAME@_H__ + +#include "mem-types.h" + +enum gf_mdc_mem_types_ { + gf_@FOP_PREFIX@_mt_ = gf_common_mt_end + 1, + gf_@FOP_PREFIX@_mt_end +}; + +#endif /* __@HFL_NAME@_H__ */ + +#pragma fragment MSG_HEADER_FMT +#ifndef __@HFL_NAME@_H__ +#define __@HFL_NAME@_H__ + +#include "glfs-message-id.h" + +/* To add new message IDs, append new identifiers at the end of the list. + * + * Never remove a message ID. If it's not used anymore, you can rename it or + * leave it as it is, but not delete it. This is to prevent reutilization of + * IDs by other messages. + * + * The component name must match one of the entries defined in + * glfs-message-id.h. + */ + +GLFS_MSGID(@FOP_PREFIX@, + @FOP_PREFIX@_MSG_NO_MEMORY +); #endif /* __@HFL_NAME@_H__ */ |