|
|
3604df |
From 3c2d866a9d7e3190b1c015228daf1c622e3a4a65 Mon Sep 17 00:00:00 2001
|
|
|
3604df |
From: Rajesh Joseph <rjoseph@redhat.com>
|
|
|
3604df |
Date: Tue, 22 Nov 2016 22:25:42 +0530
|
|
|
3604df |
Subject: [PATCH 208/227] gfapi: glfs_subvol_done should NOT wait for graph
|
|
|
3604df |
migration
|
|
|
3604df |
|
|
|
3604df |
In graph_setup function glfs_subvol_done is called which
|
|
|
3604df |
is executed in an epoll thread. glfs_lock waits on other
|
|
|
3604df |
thread to finish graph migration. This can lead to dead lock
|
|
|
3604df |
if we consume all the epoll threads.
|
|
|
3604df |
|
|
|
3604df |
In general any call-back function executed in epoll thread
|
|
|
3604df |
should not call any blocking call which waits on a network
|
|
|
3604df |
reply either directly or indirectly, e.g. syncop functions
|
|
|
3604df |
should not be called in these threads.
|
|
|
3604df |
|
|
|
3604df |
As a fix we should not wait for migration in the call-back path.
|
|
|
3604df |
|
|
|
3604df |
> Signed-off-by: Rajesh Joseph <rjoseph@redhat.com>
|
|
|
3604df |
> Reviewed-on: http://review.gluster.org/15913
|
|
|
3604df |
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
|
|
|
3604df |
> Smoke: Gluster Build System <jenkins@build.gluster.org>
|
|
|
3604df |
> Reviewed-by: Niels de Vos <ndevos@redhat.com>
|
|
|
3604df |
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
|
|
|
3604df |
|
|
|
3604df |
Change-Id: If96d0689fe1b4d74631e383048cdc30b01690dc2
|
|
|
3604df |
BUG: 1396449
|
|
|
3604df |
Signed-off-by: Rajesh Joseph <rjoseph@redhat.com>
|
|
|
3604df |
Reviewed-on: https://code.engineering.redhat.com/gerrit/91699
|
|
|
3604df |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
3604df |
---
|
|
|
3604df |
api/src/glfs-internal.h | 15 ++++++++++++---
|
|
|
3604df |
api/src/glfs-resolve.c | 19 ++++++++++++-------
|
|
|
3604df |
api/src/glfs.c | 8 ++++----
|
|
|
3604df |
3 files changed, 28 insertions(+), 14 deletions(-)
|
|
|
3604df |
|
|
|
3604df |
diff --git a/api/src/glfs-internal.h b/api/src/glfs-internal.h
|
|
|
3604df |
index fc62bbf..a428224 100644
|
|
|
3604df |
--- a/api/src/glfs-internal.h
|
|
|
3604df |
+++ b/api/src/glfs-internal.h
|
|
|
3604df |
@@ -305,17 +305,26 @@ do { \
|
|
|
3604df |
we can give up the mutex during syncop calls so
|
|
|
3604df |
that bottom up calls (particularly CHILD_UP notify)
|
|
|
3604df |
can do a mutex_lock() on @glfs without deadlocking
|
|
|
3604df |
- the filesystem
|
|
|
3604df |
+ the filesystem.
|
|
|
3604df |
+
|
|
|
3604df |
+ All the fops should wait for graph migration to finish
|
|
|
3604df |
+ before starting the fops. Therefore these functions should
|
|
|
3604df |
+ call glfs_lock with wait_for_migration as true. But waiting
|
|
|
3604df |
+ for migration to finish in call-back path can result thread
|
|
|
3604df |
+ dead-locks. The reason for this is we only have finite
|
|
|
3604df |
+ number of epoll threads. so if we wait on epoll threads
|
|
|
3604df |
+ there will not be any thread left to handle outstanding
|
|
|
3604df |
+ rpc replies.
|
|
|
3604df |
*/
|
|
|
3604df |
static inline int
|
|
|
3604df |
-glfs_lock (struct glfs *fs)
|
|
|
3604df |
+glfs_lock (struct glfs *fs, gf_boolean_t wait_for_migration)
|
|
|
3604df |
{
|
|
|
3604df |
pthread_mutex_lock (&fs->mutex);
|
|
|
3604df |
|
|
|
3604df |
while (!fs->init)
|
|
|
3604df |
pthread_cond_wait (&fs->cond, &fs->mutex);
|
|
|
3604df |
|
|
|
3604df |
- while (fs->migration_in_progress)
|
|
|
3604df |
+ while (wait_for_migration && fs->migration_in_progress)
|
|
|
3604df |
pthread_cond_wait (&fs->cond, &fs->mutex);
|
|
|
3604df |
|
|
|
3604df |
return 0;
|
|
|
3604df |
diff --git a/api/src/glfs-resolve.c b/api/src/glfs-resolve.c
|
|
|
3604df |
index b84e5d8..f8b437b 100644
|
|
|
3604df |
--- a/api/src/glfs-resolve.c
|
|
|
3604df |
+++ b/api/src/glfs-resolve.c
|
|
|
3604df |
@@ -784,7 +784,7 @@ glfs_resolve_fd (struct glfs *fs, xlator_t *subvol, struct glfs_fd *glfd)
|
|
|
3604df |
{
|
|
|
3604df |
fd_t *fd = NULL;
|
|
|
3604df |
|
|
|
3604df |
- glfs_lock (fs);
|
|
|
3604df |
+ glfs_lock (fs, _gf_true);
|
|
|
3604df |
{
|
|
|
3604df |
fd = __glfs_resolve_fd (fs, subvol, glfd);
|
|
|
3604df |
}
|
|
|
3604df |
@@ -897,12 +897,17 @@ priv_glfs_subvol_done (struct glfs *fs, xlator_t *subvol)
|
|
|
3604df |
if (!subvol)
|
|
|
3604df |
return;
|
|
|
3604df |
|
|
|
3604df |
- glfs_lock (fs);
|
|
|
3604df |
+ /* For decrementing subvol->wind ref count we need not check/wait for
|
|
|
3604df |
+ * migration-in-progress flag.
|
|
|
3604df |
+ * Also glfs_subvol_done is called in call-back path therefore waiting
|
|
|
3604df |
+ * fot migration-in-progress flag can lead to dead-lock.
|
|
|
3604df |
+ */
|
|
|
3604df |
+ glfs_lock (fs, _gf_false);
|
|
|
3604df |
{
|
|
|
3604df |
ref = (--subvol->winds);
|
|
|
3604df |
active_subvol = fs->active_subvol;
|
|
|
3604df |
}
|
|
|
3604df |
- glfs_unlock (fs);
|
|
|
3604df |
+ glfs_unlock (fs);
|
|
|
3604df |
|
|
|
3604df |
if (ref == 0) {
|
|
|
3604df |
assert (subvol != active_subvol);
|
|
|
3604df |
@@ -919,7 +924,7 @@ priv_glfs_active_subvol (struct glfs *fs)
|
|
|
3604df |
xlator_t *subvol = NULL;
|
|
|
3604df |
xlator_t *old_subvol = NULL;
|
|
|
3604df |
|
|
|
3604df |
- glfs_lock (fs);
|
|
|
3604df |
+ glfs_lock (fs, _gf_true);
|
|
|
3604df |
{
|
|
|
3604df |
subvol = __glfs_active_subvol (fs);
|
|
|
3604df |
|
|
|
3604df |
@@ -968,7 +973,7 @@ glfs_cwd_set (struct glfs *fs, inode_t *inode)
|
|
|
3604df |
{
|
|
|
3604df |
int ret = 0;
|
|
|
3604df |
|
|
|
3604df |
- glfs_lock (fs);
|
|
|
3604df |
+ glfs_lock (fs, _gf_true);
|
|
|
3604df |
{
|
|
|
3604df |
ret = __glfs_cwd_set (fs, inode);
|
|
|
3604df |
}
|
|
|
3604df |
@@ -1001,7 +1006,7 @@ glfs_cwd_get (struct glfs *fs)
|
|
|
3604df |
{
|
|
|
3604df |
inode_t *cwd = NULL;
|
|
|
3604df |
|
|
|
3604df |
- glfs_lock (fs);
|
|
|
3604df |
+ glfs_lock (fs, _gf_true);
|
|
|
3604df |
{
|
|
|
3604df |
cwd = __glfs_cwd_get (fs);
|
|
|
3604df |
}
|
|
|
3604df |
@@ -1041,7 +1046,7 @@ glfs_resolve_inode (struct glfs *fs, xlator_t *subvol,
|
|
|
3604df |
{
|
|
|
3604df |
inode_t *inode = NULL;
|
|
|
3604df |
|
|
|
3604df |
- glfs_lock (fs);
|
|
|
3604df |
+ glfs_lock (fs, _gf_true);
|
|
|
3604df |
{
|
|
|
3604df |
inode = __glfs_resolve_inode(fs, subvol, object);
|
|
|
3604df |
}
|
|
|
3604df |
diff --git a/api/src/glfs.c b/api/src/glfs.c
|
|
|
3604df |
index 307e22c..9f70cce 100644
|
|
|
3604df |
--- a/api/src/glfs.c
|
|
|
3604df |
+++ b/api/src/glfs.c
|
|
|
3604df |
@@ -549,7 +549,7 @@ glfs_fd_destroy (void *data)
|
|
|
3604df |
|
|
|
3604df |
glfd = (struct glfs_fd *)data;
|
|
|
3604df |
|
|
|
3604df |
- glfs_lock (glfd->fs);
|
|
|
3604df |
+ glfs_lock (glfd->fs, _gf_true);
|
|
|
3604df |
{
|
|
|
3604df |
list_del_init (&glfd->openfds);
|
|
|
3604df |
}
|
|
|
3604df |
@@ -592,7 +592,7 @@ glfs_fd_bind (struct glfs_fd *glfd)
|
|
|
3604df |
|
|
|
3604df |
fs = glfd->fs;
|
|
|
3604df |
|
|
|
3604df |
- glfs_lock (fs);
|
|
|
3604df |
+ glfs_lock (fs, _gf_true);
|
|
|
3604df |
{
|
|
|
3604df |
list_add_tail (&glfd->openfds, &fs->openfds);
|
|
|
3604df |
}
|
|
|
3604df |
@@ -882,7 +882,7 @@ glfs_init_wait (struct glfs *fs)
|
|
|
3604df |
int ret = -1;
|
|
|
3604df |
|
|
|
3604df |
/* Always a top-down call, use glfs_lock() */
|
|
|
3604df |
- glfs_lock (fs);
|
|
|
3604df |
+ glfs_lock (fs, _gf_true);
|
|
|
3604df |
{
|
|
|
3604df |
while (!fs->init)
|
|
|
3604df |
pthread_cond_wait (&fs->cond,
|
|
|
3604df |
@@ -1256,7 +1256,7 @@ pub_glfs_get_volfile (struct glfs *fs, void *buf, size_t len)
|
|
|
3604df |
DECLARE_OLD_THIS;
|
|
|
3604df |
__GLFS_ENTRY_VALIDATE_FS (fs, invalid_fs);
|
|
|
3604df |
|
|
|
3604df |
- glfs_lock(fs);
|
|
|
3604df |
+ glfs_lock(fs, _gf_true);
|
|
|
3604df |
if (len >= fs->oldvollen) {
|
|
|
3604df |
gf_msg_trace ("glfs", 0, "copying %zu to %p", len, buf);
|
|
|
3604df |
memcpy(buf,fs->oldvolfile,len);
|
|
|
3604df |
--
|
|
|
3604df |
2.9.3
|
|
|
3604df |
|