summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPranith Kumar K <pranithk@gluster.com>2011-10-18 13:31:35 +0530
committerVijay Bellur <vijay@gluster.com>2011-10-19 02:28:25 -0700
commiteab187ce06f6d72aeba297604e132d181da4c502 (patch)
treed5153648ab1c3e281866846ee5347d27661ecc77
parent94943e213a61c83481308dba6adc6b23c3581d2e (diff)
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 <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
-rw-r--r--libglusterfs/src/stack.h1
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-common.c1
-rw-r--r--xlators/storage/posix/src/posix.c23
3 files changed, 24 insertions, 1 deletions
diff --git a/libglusterfs/src/stack.h b/libglusterfs/src/stack.h
index 87c723112..d867a4d56 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 dc660e198..568368b9c 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 69713c5a5..7b206390f 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) {