From 60b5f5cc2cb5c23ba852ad20a84328338d0546ae Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Mon, 16 Dec 2013 23:55:47 +0530 Subject: gfid-access: fix the issue of entry creation with wrong gfid * dict_set was happening with a string instead of 'uuid_t' causing entry creations to happen with wrong gfid * revalidate was causing excessive ESTALE logs as lookup was happening on '.gfid/' path itself causing server to become clueless Change-Id: I3b76ce7fdec9c2ff785be21f506f859f489f80f0 BUG: 1054199 Signed-off-by: Amar Tumballi Reviewed-on: http://review.gluster.org/6520 Reviewed-by: Anand Avati Tested-by: Anand Avati --- xlators/features/gfid-access/src/gfid-access.c | 45 ++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 6 deletions(-) (limited to 'xlators/features/gfid-access/src/gfid-access.c') diff --git a/xlators/features/gfid-access/src/gfid-access.c b/xlators/features/gfid-access/src/gfid-access.c index 1566278ef..25ef93697 100644 --- a/xlators/features/gfid-access/src/gfid-access.c +++ b/xlators/features/gfid-access/src/gfid-access.c @@ -252,7 +252,7 @@ err: } static int32_t -ga_fill_tmp_loc (loc_t *loc, xlator_t *this, char *gfid, +ga_fill_tmp_loc (loc_t *loc, xlator_t *this, uuid_t gfid, char *bname, dict_t *xdata, loc_t *new_loc) { int ret = -1; @@ -421,15 +421,20 @@ ga_new_entry (call_frame_t *frame, xlator_t *this, loc_t *loc, data_t *data, call_frame_t *new_frame = NULL; mode_t mode = 0; ga_local_t *local = NULL; + uuid_t gfid = {0,}; args = ga_newfile_parse_args (this, data); if (!args) goto out; + ret = uuid_parse (args->gfid, gfid); + if (ret) + goto out; + if (!xdata) xdata = dict_new (); - ret = ga_fill_tmp_loc (loc, this, args->gfid, + ret = ga_fill_tmp_loc (loc, this, gfid, args->bname, xdata, &tmp_loc); if (ret) goto out; @@ -485,15 +490,20 @@ ga_heal_entry (call_frame_t *frame, xlator_t *this, loc_t *loc, data_t *data, ga_heal_args_t *args = NULL; loc_t tmp_loc = {0,}; call_frame_t *new_frame = NULL; + uuid_t gfid = {0,}; args = ga_heal_parse_args (this, data); if (!args) goto out; + ret = uuid_parse (args->gfid, gfid); + if (ret) + goto out; + if (!xdata) xdata = dict_new (); - ret = ga_fill_tmp_loc (loc, this, args->gfid, args->bname, + ret = ga_fill_tmp_loc (loc, this, gfid, args->bname, xdata, &tmp_loc); if (ret) goto out; @@ -708,8 +718,30 @@ ga_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) /* if its revalidate, and inode is not of type directory, proceed with 'wind' */ if (loc->inode && loc->inode->ia_type && - !IA_ISDIR (loc->inode->ia_type)) + !IA_ISDIR (loc->inode->ia_type)) { + + /* a revalidate on ".gfid/" is possible, check for it */ + if (((loc->parent && + __is_gfid_access_dir (loc->parent->gfid)) || + __is_gfid_access_dir (loc->pargfid))) { + + /* here, just send 'loc->gfid' and 'loc->inode' */ + tmp_loc.inode = inode_ref (loc->inode); + uuid_copy (tmp_loc.gfid, loc->inode->gfid); + + STACK_WIND (frame, default_lookup_cbk, + FIRST_CHILD(this), + FIRST_CHILD(this)->fops->lookup, + &tmp_loc, xdata); + + inode_unref (tmp_loc.inode); + + return 0; + } + + /* not something to bother, continue the flow */ goto wind; + } priv = this->private; @@ -729,8 +761,9 @@ ga_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) /* now, check if the lookup() is on an existing entry, but on gfid-path */ if (!((loc->parent && __is_gfid_access_dir (loc->parent->gfid)) || - __is_gfid_access_dir (loc->pargfid))) - goto wind; + __is_gfid_access_dir (loc->pargfid))) { + goto wind; + } /* make sure the 'basename' is actually a 'canonical-gfid', otherwise, return error */ -- cgit