summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/event-history.h
blob: b1750bbae96857713e625efa277312dadf111a41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
  Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com>
  This file is part of GlusterFS.

  This file is licensed to you under your choice of the GNU Lesser
  General Public License, version 3 or any later version (LGPLv3 or
  later), or the GNU General Public License, version 2 (GPLv2), in all
  cases as published by the Free Software Foundation.
*/

#ifndef _EH_H
#define _EH_H

#ifndef _CONFIG_H
#define _CONFIG_H
#include "config.h"
#endif

#include "mem-types.h"
#include "circ-buff.h"

struct event_hist
{
        buffer_t *buffer;
        pthread_mutex_t lock;
};

typedef struct event_hist eh_t;

void
eh_dump (eh_t *event , void *data,
         int (fn) (circular_buffer_t *buffer, void *data));

eh_t *
eh_new (size_t buffer_size, gf_boolean_t use_buffer_once);

int
eh_save_history (eh_t *history, void *string);

int
eh_destroy (eh_t *history);

#endif /* _EH_H */
upd'>xlators/mgmt/glusterd/src/glusterd-volgen.h134
4 files changed, 684 insertions, 2431 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 98ca78b5f62..317eab700ba 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -1119,50 +1119,16 @@ out:
}
-char *set_option_list[] = {
- "max-file-size",
- "min-file-size",
- "cache-timeout",
- "priority",
- "entry-change-log",
- "read-subvolume",
- "background-self-heal-count",
- "metadata-self-heal",
- "data-self-heal",
- "entry-self-heal",
- "strict-readdir",
- "data-self-heal-window-size",
- "data-change-log",
- "metadata-change-log",
- "frame-timeout",
- "ping-timeout",
- "cache-size",
- "disk-usage-limit",
- "min-free-disk-limit",
- "block-size",
- "inode-lru-limit",
- "thread-count" ,
- "lookup-unhashed",
- "min-free-disk",
- "write-behind",
- "read-ahead",
- "io-cache",
- "quick-read",
- "stat-prefetch",
- "latency-measurement",
- "dump-fd-stats",
-};
-
-
gf_boolean_t
glusterd_check_option_exists(char *optstring)
{
- //struct set_option_list *list;
- char **list = NULL;
+ struct volopt_map_entry *vme = NULL;
- for (list = &set_option_list[0]; *list ;list++)
- if (!strcmp (optstring, *list))
+ for (vme = glusterd_volopt_map; vme->key; vme++) {
+ if (strcmp (vme->key, optstring) == 0)
return _gf_true;
+ }
+
return _gf_false;
}
@@ -1781,7 +1747,7 @@ rb_regenerate_volfiles (glusterd_volinfo_t *volinfo,
goto out;
}
- ret = glusterd_rb_create_volfiles (volinfo, brickinfo);
+ ret = glusterd_create_rb_volfiles (volinfo, brickinfo);
out:
return ret;
@@ -2844,7 +2810,11 @@ glusterd_op_set_volume (gd1_mgmt_stage_op_req *req)
goto out;
}
- ret = set_xlator_option (volinfo->dict, key, value);
+ value = gf_strdup (value);
+ if (value)
+ ret = dict_set_dynstr (volinfo->dict, key, value);
+ else
+ ret = -1;
if (ret) {
gf_log ("", GF_LOG_ERROR, "Unable to set the options"
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 3fa965c8800..8ad9379a73f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -495,8 +495,8 @@ glusterd_volinfo_new (glusterd_volinfo_t **volinfo)
INIT_LIST_HEAD (&new_volinfo->vol_list);
INIT_LIST_HEAD (&new_volinfo->bricks);
- ret = glusterd_default_xlator_options (new_volinfo);
- if (ret) {
+ new_volinfo->dict = dict_new ();
+ if (!new_volinfo->dict) {
if (new_volinfo)
GF_FREE (new_volinfo);
@@ -1620,7 +1620,7 @@ glusterd_nfs_server_start ()
glusterd_conf_t *priv = NULL;
char pidfile[PATH_MAX] = {0,};
char logfile[PATH_MAX] = {0,};
- char *volfile = NULL;
+ char volfile[PATH_MAX] = {0,};
char path[PATH_MAX] = {0,};
char cmd_str[8192] = {0,};
char rundir[PATH_MAX] = {0,};
@@ -1641,11 +1641,7 @@ glusterd_nfs_server_start ()
}
GLUSTERD_GET_NFS_PIDFILE(pidfile);
- volfile = glusterd_get_nfs_filepath ();
- if (!volfile) {
- ret = -1;
- goto out;
- }
+ glusterd_get_nfs_filepath (volfile);
ret = access (volfile, F_OK);
if (ret) {
@@ -1662,8 +1658,6 @@ glusterd_nfs_server_start ()
ret = gf_system (cmd_str);
out:
- if (volfile)
- GF_FREE(volfile);
return ret;
}
@@ -1721,7 +1715,7 @@ glusterd_check_generate_start_nfs (glusterd_volinfo_t *volinfo)
goto out;
}
- ret = volgen_generate_nfs_volfile (volinfo);
+ ret = glusterd_create_nfs_volfile ();
if (ret)
goto out;
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index bed21b30030..be3e55a4745 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2006-2009 Gluster, Inc. <http://www.gluster.com>
+ Copyright (c) 2010 Gluster, Inc. <http://www.gluster.com>
This file is part of GlusterFS.
GlusterFS is GF_FREE software; you can redistribute it and/or modify
@@ -24,1987 +24,631 @@
#endif
#include "xlator.h"
-#include "protocol-common.h"
#include "glusterd.h"
#include "defaults.h"
-#include "list.h"
+#include "logging.h"
#include "dict.h"
-#include "compat.h"
-#include "compat-errno.h"
-#include "glusterd-sm.h"
-#include "glusterd-op-sm.h"
-#include "cli1.h"
+#include "graph-utils.h"
#include "glusterd-mem-types.h"
+#include "cli1.h"
#include "glusterd-volgen.h"
-#include "glusterd-utils.h"
-int
-set_xlator_option (dict_t *dict, char *key,
- char *value)
-{
- int ret = 0;
- char *str = NULL;
- str = GF_CALLOC (1, strlen (value) + 1,
- gf_gld_mt_char);
+/* dispatch table for VOLUME SET
+ *
+ * First field is the <key>, for the purpose of looking it up
+ * in volume dictionary.
+ *
+ * Second field is of the format "<xlator-type>:<action-specifier>".
+ * The ":<action-specifier>" part can be omitted, which is handled
+ * as if <action-specifier> is same as <key>.
+ *
+ * There are two type of entries: basic and special.
+ *
+ * - Basic entries are the ones where the <action-specifier>
+ * does _not_ start with the bang! character ('!').
+ * In their case, <action-specifier> is understood as
+ * an option for <xlator-type>. Their effect is to copy over
+ * the volinfo->dict[<key>] value to the graph nodes of
+ * type <xlator-type> (if such a value is set). You are free to
+ * add entries of this type, they will become functional just
+ * by being present in the table.
+ *
+ * - Special entries where the <action-specifier> starts
+ * with the bang!. They are not applied to all graphs
+ * during generation, and you cannot extend them in a
+ * trivial way which could be just picked up. Better
+ * not touch them unless you know what you do.
+ */
+
+struct volopt_map_entry glusterd_volopt_map[] = {
+ {"lookup-unhashed", "cluster/distribute"},
+ {"min-free-disk", "cluster/distribute"},
+
+ {"entry-change-log", "cluster/replicate"},
+ {"read-subvolume", "cluster/replicate"},
+ {"background-self-heal-count", "cluster/replicate"},
+ {"metadata-self-heal", "cluster/replicate"},
+ {"data-self-heal", "cluster/replicate"},
+ {"entry-self-heal", "cluster/replicate"},
+ {"strict-readdir", "cluster/replicate"},
+ {"data-self-heal-window-size", "cluster/replicate"},
+ {"data-change-log", "cluster/replicate"},
+ {"metadata-change-log", "cluster/replicate"},
+
+ {"block-size", "cluster/stripe"},
+
+ {"latency-measurement", "debug/io-stats"},
+ {"dump-fd-stats", "debug/io-stats"},
+
+ {"max-file-size", "performance/io-cache"},
+ {"min-file-size", "performance/io-cache"},
+ {"cache-timeout", "performance/io-cache"},
+ {"cache-size", "performance/io-cache"},
+ {"priority", "performance/io-cache"},
+
+ {"thread-count", "performance/io-threads"},
+
+ {"disk-usage-limit", "performance/quota"},
+ {"min-free-disk-limit", "performance/quota"},
+
+ {"window-size", "performance/write-behind:cache-size"},
+
+ {"frame-timeout", "protocol/client"},
+ {"ping-timeout", "protocol/client"},
+
+ {"inode-lru-limit", "protocol/server"},
+
+ {"write-behind", "performance/write-behind:!perf"},
+ {"read-ahead", "performance/read-ahead:!perf"},
+ {"io-cache", "performance/io-cache:!perf"},
+ {"quick-read", "performance/quick-read:!perf"},
+ {"stat-prefetch", "performance/stat-prefetch:!perf"},
+
+ {NULL, }
+};
+
+
+/* Default entries (as of now, only for special volopts). */
+
+struct volopt_map_entry2 {
+ char *key;
+ char *voltype;
+ char *option;
+ char *value;
+};
+
+static struct volopt_map_entry2 default_volopt_map2[] = {
+ {"write-behind", NULL, NULL, "on"},
+ {"read-ahead", NULL, NULL, "on"},
+ {"io-cache", NULL, NULL, "on"},
+ {"quick-read", NULL, NULL, "on"},
+ {NULL, }
+};
+
+#define VOLGEN_GET_NFS_DIR(path) \
+ do { \
+ glusterd_conf_t *priv = THIS->private; \
+ snprintf (path, PATH_MAX, "%s/nfs", priv->workdir); \
+ } while (0); \
+
+#define VOLGEN_GET_VOLUME_DIR(path, volinfo) \
+ do { \
+ glusterd_conf_t *priv = THIS->private; \
+ snprintf (path, PATH_MAX, "%s/vols/%s", priv->workdir, \
+ volinfo->volname); \
+ } while (0); \
+
+
+
+
+/*********************************************
+ *
+ * xlator generation / graph manipulation API
+ *
+ *********************************************/
+
+
- if (!str)
- return -1;
-
- strncpy (str, value, strlen (value));
-
- ret = dict_set_dynstr (dict, key, str);
-
- return ret;
-}
-
-static int32_t
-set_default_options (dict_t *dict, char *volname)
+static xlator_t *
+xlator_instantiate_va (const char *type, const char *format, va_list arg)
{
- int ret = -1;
-
- ret = dict_set_str (dict, "volname",
- volname);
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_POSIX_OPTION_ODIRECT,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_POSIX_OPTION_STATFSSIZE,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_POSIX_OPTION_MANDATTR,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_POSIX_OPTION_SPANDEVICES,
- "1");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_POSIX_OPTION_BCKUNLINK,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_LOCKS_OPTION_TRACE,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_LOCKS_OPTION_MAND,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_CLIENT_OPTION_TRANSTYPE,
- "tcp");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_CLIENT_OPTION_NODELAY,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_IOT_OPTION_THREADCOUNT,
- "16");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_IOT_OPTION_AUTOSCALING,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_IOT_OPTION_MINTHREADS,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_IOT_OPTION_MAXTHREADS,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_SERVER_OPTION_TRANSTYPE,
- "tcp");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_SERVER_OPTION_NODELAY,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_REPLICATE_OPTION_READSUBVOL,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_REPLICATE_OPTION_FAVCHILD,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_REPLICATE_OPTION_BCKSHCOUNT,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_REPLICATE_OPTION_DATASH,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_REPLICATE_OPTION_DATASHALGO,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_REPLICATE_OPTION_SHWINDOWSIZE,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_REPLICATE_OPTION_METASH,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_REPLICATE_OPTION_ENTRYSH,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_REPLICATE_OPTION_DATACHANGELOG,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_REPLICATE_OPTION_METADATACHANGELOG,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_REPLICATE_OPTION_ENTRYCHANGELOG,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_REPLICATE_OPTION_STRICTREADDIR,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_STRIPE_OPTION_BLOCKSIZE,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_STRIPE_OPTION_USEXATTR,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_DHT_OPTION_LOOKUPUNHASH,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_DHT_OPTION_MINFREEDISK,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_DHT_OPTION_UNHASHSTICKY,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_WB_OPTION_FLUSHBEHIND,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_WB_OPTION_CACHESIZE,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_WB_OPTION_DISABLENBYTES,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_WB_OPTION_OSYNC,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_WB_OPTION_TRICKLINGWRITES,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_RA_OPTION_ATIME,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_RA_OPTION_PAGECOUNT,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_IOCACHE_OPTION_PRIORITY,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_IOCACHE_OPTION_TIMEOUT,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_IOCACHE_OPTION_CACHESIZE,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_IOCACHE_OPTION_MINFILESIZE,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_IOCACHE_OPTION_MAXFILESIZE,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_QR_OPTION_PRIORITY,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_QR_OPTION_TIMEOUT,
- "on");
- if (ret)
- goto out;
-
- ret = set_xlator_option (dict, VOLGEN_QR_OPTION_CACHESIZE,
- "on");
- if (ret)
- goto out;
+ xlator_t *xl = NULL;
+ char *volname = NULL;
+ int ret = 0;
- ret = set_xlator_option (dict, VOLGEN_QR_OPTION_MAXFILESIZE,
- "on");
- if (ret)
- goto out;
+ ret = gf_vasprintf (&volname, format, arg);
+ if (ret < 0) {
+ volname = NULL;
- ret = set_xlator_option (dict, VOLGEN_IOS_OPTION_DUMP_FD_STATS,
- "no");
- if (ret)
- goto out;
+ goto error;
+ }
- ret = set_xlator_option (dict, VOLGEN_IOS_OPTION_MEASURE_LATENCY,
- "no");
+ xl = GF_CALLOC (1, sizeof (*xl), gf_common_mt_xlator_t);
+ if (!xl)
+ goto error;
+ ret = xlator_set_type_virtual (xl, type);
if (ret)
- goto out;
-
- ret = 0;
-
-out:
- return ret;
+ goto error;
+ xl->options = get_new_dict();
+ if (!xl->options)
+ goto error;
+ xl->name = volname;
+
+ return xl;
+
+ error:
+ gf_log ("", GF_LOG_ERROR, "creating xlator of type %s failed",
+ type);
+ if (volname)
+ GF_FREE (volname);
+ if (xl)
+ xlator_destroy (xl);
+
+ return NULL;
}
-int32_t
-glusterd_default_xlator_options (glusterd_volinfo_t *volinfo)
+static xlator_t *
+xlator_instantiate (const char *type, const char *format, ...)
{
- int ret = -1;
-
- volinfo->dict = dict_new ();
- if (!volinfo->dict) {
- ret = -1;
- goto out;
- }
-
- ret = set_default_options (volinfo->dict,
- volinfo->volname);
- if (ret) {
- dict_unref (volinfo->dict);
- goto out;
- }
-
- ret = 0;
+ va_list arg;
+ xlator_t *xl;
-out:
- return ret;
+ va_start (arg, format);
+ xl = xlator_instantiate_va (type, format, arg);
+ va_end (arg);
+ return xl;
}
static int
-__write_posix_xlator (FILE *file, dict_t *dict,
- char *posix_directory)
+volgen_xlator_link (xlator_t *pxl, xlator_t *cxl)
{
- char *volname = NULL;
- char *opt_odirect = NULL;
- char *opt_statfssize = NULL;
- char *opt_mandattr = NULL;
- char *opt_spandevices = NULL;
- char *opt_bckunlink = NULL;
- int ret = -1;
-
- const char *posix_str = "volume %s-%s\n"
- " type storage/posix\n"
- " option directory %s\n"
- "# option o-direct %s\n"
- "# option export-statfs-size %s\n"
- "# option mandate-attribute %s\n"
- "# option span-devices %s\n"
- "# option background-unlink %s\n"
- "end-volume\n\n";
-
- ret = dict_get_str (dict, "volname", &volname);
- if (ret) {
- goto out;
- }
-
- ret = dict_get_str (dict, VOLGEN_POSIX_OPTION_ODIRECT,
- &opt_odirect);
- if (ret) {
- goto out;
- }
-
- ret = dict_get_str (dict, VOLGEN_POSIX_OPTION_STATFSSIZE,
- &opt_statfssize);
- if (ret) {
- goto out;
- }
-
- ret = dict_get_str (dict, VOLGEN_POSIX_OPTION_MANDATTR,
- &opt_mandattr);
- if (ret) {
- goto out;
- }
-
- ret = dict_get_str (dict, VOLGEN_POSIX_OPTION_SPANDEVICES,
- &opt_spandevices);
- if (ret) {
- goto out;
- }
+ int ret = 0;
- ret = dict_get_str (dict, VOLGEN_POSIX_OPTION_BCKUNLINK,
- &opt_bckunlink);
- if (ret) {
- goto out;
+ ret = glusterfs_xlator_link (pxl, cxl);
+ if (ret == -1) {
+ gf_log ("", GF_LOG_ERROR,
+ "Out of memory, cannot link xlators %s <- %s",
+ pxl->name, cxl->name);
}
- fprintf (file, posix_str,
- volname,
- "posix",
- posix_directory,
- opt_odirect,
- opt_statfssize,
- opt_mandattr,
- opt_spandevices,
- opt_bckunlink);
-
- ret = 0;
-
-out:
return ret;
}
static int
-__write_locks_xlator (FILE *file, dict_t *dict,
- char *subvolume)
+volgen_graph_insert (glusterfs_graph_t *graph, xlator_t *xl)
{
- char *volname = NULL;
- char *opt_trace = NULL;
- char *opt_mand = NULL;
- int ret = -1;
-
- const char *locks_str = "volume %s-%s\n"
- " type features/locks\n"
- "# option trace %s\n"
- "# option mandatory %s\n"
- " subvolumes %s\n"
- "end-volume\n\n";
-
- ret = dict_get_str (dict, "volname", &volname);
- if (ret) {
- goto out;
- }
+ int ret = 0;
- ret = dict_get_str (dict, VOLGEN_LOCKS_OPTION_TRACE,
- &opt_trace);
- if (ret) {
- goto out;
- }
+ /* no need to care about graph->top here */
+ if (graph->first)
+ ret = volgen_xlator_link (xl, graph->first)