diff options
author | Venky Shankar <vshankar@redhat.com> | 2014-02-19 20:47:46 +0530 |
---|---|---|
committer | Venky Shankar <vshankar@redhat.com> | 2014-05-14 05:10:15 -0700 |
commit | d2db585ce7e26851178104433fa9422482d8719e (patch) | |
tree | 2e52f15cf261906debd8ec54106ffe9f84af881e /xlators/features/changelog/lib/src/gf-changelog-process.c | |
parent | bfde478cedda8267134ee3807c8db5e042115eae (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/lib/src/gf-changelog-process.c')
-rw-r--r-- | xlators/features/changelog/lib/src/gf-changelog-process.c | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/xlators/features/changelog/lib/src/gf-changelog-process.c b/xlators/features/changelog/lib/src/gf-changelog-process.c index 3ea2700c62b..3b8d2683672 100644 --- a/xlators/features/changelog/lib/src/gf-changelog-process.c +++ b/xlators/features/changelog/lib/src/gf-changelog-process.c @@ -459,8 +459,49 @@ gf_changelog_decode (xlator_t *this, gf_changelog_t *gfc, int from_fd, return ret; } -static int -gf_changelog_consume (xlator_t *this, gf_changelog_t *gfc, char *from_path) +int +gf_changelog_publish (xlator_t *this, gf_changelog_t *gfc, char *from_path) +{ + int ret = 0; + char dest[PATH_MAX] = {0,}; + char to_path[PATH_MAX] = {0,}; + struct stat stbuf = {0,}; + + (void) snprintf (to_path, PATH_MAX, "%s%s", + gfc->gfc_current_dir, basename (from_path)); + + /* handle zerob file that wont exist in current */ + ret = stat (from_path, &stbuf); + if (ret) + goto out; + + if (stbuf.st_size == 0) { + ret = unlink (from_path); + if (ret) + gf_log (this->name, GF_LOG_ERROR, + "could not unlink %s (reason %s)", + from_path, strerror (errno)); + goto out; + } + + (void) snprintf (dest, PATH_MAX, "%s%s", + gfc->gfc_processing_dir, basename (from_path)); + + ret = rename (to_path, dest); + if (ret){ + gf_log (this->name, GF_LOG_ERROR, + "error moving %s to processing dir" + " (reason: %s)", to_path, strerror (errno)); + } + +out: + return ret; +} + +int +gf_changelog_consume (xlator_t *this, + gf_changelog_t *gfc, + char *from_path, gf_boolean_t no_publish) { int ret = -1; int fd1 = 0; @@ -472,6 +513,7 @@ gf_changelog_consume (xlator_t *this, gf_changelog_t *gfc, char *from_path) ret = stat (from_path, &stbuf); if (ret || !S_ISREG(stbuf.st_mode)) { + ret = -1; gf_log (this->name, GF_LOG_ERROR, "stat failed on changelog file: %s", from_path); goto out; @@ -506,6 +548,8 @@ gf_changelog_consume (xlator_t *this, gf_changelog_t *gfc, char *from_path) if (!ret) { /* move it to processing on a successfull decode */ + if (no_publish == _gf_true) + goto close_fd; ret = rename (to_path, dest); if (ret) gf_log (this->name, GF_LOG_ERROR, @@ -516,10 +560,15 @@ gf_changelog_consume (xlator_t *this, gf_changelog_t *gfc, char *from_path) /* remove it from .current if it's an empty file */ if (zerob) { + if (no_publish == _gf_true) { + ret = 0; + goto close_fd; + } + ret = unlink (to_path); if (ret) gf_log (this->name, GF_LOG_ERROR, - "could not unlink %s (reason: %s", + "could not unlink %s (reason: %s)", to_path, strerror (errno)); } } @@ -546,7 +595,7 @@ gf_changelog_ext_change (xlator_t *this, alo = 1; gf_log (this->name, GF_LOG_DEBUG, "processing changelog: %s", path); - ret = gf_changelog_consume (this, gfc, path); + ret = gf_changelog_consume (this, gfc, path, _gf_false); } if (ret) |