From 8d5bb5292d75794838ee37e87a97a01cfc59b932 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Tue, 16 Oct 2012 10:24:30 +0530 Subject: cluster/afr: Link inode only on lookup Problem: When "gluster volume heal info is executed, crawl's process_entry is not going to populate iatt structure so the iatt's gfid will be empty. So inode_links are failing. Fix: inode_link should be done only after lookup i.e. when heal is performed. So moved the inode_link related code to just after the lookup which is triggered when self-heal is done. Tests: The testcase that gives this issue does not give the inode-link failures anymore. glustershd heal, info commands are working as expected. Wrote basic automation tests for proactive-self-heal-daemon https://github.com/pranithk/gluster-tests/blob/master/afr/proactive-self-heal.sh Change-Id: Ic112bf104a4d553a64d3d8559f681a25ae1a5362 BUG: 861015 Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.org/4090 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- xlators/cluster/afr/src/afr-self-heald.c | 44 ++++++++++++++++---------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/xlators/cluster/afr/src/afr-self-heald.c b/xlators/cluster/afr/src/afr-self-heald.c index 214c0fff4..61c8c91d8 100644 --- a/xlators/cluster/afr/src/afr-self-heald.c +++ b/xlators/cluster/afr/src/afr-self-heald.c @@ -372,6 +372,25 @@ out: return; } +int +_link_inode_update_loc (xlator_t *this, loc_t *loc, struct iatt *iattr) +{ + inode_t *link_inode = NULL; + int ret = -1; + + link_inode = inode_link (loc->inode, NULL, NULL, iattr); + if (link_inode == NULL) { + gf_log (this->name, GF_LOG_ERROR, "inode link failed " + "on the inode (%s)", uuid_utoa (iattr->ia_gfid)); + goto out; + } + inode_unref (loc->inode); + loc->inode = link_inode; + ret = 0; +out: + return ret; +} + int _self_heal_entry (xlator_t *this, afr_crawl_data_t *crawl_data, gf_dirent_t *entry, loc_t *child, loc_t *parent, struct iatt *iattr) @@ -388,6 +407,9 @@ _self_heal_entry (xlator_t *this, afr_crawl_data_t *crawl_data, gf_dirent_t *ent crawl_data); if (xattr_rsp) dict_unref (xattr_rsp); + if (ret == 0) + ret = _link_inode_update_loc (this, child, iattr); + return ret; } @@ -732,25 +754,6 @@ out: return ret; } -int -_link_inode_update_loc (xlator_t *this, loc_t *loc, struct iatt *iattr) -{ - inode_t *link_inode = NULL; - int ret = -1; - - link_inode = inode_link (loc->inode, NULL, NULL, iattr); - if (link_inode == NULL) { - gf_log (this->name, GF_LOG_ERROR, "inode link failed " - "on the inode (%s)", uuid_utoa (iattr->ia_gfid)); - goto out; - } - inode_unref (loc->inode); - loc->inode = link_inode; - ret = 0; -out: - return ret; -} - int afr_local_pathinfo (char *pathinfo, gf_boolean_t *local) { @@ -946,9 +949,6 @@ _process_entries (xlator_t *this, loc_t *parentloc, gf_dirent_t *entries, if (ret) continue; - ret = _link_inode_update_loc (this, &entry_loc, &iattr); - if (ret) - goto out; if (crawl_data->crawl == INDEX) continue; -- cgit