From patchwork Mon Dec 4 13:15:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guan Junxiong X-Patchwork-Id: 10090231 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 BE7A86056E for ; Mon, 4 Dec 2017 13:16:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0A1226E78 for ; Mon, 4 Dec 2017 13:16:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B312D285FF; Mon, 4 Dec 2017 13:16:31 +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 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 2411F26E78 for ; Mon, 4 Dec 2017 13:16:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CACDA4DD49; Mon, 4 Dec 2017 13:16:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9B0375D9C6; Mon, 4 Dec 2017 13:16:25 +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 195B6180474A; Mon, 4 Dec 2017 13:16:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vB4DGEwZ025050 for ; Mon, 4 Dec 2017 08:16:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id EE5EC63768; Mon, 4 Dec 2017 13:16:14 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E8E43177E1 for ; Mon, 4 Dec 2017 13:16:11 +0000 (UTC) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1 with cipher RC4-SHA (112/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CDC4B4ACA0 for ; Mon, 4 Dec 2017 13:16:08 +0000 (UTC) Received: from 172.30.72.58 (EHLO DGGEMS407-HUB.china.huawei.com) ([172.30.72.58]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DLS67241; Mon, 04 Dec 2017 21:16:06 +0800 (CST) Received: from huawei.com (10.169.94.217) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.361.1; Mon, 4 Dec 2017 21:15:58 +0800 From: Guan Junxiong To: , Date: Mon, 4 Dec 2017 21:15:50 +0800 Message-ID: <1512393350-2956-1-git-send-email-guanjunxiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.169.94.217] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.5A254A96.0277, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 64e5ae576fa2cf9ed9e8038e37f86ebf X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 04 Dec 2017 13:16:10 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 04 Dec 2017 13:16:10 +0000 (UTC) for IP:'45.249.212.190' DOMAIN:'szxga04-in.huawei.com' HELO:'szxga04-in.huawei.com' FROM:'guanjunxiong@huawei.com' RCPT:'' X-RedHat-Spam-Score: -0.021 (RCVD_IN_DNSWL_NONE, SPF_PASS, T_RP_MATCHES_RCVD) 45.249.212.190 szxga04-in.huawei.com 45.249.212.190 szxga04-in.huawei.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: dm-devel@redhat.com Cc: guanjunxiong@huawei.com, niuhaoxin@huawei.com, shenhong09@huawei.com Subject: [dm-devel] [PATCH] multipath-tools: check null path before handle path-failed event 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: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 04 Dec 2017 13:16:30 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP In the hot-plug storage OS, if we tear down the target storage, there is a race between the path removing from the path list and handling the path-failed udev event. Therefore, we need to check null path before handle path-failed event. Signed-off-by: Guan Junxiong --- multipathd/main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 31ce923..84bb2c5 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -1073,7 +1073,7 @@ uev_pathfail_check(struct uevent *uev, struct vectors *vecs) { char *action = NULL, *devt = NULL; struct path *pp; - int r; + int r = 1; action = uevent_get_dm_action(uev); if (!action) @@ -1090,15 +1090,17 @@ uev_pathfail_check(struct uevent *uev, struct vectors *vecs) lock(&vecs->lock); pthread_testcancel(); pp = find_path_by_devt(vecs->pathvec, devt); + if (!pp) + goto out_lock; r = io_err_stat_handle_pathfail(pp); - lock_cleanup_pop(vecs->lock); - if (r) condlog(3, "io_err_stat: %s: cannot handle pathfail uevent", pp->dev); +out_lock: + lock_cleanup_pop(vecs->lock); FREE(devt); FREE(action); - return 0; + return r; out: FREE(action); return 1;