From 103a9ecfaf5881b31844b8a12a5b98dc5308a800 Mon Sep 17 00:00:00 2001 From: Vikas Gorur Date: Tue, 13 Oct 2009 06:42:28 +0000 Subject: cluster/afr: Set mtime of parent directory in self-heal properly. While creating/deleting an entry as part of entry self-heal, set the parent directory's mtime to match that on the source subvolume. Signed-off-by: Anand V. Avati BUG: 137 (Parent directory mtime not reset after a create in self-heal) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=137 --- xlators/cluster/afr/src/afr-self-heal-entry.c | 92 ++++++++++++++++++++++++++- 1 file changed, 89 insertions(+), 3 deletions(-) (limited to 'xlators/cluster/afr/src/afr-self-heal-entry.c') diff --git a/xlators/cluster/afr/src/afr-self-heal-entry.c b/xlators/cluster/afr/src/afr-self-heal-entry.c index 5953fce15..deaf24f07 100644 --- a/xlators/cluster/afr/src/afr-self-heal-entry.c +++ b/xlators/cluster/afr/src/afr-self-heal-entry.c @@ -443,6 +443,37 @@ afr_sh_entry_expunge_entry_done (call_frame_t *frame, xlator_t *this, return 0; } +int +afr_sh_entry_expunge_parent_setattr_cbk (call_frame_t *expunge_frame, + void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, + struct stat *preop, struct stat *postop) +{ + afr_private_t *priv = NULL; + afr_local_t *expunge_local = NULL; + afr_self_heal_t *expunge_sh = NULL; + call_frame_t *frame = NULL; + + int active_src = (long) cookie; + + priv = this->private; + expunge_local = expunge_frame->local; + expunge_sh = &expunge_local->self_heal; + frame = expunge_sh->sh_frame; + + if (op_ret != 0) { + gf_log (this->name, GF_LOG_DEBUG, + "setattr on parent directory of %s on subvolume %s failed: %s", + expunge_local->loc.path, + priv->children[active_src]->name, strerror (op_errno)); + } + + AFR_STACK_DESTROY (expunge_frame); + afr_sh_entry_expunge_entry_done (frame, this, active_src); + + return 0; +} + int afr_sh_entry_expunge_remove_cbk (call_frame_t *expunge_frame, void *cookie, @@ -457,6 +488,8 @@ afr_sh_entry_expunge_remove_cbk (call_frame_t *expunge_frame, void *cookie, int active_src = 0; call_frame_t *frame = NULL; + loc_t parent_loc; + int32_t valid = 0; priv = this->private; expunge_local = expunge_frame->local; @@ -478,10 +511,18 @@ afr_sh_entry_expunge_remove_cbk (call_frame_t *expunge_frame, void *cookie, strerror (op_errno)); } - AFR_STACK_DESTROY (expunge_frame); - afr_sh_entry_expunge_entry_done (frame, this, active_src); + valid = GF_SET_ATTR_ATIME | GF_SET_ATTR_MTIME; + afr_build_parent_loc (&parent_loc, &expunge_local->loc); - return 0; + STACK_WIND_COOKIE (expunge_frame, afr_sh_entry_expunge_parent_setattr_cbk, + (void *) (long) active_src, + priv->children[active_src], + priv->children[active_src]->fops->setattr, + &parent_loc, + &expunge_sh->parentbuf, + valid); + + return 0; } @@ -675,6 +716,8 @@ afr_sh_entry_expunge_entry_cbk (call_frame_t *expunge_frame, void *cookie, expunge_local->loc.path, priv->children[source]->name); + expunge_sh->parentbuf = *postparent; + afr_sh_entry_expunge_purge (expunge_frame, this, active_src); return 0; @@ -1042,6 +1085,31 @@ afr_sh_entry_impunge_xattrop_cbk (call_frame_t *impunge_frame, void *cookie, } +int +afr_sh_entry_impunge_parent_setattr_cbk (call_frame_t *impunge_frame, + void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, + struct stat *preop, struct stat *postop) +{ + afr_private_t *priv = NULL; + afr_local_t *impunge_local = NULL; + + int child_index = (long) cookie; + + priv = this->private; + impunge_local = impunge_frame->local; + + if (op_ret != 0) { + gf_log (this->name, GF_LOG_DEBUG, + "setattr on parent directory of %s on subvolume %s failed: %s", + impunge_local->loc.path, + priv->children[child_index]->name, strerror (op_errno)); + } + + return 0; +} + + int afr_sh_entry_impunge_newfile_cbk (call_frame_t *impunge_frame, void *cookie, xlator_t *this, @@ -1064,6 +1132,9 @@ afr_sh_entry_impunge_newfile_cbk (call_frame_t *impunge_frame, void *cookie, afr_local_t *local = NULL; afr_self_heal_t *sh = NULL; + loc_t parent_loc; + int32_t valid = 0; + priv = this->private; impunge_local = impunge_frame->local; impunge_sh = &impunge_local->self_heal; @@ -1105,6 +1176,17 @@ afr_sh_entry_impunge_newfile_cbk (call_frame_t *impunge_frame, void *cookie, priv->children[active_src]->fops->xattrop, &impunge_local->loc, GF_XATTROP_ADD_ARRAY, xattr); + valid = GF_SET_ATTR_ATIME | GF_SET_ATTR_MTIME; + afr_build_parent_loc (&parent_loc, &impunge_local->loc); + + STACK_WIND_COOKIE (impunge_frame, afr_sh_entry_impunge_parent_setattr_cbk, + (void *) (long) child_index, + priv->children[child_index], + priv->children[child_index]->fops->setattr, + &parent_loc, + &impunge_sh->parentbuf, + valid); + dict_unref (xattr); return 0; @@ -1321,6 +1403,8 @@ afr_sh_entry_impunge_recreate_lookup_cbk (call_frame_t *impunge_frame, goto out; } + impunge_sh->parentbuf = *postparent; + impunge_local->cont.lookup.buf = *buf; type = (buf->st_mode & S_IFMT); @@ -1434,6 +1518,8 @@ afr_sh_entry_impunge_entry_cbk (call_frame_t *impunge_frame, void *cookie, "%s exists under %s", impunge_local->loc.path, priv->children[child_index]->name); + + impunge_sh->parentbuf = *postparent; } else { gf_log (this->name, GF_LOG_TRACE, "looking up %s under %s failed (%s)", -- cgit