From 633d88ea7ef621bcce9a408188bc57858f6ca942 Mon Sep 17 00:00:00 2001 From: Krutika Dhananjay Date: Thu, 7 Jul 2016 14:33:20 +0530 Subject: features/index: Ignore regular files when examining state of the inode wrt ENTRY_CHANGES This prevents unnecessary sys_lstat() syscall when xattrop is operating on regular files. Also, to avoid (even) the one-time execution of sys_lstat() syscalls on disperse volumes or replicate volumes when granular entry self-heal is disabled, we pass a key in afr_selfheal_undo_pending() indicating to index that this xattrop is on a granular directory index. Index will accordingly decide whether or not to attempt the index state initialization. Change-Id: I616d9a4b3704066f4a2770d3ca307f7dca9122e0 BUG: 1331323 Signed-off-by: Krutika Dhananjay Reviewed-on: http://review.gluster.org/14870 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Anuradha Talur Reviewed-by: Pranith Kumar Karampuri --- xlators/features/index/src/index.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/xlators/features/index/src/index.c b/xlators/features/index/src/index.c index 4f431648913..7b8713c89ef 100644 --- a/xlators/features/index/src/index.c +++ b/xlators/features/index/src/index.c @@ -945,6 +945,7 @@ xattrop_index_action (xlator_t *this, index_local_t *local, dict_t *xattr, int i = 0; int ret = 0; int zfilled[XATTROP_TYPE_END] = {0,}; + int8_t value = 0; char *subdir = NULL; dict_t *req_xdata = NULL; inode_t *inode = NULL; @@ -959,22 +960,32 @@ xattrop_index_action (xlator_t *this, index_local_t *local, dict_t *xattr, _check_key_is_zero_filled, zfilled); _index_action (this, inode, zfilled); - if (req_xdata) + if (req_xdata) { ret = index_entry_action (this, inode, req_xdata, GF_XATTROP_ENTRY_OUT_KEY); - if (zfilled[XATTROP] == 1) { - subdir = index_get_subdir_from_type (ENTRY_CHANGES); - ret = index_inode_ctx_get (inode, this, &ctx); - if (ctx->state[ENTRY_CHANGES] == UNKNOWN) - index_init_state (this, inode, ctx, subdir); - if (ctx->state[ENTRY_CHANGES] == IN) { - ret = index_del (this, inode->gfid, subdir, - ENTRY_CHANGES); - ctx->state[ENTRY_CHANGES] = NOTIN; - } + ret = dict_get_int8 (req_xdata, GF_XATTROP_PURGE_INDEX, &value); + if ((ret) || (value == 0)) + goto out; + } + + if (zfilled[XATTROP] != 1) + goto out; + + if (inode->ia_type != IA_IFDIR) + goto out; + + subdir = index_get_subdir_from_type (ENTRY_CHANGES); + ret = index_inode_ctx_get (inode, this, &ctx); + if (ctx->state[ENTRY_CHANGES] == UNKNOWN) + index_init_state (this, inode, ctx, subdir); + if (ctx->state[ENTRY_CHANGES] == IN) { + ret = index_del (this, inode->gfid, subdir, + ENTRY_CHANGES); + ctx->state[ENTRY_CHANGES] = NOTIN; } +out: return; } -- cgit