summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/ec/src/ec-helpers.c
diff options
context:
space:
mode:
authorXavier Hernandez <xhernandez@datalab.es>2015-01-07 12:29:48 +0100
committerPranith Kumar Karampuri <pkarampu@redhat.com>2015-05-09 17:29:46 -0700
commitb46e65db722c14985db62a1679e0388d217b713b (patch)
treefac847af8f529505bf364ed54df25658552fbae3 /xlators/cluster/ec/src/ec-helpers.c
parent73b61d709712692b48a1c9b18b4547410fb9078c (diff)
ec: Fix failures with missing files
When a file does not exist on a brick but it does on others, there could be problems trying to access it because there was some loc_t structures with null 'pargfid' but 'name' was set. This forced inode resolution based on <pargfid>/name instead of <gfid> which would be the correct one. To solve this problem, 'name' is always set to NULL when 'pargfid' is not present. Another problem was caused by an incorrect management of errors while doing incremental locking. The only allowed error during an incremental locking was ENOTCONN, but missing files on a brick can be returned as ESTALE. This caused an EIO on the operation. This patch doesn't care of errors during an incremental locking. At the end of the operation it will check if there are enough successfully locked bricks to continue or not. Change-Id: I9360ebf8d819d219cea2d173c09bd37679a6f15a BUG: 1176062 Signed-off-by: Xavier Hernandez <xhernandez@datalab.es> Reviewed-on: http://review.gluster.org/9407 Tested-by: NetBSD Build System Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'xlators/cluster/ec/src/ec-helpers.c')
-rw-r--r--xlators/cluster/ec/src/ec-helpers.c55
1 files changed, 38 insertions, 17 deletions
diff --git a/xlators/cluster/ec/src/ec-helpers.c b/xlators/cluster/ec/src/ec-helpers.c
index 2b497efd166..8ce3087d5a6 100644
--- a/xlators/cluster/ec/src/ec-helpers.c
+++ b/xlators/cluster/ec/src/ec-helpers.c
@@ -332,7 +332,7 @@ int32_t ec_loc_gfid_check(xlator_t * xl, uuid_t dst, uuid_t src)
return 1;
}
-int32_t ec_loc_setup_inode(xlator_t *xl, loc_t *loc)
+int32_t ec_loc_setup_inode(xlator_t *xl, inode_table_t *table, loc_t *loc)
{
int32_t ret = -1;
@@ -340,11 +340,11 @@ int32_t ec_loc_setup_inode(xlator_t *xl, loc_t *loc)
if (!ec_loc_gfid_check(xl, loc->gfid, loc->inode->gfid)) {
goto out;
}
- } else if (loc->parent != NULL) {
+ } else if (table != NULL) {
if (!gf_uuid_is_null(loc->gfid)) {
- loc->inode = inode_find(loc->parent->table, loc->gfid);
+ loc->inode = inode_find(table, loc->gfid);
} else if (loc->path && strchr (loc->path, '/')) {
- loc->inode = inode_resolve(loc->parent->table, (char *)loc->path);
+ loc->inode = inode_resolve(table, (char *)loc->path);
}
}
@@ -354,7 +354,7 @@ out:
return ret;
}
-int32_t ec_loc_setup_parent(xlator_t *xl, loc_t *loc)
+int32_t ec_loc_setup_parent(xlator_t *xl, inode_table_t *table, loc_t *loc)
{
char *path, *parent;
int32_t ret = -1;
@@ -363,9 +363,9 @@ int32_t ec_loc_setup_parent(xlator_t *xl, loc_t *loc)
if (!ec_loc_gfid_check(xl, loc->pargfid, loc->parent->gfid)) {
goto out;
}
- } else if (loc->inode != NULL) {
+ } else if (table != NULL) {
if (!gf_uuid_is_null(loc->pargfid)) {
- loc->parent = inode_find(loc->inode->table, loc->pargfid);
+ loc->parent = inode_find(table, loc->pargfid);
} else if (loc->path && strchr (loc->path, '/')) {
path = gf_strdup(loc->path);
if (path == NULL) {
@@ -375,11 +375,20 @@ int32_t ec_loc_setup_parent(xlator_t *xl, loc_t *loc)
goto out;
}
parent = dirname(path);
- loc->parent = inode_resolve(loc->inode->table, parent);
+ loc->parent = inode_resolve(table, parent);
+ if (loc->parent != NULL) {
+ gf_uuid_copy(loc->pargfid, loc->parent->gfid);
+ }
GF_FREE(path);
}
}
+ /* If 'pargfid' has not been determined, clear 'name' to avoid resolutions
+ based on <gfid:pargfid>/name. */
+ if (gf_uuid_is_null(loc->pargfid)) {
+ loc->name = NULL;
+ }
+
ret = 0;
out:
@@ -431,13 +440,17 @@ out:
int32_t ec_loc_parent(xlator_t *xl, loc_t *loc, loc_t *parent)
{
+ inode_table_t *table = NULL;
char *str = NULL;
int32_t ret = -1;
memset(parent, 0, sizeof(loc_t));
if (loc->parent != NULL) {
+ table = loc->parent->table;
parent->inode = inode_ref(loc->parent);
+ } else if (loc->inode != NULL) {
+ table = loc->inode->table;
}
if (!gf_uuid_is_null(loc->pargfid)) {
gf_uuid_copy(parent->gfid, loc->pargfid);
@@ -460,8 +473,8 @@ int32_t ec_loc_parent(xlator_t *xl, loc_t *loc, loc_t *parent)
}
if ((ec_loc_setup_path(xl, parent) != 0) ||
- (ec_loc_setup_inode(xl, parent) != 0) ||
- (ec_loc_setup_parent(xl, parent) != 0)) {
+ (ec_loc_setup_inode(xl, table, parent) != 0) ||
+ (ec_loc_setup_parent(xl, table, parent) != 0)) {
goto out;
}
@@ -488,14 +501,22 @@ out:
int32_t ec_loc_update(xlator_t *xl, loc_t *loc, inode_t *inode,
struct iatt *iatt)
{
+ inode_table_t *table = NULL;
int32_t ret = -1;
- if ((inode != NULL) && (loc->inode != inode)) {
- if (loc->inode != NULL) {
- inode_unref(loc->inode);
+ if (inode != NULL) {
+ table = inode->table;
+ if (loc->inode != inode) {
+ if (loc->inode != NULL) {
+ inode_unref(loc->inode);
+ }
+ loc->inode = inode_ref(inode);
+ gf_uuid_copy(loc->gfid, inode->gfid);
}
- loc->inode = inode_ref(inode);
- gf_uuid_copy(loc->gfid, inode->gfid);
+ } else if (loc->inode != NULL) {
+ table = loc->inode->table;
+ } else if (loc->parent != NULL) {
+ table = loc->parent->table;
}
if (iatt != NULL) {
@@ -505,8 +526,8 @@ int32_t ec_loc_update(xlator_t *xl, loc_t *loc, inode_t *inode,
}
if ((ec_loc_setup_path(xl, loc) != 0) ||
- (ec_loc_setup_inode(xl, loc) != 0) ||
- (ec_loc_setup_parent(xl, loc) != 0)) {
+ (ec_loc_setup_inode(xl, table, loc) != 0) ||
+ (ec_loc_setup_parent(xl, table, loc) != 0)) {
goto out;
}