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-18 04:20:33 -0800
commit3bc27345bf3aaf911960793ef4d48909f585bd84 (patch)
treedb3097cffcbc1bfd8e6732b852081cefe5ff578b
parent7e085ebc9ca0d34e6251611fdc42dadc243ce276 (diff)
dht,afr: Fixed gfid problems
*) removed uuid_generate usage in pump and afr, self-heald *) filled the gfids for the fops which were sending no gfid in loc Change-Id: I85da3c10f5ee2006248b0123155a60867870d202 BUG: 3760 Reviewed-on: http://review.gluster.com/679 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-self-heald.c57
-rw-r--r--xlators/cluster/afr/src/afr-self-heald.h6
-rw-r--r--xlators/cluster/afr/src/afr.h1
-rw-r--r--xlators/cluster/afr/src/pump.c39
-rw-r--r--xlators/cluster/dht/src/dht-common.c3
8 files changed, 68 insertions, 82 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c
index 57d069ddcc3..5ea7bcc2f4f 100644
--- a/xlators/cluster/afr/src/afr-self-heal-common.c
+++ b/xlators/cluster/afr/src/afr-self-heal-common.c
@@ -1243,10 +1243,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)
@@ -1281,6 +1283,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);
sh->type = sh->buf[sh->source].ia_type;
+ 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:
@@ -1846,6 +1850,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 {
@@ -2084,9 +2089,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;
@@ -2189,6 +2194,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);
@@ -2256,7 +2268,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;
@@ -2290,6 +2302,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 bc0dcd78cb8..da02bfdcf55 100644
--- a/xlators/cluster/afr/src/afr-self-heal-common.h
+++ b/xlators/cluster/afr/src/afr-self-heal-common.h
@@ -124,7 +124,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 98ef82fe5ce..f87de0c1f51 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);
@@ -721,7 +727,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;
@@ -1706,8 +1713,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->success_children,
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 |
@@ -1776,7 +1788,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-self-heald.c b/xlators/cluster/afr/src/afr-self-heald.c
index d0cd2f02d26..c75b7fa92ad 100644
--- a/xlators/cluster/afr/src/afr-self-heald.c
+++ b/xlators/cluster/afr/src/afr-self-heald.c
@@ -27,7 +27,7 @@
#include "afr-self-heal-common.h"
static int
-_crawl_directory (loc_t *loc, pid_t pid, uuid_t gfid);
+_crawl_directory (loc_t *loc, pid_t pid);
static int
get_pathinfo_host (char *pathinfo, char *hostname, size_t size)
{
@@ -85,20 +85,6 @@ out:
}
inline void
-afr_generate_gfid_on_empty (uuid_t gfid)
-{
- if (uuid_is_null (gfid))
- uuid_generate (gfid);
-}
-
-inline void
-afr_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);
-}
-
-inline void
afr_fill_loc_info (loc_t *loc, struct iatt *iatt, struct iatt *parent)
{
afr_update_loc_gfids (loc, iatt, parent);
@@ -107,7 +93,7 @@ afr_fill_loc_info (loc_t *loc, struct iatt *iatt, struct iatt *parent)
static int
_perform_self_heal (xlator_t *this, loc_t *parentloc, gf_dirent_t *entries,
- uuid_t gfid, off_t *offset, pid_t pid)
+ off_t *offset, pid_t pid)
{
gf_dirent_t *entry = NULL;
gf_dirent_t *tmp = NULL;
@@ -115,57 +101,45 @@ _perform_self_heal (xlator_t *this, loc_t *parentloc, gf_dirent_t *entries,
struct iatt parent = {0};;
int ret = 0;
loc_t entry_loc = {0};
- dict_t *xattr_req = NULL;
-
- xattr_req = dict_new ();
- if (!xattr_req) {
- ret = -1;
- goto out;
- }
list_for_each_entry_safe (entry, tmp, &entries->list, list) {
*offset = entry->d_off;
if (IS_ENTRY_CWD (entry->d_name) ||
IS_ENTRY_PARENT (entry->d_name))
continue;
-
- ret = dict_reset (xattr_req);
- if (ret)
- goto out;
+ if (uuid_is_null (entry->d_stat.ia_gfid)) {
+ gf_log (this->name, GF_LOG_WARNING, "%s/%s: No "
+ "gfid present skipping",
+ parentloc->path, entry->d_name);
+ continue;
+ }
loc_wipe (&entry_loc);
- ret = afr_build_child_loc (this, &entry_loc,
- parentloc, entry->d_name);
+ ret = afr_build_child_loc (this, &entry_loc, parentloc,
+ entry->d_name, entry->d_stat.ia_gfid);
if (ret)
goto out;
- afr_generate_gfid_on_empty (gfid);
- ret = afr_set_dict_gfid (xattr_req, gfid);
- if (ret)
- goto out;
gf_log (this->name, GF_LOG_DEBUG, "lookup %s", entry_loc.path);
- ret = syncop_lookup (this, &entry_loc, xattr_req,
+ ret = syncop_lookup (this, &entry_loc, NULL,
&iatt, NULL, &parent);
- afr_empty_gfid_on_set (gfid, ret, &iatt);
//Don't fail the crawl if lookup fails as it
//could be because of split-brain
if (ret || (!IA_ISDIR (iatt.ia_type)))
continue;
afr_fill_loc_info (&entry_loc, &iatt, &parent);
- ret = _crawl_directory (&entry_loc, pid, gfid);
+ ret = _crawl_directory (&entry_loc, pid);
}
ret = 0;
out:
- if (xattr_req)
- dict_unref (xattr_req);
if (entry_loc.path)
loc_wipe (&entry_loc);
return ret;
}
static int
-_crawl_directory (loc_t *loc, pid_t pid, uuid_t gfid)
+_crawl_directory (loc_t *loc, pid_t pid)
{
xlator_t *this = NULL;
afr_private_t *priv = NULL;
@@ -217,7 +191,7 @@ _crawl_directory (loc_t *loc, pid_t pid, uuid_t gfid)
if (list_empty (&entries.list))
goto out;
- ret = _perform_self_heal (this, loc, &entries, gfid, &offset, pid);
+ ret = _perform_self_heal (this, loc, &entries, &offset, pid);
gf_dirent_free (&entries);
free_entries = _gf_false;
}
@@ -382,7 +356,6 @@ afr_crawl_directory (xlator_t *this, pid_t pid)
loc_t loc = {0};
gf_boolean_t crawl = _gf_false;
int ret = 0;
- uuid_t gfid = {0};
priv = this->private;
shd = &priv->shd;
@@ -409,7 +382,7 @@ afr_crawl_directory (xlator_t *this, pid_t pid)
afr_build_root_loc (priv->root_inode, &loc);
while (crawl) {
- ret = _crawl_directory (&loc, pid, gfid);
+ ret = _crawl_directory (&loc, pid);
if (ret)
gf_log (this->name, GF_LOG_ERROR, "Crawl failed");
else
diff --git a/xlators/cluster/afr/src/afr-self-heald.h b/xlators/cluster/afr/src/afr-self-heald.h
index d5f9552c1d5..6eb119b073f 100644
--- a/xlators/cluster/afr/src/afr-self-heald.h
+++ b/xlators/cluster/afr/src/afr-self-heald.h
@@ -38,12 +38,6 @@ void afr_build_root_loc (inode_t *inode, loc_t *loc);
int afr_set_root_gfid (dict_t *dict);
inline void
-afr_generate_gfid_on_empty (uuid_t gfid);
-
-inline void
-afr_empty_gfid_on_set (uuid_t gfid, int lookup_status, struct iatt *iatt);
-
-inline void
afr_fill_loc_info (loc_t *loc, struct iatt *iatt, struct iatt *parent);
#endif /* __AFR_SELF_HEALD_H__ */
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index 45b09f7dda4..e1f13b37655 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -227,6 +227,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 aeb2ea7605e..007daa6f11d 100644
--- a/xlators/cluster/afr/src/pump.c
+++ b/xlators/cluster/afr/src/pump.c
@@ -323,7 +323,7 @@ pump_save_file_stats (xlator_t *this, const char *path)
}
static int
-gf_pump_traverse_directory (loc_t *loc, uuid_t gfid)
+gf_pump_traverse_directory (loc_t *loc)
{
xlator_t *this = NULL;
fd_t *fd = NULL;
@@ -337,15 +337,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;
@@ -382,9 +375,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",
+ loc->path, entry->d_name);
+ continue;
+ }
loc_wipe (&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;
@@ -397,17 +398,9 @@ gf_pump_traverse_directory (loc_t *loc, uuid_t gfid)
entry_loc.path,
iatt.ia_ino);
- afr_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);
- afr_empty_gfid_on_set (gfid, ret, &iatt);
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
"%s: lookup failed",
@@ -434,11 +427,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);
@@ -456,8 +448,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)
@@ -626,7 +616,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;
@@ -666,7 +655,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 0998eef0d68..49f3bc7be0c 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -260,6 +260,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:
@@ -3296,6 +3297,8 @@ 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) {
dht_selfheal_directory (frame, dht_mkdir_selfheal_cbk,
&local->loc, layout);