summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
authorJeff Darcy <jdarcy@fb.com>2017-09-15 06:59:01 -0700
committerJeff Darcy <jdarcy@fb.com>2017-09-15 13:47:01 -0700
commit8dfdecf220d1c9365e1f8d6af9ead5e48c61e2eb (patch)
treebccd5906be43cf81792248b06099006525ed0c27 /libglusterfs/src
parente4b47b5d54644c398c424a99116a0cc37e4431d6 (diff)
Replace namespace/io-stats/io-threads with 3.6-fb versions
This rolls up multiple patches related to namespace identificaton and throttling/QoS. This primarily includes the following, all by Michael Goulet <mgoulet@fb.com>. io-threads: Add weighted round robin queueing by namespace https://phabricator.facebook.com/D5615269 io-threads: Add per-namespaces queue sizes to IO_THREADS_QUEUE_SIZE_KEY https://phabricator.facebook.com/D5683162 io-threads: Implement better slot allocation algorithm https://phabricator.facebook.com/D5683186 io-threads: Only enable weighted queueing on bricks https://phabricator.facebook.com/D5700062 io-threads: Update queue sizes on drain https://phabricator.facebook.com/D5704832 Fix parsing (-1) as default NS weight https://phabricator.facebook.com/D5723383 Parts of the following patches have also been applied to satisfy dependencies. io-throttling: Calculate moving averages and throttle offending hosts https://phabricator.fb.com/D2516161 Shreyas Siravara <sshreyas@fb.com> Hook up ODS logging for FUSE clients. https://phabricator.facebook.com/D3963376 Kevin Vigor <kvigor@fb.com> Add the flag --skip-nfsd-start to skip the NFS daemon stating, even if it is enabled https://phabricator.facebook.com/D4575368 Alex Lorca <alexlorca@fb.com> There are also some "standard" changes: dealing with code that moved, reindenting to comply with Gluster coding standards, gf_uuid_xxx, etc. This patch *does* revert some changes which have occurred upstream since 3.6; these will be re-applied as apppropriate on top of this new base. Change-Id: I69024115da7a60811e5b86beae781d602bdb558d Signed-off-by: Jeff Darcy <jdarcy@fb.com>
Diffstat (limited to 'libglusterfs/src')
-rw-r--r--libglusterfs/src/common-utils.c28
-rw-r--r--libglusterfs/src/dict.c42
-rw-r--r--libglusterfs/src/dict.h16
-rw-r--r--libglusterfs/src/glusterfs.h11
-rw-r--r--libglusterfs/src/stack.c1
-rw-r--r--libglusterfs/src/stack.h15
6 files changed, 101 insertions, 12 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index 84a0785d660..62c41a767d0 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -4349,9 +4349,11 @@ list_node_del (struct list_node *node)
GF_FREE (node);
}
-const char *
-fop_enum_to_pri_string (glusterfs_fop_t fop)
+iot_pri_t
+iot_fop_to_pri (glusterfs_fop_t fop)
{
+ iot_pri_t pri = IOT_PRI_MAX - 1;
+
switch (fop) {
case GF_FOP_OPEN:
case GF_FOP_STAT:
@@ -4365,7 +4367,8 @@ fop_enum_to_pri_string (glusterfs_fop_t fop)
case GF_FOP_READDIRP:
case GF_FOP_GETACTIVELK:
case GF_FOP_SETACTIVELK:
- return "HIGH";
+ pri = IOT_PRI_HI;
+ break;
case GF_FOP_CREATE:
case GF_FOP_FLUSH:
@@ -4391,7 +4394,8 @@ fop_enum_to_pri_string (glusterfs_fop_t fop)
case GF_FOP_FREMOVEXATTR:
case GF_FOP_IPC:
case GF_FOP_LEASE:
- return "NORMAL";
+ pri = IOT_PRI_NORMAL;
+ break;
case GF_FOP_READ:
case GF_FOP_WRITE:
@@ -4402,22 +4406,26 @@ fop_enum_to_pri_string (glusterfs_fop_t fop)
case GF_FOP_XATTROP:
case GF_FOP_FXATTROP:
case GF_FOP_RCHECKSUM:
+ case GF_FOP_FALLOCATE:
+ case GF_FOP_DISCARD:
case GF_FOP_ZEROFILL:
- case GF_FOP_FALLOCATE:
case GF_FOP_SEEK:
- return "LOW";
+ pri = IOT_PRI_LO;
+ break;
case GF_FOP_NULL:
case GF_FOP_FORGET:
case GF_FOP_RELEASE:
case GF_FOP_RELEASEDIR:
case GF_FOP_GETSPEC:
+ case GF_FOP_COMPOUND:
case GF_FOP_MAXVALUE:
- case GF_FOP_DISCARD:
- return "LEAST";
- default:
- return "UNKNOWN";
+ //fail compilation on missing fop
+ //new fop must choose priority.
+ break;
}
+
+ return pri;
}
const char *
diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c
index 6a61e641e19..82b9236e661 100644
--- a/libglusterfs/src/dict.c
+++ b/libglusterfs/src/dict.c
@@ -1258,6 +1258,38 @@ dict_foreach (dict_t *dict,
return ret;
}
+int
+dict_foreach_with_idx (dict_t *dict,
+ int (*fn)(dict_t *this,
+ char *key,
+ data_t *value,
+ void *data, uint64_t idx),
+ void *data)
+{
+ if (!dict) {
+ gf_log_callingfn ("dict", GF_LOG_WARNING,
+ "dict is NULL");
+ return -1;
+ }
+
+ uint64_t idx = 0;
+ int ret = -1;
+ data_pair_t *pairs = NULL;
+ data_pair_t *next = NULL;
+
+ pairs = dict->members_list;
+ while (pairs) {
+ next = pairs->next;
+ ret = fn (dict, pairs->key, pairs->value, data, idx);
+ if (ret < 0)
+ return ret;
+ pairs = next;
+ idx++;
+ }
+
+ return 0;
+}
+
/* return values:
-1 = failure,
0 = no matches found,
@@ -2979,6 +3011,16 @@ dict_dump_to_str (dict_t *dict, char *dump, int dumpsize, char *format)
return 0;
}
+/* This function converts a uint32 to a (string) key for use in a dictionary.
+ * Ensure that the key string buffer is at least DICT_UINT32_KEY_SIZE in
+ * length, since that's the maximum length of a uint32's string representation
+ * plus a NULL delimiter char. */
+void
+dict_uint32_to_key (uint32_t num, char *key_buf)
+{
+ snprintf (key_buf, DICT_UINT32_KEY_SIZE, "%u", num);
+}
+
void
dict_dump_to_log (dict_t *dict)
{
diff --git a/libglusterfs/src/dict.h b/libglusterfs/src/dict.h
index 5259c6befa1..da95bc86bec 100644
--- a/libglusterfs/src/dict.h
+++ b/libglusterfs/src/dict.h
@@ -22,7 +22,6 @@ typedef struct _data data_t;
typedef struct _dict dict_t;
typedef struct _data_pair data_pair_t;
-
#define GF_PROTOCOL_DICT_SERIALIZE(this,from_dict,to,len,ope,labl) do { \
int ret = 0; \
\
@@ -161,6 +160,8 @@ dict_t *get_new_dict ();
#define dict_for_each(d, c) for (c = d->members_list; c; c = c->next)
+#define dict_foreach_inline(d, c) for (c = d->members_list; c; c = c->next)
+
int dict_foreach (dict_t *this,
int (*fn)(dict_t *this,
char *key,
@@ -168,6 +169,13 @@ int dict_foreach (dict_t *this,
void *data),
void *data);
+int dict_foreach_with_idx (dict_t *this,
+ int (*fn)(dict_t *this,
+ char *key,
+ data_t *value,
+ void *data, uint64_t idx),
+ void *data);
+
int dict_foreach_fnmatch (dict_t *dict, char *pattern,
int (*fn)(dict_t *this,
char *key,
@@ -246,6 +254,12 @@ GF_MUST_CHECK int dict_get_str (dict_t *this, char *key, char **str);
GF_MUST_CHECK int dict_get_str_boolean (dict_t *this, char *key, int default_val);
GF_MUST_CHECK int dict_serialize_value_with_delim (dict_t *this, char *buf, int32_t *serz_len,
char delimiter);
+/* Log_10(2^32) + 1. This is the length of the longest string representation of
+ * a 32-bit integer, plus space for '\0'. */
+#define DICT_UINT32_KEY_SIZE 11
+
+void dict_uint32_to_key (uint32_t num, char *key_buf);
+
void
dict_dump_to_statedump (dict_t *dict, char *dict_name, char *domain);
diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h
index 0b033d8bfcf..f618c7aba19 100644
--- a/libglusterfs/src/glusterfs.h
+++ b/libglusterfs/src/glusterfs.h
@@ -331,7 +331,14 @@ static inline const char *fop_pri_to_string (gf_fop_pri_t pri)
return FOP_PRI_STRINGS[pri];
}
-const char *fop_enum_to_pri_string (glusterfs_fop_t fop);
+iot_pri_t iot_fop_to_pri (glusterfs_fop_t fop);
+
+static inline const char *fop_enum_to_pri_string (glusterfs_fop_t fop)
+{
+ iot_pri_t pri = iot_fop_to_pri (fop);
+ return fop_pri_to_string (pri);
+}
+
const char *fop_enum_to_string (glusterfs_fop_t fop);
#define GF_SET_IF_NOT_PRESENT 0x1 /* default behaviour */
@@ -444,6 +451,8 @@ struct _cmd_args {
#ifdef GF_LINUX_HOST_OS
char *oom_score_adj;
#endif
+
+ char *stats_instance_name;
};
typedef struct _cmd_args cmd_args_t;
diff --git a/libglusterfs/src/stack.c b/libglusterfs/src/stack.c
index 6977814ec69..adcedd4cc96 100644
--- a/libglusterfs/src/stack.c
+++ b/libglusterfs/src/stack.c
@@ -36,6 +36,7 @@ create_frame (xlator_t *xl, call_pool_t *pool)
frame->root = stack;
frame->this = xl;
+ frame->pri = GF_FOP_PRI_UNSPEC;
LOCK_INIT (&frame->lock);
INIT_LIST_HEAD (&frame->frames);
list_add (&frame->frames, &stack->myframes);
diff --git a/libglusterfs/src/stack.h b/libglusterfs/src/stack.h
index 9e5355a6044..094dc62312c 100644
--- a/libglusterfs/src/stack.h
+++ b/libglusterfs/src/stack.h
@@ -77,6 +77,8 @@ struct _call_frame_t {
const char *wind_to;
const char *unwind_from;
const char *unwind_to;
+
+ gf_fop_pri_t pri;
};
struct _ns_info {
@@ -122,6 +124,16 @@ struct _call_stack_t {
ns_info_t ns_info;
};
+#define frame_set_throttling(frm, should_throttle) \
+ do { \
+ if (frm) { \
+ if (should_throttle) { \
+ frm->pri = IOT_PRI_LEAST; \
+ } else { \
+ frm->pri = IOT_PRI_UNSPEC; \
+ } \
+ } \
+ } while (0)
#define frame_set_uid_gid(frm, u, g) \
do { \
@@ -259,6 +271,7 @@ STACK_RESET (call_stack_t *stack)
_new->wind_from = __FUNCTION__; \
_new->wind_to = #fn; \
_new->unwind_to = #rfn; \
+ _new->pri = frame->pri; \
\
LOCK_INIT (&_new->lock); \
LOCK(&frame->root->stack_lock); \
@@ -321,6 +334,8 @@ STACK_RESET (call_stack_t *stack)
_new->wind_from = __FUNCTION__; \
_new->wind_to = #fn; \
_new->unwind_to = #rfn; \
+ _new->pri = frame->pri; \
+ \
LOCK_INIT (&_new->lock); \
LOCK(&frame->root->stack_lock); \
{ \