From 69c434432853e2ba1ee53296f05c6a54ab300d02 Mon Sep 17 00:00:00 2001 From: Raghavendra Bhat Date: Fri, 12 Jun 2015 15:12:05 +0530 Subject: libgfapi: send explicit lookups on inodes linked in readdirp Backport of http://review.gluster.org/11236 If the inode is linked via readdirp, then the consuners of gfapi which are using handles (got either in lookup or readdirp) might not send an explicit lookup on that object again (ex: NFS, samba, USS). If there is a replicate volume where the replicas of the object are not in sync, then readdirp followed by fops might lead data being served from the subvolume which is not in sync with latest data. And since lookup is needed to trigger self-heal on that object the consumers might keep getting wrong data until an explicit lookup is not done. Fuse handles this situation by sending an explicit lookup by itself (fuse xlator) on those inodes which are linked via readdirp, whenever a fop comes on that inode. The same procedure is done in gfapi as well to address this situation. Thanks to shyam(srangana@redhat.com) for valuable inputs Change-Id: I4230fae8e0b01a95c056282b08ed30832d4804a7 BUG: 1240190 Signed-off-by: Raghavendra Bhat Reviewed-on: http://review.gluster.org/11545 Tested-by: NetBSD Build System Tested-by: Gluster Build System Reviewed-by: Shyamsundar Ranganathan Reviewed-by: Niels de Vos --- libglusterfs/src/inode.c | 31 +++++++++++++++++++++++++++++++ libglusterfs/src/inode.h | 6 ++++++ 2 files changed, 37 insertions(+) (limited to 'libglusterfs') diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c index 7d3215ed16e..579b94ca036 100644 --- a/libglusterfs/src/inode.c +++ b/libglusterfs/src/inode.c @@ -1775,6 +1775,37 @@ out: return inode; } +void +inode_set_need_lookup (inode_t *inode, xlator_t *this) +{ + uint64_t need_lookup = 1; + + if (!inode | !this) + return; + + inode_ctx_set (inode, this, &need_lookup); + + return; +} + +gf_boolean_t +inode_needs_lookup (inode_t *inode, xlator_t *this) +{ + uint64_t need_lookup = 0; + gf_boolean_t ret = _gf_false; + + if (!inode || !this) + return ret; + + inode_ctx_get (inode, this, &need_lookup); + if (need_lookup) { + ret = _gf_true; + need_lookup = 0; + inode_ctx_set (inode, this, &need_lookup); + } + + return ret; +} int __inode_ctx_set2 (inode_t *inode, xlator_t *xlator, uint64_t *value1_p, diff --git a/libglusterfs/src/inode.h b/libglusterfs/src/inode.h index 474dc3992fc..b8bac7932c3 100644 --- a/libglusterfs/src/inode.h +++ b/libglusterfs/src/inode.h @@ -272,4 +272,10 @@ inode_ctx_merge (fd_t *fd, inode_t *inode, inode_t *linked_inode); int inode_is_linked (inode_t *inode); +void +inode_set_need_lookup (inode_t *inode, xlator_t *this); + +gf_boolean_t +inode_needs_lookup (inode_t *inode, xlator_t *this); + #endif /* _INODE_H */ -- cgit