From ad8c65612d6d7e32c06fd3aed11b7a9edd514607 Mon Sep 17 00:00:00 2001 From: Mohammed Rafi KC Date: Tue, 12 Jan 2016 12:54:42 +0530 Subject: fuse: send lookup if inode_ctx is not set During resolving of an entry or inode, if inode ctx was not set, we will send a lookup. This patch also make sure that inode_ctx will be created after every inode_link Change-Id: I4211533ca96a51b89d9f010fc57133470e52dc11 BUG: 1297311 Signed-off-by: Mohammed Rafi KC Reviewed-on: http://review.gluster.org/13225 Reviewed-by: Dan Lambright Tested-by: Dan Lambright --- libglusterfs/src/inode.c | 18 ++++++++++++++---- libglusterfs/src/inode.h | 3 +++ 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'libglusterfs/src') diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c index 50ef98fba20..26e0194a761 100644 --- a/libglusterfs/src/inode.c +++ b/libglusterfs/src/inode.c @@ -1845,7 +1845,7 @@ out: void inode_set_need_lookup (inode_t *inode, xlator_t *this) { - uint64_t need_lookup = 1; + uint64_t need_lookup = LOOKUP_NEEDED; if (!inode | !this) return; @@ -1855,19 +1855,29 @@ inode_set_need_lookup (inode_t *inode, xlator_t *this) return; } +/* Function behaviour: + * Function return true if inode_ctx is not present, + * or value stored in inode_ctx is LOOKUP_NEEDED. + * If inode_ctx value is LOOKUP_NOT_NEEDED, which means + * inode_ctx is present for xlator this, but no lookup + * needed. + */ gf_boolean_t inode_needs_lookup (inode_t *inode, xlator_t *this) { uint64_t need_lookup = 0; gf_boolean_t ret = _gf_false; + int op_ret = -1; if (!inode || !this) return ret; - inode_ctx_get (inode, this, &need_lookup); - if (need_lookup) { + op_ret = inode_ctx_get (inode, this, &need_lookup); + if (op_ret == -1) { + ret = _gf_true; + } else if (need_lookup == LOOKUP_NEEDED) { ret = _gf_true; - need_lookup = 0; + need_lookup = LOOKUP_NOT_NEEDED; inode_ctx_set (inode, this, &need_lookup); } diff --git a/libglusterfs/src/inode.h b/libglusterfs/src/inode.h index 37083fae05b..114aeae78bb 100644 --- a/libglusterfs/src/inode.h +++ b/libglusterfs/src/inode.h @@ -14,6 +14,9 @@ #include #include +#define LOOKUP_NEEDED 1 +#define LOOKUP_NOT_NEEDED 2 + #define DEFAULT_INODE_MEMPOOL_ENTRIES 32 * 1024 #define INODE_PATH_FMT "" struct _inode_table; -- cgit