summaryrefslogtreecommitdiffstats
path: root/api/src/glfs-fops.c
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendra@redhat.com>2015-06-12 15:12:05 +0530
committerNiels de Vos <ndevos@redhat.com>2015-07-06 08:14:02 -0700
commit69c434432853e2ba1ee53296f05c6a54ab300d02 (patch)
tree5a72c7c4d03bd57b47ab143c2b7e114e405d9f01 /api/src/glfs-fops.c
parent36a5c9beb60fe34c24a6fd7bf222f16e62a679ef (diff)
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 <raghavendra@redhat.com> Reviewed-on: http://review.gluster.org/11545 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com> Reviewed-by: Niels de Vos <ndevos@redhat.com>
Diffstat (limited to 'api/src/glfs-fops.c')
-rw-r--r--api/src/glfs-fops.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c
index e1762ae1285..b66f336338d 100644
--- a/api/src/glfs-fops.c
+++ b/api/src/glfs-fops.c
@@ -2270,6 +2270,7 @@ glfd_entry_refresh (struct glfs_fd *glfd, int plus)
xlator_t *subvol = NULL;
gf_dirent_t entries;
gf_dirent_t old;
+ gf_dirent_t *entry = NULL;
int ret = -1;
fd_t *fd = NULL;
@@ -2304,8 +2305,20 @@ glfd_entry_refresh (struct glfs_fd *glfd, int plus)
&entries, NULL, NULL);
DECODE_SYNCOP_ERR (ret);
if (ret >= 0) {
- if (plus)
+ if (plus) {
+ /**
+ * Set inode_needs_lookup flag before linking the
+ * inode. Doing it later post linkage might lead
+ * to a race where a fop comes after inode link
+ * but before setting need_lookup flag.
+ */
+ list_for_each_entry (entry, &glfd->entries, list) {
+ if (entry->inode)
+ inode_set_need_lookup (entry->inode, THIS);
+ }
+
gf_link_inodes_from_dirent (THIS, fd->inode, &entries);
+ }
list_splice_init (&glfd->entries, &old.list);
list_splice_init (&entries.list, &glfd->entries);
@@ -2314,6 +2327,7 @@ glfd_entry_refresh (struct glfs_fd *glfd, int plus)
errno = 0;
}
+
if (ret > 0)
glfd->next = list_entry (glfd->entries.next, gf_dirent_t, list);