From eab187ce06f6d72aeba297604e132d181da4c502 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Tue, 18 Oct 2011 13:31:35 +0530 Subject: storage/posix: posix changes to handle gfid/conflicts self-heal Change-Id: Ib759befe1800bc6fd93bdf44f3a7f89bfffff46e BUG: 3734 Reviewed-on: http://review.gluster.com/612 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- libglusterfs/src/stack.h | 1 + xlators/cluster/afr/src/afr-self-heal-common.c | 1 + xlators/storage/posix/src/posix.c | 23 ++++++++++++++++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/libglusterfs/src/stack.h b/libglusterfs/src/stack.h index 87c723112c6..d867a4d5659 100644 --- a/libglusterfs/src/stack.h +++ b/libglusterfs/src/stack.h @@ -46,6 +46,7 @@ typedef struct _call_pool_t call_pool_t; #include "globals.h" #define NFS_PID 1 +#define SELF_HEAL_PID -1 typedef int32_t (*ret_fn_t) (call_frame_t *frame, call_frame_t *prev_frame, xlator_t *this, diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c index dc660e19888..568368b9ccd 100644 --- a/xlators/cluster/afr/src/afr-self-heal-common.c +++ b/xlators/cluster/afr/src/afr-self-heal-common.c @@ -2054,6 +2054,7 @@ afr_self_heal (call_frame_t *frame, xlator_t *this, inode_t *inode) local->self_heal.need_entry_self_heal); sh_frame = copy_frame (frame); + sh_frame->root->pid = SELF_HEAL_PID; sh_local = afr_local_copy (local, this); sh_frame->local = sh_local; sh = &sh_local->self_heal; diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 69713c5a5f3..7b206390fb8 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -497,6 +497,8 @@ posix_gfid_heal (xlator_t *this, const char *path, dict_t *xattr_req) ret = sys_lgetxattr (path, GFID_XATTR_KEY, uuid_curr, 16); if (ret != 16) { if (is_fresh_file (&stat)) { + gf_log (this->name, GF_LOG_DEBUG, "This is a fresh file" + " Continue"); ret = -1; errno = ENOENT; goto out; @@ -578,6 +580,18 @@ out: } +static inline gf_boolean_t +posix_is_heal_needed (call_frame_t *frame) +{ + return frame->root->pid != SELF_HEAL_PID; +} + +static inline gf_boolean_t +posix_is_gfid_req_present (dict_t *xattr_req) +{ + void *uuid_req = NULL; + return !dict_get_ptr (xattr_req, "gfid-req", &uuid_req); +} int32_t posix_lookup (call_frame_t *frame, xlator_t *this, @@ -600,10 +614,17 @@ posix_lookup (call_frame_t *frame, xlator_t *this, MAKE_REAL_PATH (real_path, this, loc->path); - posix_gfid_heal (this, real_path, xattr_req); + if (posix_is_heal_needed (frame)) + posix_gfid_heal (this, real_path, xattr_req); + else + posix_gfid_set (this, real_path, xattr_req); op_ret = posix_lstat_with_gfid (this, real_path, &buf); op_errno = errno; + //Afr does lookups without gfid-req, prevent ENODATA in that case + if ((op_errno == ENODATA) && + !posix_is_gfid_req_present (xattr_req)) + op_ret = 0; if (op_ret == -1) { if (op_errno != ENOENT) { -- cgit