diff options
author | Vikas Gorur <vikas@gluster.com> | 2009-05-25 05:02:25 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2009-05-26 00:08:23 -0700 |
commit | 2951b04c7ac8a2888fffb2ebc127ecc1ec617d79 (patch) | |
tree | f111730daa315822090f054f374850fe225d62fc /xlators/cluster/afr/src/afr-self-heal-data.c | |
parent | 8b56178a7928bc7d30f408096303eaff3fe6d823 (diff) |
Preserve atime/mtime during data self heal.
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
Diffstat (limited to 'xlators/cluster/afr/src/afr-self-heal-data.c')
-rw-r--r-- | xlators/cluster/afr/src/afr-self-heal-data.c | 59 |
1 files changed, 51 insertions, 8 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c index 2b22727fa..05f9000ca 100644 --- a/xlators/cluster/afr/src/afr-self-heal-data.c +++ b/xlators/cluster/afr/src/afr-self-heal-data.c @@ -106,28 +106,56 @@ afr_sh_data_flush_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int +afr_sh_data_utimes_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct stat *buf) +{ + afr_sh_data_flush_cbk (frame, cookie, this, op_ret, op_errno); + + return 0; +} + + +int afr_sh_data_close (call_frame_t *frame, xlator_t *this) { afr_local_t *local = NULL; afr_private_t *priv = NULL; - afr_self_heal_t *sh = NULL; - int i = 0; - int call_count = 0; + afr_self_heal_t *sh = NULL; + + int i = 0; + int call_count = 0; + int source = 0; + int active_sinks = 0; + struct timespec ts[2]; + + local = frame->local; + sh = &local->self_heal; + priv = this->private; - local = frame->local; - sh = &local->self_heal; - priv = this->private; + source = sh->source; + active_sinks = sh->active_sinks; + +#ifdef HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC + ts[0] = sh->buf[source].st_atim; + ts[1] = sh->buf[source].st_mtim; + +#elif HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC + ts[0] = sh->buf[source].st_atimespec; + ts[1] = sh->buf[source].st_mtimespec; +#else + ts[0].tv_sec = sh->buf[source].st_atime; + ts[1].tv_sec = sh->buf[source].st_mtime; +#endif if (!sh->healing_fd) { afr_sh_data_done (frame, this); return 0; } - call_count = sh->active_sinks + 1; + call_count = (sh->active_sinks + 1) * 2; local->call_count = call_count; - /* closed source */ gf_log (this->name, GF_LOG_TRACE, "closing fd of %s on %s", @@ -140,6 +168,14 @@ afr_sh_data_close (call_frame_t *frame, xlator_t *this) sh->healing_fd); call_count--; + STACK_WIND_COOKIE (frame, afr_sh_data_utimes_cbk, + (void *) (long) sh->source, + priv->children[sh->source], + priv->children[sh->source]->fops->utimens, + &local->loc, ts); + + call_count--; + for (i = 0; i < priv->child_count; i++) { if (sh->sources[i] || !local->child_up[i]) continue; @@ -153,6 +189,13 @@ afr_sh_data_close (call_frame_t *frame, xlator_t *this) priv->children[i], priv->children[i]->fops->flush, sh->healing_fd); + + STACK_WIND_COOKIE (frame, afr_sh_data_utimes_cbk, + (void *) (long) i, + priv->children[i], + priv->children[i]->fops->utimens, + &local->loc, ts); + if (!--call_count) break; } |