From 0a6b3ce3bf4acd994cb67c9c79b7c03909443bdd Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Tue, 1 Dec 2009 20:06:18 +0000 Subject: afr: remove memcpy of @local contents in afr_local_copy copy out members which are needed. memcpy of full local causes a copy of pointers without references and results in various corruption errors Signed-off-by: Anand V. Avati Signed-off-by: Anand V. Avati BUG: 170 (Auto-heal fails on files that are open()-ed/mmap()-ed) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=170 --- xlators/cluster/afr/src/afr-self-heal-common.c | 31 +++++++++++++++++++------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'xlators/cluster') diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c index 721f69a8d..7a888657d 100644 --- a/xlators/cluster/afr/src/afr-self-heal-common.c +++ b/xlators/cluster/afr/src/afr-self-heal-common.c @@ -1387,15 +1387,29 @@ afr_self_heal_missing_entries (call_frame_t *frame, xlator_t *this) afr_local_t *afr_local_copy (afr_local_t *l, xlator_t *this) { afr_private_t *priv = NULL; - afr_local_t *lc = NULL; + afr_local_t *lc = NULL; + afr_self_heal_t *sh = NULL; + afr_self_heal_t *shc = NULL; - priv = this->private; - lc = CALLOC (1, sizeof (afr_local_t)); + priv = this->private; -// memcpy (lc, l, sizeof (afr_local_t)); + sh = &l->self_heal; - lc->self_heal = l->self_heal; + lc = CALLOC (1, sizeof (afr_local_t)); + shc = &lc->self_heal; + + shc->unwind = sh->unwind; + shc->need_data_self_heal = sh->need_data_self_heal; + shc->need_metadata_self_heal = sh->need_metadata_self_heal; + shc->need_entry_self_heal = sh->need_entry_self_heal; + shc->forced_merge = sh->forced_merge; + shc->healing_fd_opened = sh->healing_fd_opened; + shc->data_lock_held = sh->data_lock_held; + if (sh->healing_fd) + shc->healing_fd = fd_ref (sh->healing_fd); + shc->background = sh->background; + shc->mode = sh->mode; if (l->loc.path) loc_copy (&lc->loc, &l->loc); @@ -1404,9 +1418,10 @@ afr_local_t *afr_local_copy (afr_local_t *l, xlator_t *this) if (l->xattr_req) lc->xattr_req = dict_copy_with_ref (l->xattr_req, NULL); - lc->cont.lookup.inode = l->cont.lookup.inode; -// if (l->cont.lookup.xattr) -// lc->cont.lookup.xattr = dict_copy_with_ref (l->cont.lookup.xattr, NULL); + if (l->cont.lookup.inode) + lc->cont.lookup.inode = inode_ref (l->cont.lookup.inode); + if (l->cont.lookup.xattr) + lc->cont.lookup.xattr = dict_copy_with_ref (l->cont.lookup.xattr, NULL); return lc; } -- cgit