summaryrefslogtreecommitdiffstats
path: root/xlators/features/changelog/src/changelog.c
diff options
context:
space:
mode:
authorAjeet Jha <ajha@redhat.com>2014-08-23 19:06:45 +0530
committerVijay Bellur <vbellur@redhat.com>2014-08-26 03:16:53 -0700
commitacabde2c297c4175946565017ba17a251ad3fb1c (patch)
tree45a48a9f1c68b1966ce9c68dbb456997f62bdc63 /xlators/features/changelog/src/changelog.c
parentb56751b3b9a9ed3cceb2f0d221fa40ef94a8d516 (diff)
features/changelog: Crash consistency of changelog wrt snapshot
This patch introduces call-path fop details logging for data operations in CHANGELOG.SNAP. This feature is enabled with barrier-enable notification and disabled with barrier-disable notification. Change-Id: Ib548d34203eb99cea478a6baff402e82251c73a4 BUG: 1128093 Signed-off-by: Ajeet Jha <ajha@redhat.com> Reviewed-on: http://review.gluster.org/8533 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/features/changelog/src/changelog.c')
-rw-r--r--xlators/features/changelog/src/changelog.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/xlators/features/changelog/src/changelog.c b/xlators/features/changelog/src/changelog.c
index 36643395815..75a62d686d6 100644
--- a/xlators/features/changelog/src/changelog.c
+++ b/xlators/features/changelog/src/changelog.c
@@ -1433,6 +1433,16 @@ changelog_truncate (call_frame_t *frame,
CHANGELOG_INIT (this, frame->local,
loc->inode, loc->inode->gfid, 0);
+ LOCK(&priv->c_snap_lock);
+ {
+ if (priv->c_snap_fd != -1 &&
+ priv->barrier_enabled == _gf_true) {
+ changelog_snap_handle_ascii_change (this,
+ &( ((changelog_local_t *)(frame->local))->cld));
+ }
+ }
+ UNLOCK(&priv->c_snap_lock);
+
wind:
changelog_color_fop_and_inc_cnt (this, priv, frame->local);
@@ -1476,6 +1486,15 @@ changelog_ftruncate (call_frame_t *frame,
CHANGELOG_INIT (this, frame->local,
fd->inode, fd->inode->gfid, 0);
+ LOCK(&priv->c_snap_lock);
+ {
+ if (priv->c_snap_fd != -1 &&
+ priv->barrier_enabled == _gf_true) {
+ changelog_snap_handle_ascii_change (this,
+ &( ((changelog_local_t *)(frame->local))->cld));
+ }
+ }
+ UNLOCK(&priv->c_snap_lock);
wind:
changelog_color_fop_and_inc_cnt (this, priv, frame->local);
@@ -1523,6 +1542,15 @@ changelog_writev (call_frame_t *frame,
CHANGELOG_INIT (this, frame->local,
fd->inode, fd->inode->gfid, 0);
+ LOCK(&priv->c_snap_lock);
+ {
+ if (priv->c_snap_fd != -1 &&
+ priv->barrier_enabled == _gf_true) {
+ changelog_snap_handle_ascii_change (this,
+ &( ((changelog_local_t *)(frame->local))->cld));
+ }
+ }
+ UNLOCK(&priv->c_snap_lock);
wind:
changelog_color_fop_and_inc_cnt (this, priv, frame->local);
@@ -1751,6 +1779,11 @@ notify (xlator_t *this, int event, void *data, ...)
"Barrier off notification");
CHANGELOG_NOT_ON_THEN_GOTO(priv, ret, out);
+ LOCK(&priv->c_snap_lock);
+ {
+ changelog_snap_logging_stop (this, priv);
+ }
+ UNLOCK(&priv->c_snap_lock);
LOCK (&priv->bflags.lock);
{
@@ -1800,6 +1833,11 @@ notify (xlator_t *this, int event, void *data, ...)
"Barrier on notification");
CHANGELOG_NOT_ON_THEN_GOTO(priv, ret, out);
+ LOCK(&priv->c_snap_lock);
+ {
+ changelog_snap_logging_start (this, priv);
+ }
+ UNLOCK(&priv->c_snap_lock);
LOCK (&priv->bflags.lock);
{
@@ -2080,6 +2118,7 @@ reconfigure (xlator_t *this, dict_t *options)
changelog_time_slice_t *slice = NULL;
changelog_log_data_t cld = {0,};
char htime_dir[PATH_MAX] = {0,};
+ char csnap_dir[PATH_MAX] = {0,};
struct timeval tv = {0,};
uint32_t timeout = 0;
@@ -2115,6 +2154,12 @@ reconfigure (xlator_t *this, dict_t *options)
if (ret)
goto out;
+ CHANGELOG_FILL_CSNAP_DIR(priv->changelog_dir, csnap_dir);
+ ret = mkdir_p (csnap_dir, 0600, _gf_true);
+
+ if (ret)
+ goto out;
+
GF_OPTION_RECONF ("changelog", active_now, options, bool, out);
/**
@@ -2197,6 +2242,7 @@ init (xlator_t *this)
changelog_priv_t *priv = NULL;
gf_boolean_t cond_lock_init = _gf_false;
char htime_dir[PATH_MAX] = {0,};
+ char csnap_dir[PATH_MAX] = {0,};
uint32_t timeout = 0;
GF_VALIDATE_OR_GOTO ("changelog", this, out);
@@ -2225,6 +2271,7 @@ init (xlator_t *this)
}
LOCK_INIT (&priv->lock);
+ LOCK_INIT (&priv->c_snap_lock);
GF_OPTION_INIT ("changelog-brick", tmp, str, out);
if (!tmp) {
@@ -2264,6 +2311,11 @@ init (xlator_t *this)
if (ret)
goto out;
+ CHANGELOG_FILL_CSNAP_DIR(priv->changelog_dir, csnap_dir);
+ ret = mkdir_p (csnap_dir, 0600, _gf_true);
+ if (ret)
+ goto out;
+
GF_OPTION_INIT ("changelog", priv->active, bool, out);
GF_OPTION_INIT ("op-mode", tmp, str, out);