From patchwork Tue May 31 23:16:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 9145781 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.web.codeaurora.org (Postfix) with ESMTP id 418AD60752 for ; Tue, 31 May 2016 23:20:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21D3A263DC for ; Tue, 31 May 2016 23:20:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01FB9266D8; Tue, 31 May 2016 23:20:42 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) (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 94671263DC for ; Tue, 31 May 2016 23:20:42 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4VNGscS029361; Tue, 31 May 2016 19:16:55 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u4VNGrwm026179 for ; Tue, 31 May 2016 19:16:53 -0400 Received: from redhat.com (octiron.msp.redhat.com [10.15.80.209]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id u4VNGq8r006122; Tue, 31 May 2016 19:16:52 -0400 Received: by redhat.com (sSMTP sendmail emulation); Tue, 31 May 2016 18:16:52 -0500 From: "Benjamin Marzinski" To: device-mapper development Date: Tue, 31 May 2016 18:16:44 -0500 Message-Id: <1464736610-20027-2-git-send-email-bmarzins@redhat.com> In-Reply-To: <1464736610-20027-1-git-send-email-bmarzins@redhat.com> References: <1464736610-20027-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: dm-devel@redhat.com Cc: Christophe Varoqui Subject: [dm-devel] [PATCH 1/7] multipathd: handler fixes 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-Virus-Scanned: ClamAV using ClamSMTP We now have unlocked handlers, but these can't be used to call functions that will access the pathvec, mpvec, or conf, since these are what the vecs lock protects. cli_list_config and cli_list_blacklist both need to access conf, so they can't be unlocked handlers. Also, if parse_cmd fails to lock the vecs->lock when it calls pthread_mutex_timedlock, we can't call unlock() on it, because unlocking a mutex you haven't locked causes undefined behviour. So we need to only execute the handler if didn't timeout trying to acquire the lock. Signed-off-by: Benjamin Marzinski --- multipathd/cli.c | 2 +- multipathd/main.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/multipathd/cli.c b/multipathd/cli.c index d991cd0..1925d82 100644 --- a/multipathd/cli.c +++ b/multipathd/cli.c @@ -496,7 +496,7 @@ parse_cmd (char * cmd, char ** reply, int * len, void * data, int timeout ) pthread_testcancel(); r = h->fn(cmdvec, reply, len, data); } - lock_cleanup_pop(vecs->lock); + pthread_cleanup_pop(!r); } else r = h->fn(cmdvec, reply, len, data); free_keys(cmdvec); diff --git a/multipathd/main.c b/multipathd/main.c index 2c7486d..77c802b 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -1132,8 +1132,8 @@ uxlsnrloop (void * ap) set_handler_callback(LIST+MAP+TOPOLOGY, cli_list_map_topology); set_handler_callback(LIST+MAP+FMT, cli_list_map_fmt); set_handler_callback(LIST+MAP+RAW+FMT, cli_list_map_fmt); - set_unlocked_handler_callback(LIST+CONFIG, cli_list_config); - set_unlocked_handler_callback(LIST+BLACKLIST, cli_list_blacklist); + set_handler_callback(LIST+CONFIG, cli_list_config); + set_handler_callback(LIST+BLACKLIST, cli_list_blacklist); set_handler_callback(LIST+DEVICES, cli_list_devices); set_handler_callback(LIST+WILDCARDS, cli_list_wildcards); set_handler_callback(ADD+PATH, cli_add_path);