From patchwork Tue May 31 23:16:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 9145789 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 1E2E360752 for ; Tue, 31 May 2016 23:21:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1137A26464 for ; Tue, 31 May 2016 23:21:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06504266CC; Tue, 31 May 2016 23:21:03 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A2AEE26464 for ; Tue, 31 May 2016 23:21:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u4VNHPdY027633; Tue, 31 May 2016 19:17:25 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u4VNGtCE026192 for ; Tue, 31 May 2016 19:16:55 -0400 Received: from redhat.com (octiron.msp.redhat.com [10.15.80.209]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id u4VNGrta011743; Tue, 31 May 2016 19:16:54 -0400 Received: by redhat.com (sSMTP sendmail emulation); Tue, 31 May 2016 18:16:53 -0500 From: "Benjamin Marzinski" To: device-mapper development Date: Tue, 31 May 2016 18:16:45 -0500 Message-Id: <1464736610-20027-3-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.24 X-loop: dm-devel@redhat.com Cc: Christophe Varoqui Subject: [dm-devel] [PATCH 2/7] libmultipath: remove calls to dm_udev_complete 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 There were two places where the code was calling dm_udev_complete, when dm_task_set_cookie() failed and when a subsequent call dm_task_run() failed. It is correct in neither of these cases. If dm_task_set_cookie() fails, device mapper will zero out the cookie before returning, so there is nothing to complete. If it succeeds and there is a cookie, something has to wait on it, or it will hang around in the system forever. dm_udev_complete() will not wait on the cookie or clean it up. Its job is to signal to the waiters that they are done waiting. This is called for us when dm_task_run() fails, so calling dm_udev_wait() then will not block but immediately clean up the cookie. This patch simply removes all of the dm_udev_complete() calls. Signed-off-by: Benjamin Marzinski --- kpartx/devmapper.c | 20 ++++---------------- libmultipath/devmapper.c | 17 +++-------------- 2 files changed, 7 insertions(+), 30 deletions(-) diff --git a/kpartx/devmapper.c b/kpartx/devmapper.c index e006bc3..c5ba39d 100644 --- a/kpartx/devmapper.c +++ b/kpartx/devmapper.c @@ -77,19 +77,13 @@ dm_simplecmd (int task, const char *name, int no_flush, uint16_t udev_flags) { #ifdef LIBDM_API_COOKIE if (!udev_sync) udev_flags |= DM_UDEV_DISABLE_LIBRARY_FALLBACK; - if (udev_wait_flag && !dm_task_set_cookie(dmt, &cookie, udev_flags)) { - dm_udev_complete(cookie); + if (udev_wait_flag && !dm_task_set_cookie(dmt, &cookie, udev_flags)) goto out; - } #endif r = dm_task_run(dmt); #ifdef LIBDM_API_COOKIE - if (udev_wait_flag) { - if (!r) - dm_udev_complete(cookie); - else + if (udev_wait_flag) dm_udev_wait(cookie); - } #endif out: dm_task_destroy(dmt); @@ -145,19 +139,13 @@ dm_addmap (int task, const char *name, const char *target, if (!udev_sync) udev_flags = DM_UDEV_DISABLE_LIBRARY_FALLBACK; if (task == DM_DEVICE_CREATE && - !dm_task_set_cookie(dmt, &cookie, udev_flags)) { - dm_udev_complete(cookie); + !dm_task_set_cookie(dmt, &cookie, udev_flags)) goto addout; - } #endif r = dm_task_run (dmt); #ifdef LIBDM_API_COOKIE - if (task == DM_DEVICE_CREATE) { - if (!r) - dm_udev_complete(cookie); - else + if (task == DM_DEVICE_CREATE) dm_udev_wait(cookie); - } #endif addout: dm_task_destroy (dmt); diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index 6d1a5d6..ce884e2 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -237,12 +237,8 @@ dm_simplecmd (int task, const char *name, int no_flush, int need_sync, uint16_t r = dm_task_run (dmt); - if (udev_wait_flag) { - if (!r) - dm_udev_complete(cookie); - else + if (udev_wait_flag) dm_udev_wait(cookie); - } out: dm_task_destroy (dmt); return r; @@ -325,12 +321,8 @@ dm_addmap (int task, const char *target, struct multipath *mpp, r = dm_task_run (dmt); - if (task == DM_DEVICE_CREATE) { - if (!r) - dm_udev_complete(cookie); - else + if (task == DM_DEVICE_CREATE) dm_udev_wait(cookie); - } freeout: if (prefixed_uuid) FREE(prefixed_uuid); @@ -1431,10 +1423,7 @@ dm_rename (const char * old, char * new) goto out; r = dm_task_run(dmt); - if (!r) - dm_udev_complete(cookie); - else - dm_udev_wait(cookie); + dm_udev_wait(cookie); out: dm_task_destroy(dmt);