From patchwork Fri Sep 21 23:05:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 10611183 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35DD31709 for ; Fri, 21 Sep 2018 23:05:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 253EA2D79D for ; Fri, 21 Sep 2018 23:05:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 193672E0C0; Fri, 21 Sep 2018 23:05:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C0A5B2D79D for ; Fri, 21 Sep 2018 23:05:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D2800307D942; Fri, 21 Sep 2018 23:05:53 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A344F308BDAE; Fri, 21 Sep 2018 23:05:53 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6DBC84A460; Fri, 21 Sep 2018 23:05:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8LN5oZE027315 for ; Fri, 21 Sep 2018 19:05:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8F3CD7E310; Fri, 21 Sep 2018 23:05:50 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from redhat.com (octiron.msp.redhat.com [10.15.80.209]) by smtp.corp.redhat.com (Postfix) with SMTP id 4D3C37E312; Fri, 21 Sep 2018 23:05:49 +0000 (UTC) Received: by redhat.com (sSMTP sendmail emulation); Fri, 21 Sep 2018 18:05:48 -0500 From: "Benjamin Marzinski" To: device-mapper development Date: Fri, 21 Sep 2018 18:05:13 -0500 Message-Id: <1537571127-10143-6-git-send-email-bmarzins@redhat.com> In-Reply-To: <1537571127-10143-1-git-send-email-bmarzins@redhat.com> References: <1537571127-10143-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: dm-devel@redhat.com Cc: Martin Wilck Subject: [dm-devel] [PATCH v3 05/19] libmultipath: fix tur checker timeout issue X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk 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 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 21 Sep 2018 23:05:54 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP If the tur checker is run, and the tur_thread has timed out, libcheck_check() doesn't actually check if the thread is still running. This means that the thread could have already completed successfully, but the tur checker would still return PATH_TIMEOUT, instead of the value returned by the thread. This patch makes libcheck_check() actually check if the thread completed, and if so, it returns the proper value. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- libmultipath/checkers/tur.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/libmultipath/checkers/tur.c b/libmultipath/checkers/tur.c index 9f6ef51..4e2c7a8 100644 --- a/libmultipath/checkers/tur.c +++ b/libmultipath/checkers/tur.c @@ -276,12 +276,19 @@ int libcheck_check(struct checker * c) if (ct->thread) { if (tur_check_async_timeout(c)) { int running = uatomic_xchg(&ct->running, 0); - if (running) + if (running) { pthread_cancel(ct->thread); - condlog(3, "%s: tur checker timeout", ct->devt); + condlog(3, "%s: tur checker timeout", ct->devt); + MSG(c, MSG_TUR_TIMEOUT); + tur_status = PATH_TIMEOUT; + } else { + pthread_mutex_lock(&ct->lock); + tur_status = ct->state; + strlcpy(c->message, ct->message, + sizeof(c->message)); + pthread_mutex_unlock(&ct->lock); + } ct->thread = 0; - MSG(c, MSG_TUR_TIMEOUT); - tur_status = PATH_TIMEOUT; } else if (uatomic_read(&ct->running) != 0) { condlog(3, "%s: tur checker not finished", ct->devt); tur_status = PATH_PENDING;