summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src/afr-self-heald.c
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2015-02-25 11:37:57 +0530
committerVijay Bellur <vbellur@redhat.com>2015-02-27 01:28:35 -0800
commitd5624b2d4baf509ad8d6037a0d9cabf9cd5ab1c5 (patch)
treea5f257e370606282a1f9c98418e48c466077e5f3 /xlators/cluster/afr/src/afr-self-heald.c
parent6a77db6d19dba5367c02cbf2a5883ac49cef94e2 (diff)
libglusterfs: Moved common functions as utils in syncop/common-utils
These will be used by both afr and ec. Moved syncop_dirfd, syncop_ftw, syncop_dir_scan functions also into syncop-utils.c Change-Id: I467253c74a346e1e292d36a8c1a035775c3aa670 BUG: 1177601 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/9740 Reviewed-by: Krutika Dhananjay <kdhananj@redhat.com> Reviewed-by: Anuradha Talur <atalur@redhat.com> Reviewed-by: Ravishankar N <ravishankar@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/cluster/afr/src/afr-self-heald.c')
-rw-r--r--xlators/cluster/afr/src/afr-self-heald.c88
1 files changed, 10 insertions, 78 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heald.c b/xlators/cluster/afr/src/afr-self-heald.c
index f979f992660..707c12b7565 100644
--- a/xlators/cluster/afr/src/afr-self-heald.c
+++ b/xlators/cluster/afr/src/afr-self-heald.c
@@ -18,6 +18,7 @@
#include "afr-self-heal.h"
#include "afr-self-heald.h"
#include "protocol-common.h"
+#include "syncop-utils.h"
#define SHD_INODE_LRU_LIMIT 2048
#define AFR_EH_SPLIT_BRAIN_LIMIT 1024
@@ -76,46 +77,15 @@ afr_destroy_shd_event_data (void *data)
gf_boolean_t
afr_shd_is_subvol_local (xlator_t *this, int subvol)
{
- char *pathinfo = NULL;
- afr_private_t *priv = NULL;
- dict_t *xattr = NULL;
- int ret = 0;
- gf_boolean_t is_local = _gf_false;
- loc_t loc = {0, };
+ afr_private_t *priv = NULL;
+ gf_boolean_t is_local = _gf_false;
+ loc_t loc = {0, };
+ loc.inode = this->itable->root;
+ uuid_copy (loc.gfid, loc.inode->gfid);
priv = this->private;
-
- loc.inode = this->itable->root;
- uuid_copy (loc.gfid, loc.inode->gfid);
-
- ret = syncop_getxattr (priv->children[subvol], &loc, &xattr,
- GF_XATTR_PATHINFO_KEY, NULL);
- if (ret) {
- is_local = _gf_false;
- goto out;
- }
-
- if (!xattr) {
- is_local = _gf_false;
- goto out;
- }
-
- ret = dict_get_str (xattr, GF_XATTR_PATHINFO_KEY, &pathinfo);
- if (ret) {
- is_local = _gf_false;
- goto out;
- }
-
- afr_local_pathinfo (pathinfo, &is_local);
-
- gf_log (this->name, GF_LOG_DEBUG, "subvol %s is %slocal",
- priv->children[subvol]->name, is_local? "" : "not ");
-
-out:
- if (xattr)
- dict_unref (xattr);
-
- return is_local;
+ syncop_is_subvol_local(priv->children[subvol], &loc, &is_local);
+ return is_local;
}
@@ -301,7 +271,7 @@ afr_shd_selfheal (struct subvol_healer *healer, int child, uuid_t gfid)
subvol = priv->children[child];
//If this fails with ENOENT/ESTALE index is stale
- ret = afr_shd_gfid_to_path (this, subvol, gfid, &path);
+ ret = syncop_gfid_to_path (this->itable, subvol, gfid, &path);
if (ret < 0)
return ret;
@@ -805,44 +775,6 @@ out:
return ret;
}
-
-int
-afr_shd_gfid_to_path (xlator_t *this, xlator_t *subvol, uuid_t gfid, char **path_p)
-{
- int ret = 0;
- char *path = NULL;
- loc_t loc = {0,};
- dict_t *xattr = NULL;
-
- uuid_copy (loc.gfid, gfid);
- loc.inode = inode_new (this->itable);
-
- ret = syncop_getxattr (subvol, &loc, &xattr, GFID_TO_PATH_KEY, NULL);
- if (ret)
- goto out;
-
- ret = dict_get_str (xattr, GFID_TO_PATH_KEY, &path);
- if (ret || !path) {
- ret = -EINVAL;
- goto out;
- }
-
- *path_p = gf_strdup (path);
- if (!*path_p) {
- ret = -ENOMEM;
- goto out;
- }
-
- ret = 0;
-
-out:
- if (xattr)
- dict_unref (xattr);
- loc_wipe (&loc);
-
- return ret;
-}
-
int
afr_shd_gather_entry (xlator_t *subvol, gf_dirent_t *entry, loc_t *parent,
void *data)
@@ -872,7 +804,7 @@ afr_shd_gather_entry (xlator_t *subvol, gf_dirent_t *entry, loc_t *parent,
if (child == priv->child_count)
return 0;
- ret = afr_shd_gfid_to_path (this, subvol, gfid, &path);
+ ret = syncop_gfid_to_path (this->itable, subvol, gfid, &path);
if (ret == -ENOENT || ret == -ESTALE) {
afr_shd_index_purge (subvol, parent->inode, entry->d_name);