summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/ec/src/ec-inode-write.c
diff options
context:
space:
mode:
authorXavier Hernandez <xhernandez@datalab.es>2014-10-08 09:20:11 +0200
committerVijay Bellur <vbellur@redhat.com>2014-10-21 11:38:45 -0700
commit56caf4349c8824fde70783fe404cc6f646dce149 (patch)
tree02bef10cd75c1422c3ed272d5ecd01edcb404033 /xlators/cluster/ec/src/ec-inode-write.c
parentd57ecca6322a451242f4a2b7b5978de7c8f9088e (diff)
ec: Fix self-heal issues
Problem: Doing an 'ls' of a directory that has been modified while one of the bricks was down, sometimes returns the old directory contents. Cause: Directories are not marked when they are modified as files are. The ec xlator balances requests amongst available and healthy bricks. Since there is no way to detect that a directory is out of date in one of the bricks, it is used from time to time to return the directory contents. Solution: Basically the solution consists in use versioning information also for directories, however some additional changes have been necessary. Changes: * Use directory versioning: This required to lock full directory instead of a single entry for all requests that add or remove entries from it. This is needed to allow atomic version update. This affects the following fops: create, mkdir, mknod, link, symlink, rename, unlink, rmdir Another side effect is that opendir requires to do a previous lookup to get versioning information and discard out of date bricks for subsequent readdir(p) calls. * Restrict directory self-heal: Till now, when one discrepancy was found in lookup, a self-heal was automatically started. This caused the versioning information of a bad directory to be healed instantly, making the original problem to reapear again. To solve this, when a missing directory is detected in one or more bricks on lookup or opendir fops, only a partial self-heal is performed on it. A partial self-heal basically creates the directory but does not restore any additional information. This avoids that an 'ls' could repair the directory and cause the problem to happen again. With this change, output of 'ls' is always consistent. However, since the directory has been created in the brick, this allows any other operation on it (create new files, for example) to succeed on all bricks and not add additional work to the self-heal process. To force a self-heal of a directory, any other operation must be done on it. For example a getxattr. With these changes, the correct healing procedure that would avoid inconsistent directory browsing consists on a post-order traversal of directoriesi being healed. This way, the directory contents will be healed before healing the directory itslef. * Additional changes to fix self-heal errors - Don't use fop->fd to decide between fd/loc. open, opendir and create have an fd, but the correct data is in loc. - Fix incorrect management of bad bricks per inode/fd. - Fix incorrect selection of fop's target bricks when there are bad bricks involved. - Improved ec_loc_parent() to always return a parent loc as complete as possible. Change-Id: Iaf3df174d7857da57d4a87b4a8740a7048b366ad BUG: 1149726 Signed-off-by: Xavier Hernandez <xhernandez@datalab.es> Reviewed-on: http://review.gluster.org/8916 Reviewed-by: Dan Lambright <dlambrig@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/cluster/ec/src/ec-inode-write.c')
-rw-r--r--xlators/cluster/ec/src/ec-inode-write.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/xlators/cluster/ec/src/ec-inode-write.c b/xlators/cluster/ec/src/ec-inode-write.c
index 7e557f12aa3..aa3682516ed 100644
--- a/xlators/cluster/ec/src/ec-inode-write.c
+++ b/xlators/cluster/ec/src/ec-inode-write.c
@@ -94,11 +94,11 @@ int32_t ec_manager_removexattr(ec_fop_data_t * fop, int32_t state)
case EC_STATE_LOCK:
if (fop->fd == NULL)
{
- ec_lock_prepare_inode(fop, &fop->loc[0]);
+ ec_lock_prepare_inode(fop, &fop->loc[0], 1);
}
else
{
- ec_lock_prepare_fd(fop, fop->fd);
+ ec_lock_prepare_fd(fop, fop->fd, 1);
}
ec_lock(fop);
@@ -186,7 +186,7 @@ int32_t ec_manager_removexattr(ec_fop_data_t * fop, int32_t state)
case -EC_STATE_LOCK_REUSE:
case EC_STATE_LOCK_REUSE:
- ec_lock_reuse(fop, 1);
+ ec_lock_reuse(fop);
return EC_STATE_UNLOCK;
@@ -351,6 +351,8 @@ void ec_fremovexattr(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
+ fop->use_fd = 1;
+
if (fd != NULL)
{
fop->fd = fd_ref(fd);
@@ -490,11 +492,11 @@ int32_t ec_manager_setattr(ec_fop_data_t * fop, int32_t state)
case EC_STATE_LOCK:
if (fop->fd == NULL)
{
- ec_lock_prepare_inode(fop, &fop->loc[0]);
+ ec_lock_prepare_inode(fop, &fop->loc[0], 1);
}
else
{
- ec_lock_prepare_fd(fop, fop->fd);
+ ec_lock_prepare_fd(fop, fop->fd, 1);
}
ec_lock(fop);
@@ -598,7 +600,7 @@ int32_t ec_manager_setattr(ec_fop_data_t * fop, int32_t state)
case -EC_STATE_LOCK_REUSE:
case EC_STATE_LOCK_REUSE:
- ec_lock_reuse(fop, 1);
+ ec_lock_reuse(fop);
return EC_STATE_UNLOCK;
@@ -772,6 +774,8 @@ void ec_fsetattr(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
+ fop->use_fd = 1;
+
fop->int32 = valid;
if (fd != NULL)
@@ -880,11 +884,11 @@ int32_t ec_manager_setxattr(ec_fop_data_t * fop, int32_t state)
case EC_STATE_LOCK:
if (fop->fd == NULL)
{
- ec_lock_prepare_inode(fop, &fop->loc[0]);
+ ec_lock_prepare_inode(fop, &fop->loc[0], 1);
}
else
{
- ec_lock_prepare_fd(fop, fop->fd);
+ ec_lock_prepare_fd(fop, fop->fd, 1);
}
ec_lock(fop);
@@ -971,7 +975,7 @@ int32_t ec_manager_setxattr(ec_fop_data_t * fop, int32_t state)
case -EC_STATE_LOCK_REUSE:
case EC_STATE_LOCK_REUSE:
- ec_lock_reuse(fop, 1);
+ ec_lock_reuse(fop);
return EC_STATE_UNLOCK;
@@ -1138,6 +1142,8 @@ void ec_fsetxattr(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
+ fop->use_fd = 1;
+
fop->int32 = flags;
if (fd != NULL)
@@ -1380,11 +1386,11 @@ int32_t ec_manager_truncate(ec_fop_data_t * fop, int32_t state)
case EC_STATE_LOCK:
if (fop->id == GF_FOP_TRUNCATE)
{
- ec_lock_prepare_inode(fop, &fop->loc[0]);
+ ec_lock_prepare_inode(fop, &fop->loc[0], 1);
}
else
{
- ec_lock_prepare_fd(fop, fop->fd);
+ ec_lock_prepare_fd(fop, fop->fd, 1);
}
ec_lock(fop);
@@ -1497,7 +1503,7 @@ int32_t ec_manager_truncate(ec_fop_data_t * fop, int32_t state)
case -EC_STATE_LOCK_REUSE:
case EC_STATE_LOCK_REUSE:
- ec_lock_reuse(fop, 1);
+ ec_lock_reuse(fop);
return EC_STATE_UNLOCK;
@@ -1666,6 +1672,8 @@ void ec_ftruncate(call_frame_t * frame, xlator_t * this, uintptr_t target,
goto out;
}
+ fop->use_fd = 1;
+
fop->offset = offset;
if (fd != NULL)
@@ -2019,7 +2027,7 @@ int32_t ec_manager_writev(ec_fop_data_t * fop, int32_t state)
/* Fall through */
case EC_STATE_LOCK:
- ec_lock_prepare_fd(fop, fop->fd);
+ ec_lock_prepare_fd(fop, fop->fd, 1);
ec_lock(fop);
return EC_STATE_GET_SIZE_AND_VERSION;
@@ -2125,7 +2133,7 @@ int32_t ec_manager_writev(ec_fop_data_t * fop, int32_t state)
case -EC_STATE_LOCK_REUSE:
case EC_STATE_LOCK_REUSE:
- ec_lock_reuse(fop, 1);
+ ec_lock_reuse(fop);
return EC_STATE_UNLOCK;
@@ -2171,6 +2179,8 @@ void ec_writev(call_frame_t * frame, xlator_t * this, uintptr_t target,
fop->offset = offset;
fop->uint32 = flags;
+ fop->use_fd = 1;
+
if (fd != NULL)
{
fop->fd = fd_ref(fd);