summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVikas Gorur <vikas@gluster.com>2009-10-13 06:42:28 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-10-13 06:23:06 -0700
commit103a9ecfaf5881b31844b8a12a5b98dc5308a800 (patch)
tree821a94852500d83fa378f1e61b845bcaf3c17934
parent7d6e73d4421265a304fd22964649e555a2db8097 (diff)
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 <avati@dev.gluster.com> 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
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-common.c5
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-entry.c92
-rw-r--r--xlators/cluster/afr/src/afr.h1
3 files changed, 93 insertions, 5 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c
index b42801ced..42d57a186 100644
--- a/xlators/cluster/afr/src/afr-self-heal-common.c
+++ b/xlators/cluster/afr/src/afr-self-heal-common.c
@@ -853,9 +853,9 @@ sh_missing_entries_newentry_cbk (call_frame_t *frame, void *cookie,
call_frame_t *setattr_frame = NULL;
int call_count = 0;
int child_index = 0;
-
+
struct stat stbuf;
- int32_t valid = 0;
+ int32_t valid;
local = frame->local;
sh = &local->self_heal;
@@ -1204,6 +1204,7 @@ sh_missing_entries_lookup_cbk (call_frame_t *frame, void *cookie,
buf->st_mode);
local->self_heal.buf[child_index] = *buf;
+
} else {
gf_log (this->name, GF_LOG_TRACE,
"path %s on subvolume %s => -1 (%s)",
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;
@@ -1043,6 +1086,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,
int32_t op_ret, int32_t op_errno,
@@ -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)",
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index 4cbb1b19c..4e937fb17 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -69,6 +69,7 @@ typedef struct _afr_private {
typedef struct {
/* array of stat's, one for each child */
struct stat *buf;
+ struct stat parentbuf;
/* array of xattr's, one for each child */
dict_t **xattr;