diff options
author | Pranith Kumar K <pkarampu@redhat.com> | 2014-06-12 20:38:34 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2014-06-14 04:10:06 -0700 |
commit | 12b7797bfb143890ad4ca085332ec2f5e1ed08b8 (patch) | |
tree | 36fc239722c1df779e7a4efc43f64063bcd39ffd /xlators/cluster | |
parent | 7aa3630b1f5e07227e9cd167cbd717bd7932ae78 (diff) |
Fix resolution issues across fuse/server/afr
Problems with fuse/server:
Fuse loc touch up sets loc->name even when pargfid
is not known. Server lookup does (pargfid, name) based
lookup when name is set ignoring the gfid. Because of this server
resolver finds that the lookup came on (null-pargfid, name) and
fails the lookup with EINVAL.
Fix:
Don't set loc->name in loc_touchup if the pargfid is not known.
Did the same even for server-resolver
Problem with afr:
Lets say there is a directory hierarchy a/b/c/d on the mount and the
user is cd'ed into the directory. Bring down one of the bricks of replica and
remove all directories/files to simulate disk replacement on that brick. Now
this brick is brought back up. Creates on the cd'ed directory fail with ESTALE.
Basically before sending a create of 'f' inside 'd', fuse sends a lookup to
make sure the file is not present. On one of the bricks 'd' is present and
'f' is not so it sends ENOENT as response. On the new brick 'd' itself is not
present. So it sends ESTALE. In afr ESTALE is considered to be special errno on
witnessing which lookup has to fail. And ESTALE is given more priority than
ENOENT. Due to these reasons lookup fails with ESTALE rather than ENOENT. Since
lookup didn't fail with ENOENT, 'create' can't be issued so the command is
failed with ESTALE.
Solution:
Afr needs to consider ESTALE errno normally and ENOENT needs to
be given more priority so that operations like create can proceed even when
only one of the brick is up and running. Whenever client xlator identifies
that gfid-changed, it sets that information in lookup xdata. Afr uses this
information to fail the lookup with ESTALE so that top xlator can send
fresh lookup.
Change-Id: Ica6ce01baef08620154050a635e6f97d51029ef6
BUG: 1106408
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/8015
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/cluster')
-rw-r--r-- | xlators/cluster/afr/src/afr-common.c | 29 | ||||
-rw-r--r-- | xlators/cluster/afr/src/afr.h | 4 |
2 files changed, 23 insertions, 10 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c index 11aae4617e7..e4fbe794f08 100644 --- a/xlators/cluster/afr/src/afr-common.c +++ b/xlators/cluster/afr/src/afr-common.c @@ -1157,17 +1157,18 @@ afr_lookup_done (call_frame_t *frame, xlator_t *this) afr_inode_read_subvol_get (local->loc.parent, this, readable, NULL, &event); - /* First, check if we have an ESTALE from somewhere, - If so, propagate that so that a revalidate can be + /* First, check if we have a gfid-change from somewhere, + If so, propagate that so that a fresh lookup can be issued */ + if (local->cont.lookup.needs_fresh_lookup) { + local->op_ret = -1; + local->op_errno = ESTALE; + goto unwind; + } + op_errno = afr_final_errno (frame->local, this->private); local->op_errno = op_errno; - if (op_errno == ESTALE) { - local->op_errno = op_errno; - local->op_ret = -1; - goto unwind; - } read_subvol = -1; for (i = 0; i < priv->child_count; i++) { @@ -1270,7 +1271,7 @@ unwind: * others in that they must be given higher priority while * returning to the user. * - * The hierarchy is ESTALE > ENOENT > others + * The hierarchy is ENODATA > ENOENT > ESTALE > others */ int @@ -1278,10 +1279,10 @@ afr_higher_errno (int32_t old_errno, int32_t new_errno) { if (old_errno == ENODATA || new_errno == ENODATA) return ENODATA; + if (old_errno == ENOENT || new_errno == ENOENT) + return ENOENT; if (old_errno == ESTALE || new_errno == ESTALE) return ESTALE; - if (old_errno == ENOENT || new_errno == ENOENT) - return ENOENT; return new_errno; } @@ -1523,6 +1524,14 @@ afr_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, local->replies[child_index].valid = 1; local->replies[child_index].op_ret = op_ret; local->replies[child_index].op_errno = op_errno; + /* + * On revalidate lookup if the gfid-changed, afr should unwind the fop + * with ESTALE so that a fresh lookup will be sent by the top xlator. + * So remember it. + */ + if (xdata && dict_get (xdata, "gfid-changed")) + local->cont.lookup.needs_fresh_lookup = _gf_true; + if (op_ret != -1) { local->replies[child_index].poststat = *buf; local->replies[child_index].postparent = *postparent; diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h index c5b326cee06..b02ecaf3050 100644 --- a/xlators/cluster/afr/src/afr.h +++ b/xlators/cluster/afr/src/afr.h @@ -418,6 +418,10 @@ typedef struct _afr_local { struct { struct { + gf_boolean_t needs_fresh_lookup; + } lookup; + + struct { unsigned char buf_set; struct statvfs buf; } statfs; |