From 3c474a042aed68659fe0cfdf32e01285bde9f689 Mon Sep 17 00:00:00 2001 From: Venky Shankar Date: Sun, 15 Mar 2015 03:43:49 +0530 Subject: core: Add inode context merge callback Certain translators may require to update the inode context of an already linked inode before unwinding the call to the client. Normally, such a case in encountered during parallel operations when a fresh inode is chosen at call (wind) time. In the callback path, one of inodes is successfully linked in the inode table, thereby the other inodes being thrown away (and the inode pointers for these calls being pointed to the linked inode). Translators which may have strict dependency on the correct value in the inode context would get stale values in inode context. This patch introduces a new callback which provides gives translators an opportunity to "patch" their respective inode contexts. Note that, as of now, this callback is only invoked during create()s unwind path. Although this might needed to be done for all dentry fops and lookup, but let that be done as an when required (bitrot stub requires this *only* for create()). Change-Id: I6cd91c2af473c44d1511208060d3978e580c67a6 BUG: 1170075 Original-Author: Raghavendra Bhat Original-Author: Venky Shankar Signed-off-by: Venky Shankar Reviewed-on: http://review.gluster.org/9913 Reviewed-by: Vijay Bellur Tested-by: Vijay Bellur --- libglusterfs/src/inode.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'libglusterfs/src/inode.c') diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c index a8958fa3bcc..1ed897ef5ec 100644 --- a/libglusterfs/src/inode.c +++ b/libglusterfs/src/inode.c @@ -344,6 +344,38 @@ __inode_destroy (inode_t *inode) mem_put (inode); } +void +inode_ctx_merge (fd_t *fd, inode_t *inode, inode_t *linked_inode) +{ + int index = 0; + xlator_t *xl = NULL; + xlator_t *old_THIS = NULL; + + if (!fd || !inode || !linked_inode) { + gf_log_callingfn (THIS->name, GF_LOG_WARNING, "invalid inode"); + return; + } + + if (!inode->_ctx || !linked_inode->_ctx) { + gf_log_callingfn (THIS->name, GF_LOG_WARNING, + "invalid inode context"); + return; + } + + for (; index < inode->table->ctxcount; index++) { + if (inode->_ctx[index].xl_key) { + xl = (xlator_t *)(long) inode->_ctx[index].xl_key; + + old_THIS = THIS; + THIS = xl; + if (xl->cbks->ictxmerge) + xl->cbks->ictxmerge (xl, fd, + inode, linked_inode); + THIS = old_THIS; + } + } +} + static void __inode_activate (inode_t *inode) { -- cgit