summaryrefslogtreecommitdiffstats
path: root/xlators/features/changelog/src/changelog.c
diff options
context:
space:
mode:
authorVenky Shankar <vshankar@redhat.com>2014-02-19 20:47:46 +0530
committerVenky Shankar <vshankar@redhat.com>2014-05-14 05:10:15 -0700
commitd2db585ce7e26851178104433fa9422482d8719e (patch)
tree2e52f15cf261906debd8ec54106ffe9f84af881e /xlators/features/changelog/src/changelog.c
parentbfde478cedda8267134ee3807c8db5e042115eae (diff)
features/changelog : historical journal consumption.
Facilitates Glusterfs with the ability to detect file-operations happened in past by scanning the back-end(brick-level) glusterfs journal (changelog). Design: * List of changelogs produces in one perfectly running session are stored in htime file which also holds necessary information about the session start and end time. * Involves fixed sized seeks to identify N'th changelog in the list. * Requires O(log n), (where n is number of changelogs in the list), time to identify the end changelog for the given start-end time interval. Currently the background processing of changelogs is sub optimal. BZ 1097041 tracks the development effort. For complete design, refer the below link: http://lists.nongnu.org/archive/html/gluster-devel/2014-02/msg00206.html Change-Id: I27e49f75e492e843084d0ecaf9130224d08462a0 BUG: 1091961 Signed-off-by: Ajeet Jha <ajha@redhat.com> Signed-off-by: Venky Shankar <vshankar@redhat.com> Signed-off-by: Ajeet Jha <ajha@redhat.com> Reviewed-on: http://review.gluster.org/6930 Reviewed-by: Kotresh HR <khiremat@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/features/changelog/src/changelog.c')
-rw-r--r--xlators/features/changelog/src/changelog.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/xlators/features/changelog/src/changelog.c b/xlators/features/changelog/src/changelog.c
index 5eb2cd93fd3..0b982148f44 100644
--- a/xlators/features/changelog/src/changelog.c
+++ b/xlators/features/changelog/src/changelog.c
@@ -1661,6 +1661,11 @@ changelog_init (xlator_t *this, changelog_priv_t *priv)
* simple here.
*/
ret = changelog_fill_rollover_data (&cld, _gf_false);
+ if(ret)
+ goto out;
+
+ ret = htime_open (this, priv, cld.cld_roll_time);
+ /* call htime open with cld's rollover_time */
if (ret)
goto out;
@@ -1779,6 +1784,8 @@ reconfigure (xlator_t *this, dict_t *options)
gf_boolean_t active_now = _gf_true;
changelog_time_slice_t *slice = NULL;
changelog_log_data_t cld = {0,};
+ char htime_dir[PATH_MAX] = {0,};
+ struct timeval tv = {0,};
priv = this->private;
if (!priv)
@@ -1803,6 +1810,12 @@ reconfigure (xlator_t *this, dict_t *options)
goto out;
ret = mkdir_p (priv->changelog_dir, 0600, _gf_true);
+
+ if (ret)
+ goto out;
+ CHANGELOG_FILL_HTIME_DIR(priv->changelog_dir, htime_dir);
+ ret = mkdir_p (htime_dir, 0600, _gf_true);
+
if (ret)
goto out;
@@ -1847,6 +1860,15 @@ reconfigure (xlator_t *this, dict_t *options)
goto out;
if (active_now) {
+ if (!active_earlier) {
+ if (gettimeofday(&tv, NULL) ) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "unable to fetch htime");
+ ret = -1;
+ goto out;
+ }
+ htime_open(this, priv, tv.tv_sec);
+ }
ret = changelog_spawn_notifier (this, priv);
if (!ret)
ret = changelog_spawn_helper_threads (this,
@@ -1871,10 +1893,11 @@ reconfigure (xlator_t *this, dict_t *options)
int32_t
init (xlator_t *this)
{
- int ret = -1;
- char *tmp = NULL;
- changelog_priv_t *priv = NULL;
- gf_boolean_t cond_lock_init = _gf_false;
+ int ret = -1;
+ char *tmp = NULL;
+ changelog_priv_t *priv = NULL;
+ gf_boolean_t cond_lock_init = _gf_false;
+ char htime_dir[PATH_MAX] = {0,};
GF_VALIDATE_OR_GOTO ("changelog", this, out);
@@ -1932,6 +1955,12 @@ init (xlator_t *this)
* so that consumers can _look_ into it (finding nothing...)
*/
ret = mkdir_p (priv->changelog_dir, 0600, _gf_true);
+
+ if (ret)
+ goto out;
+
+ CHANGELOG_FILL_HTIME_DIR(priv->changelog_dir, htime_dir);
+ ret = mkdir_p (htime_dir, 0600, _gf_true);
if (ret)
goto out;