diff options
author | Kotresh H R <khiremat@redhat.com> | 2014-05-05 15:33:25 +0530 |
---|---|---|
committer | Venky Shankar <vshankar@redhat.com> | 2014-06-10 03:35:59 -0700 |
commit | b97e8f4ef649ed825b4f02b74e33946f6b551cec (patch) | |
tree | 5a4bd17192b919fd7d19b6b8572f433a36ee56b9 /xlators/features/changelog/src/changelog.c | |
parent | a9cdfa3072f60171a97d9f6af6988b179d45747f (diff) |
feature/changelog: Add timeout to changelog barrier.
This patch introduces configurable 'changelog-barrier-timeout'
in changelog. The default changelog-barrier-timeout is set to
120 sec which is same as barrier-timeout of barrier translator.
On this timeout, all the barriered fops are unbarriered. It is
safe to have this internal timeout for changelog barrier to
prevent it from indefinite barrierring of fops if barrier
disable notification does not come from snapshot for some
reason.
Change-Id: Iad07807935f88222cdefcd46312b4b6579186dce
BUG: 1094226
Signed-off-by: Kotresh H R <khiremat@redhat.com>
Reviewed-on: http://review.gluster.org/7669
Reviewed-by: Kaushal M <kaushal@redhat.com>
Reviewed-by: Venky Shankar <vshankar@redhat.com>
Tested-by: Venky Shankar <vshankar@redhat.com>
Diffstat (limited to 'xlators/features/changelog/src/changelog.c')
-rw-r--r-- | xlators/features/changelog/src/changelog.c | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/xlators/features/changelog/src/changelog.c b/xlators/features/changelog/src/changelog.c index 0b982148f44..4ed7cc7f0e9 100644 --- a/xlators/features/changelog/src/changelog.c +++ b/xlators/features/changelog/src/changelog.c @@ -1281,6 +1281,16 @@ changelog_assign_encoding (changelog_priv_t *priv, char *enc) } } +static void +changelog_assign_barrier_timeout(changelog_priv_t *priv, uint32_t timeout) +{ + LOCK (&priv->lock); + { + priv->timeout.tv_sec = timeout; + } + UNLOCK (&priv->lock); +} + /* cleanup any helper threads that are running */ static void changelog_cleanup_helper_threads (xlator_t *this, changelog_priv_t *priv) @@ -1444,9 +1454,7 @@ notify (xlator_t *this, int event, void *data, ...) if (event == GF_EVENT_TRANSLATOR_OP) { dict = data; - /*TODO: Also barrier option is persistent. Need to - * decide on the brick crash scenarios. - */ + barrier = dict_get_str_boolean (dict, "barrier", DICT_DEFAULT); switch (barrier) { @@ -1540,9 +1548,14 @@ notify (xlator_t *this, int event, void *data, ...) /* Start changelog barrier */ LOCK (&priv->lock); { - priv->barrier_enabled = _gf_true; + ret = __chlog_barrier_enable (this, priv); } UNLOCK (&priv->lock); + if (ret == -1) { + changelog_barrier_cleanup (this, priv, &queue); + goto out; + } + gf_log(this->name, GF_LOG_DEBUG, "Enabled changelog barrier"); @@ -1786,6 +1799,7 @@ reconfigure (xlator_t *this, dict_t *options) changelog_log_data_t cld = {0,}; char htime_dir[PATH_MAX] = {0,}; struct timeval tv = {0,}; + uint32_t timeout = 0; priv = this->private; if (!priv) @@ -1840,6 +1854,9 @@ reconfigure (xlator_t *this, dict_t *options) priv->rollover_time, options, int32, out); GF_OPTION_RECONF ("fsync-interval", priv->fsync_interval, options, int32, out); + GF_OPTION_RECONF ("changelog-barrier-timeout", + timeout, options, time, out); + changelog_assign_barrier_timeout (priv, timeout); if (active_now || active_earlier) { ret = changelog_fill_rollover_data (&cld, !active_now); @@ -1898,6 +1915,7 @@ init (xlator_t *this) changelog_priv_t *priv = NULL; gf_boolean_t cond_lock_init = _gf_false; char htime_dir[PATH_MAX] = {0,}; + uint32_t timeout = 0; GF_VALIDATE_OR_GOTO ("changelog", this, out); @@ -1977,6 +1995,8 @@ init (xlator_t *this) GF_OPTION_INIT ("rollover-time", priv->rollover_time, int32, out); GF_OPTION_INIT ("fsync-interval", priv->fsync_interval, int32, out); + GF_OPTION_INIT ("changelog-barrier-timeout", timeout, time, out); + priv->timeout.tv_sec = timeout; changelog_encode_change(priv); @@ -2127,6 +2147,14 @@ struct volume_options options[] = { .description = "do not open CHANGELOG file with O_SYNC mode." " instead perform fsync() at specified intervals" }, + { .key = {"changelog-barrier-timeout"}, + .type = GF_OPTION_TYPE_TIME, + .default_value = BARRIER_TIMEOUT, + .description = "After 'timeout' seconds since the time 'barrier' " + "option was set to \"on\", unlink/rmdir/rename " + "operations are no longer blocked and previously " + "blocked fops are allowed to go through" + }, {.key = {NULL} }, }; |