summaryrefslogtreecommitdiffstats
path: root/xlators/features/bit-rot/src/bitd/bit-rot.c
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2016-07-01 15:54:07 +0530
committerJeff Darcy <jdarcy@redhat.com>2016-07-18 05:03:17 -0700
commit713d7d080df51bf19ce29cf5d682bc006e1c3a19 (patch)
tree10a38c8d8845d879767f2246cf7f77bd4fd5aa4d /xlators/features/bit-rot/src/bitd/bit-rot.c
parent98b95fc97e896c84de462445c48565a73b2144c2 (diff)
features/bitrot: Move throttling code to libglusterfs
Since throttling is a separate feature by itself, move throttling code to libglusterfs. Change-Id: If9b99885ceb46e5b1865a4af18b2a2caecf59972 BUG: 1352019 Signed-off-by: Kotresh HR <khiremat@redhat.com> Reviewed-on: http://review.gluster.org/14846 Smoke: Gluster Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Ravishankar N <ravishankar@redhat.com> Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Diffstat (limited to 'xlators/features/bit-rot/src/bitd/bit-rot.c')
-rw-r--r--xlators/features/bit-rot/src/bitd/bit-rot.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.c b/xlators/features/bit-rot/src/bitd/bit-rot.c
index 174af2b6a15..ca3fc273e9f 100644
--- a/xlators/features/bit-rot/src/bitd/bit-rot.c
+++ b/xlators/features/bit-rot/src/bitd/bit-rot.c
@@ -278,7 +278,7 @@ br_object_read_block_and_sign (xlator_t *this, fd_t *fd, br_child_t *child,
off_t offset, size_t size, SHA256_CTX *sha256)
{
int32_t ret = -1;
- br_tbf_t *tbf = NULL;
+ tbf_t *tbf = NULL;
struct iovec *iovec = NULL;
struct iobref *iobref = NULL;
br_private_t *priv = NULL;
@@ -311,12 +311,12 @@ br_object_read_block_and_sign (xlator_t *this, fd_t *fd, br_child_t *child,
goto out;
for (i = 0; i < count; i++) {
- TBF_THROTTLE_BEGIN (tbf, BR_TBF_OP_HASH, iovec[i].iov_len);
+ TBF_THROTTLE_BEGIN (tbf, TBF_OP_HASH, iovec[i].iov_len);
{
SHA256_Update (sha256, (const unsigned char *)
(iovec[i].iov_base), iovec[i].iov_len);
}
- TBF_THROTTLE_BEGIN (tbf, BR_TBF_OP_HASH, iovec[i].iov_len);
+ TBF_THROTTLE_BEGIN (tbf, TBF_OP_HASH, iovec[i].iov_len);
}
out:
@@ -1756,14 +1756,32 @@ static int32_t
br_rate_limit_signer (xlator_t *this, int child_count, int numbricks)
{
br_private_t *priv = NULL;
- br_tbf_opspec_t spec = {0,};
+ tbf_opspec_t spec = {0,};
priv = this->private;
- spec.op = BR_TBF_OP_HASH;
+ spec.op = TBF_OP_HASH;
spec.rate = 0;
spec.maxlimit = 0;
+/**
+ * OK. Most implementations of TBF I've come across generate tokens
+ * every second (UML, etc..) and some chose sub-second granularity
+ * (blk-iothrottle cgroups). TBF algorithm itself does not enforce
+ * any logic for choosing generation interval and it seems pretty
+ * logical as one could jack up token count per interval w.r.t.
+ * generation rate.
+ *
+ * Value used here is chosen based on a series of test(s) performed
+ * to balance object signing time and not maxing out on all available
+ * CPU cores. It's obvious to have seconds granularity and jack up
+ * token count per interval, thereby achieving close to similar
+ * results. Let's stick to this as it seems to be working fine for
+ * the set of ops that are throttled.
+ **/
+ spec.token_gen_interval = 600000; /* In usec */
+
+
#ifdef BR_RATE_LIMIT_SIGNER
double contribution = 0;
@@ -1783,7 +1801,7 @@ br_rate_limit_signer (xlator_t *this, int child_count, int numbricks)
"[Rate Limit Info] \"tokens/sec (rate): %lu, "
"maxlimit: %lu\"", spec.rate, spec.maxlimit);
- priv->tbf = br_tbf_init (&spec, 1);
+ priv->tbf = tbf_init (&spec, 1);
return priv->tbf ? 0 : -1;
}