summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPranith Kumar K <pranithk@gluster.com>2011-11-04 19:10:11 +0530
committerVijay Bellur <vijay@gluster.com>2011-11-04 09:54:01 -0700
commitf356095377db83864c56f0bf86a8bf30563ed776 (patch)
treeebe807b599fdf48168f5f615d658de9dbad92f00
parent68fa84827120558a80f132da6918490885611a19 (diff)
dht,afr: Fixed gfid problems
*) removed uuid_generate usage in pump and afr *) filled the gfids for the fops which were sending no gfid in loc Change-Id: Id6780da76c3ae18ae5130368b687ea026e338ac0 BUG: 3760 Reviewed-on: http://review.gluster.com/673 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-common.c21
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-common.h3
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-entry.c20
-rw-r--r--xlators/cluster/afr/src/afr.h1
-rw-r--r--xlators/cluster/afr/src/pump.c53
-rw-r--r--xlators/cluster/dht/src/dht-common.c5
6 files changed, 53 insertions, 50 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c
index b925b0adcef..4f3a556b6a8 100644
--- a/xlators/cluster/afr/src/afr-self-heal-common.c
+++ b/xlators/cluster/afr/src/afr-self-heal-common.c
@@ -1223,10 +1223,12 @@ afr_sh_missing_entries_lookup_done (call_frame_t *frame, xlator_t *this,
afr_private_t *priv = NULL;
ia_type_t ia_type = IA_INVAL;
int32_t nsources = 0;
+ loc_t *loc = NULL;
local = frame->local;
sh = &local->self_heal;
priv = this->private;
+ loc = &local->loc;
if (op_ret < 0) {
if (op_errno == EIO)
@@ -1260,6 +1262,8 @@ afr_sh_missing_entries_lookup_done (call_frame_t *frame, xlator_t *this,
if (sh->gfid_sh_success_cbk)
sh->gfid_sh_success_cbk (frame, this);
+ if (uuid_is_null (loc->inode->gfid))
+ uuid_copy (loc->gfid, sh->buf[sh->source].ia_gfid);
sh_missing_entries_create (frame, this);
return;
out:
@@ -1824,6 +1828,7 @@ afr_sh_post_nb_entrylk_conflicting_sh_cbk (call_frame_t *frame, xlator_t *this)
if (int_lock->lock_op_ret < 0) {
gf_log (this->name, GF_LOG_INFO,
"Non blocking entrylks failed.");
+ sh->op_failed = -1;
afr_sh_missing_entries_done (frame, this);
} else {
@@ -2073,9 +2078,9 @@ afr_self_heal (call_frame_t *frame, xlator_t *this, inode_t *inode)
int32_t op_errno = 0;
int ret = 0;
afr_self_heal_t *orig_sh = NULL;
-
- call_frame_t *sh_frame = NULL;
- afr_local_t *sh_local = NULL;
+ call_frame_t *sh_frame = NULL;
+ afr_local_t *sh_local = NULL;
+ loc_t *loc = NULL;
local = frame->local;
orig_sh = &local->self_heal;
@@ -2177,6 +2182,13 @@ afr_self_heal (call_frame_t *frame, xlator_t *this, inode_t *inode)
GF_ASSERT (!uuid_is_null (sh->sh_gfid_req));
afr_self_heal_gfids (sh_frame, this);
} else {
+ loc = &sh_local->loc;
+ if (uuid_is_null (loc->inode->gfid) && uuid_is_null (loc->gfid)) {
+ if (!uuid_is_null (inode->gfid))
+ GF_ASSERT (!uuid_compare (inode->gfid,
+ sh->sh_gfid_req));
+ uuid_copy (loc->gfid, sh->sh_gfid_req);
+ }
gf_log (this->name, GF_LOG_TRACE,
"proceeding to metadata check on %s",
local->loc.path);
@@ -2244,7 +2256,7 @@ afr_self_heal_type_for_transaction (afr_transaction_type type)
}
int
-afr_build_child_loc (xlator_t *this, loc_t *child, loc_t *parent, char *name)
+afr_build_child_loc (xlator_t *this, loc_t *child, loc_t *parent, char *name, uuid_t gfid)
{
int ret = -1;
@@ -2278,6 +2290,7 @@ afr_build_child_loc (xlator_t *this, loc_t *child, loc_t *parent, char *name)
ret = -1;
goto out;
}
+ uuid_copy (child->gfid, gfid);
ret = 0;
out:
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.h b/xlators/cluster/afr/src/afr-self-heal-common.h
index 7a06c2f4b13..d58fdb7654e 100644
--- a/xlators/cluster/afr/src/afr-self-heal-common.h
+++ b/xlators/cluster/afr/src/afr-self-heal-common.h
@@ -105,7 +105,8 @@ typedef int
xlator_t *this, int32_t op_ret, int32_t op_errno,
dict_t *xattr);
int
-afr_build_child_loc (xlator_t *this, loc_t *child, loc_t *parent, char *name);
+afr_build_child_loc (xlator_t *this, loc_t *child, loc_t *parent, char *name,
+ uuid_t gfid);
int
afr_impunge_frame_create (call_frame_t *frame, xlator_t *this,
int active_source, int ret_child, mode_t entry_mode,
diff --git a/xlators/cluster/afr/src/afr-self-heal-entry.c b/xlators/cluster/afr/src/afr-self-heal-entry.c
index 21b248f496c..16dd46d2ee1 100644
--- a/xlators/cluster/afr/src/afr-self-heal-entry.c
+++ b/xlators/cluster/afr/src/afr-self-heal-entry.c
@@ -177,6 +177,11 @@ afr_sh_entry_erase_pending (call_frame_t *frame, xlator_t *this)
sh = &local->self_heal;
priv = this->private;
+ if (sh->entries_skipped) {
+ need_unwind = 1;
+ sh->op_failed = _gf_true;
+ goto out;
+ }
afr_sh_pending_to_delta (priv, sh->xattr, sh->delta_matrix, sh->success,
priv->child_count, AFR_ENTRY_TRANSACTION);
@@ -224,6 +229,7 @@ afr_sh_entry_erase_pending (call_frame_t *frame, xlator_t *this)
}
GF_FREE (erase_xattr);
+out:
if (need_unwind)
afr_sh_entry_finish (frame, this);
@@ -723,7 +729,8 @@ afr_sh_entry_expunge_entry (call_frame_t *frame, xlator_t *this,
expunge_sh->active_source = active_src;
expunge_sh->entrybuf = entry->d_stat;
- ret = afr_build_child_loc (this, &expunge_local->loc, &local->loc, name);
+ ret = afr_build_child_loc (this, &expunge_local->loc, &local->loc,
+ name, entry->d_stat.ia_gfid);
if (ret != 0) {
op_errno = EINVAL;
goto out;
@@ -1727,8 +1734,13 @@ afr_sh_entry_common_lookup_done (call_frame_t *impunge_frame, xlator_t *this,
afr_update_gfid_from_iatts (gfid, impunge_sh->buf,
impunge_sh->child_success,
priv->child_count);
- if (uuid_is_null (gfid))
- uuid_generate (gfid);
+ if (uuid_is_null (gfid)) {
+ sh->entries_skipped = _gf_true;
+ gf_log (this->name, GF_LOG_INFO, "%s: Skipping entry "
+ "self-heal because of gfid absence",
+ impunge_local->loc.path);
+ goto done;
+ }
afr_sh_common_lookup (impunge_frame, this, &impunge_local->loc,
afr_sh_entry_common_lookup_done, gfid,
AFR_LOOKUP_FAIL_CONFLICTS |
@@ -1799,7 +1811,7 @@ afr_sh_entry_impunge_entry (call_frame_t *frame, xlator_t *this,
impunge_local = impunge_frame->local;
ret = afr_build_child_loc (this, &impunge_local->loc, &local->loc,
- entry->d_name);
+ entry->d_name, entry->d_stat.ia_gfid);
if (ret != 0) {
op_errno = ENOMEM;
goto out;
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index f99ce471994..f29dcae4121 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -193,6 +193,7 @@ typedef struct {
mode_t impunging_entry_mode;
const char *linkname;
+ gf_boolean_t entries_skipped;
int op_failed;
diff --git a/xlators/cluster/afr/src/pump.c b/xlators/cluster/afr/src/pump.c
index 0eb57ac2408..15eee3ee43e 100644
--- a/xlators/cluster/afr/src/pump.c
+++ b/xlators/cluster/afr/src/pump.c
@@ -336,20 +336,6 @@ pump_save_file_stats (xlator_t *this, const char *path)
}
static void
-_generate_gfid_on_empty (uuid_t gfid)
-{
- if (uuid_is_null (gfid))
- uuid_generate (gfid);
-}
-
-static void
-_empty_gfid_on_set (uuid_t gfid, int lookup_status, struct iatt *iatt)
-{
- if (lookup_status || !uuid_compare (gfid, iatt->ia_gfid))
- uuid_clear (gfid);
-}
-
-static void
_fill_loc_info (loc_t *loc, struct iatt *iatt, struct iatt *parent)
{
afr_update_loc_gfids (loc, iatt, parent);
@@ -368,7 +354,7 @@ _wipe_loc (loc_t *loc)
}
static int
-gf_pump_traverse_directory (loc_t *loc, uuid_t gfid)
+gf_pump_traverse_directory (loc_t *loc)
{
xlator_t *this = NULL;
afr_private_t *priv = NULL;
@@ -383,15 +369,8 @@ gf_pump_traverse_directory (loc_t *loc, uuid_t gfid)
dict_t *xattr_rsp = NULL;
int ret = 0;
gf_boolean_t is_directory_empty = _gf_true;
- dict_t *xattr_req = NULL;
gf_boolean_t free_entries = _gf_false;
- xattr_req = dict_new ();
- if (!xattr_req) {
- ret = -1;
- goto out;
- }
-
INIT_LIST_HEAD (&entries.list);
this = THIS;
priv = this->private;
@@ -429,9 +408,17 @@ gf_pump_traverse_directory (loc_t *loc, uuid_t gfid)
gf_log (this->name, GF_LOG_DEBUG,
"found readdir entry=%s", entry->d_name);
+ offset = entry->d_off;
+ if (uuid_is_null (entry->d_stat.ia_gfid)) {
+ gf_log (this->name, GF_LOG_WARNING, "%s/%s: No "
+ "gfid present skipping the file",
+ loc->path, entry->d_name);
+ continue;
+ }
_wipe_loc (&entry_loc);
- ret = afr_build_child_loc (this, &entry_loc,
- loc, entry->d_name);
+ ret = afr_build_child_loc (this, &entry_loc, loc,
+ entry->d_name,
+ entry->d_stat.ia_gfid);
if (ret)
goto out;
if (!IS_ENTRY_CWD (entry->d_name) &&
@@ -444,17 +431,9 @@ gf_pump_traverse_directory (loc_t *loc, uuid_t gfid)
entry_loc.path,
iatt.ia_ino);
- _generate_gfid_on_empty (gfid);
- ret = dict_reset (xattr_req);
- if (ret)
- goto out;
- ret = afr_set_dict_gfid (xattr_req, gfid);
- if (ret)
- goto out;
- ret = syncop_lookup (this, &entry_loc, xattr_req,
+ ret = syncop_lookup (this, &entry_loc, NULL,
&iatt, &xattr_rsp, &parent);
- _empty_gfid_on_set (gfid, ret, &iatt);
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
"%s: lookup failed",
@@ -480,11 +459,10 @@ gf_pump_traverse_directory (loc_t *loc, uuid_t gfid)
gf_log (this->name, GF_LOG_TRACE,
"entering dir=%s",
entry->d_name);
- gf_pump_traverse_directory (&entry_loc, gfid);
+ gf_pump_traverse_directory (&entry_loc);
}
}
}
- offset = entry->d_off;
}
gf_dirent_free (&entries);
@@ -502,8 +480,6 @@ gf_pump_traverse_directory (loc_t *loc, uuid_t gfid)
}
out:
- if (xattr_req)
- dict_unref (xattr_req);
if (entry_loc.path)
loc_wipe (&entry_loc);
if (free_entries)
@@ -660,7 +636,6 @@ pump_task (void *data)
struct iatt iatt, parent;
dict_t *xattr_rsp = NULL;
dict_t *xattr_req = NULL;
- uuid_t gfid = {0};
int ret = -1;
@@ -701,7 +676,7 @@ pump_task (void *data)
goto out;
}
- gf_pump_traverse_directory (&loc, gfid);
+ gf_pump_traverse_directory (&loc);
pump_complete_migration (this);
out:
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index 111ba193318..062371db6ae 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -274,6 +274,7 @@ unlock:
selfheal:
FRAME_SU_DO (frame, dht_local_t);
+ uuid_copy (local->loc.gfid, local->gfid);
ret = dht_selfheal_directory (frame, dht_lookup_selfheal_cbk,
&local->loc, layout);
out:
@@ -4122,9 +4123,9 @@ dht_mkdir_hashed_cbk (call_frame_t *frame, void *cookie,
local->call_cnt = conf->subvolume_cnt - 1;
+ if (uuid_is_null (local->loc.gfid))
+ uuid_copy (local->loc.gfid, stbuf->ia_gfid);
if (local->call_cnt == 0) {
- if (uuid_is_null (local->loc.gfid) && !op_ret)
- uuid_copy (local->loc.gfid, stbuf->ia_gfid);
dht_selfheal_directory (frame, dht_mkdir_selfheal_cbk,
&local->loc, layout);
}