"Fossies" - the Fresh Open Source Software Archive

Member "glusterfs-8.2/xlators/mgmt/glusterd/src/glusterd-volgen.h" (16 Sep 2020, 11183 Bytes) of package /linux/misc/glusterfs-8.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "glusterd-volgen.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2    Copyright (c) 2006-2012 Red Hat, Inc. <http://www.redhat.com>
    3    This file is part of GlusterFS.
    4 
    5    This file is licensed to you under your choice of the GNU Lesser
    6    General Public License, version 3 or any later version (LGPLv3 or
    7    later), or the GNU General Public License, version 2 (GPLv2), in all
    8    cases as published by the Free Software Foundation.
    9 */
   10 #ifndef _GLUSTERD_VOLGEN_H_
   11 #define _GLUSTERD_VOLGEN_H_
   12 
   13 #if (HAVE_LIB_XML)
   14 #include <libxml/encoding.h>
   15 #include <libxml/xmlwriter.h>
   16 #endif
   17 
   18 #include "glusterd.h"
   19 #include "glusterd-messages.h"
   20 
   21 /* volopt map key name definitions */
   22 
   23 #define VKEY_DIAG_CNT_FOP_HITS "diagnostics.count-fop-hits"
   24 #define VKEY_DIAG_LAT_MEASUREMENT "diagnostics.latency-measurement"
   25 #define VKEY_FEATURES_LIMIT_USAGE "features.limit-usage"
   26 #define VKEY_FEATURES_SOFT_LIMIT "features.soft-limit"
   27 #define VKEY_MARKER_XTIME GEOREP ".indexing"
   28 #define VKEY_MARKER_XTIME_FORCE GEOREP ".ignore-pid-check"
   29 #define VKEY_CHANGELOG "changelog.changelog"
   30 #define VKEY_FEATURES_QUOTA "features.quota"
   31 #define VKEY_FEATURES_INODE_QUOTA "features.inode-quota"
   32 #define VKEY_FEATURES_TRASH "features.trash"
   33 #define VKEY_FEATURES_BITROT "features.bitrot"
   34 #define VKEY_FEATURES_SCRUB "features.scrub"
   35 #define VKEY_FEATURES_SELINUX "features.selinux"
   36 #define VKEY_PARALLEL_READDIR "performance.parallel-readdir"
   37 #define VKEY_READDIR_AHEAD "performance.readdir-ahead"
   38 #define VKEY_RDA_CACHE_LIMIT "performance.rda-cache-limit"
   39 #define VKEY_RDA_REQUEST_SIZE "performance.rda-request-size"
   40 #define VKEY_CONFIG_GFPROXY "config.gfproxyd"
   41 #define VKEY_CONFIG_GLOBAL_THREADING "config.global-threading"
   42 #define VKEY_CONFIG_CLIENT_THREADS "config.client-threads"
   43 #define VKEY_CONFIG_BRICK_THREADS "config.brick-threads"
   44 
   45 #define AUTH_ALLOW_MAP_KEY "auth.allow"
   46 #define AUTH_REJECT_MAP_KEY "auth.reject"
   47 #define NFS_DISABLE_MAP_KEY "nfs.disable"
   48 #define AUTH_ALLOW_OPT_KEY "auth.addr.*.allow"
   49 #define AUTH_REJECT_OPT_KEY "auth.addr.*.reject"
   50 #define NFS_DISABLE_OPT_KEY "nfs.*.disable"
   51 
   52 #define SSL_OWN_CERT_OPT "ssl.own-cert"
   53 #define SSL_PRIVATE_KEY_OPT "ssl.private-key"
   54 #define SSL_CA_LIST_OPT "ssl.ca-list"
   55 #define SSL_CRL_PATH_OPT "ssl.crl-path"
   56 #define SSL_CERT_DEPTH_OPT "ssl.certificate-depth"
   57 #define SSL_CIPHER_LIST_OPT "ssl.cipher-list"
   58 #define SSL_DH_PARAM_OPT "ssl.dh-param"
   59 #define SSL_EC_CURVE_OPT "ssl.ec-curve"
   60 
   61 typedef enum {
   62     GF_CLIENT_TRUSTED,
   63     GF_CLIENT_OTHER,
   64     GF_CLIENT_TRUSTED_PROXY,
   65 } glusterd_client_type_t;
   66 
   67 /* It indicates the type of volfile that the graph is built for */
   68 typedef enum {
   69     GF_REBALANCED = 1,
   70     GF_QUOTAD,
   71     GF_SNAPD,
   72     GF_SHD,
   73 } glusterd_graph_type_t;
   74 
   75 struct volgen_graph {
   76     char **errstr;
   77     glusterfs_graph_t graph;
   78     glusterd_graph_type_t type;
   79 };
   80 typedef struct volgen_graph volgen_graph_t;
   81 
   82 typedef int (*glusterd_graph_builder_t)(volgen_graph_t *graph,
   83                                         dict_t *mod_dict);
   84 typedef int (*glusterd_vol_graph_builder_t)(glusterd_volinfo_t *,
   85                                             char *filename, dict_t *mod_dict);
   86 
   87 #define COMPLETE_OPTION(key, completion, ret)                                  \
   88     do {                                                                       \
   89         if (!strchr(key, '.')) {                                               \
   90             ret = option_complete(key, &completion);                           \
   91             if (ret) {                                                         \
   92                 gf_msg("", GF_LOG_ERROR, ENOMEM, GD_MSG_NO_MEMORY,             \
   93                        "Out of memory");                                       \
   94                 return _gf_false;                                              \
   95             }                                                                  \
   96                                                                                \
   97             if (!completion) {                                                 \
   98                 gf_msg("", GF_LOG_ERROR, 0, GD_MSG_INVALID_ENTRY,              \
   99                        "option %s does not"                                    \
  100                        "exist",                                                \
  101                        key);                                                   \
  102                 return _gf_false;                                              \
  103             }                                                                  \
  104         }                                                                      \
  105                                                                                \
  106         if (completion)                                                        \
  107             GF_FREE(completion);                                               \
  108     } while (0);
  109 
  110 typedef enum gd_volopt_flags_ {
  111     VOLOPT_FLAG_NONE,
  112     VOLOPT_FLAG_FORCE = 0x01,       /* option needs force to be reset */
  113     VOLOPT_FLAG_XLATOR_OPT = 0x02,  /* option enables/disables xlators */
  114     VOLOPT_FLAG_CLIENT_OPT = 0x04,  /* option affects clients */
  115     VOLOPT_FLAG_NEVER_RESET = 0x08, /* option which should not be reset */
  116 } gd_volopt_flags_t;
  117 
  118 typedef enum {
  119     GF_XLATOR_POSIX = 0,
  120     GF_XLATOR_ACL,
  121     GF_XLATOR_LOCKS,
  122     GF_XLATOR_LEASES,
  123     GF_XLATOR_UPCALL,
  124     GF_XLATOR_IOT,
  125     GF_XLATOR_INDEX,
  126     GF_XLATOR_MARKER,
  127     GF_XLATOR_IO_STATS,
  128     GF_XLATOR_BD,
  129     GF_XLATOR_SERVER,
  130     GF_XLATOR_NONE,
  131 } glusterd_server_xlator_t;
  132 
  133 /* As of now debug xlators can be loaded only below fuse in the client
  134  * graph via cli. More xlators can be added below when the cli option
  135  * for adding debug xlators anywhere in the client graph has to be made
  136  * available.
  137  */
  138 typedef enum {
  139     GF_CLNT_XLATOR_FUSE = 0,
  140     GF_CLNT_XLATOR_NONE,
  141 } glusterd_client_xlator_t;
  142 
  143 typedef enum { DOC, NO_DOC, GLOBAL_DOC, GLOBAL_NO_DOC } option_type_t;
  144 
  145 typedef int (*vme_option_validation)(glusterd_volinfo_t *volinfo, dict_t *dict,
  146                                      char *key, char *value, char **op_errstr);
  147 
  148 struct volopt_map_entry {
  149     char *key;
  150     char *voltype;
  151     char *option;
  152     char *value;
  153     option_type_t type;
  154     uint32_t flags;
  155     uint32_t op_version;
  156     char *description;
  157     vme_option_validation validate_fn;
  158     /* If client_option is true, the option affects clients.
  159      * this is used to calculate client-op-version of volumes
  160      */
  161     // gf_boolean_t client_option;
  162 };
  163 
  164 typedef int (*brick_xlator_builder)(volgen_graph_t *graph,
  165                                     glusterd_volinfo_t *volinfo,
  166                                     dict_t *set_dict,
  167                                     glusterd_brickinfo_t *brickinfo);
  168 
  169 struct volgen_brick_xlator {
  170     /* function that builds a xlator */
  171     brick_xlator_builder builder;
  172     /* debug key for a xlator that
  173      * gets used for adding debug translators like trace, error-gen,
  174      * delay-gen before this xlator */
  175     char *dbg_key;
  176 };
  177 
  178 struct nfs_opt {
  179     const char *pattern;
  180     const char *printf_pattern;
  181 };
  182 
  183 typedef struct volgen_brick_xlator volgen_brick_xlator_t;
  184 
  185 int
  186 glusterd_snapdsvc_create_volfile(glusterd_volinfo_t *volinfo);
  187 
  188 int
  189 glusterd_snapdsvc_generate_volfile(volgen_graph_t *graph,
  190                                    glusterd_volinfo_t *volinfo);
  191 
  192 int
  193 glusterd_create_global_volfile(glusterd_graph_builder_t builder, char *filepath,
  194                                dict_t *mod_dict);
  195 
  196 int
  197 glusterd_create_rb_volfiles(glusterd_volinfo_t *volinfo,
  198                             glusterd_brickinfo_t *brickinfo);
  199 
  200 int
  201 glusterd_create_volfiles(glusterd_volinfo_t *volinfo);
  202 
  203 int
  204 glusterd_create_volfiles_and_notify_services(glusterd_volinfo_t *volinfo);
  205 
  206 int
  207 glusterd_generate_client_per_brick_volfile(glusterd_volinfo_t *volinfo);
  208 
  209 void
  210 glusterd_get_nfs_filepath(char *filename);
  211 
  212 void
  213 glusterd_get_shd_filepath(char *filename);
  214 
  215 int
  216 build_shd_graph(glusterd_volinfo_t *volinfo, volgen_graph_t *graph,
  217                 dict_t *mod_dict);
  218 
  219 #ifdef BUILD_GNFS
  220 int
  221 build_nfs_graph(volgen_graph_t *graph, dict_t *mod_dict);
  222 #endif
  223 int
  224 build_quotad_graph(volgen_graph_t *graph, dict_t *mod_dict);
  225 
  226 int
  227 build_rebalance_volfile(glusterd_volinfo_t *volinfo, char *filepath,
  228                         dict_t *mod_dict);
  229 
  230 int
  231 build_bitd_graph(volgen_graph_t *graph, dict_t *mod_dict);
  232 
  233 int
  234 build_scrub_graph(volgen_graph_t *graph, dict_t *mod_dict);
  235 
  236 int
  237 glusterd_delete_volfile(glusterd_volinfo_t *volinfo,
  238                         glusterd_brickinfo_t *brickinfo);
  239 int
  240 glusterd_delete_snap_volfile(glusterd_volinfo_t *volinfo,
  241                              glusterd_volinfo_t *snap_volinfo,
  242                              glusterd_brickinfo_t *brickinfo);
  243 
  244 int
  245 glusterd_volinfo_get(glusterd_volinfo_t *volinfo, char *key, char **value);
  246 
  247 int
  248 glusterd_volinfo_get_boolean(glusterd_volinfo_t *volinfo, char *key);
  249 
  250 int
  251 glusterd_validate_globalopts(glusterd_volinfo_t *volinfo, dict_t *val_dict,
  252                              char **op_errstr);
  253 
  254 int
  255 glusterd_validate_localopts(dict_t *val_dict, char **op_errstr);
  256 
  257 gf_boolean_t
  258 glusterd_check_globaloption(char *key);
  259 
  260 gf_boolean_t
  261 glusterd_check_voloption_flags(char *key, int32_t flags);
  262 
  263 gf_boolean_t
  264 glusterd_is_valid_volfpath(char *volname, char *brick);
  265 
  266 int
  267 generate_brick_volfiles(glusterd_volinfo_t *volinfo);
  268 
  269 int
  270 generate_snap_brick_volfiles(glusterd_volinfo_t *volinfo,
  271                              glusterd_volinfo_t *snap_volinfo);
  272 int
  273 generate_client_volfiles(glusterd_volinfo_t *volinfo,
  274                          glusterd_client_type_t client_type);
  275 int
  276 generate_snap_client_volfiles(glusterd_volinfo_t *actual_volinfo,
  277                               glusterd_volinfo_t *snap_volinfo,
  278                               glusterd_client_type_t client_type,
  279                               gf_boolean_t vol_restore);
  280 
  281 int
  282 _get_xlator_opt_key_from_vme(struct volopt_map_entry *vme, char **key);
  283 
  284 void
  285 _free_xlator_opt_key(char *key);
  286 
  287 #if (HAVE_LIB_XML)
  288 int
  289 init_sethelp_xml_doc(xmlTextWriterPtr *writer, xmlBufferPtr *buf);
  290 
  291 int
  292 xml_add_volset_element(xmlTextWriterPtr writer, const char *name,
  293                        const char *def_val, const char *dscrpt);
  294 int
  295 end_sethelp_xml_doc(xmlTextWriterPtr writer);
  296 #endif /* HAVE_LIB_XML */
  297 
  298 char *
  299 glusterd_get_trans_type_rb(gf_transport_type ttype);
  300 
  301 struct volopt_map_entry *
  302 gd_get_vmep(const char *key);
  303 
  304 uint32_t
  305 glusterd_get_op_version_from_vmep(struct volopt_map_entry *vmep);
  306 
  307 gf_boolean_t
  308 gd_is_client_option(struct volopt_map_entry *vmep);
  309 
  310 gf_boolean_t
  311 gd_is_xlator_option(struct volopt_map_entry *vmep);
  312 
  313 gf_boolean_t
  314 gd_is_boolean_option(struct volopt_map_entry *vmep);
  315 
  316 char *
  317 volgen_get_shd_key(int type);
  318 
  319 int
  320 glusterd_volopt_validate(glusterd_volinfo_t *volinfo, dict_t *dict, char *key,
  321                          char *value, char **op_errstr);
  322 gf_boolean_t
  323 gd_is_self_heal_enabled(glusterd_volinfo_t *volinfo, dict_t *dict);
  324 
  325 int
  326 generate_dummy_client_volfiles(glusterd_volinfo_t *volinfo);
  327 
  328 int
  329 glusterd_generate_gfproxyd_volfile(glusterd_volinfo_t *volinfo);
  330 
  331 int
  332 glusterd_build_gfproxyd_volfile(glusterd_volinfo_t *volinfo, char *filename);
  333 
  334 int
  335 glusterd_shdsvc_generate_volfile(glusterd_volinfo_t *volinfo, char *filename,
  336                                  dict_t *mode_dict);
  337 
  338 #endif