From patchwork Sat Oct 29 02:55:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 9403053 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 5F3CC60588 for ; Sat, 29 Oct 2016 02:58:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F66C2A6B1 for ; Sat, 29 Oct 2016 02:58:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E1532A6A6; Sat, 29 Oct 2016 02:58:45 +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 C3AA92A6A6 for ; Sat, 29 Oct 2016 02:58:44 +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 u9T2uVgQ057426; Fri, 28 Oct 2016 22:56:31 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u9T2tgUl026913 for ; Fri, 28 Oct 2016 22:55:42 -0400 Received: from redhat.com (octiron.msp.redhat.com [10.15.80.209]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id u9T2teut000557; Fri, 28 Oct 2016 22:55:40 -0400 Received: by redhat.com (sSMTP sendmail emulation); Fri, 28 Oct 2016 21:55:40 -0500 From: "Benjamin Marzinski" To: device-mapper development Date: Fri, 28 Oct 2016 21:55:24 -0500 Message-Id: <1477709726-5442-9-git-send-email-bmarzins@redhat.com> In-Reply-To: <1477709726-5442-1-git-send-email-bmarzins@redhat.com> References: <1477709726-5442-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-loop: dm-devel@redhat.com Subject: [dm-devel] [PATCH 08/10] fix INIT_REQUESTED_UDEV code 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 uev_update_path was not checking pp->initialized to see if multipathd had requested that the path be reinitialized unless the path's read-only state had changed. This kept the reinitialization code from running in most cases where it was supposed to. This patch reorders the function to move that check outside the read-only status change code block. This does mean that uev_update_path now always grabs the vecs lock, where before it would only be grabbed if the read-only status had changed. If people are worried about this, I can add some code to limit this so that uev_update_path will only grab it if there is a chance that it needs to reinitialize the path. Cc: Hannes Reinecke Signed-off-by: Benjamin Marzinski Reviewed-by: Hannes Reinecke --- multipathd/main.c | 54 +++++++++++++++++++----------------------------------- 1 file changed, 19 insertions(+), 35 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index f423e35..dbb4554 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -957,51 +957,35 @@ static int uev_update_path (struct uevent *uev, struct vectors * vecs) { int ro, retval = 0; + struct path * pp; ro = uevent_get_disk_ro(uev); - if (ro >= 0) { - struct path * pp; - struct multipath *mpp = NULL; + pthread_cleanup_push(cleanup_lock, &vecs->lock); + lock(&vecs->lock); + pthread_testcancel(); - condlog(2, "%s: update path write_protect to '%d' (uevent)", - uev->kernel, ro); - pthread_cleanup_push(cleanup_lock, &vecs->lock); - lock(&vecs->lock); - pthread_testcancel(); - /* - * pthread_mutex_lock() and pthread_mutex_unlock() - * need to be at the same indentation level, hence - * this slightly convoluted codepath. - */ - pp = find_path_by_dev(vecs->pathvec, uev->kernel); - if (pp) { - if (pp->initialized == INIT_REQUESTED_UDEV) { - retval = 2; - } else { - mpp = pp->mpp; - if (mpp && mpp->wait_for_udev) { - mpp->wait_for_udev = 2; - mpp = NULL; - retval = 0; - } - } - if (mpp) { - retval = reload_map(vecs, mpp, 0, 1); + pp = find_path_by_dev(vecs->pathvec, uev->kernel); + if (pp) { + struct multipath *mpp = pp->mpp; + + if (pp->initialized == INIT_REQUESTED_UDEV) + retval = uev_add_path(uev, vecs); + else if (mpp && ro >= 0) { + condlog(2, "%s: update path write_protect to '%d' (uevent)", uev->kernel, ro); + if (mpp->wait_for_udev) + mpp->wait_for_udev = 2; + else { + retval = reload_map(vecs, mpp, 0, 1); condlog(2, "%s: map %s reloaded (retval %d)", uev->kernel, mpp->alias, retval); } } - lock_cleanup_pop(vecs->lock); - if (!pp) { - condlog(0, "%s: spurious uevent, path not found", - uev->kernel); - return 1; - } - if (retval == 2) - return uev_add_path(uev, vecs); } + lock_cleanup_pop(vecs->lock); + if (!pp) + condlog(0, "%s: spurious uevent, path not found", uev->kernel); return retval; }