From 20ef211cfa5b5fcc437484a879fdc5d4c66bbaf5 Mon Sep 17 00:00:00 2001 From: ShyamsundarR Date: Thu, 29 Nov 2018 14:08:06 -0500 Subject: libglusterfs: Move devel headers under glusterfs directory libglusterfs devel package headers are referenced in code using include semantics for a program, this while it works can be better especially when dealing with out of tree xlator builds or in general out of tree devel package usage. Towards this, the following changes are done, - moved all devel headers under a glusterfs directory - Included these headers using system header notation <> in all code outside of libglusterfs - Included these headers using own program notation "" within libglusterfs This change although big, is just moving around the headers and making it correct when including these headers from other sources. This helps us correctly include libglusterfs includes without namespace conflicts. Change-Id: Id2a98854e671a7ee5d73be44da5ba1a74252423b Updates: bz#1193929 Signed-off-by: ShyamsundarR --- libglusterfs/src/glusterfs/throttle-tbf.h | 74 +++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 libglusterfs/src/glusterfs/throttle-tbf.h (limited to 'libglusterfs/src/glusterfs/throttle-tbf.h') diff --git a/libglusterfs/src/glusterfs/throttle-tbf.h b/libglusterfs/src/glusterfs/throttle-tbf.h new file mode 100644 index 00000000000..cccb13c83d9 --- /dev/null +++ b/libglusterfs/src/glusterfs/throttle-tbf.h @@ -0,0 +1,74 @@ +/* + Copyright (c) 2015 Red Hat, Inc. + 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. +*/ + +#include "glusterfs/list.h" +#include "glusterfs/xlator.h" +#include "glusterfs/locking.h" + +#ifndef THROTTLE_TBF_H__ +#define THROTTLE_TBF_H__ + +typedef enum tbf_ops { + TBF_OP_MIN = -1, + TBF_OP_HASH = 0, /* checksum calculation */ + TBF_OP_READ = 1, /* inode read(s) */ + TBF_OP_READDIR = 2, /* dentry read(s) */ + TBF_OP_MAX = 3, +} tbf_ops_t; + +/** + * Operation rate specification + */ +typedef struct tbf_opspec { + tbf_ops_t op; + + unsigned long rate; + + unsigned long maxlimit; + + unsigned long token_gen_interval; /* Token generation interval in usec */ +} tbf_opspec_t; + +/** + * Token bucket for each operation type + */ +typedef struct tbf_bucket { + gf_lock_t lock; + + pthread_t tokener; /* token generator thread */ + + unsigned long tokenrate; /* token generation rate */ + + unsigned long tokens; /* number of current tokens */ + + unsigned long maxtokens; /* maximum token in the bucket */ + + struct list_head queued; /* list of non-conformant requests */ + + unsigned long token_gen_interval; /* Token generation interval in usec */ +} tbf_bucket_t; + +typedef struct tbf { + tbf_bucket_t **bucket; +} tbf_t; + +tbf_t * +tbf_init(tbf_opspec_t *, unsigned int); + +int +tbf_mod(tbf_t *, tbf_opspec_t *); + +void +tbf_throttle(tbf_t *, tbf_ops_t, unsigned long); + +#define TBF_THROTTLE_BEGIN(tbf, op, tokens) (tbf_throttle(tbf, op, tokens)) +#define TBF_THROTTLE_END(tbf, op, tokens) + +#endif /** THROTTLE_TBF_H__ */ -- cgit