From 4c08d36e7c6f189499f2340eb529b7f4ceff57f6 Mon Sep 17 00:00:00 2001 From: Xavier Hernandez Date: Thu, 9 Jun 2016 16:53:19 +0200 Subject: cluster/dht: Fix unsafe iteration on inode->fd_list When DHT traverses the inode->fd_list, it does that in an unsafe way that can generate races with fd_unref() called from other threads. This patch fixes this problem taking the inode->lock and adding a reference to the fd while it's being used outside of the mutex protected region. A minor change in storage/posix has been done to also access the inode->fd_list in a safe way. Change-Id: I10d469ca6a8f76e950a8c9779ae9c8b70f88ef93 BUG: 1344340 Signed-off-by: Xavier Hernandez Reviewed-on: http://review.gluster.org/14682 CentOS-regression: Gluster Build System Smoke: Gluster Build System NetBSD-regression: NetBSD Build System Reviewed-by: Raghavendra G --- xlators/storage/posix/src/posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xlators/storage/posix/src/posix.c') diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index c6bf5174186..2320bf13449 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -4388,7 +4388,7 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, } if (loc->inode && name && !strcmp (name, GLUSTERFS_OPEN_FD_COUNT)) { - if (!list_empty (&loc->inode->fd_list)) { + if (!fd_list_empty (loc->inode)) { ret = dict_set_uint32 (dict, (char *)name, 1); if (ret < 0) gf_msg (this->name, GF_LOG_WARNING, 0, -- cgit