summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/afr/src/afr-common.c58
-rw-r--r--xlators/cluster/afr/src/afr-self-heald.c88
-rw-r--r--xlators/cluster/afr/src/afr.h3
-rw-r--r--xlators/storage/posix/src/posix.c12
4 files changed, 20 insertions, 141 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
index 333c2bda556..04a90aae4c6 100644
--- a/xlators/cluster/afr/src/afr-common.c
+++ b/xlators/cluster/afr/src/afr-common.c
@@ -1442,62 +1442,6 @@ afr_final_errno (afr_local_t *local, afr_private_t *priv)
return op_errno;
}
-static int
-get_pathinfo_host (char *pathinfo, char *hostname, size_t size)
-{
- char *start = NULL;
- char *end = NULL;
- int ret = -1;
- int i = 0;
-
- if (!pathinfo)
- goto out;
-
- start = strchr (pathinfo, ':');
- if (!start)
- goto out;
- end = strrchr (pathinfo, ':');
- if (start == end)
- goto out;
-
- memset (hostname, 0, size);
- i = 0;
- while (++start != end)
- hostname[i++] = *start;
- ret = 0;
-out:
- return ret;
-}
-
-int
-afr_local_pathinfo (char *pathinfo, gf_boolean_t *local)
-{
- int ret = 0;
- char pathinfohost[1024] = {0};
- char localhost[1024] = {0};
- xlator_t *this = THIS;
-
- *local = _gf_false;
- ret = get_pathinfo_host (pathinfo, pathinfohost, sizeof (pathinfohost));
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Invalid pathinfo: %s",
- pathinfo);
- goto out;
- }
-
- ret = gethostname (localhost, sizeof (localhost));
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "gethostname() failed, "
- "reason: %s", strerror (errno));
- goto out;
- }
-
- if (!strcmp (localhost, pathinfohost))
- *local = _gf_true;
-out:
- return ret;
-}
-
static int32_t
afr_local_discovery_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, dict_t *dict,
@@ -1521,7 +1465,7 @@ afr_local_discovery_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto out;
}
- ret = afr_local_pathinfo (pathinfo, &is_local);
+ ret = glusterfs_is_local_pathinfo (pathinfo, &is_local);
if (ret) {
goto out;
}
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);
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index d9233eedadc..8156eaa995e 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -1003,9 +1003,6 @@ afr_inodelk_init (afr_inodelk_t *lk, char *dom, size_t child_count);
void
afr_handle_open_fd_count (call_frame_t *frame, xlator_t *this);
-int
-afr_local_pathinfo (char *pathinfo, gf_boolean_t *is_local);
-
void
afr_remove_eager_lock_stub (afr_local_t *local);
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index ea9cb3def62..8ac3c5d4b68 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -3737,8 +3737,8 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
dyn_rpath = gf_strdup (host_buf);
if (!dyn_rpath) {
- ret = -1;
- goto done;
+ op_errno = ENOMEM;
+ goto out;
}
size = strlen (dyn_rpath) + 1;
@@ -3749,6 +3749,8 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
"could not set value (%s) in dictionary",
dyn_rpath);
GF_FREE (dyn_rpath);
+ op_errno = -ret;
+ goto out;
}
goto done;
}
@@ -3757,17 +3759,21 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
(strcmp (name, GFID_TO_PATH_KEY) == 0)) {
ret = inode_path (loc->inode, NULL, &path);
if (ret < 0) {
+ op_errno = -ret;
gf_log (this->name, GF_LOG_WARNING, "%s: could not get "
"inode path", uuid_utoa (loc->inode->gfid));
- goto done;
+ goto out;
}
+ size = ret;
ret = dict_set_dynstr (dict, GFID_TO_PATH_KEY, path);
if (ret < 0) {
+ op_errno = ENOMEM;
gf_log (this->name, GF_LOG_WARNING,
"could not set value (%s) in dictionary",
host_buf);
GF_FREE (path);
+ goto out;
}
goto done;
}