From patchwork Tue Jan 8 13:54:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 1946201 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by patchwork1.kernel.org (Postfix) with ESMTP id DF3193FC5A for ; Tue, 8 Jan 2013 13:58:51 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r08Du2fw019982; Tue, 8 Jan 2013 08:56:02 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r08DsYPS004704 for ; Tue, 8 Jan 2013 08:54:34 -0500 Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.21]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r08DsYXd010418 for ; Tue, 8 Jan 2013 08:54:34 -0500 Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r08DsXm6022841 for ; Tue, 8 Jan 2013 08:54:33 -0500 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 0BDFCA520C; Tue, 8 Jan 2013 14:54:30 +0100 (CET) From: Hannes Reinecke To: Christophe Varoqui Date: Tue, 8 Jan 2013 14:54:16 +0100 Message-Id: <1357653259-62650-39-git-send-email-hare@suse.de> In-Reply-To: <1357653259-62650-1-git-send-email-hare@suse.de> References: <1357653259-62650-1-git-send-email-hare@suse.de> X-RedHat-Spam-Score: -7.299 (BAYES_00, DCC_REPUT_00_12, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.21 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com Subject: [dm-devel] [PATCH 39/42] multipathd deadlocks during restart X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com During restart multipathd might deadlock as the uevent handler is missing a cleanup handler. Thus the thread might be terminated while it still holds the vector lock. Signed-off-by: Hannes Reinecke --- multipathd/main.c | 19 ++++++++++++------- 1 files changed, 12 insertions(+), 7 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 6c5e243..3a6e88f 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -895,13 +895,11 @@ exit_daemon (int status) if (status != 0) fprintf(stderr, "bad exit status. see daemon.log\n"); - condlog(3, "unlink pidfile"); - unlink(DEFAULT_PIDFILE); - - pthread_mutex_lock(&exit_mutex); - pthread_cond_signal(&exit_cond); - pthread_mutex_unlock(&exit_mutex); - + if (running_state != DAEMON_SHUTDOWN) { + pthread_mutex_lock(&exit_mutex); + pthread_cond_signal(&exit_cond); + pthread_mutex_unlock(&exit_mutex); + } return status; } @@ -1560,6 +1558,7 @@ child (void * param) struct vectors * vecs; struct multipath * mpp; int i; + sigset_t set; int rc, pid_rc; mlockall(MCL_CURRENT | MCL_FUTURE); @@ -1672,11 +1671,17 @@ child (void * param) running_state = DAEMON_RUNNING; pthread_cond_wait(&exit_cond, &exit_mutex); + /* Need to block these to avoid deadlocking */ + sigemptyset(&set); + sigaddset(&set, SIGTERM); + sigaddset(&set, SIGINT); + pthread_sigmask(SIG_BLOCK, &set, NULL); /* * exit path */ running_state = DAEMON_SHUTDOWN; + pthread_sigmask(SIG_UNBLOCK, &set, NULL); block_signal(SIGHUP, NULL); lock(vecs->lock); if (conf->queue_without_daemon == QUE_NO_DAEMON_OFF)