From patchwork Tue Dec 27 08:03:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tang.junhui@zte.com.cn X-Patchwork-Id: 9489041 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 5BB5062AB0 for ; Tue, 27 Dec 2016 08:07:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C7ED20223 for ; Tue, 27 Dec 2016 08:07:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41077204BE; Tue, 27 Dec 2016 08:07:19 +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 mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) (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 3D670203C0 for ; Tue, 27 Dec 2016 08:07:17 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uBR85XZV028220; Tue, 27 Dec 2016 03:05:34 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id uBR85VNP020964 for ; Tue, 27 Dec 2016 03:05:31 -0500 Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uBR85VQY016910 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 27 Dec 2016 03:05:31 -0500 Received: from mx5.zte.com.cn (mx5.zte.com.cn [63.217.80.70]) by mx1.redhat.com (Postfix) with ESMTP id 7F0368FCF3 for ; Tue, 27 Dec 2016 08:05:29 +0000 (UTC) X-MAILFROM: X-RCPTTO: X-FROMIP: 10.30.3.20 X-SEG-Scaned: 1 X-Received: unknown,10.30.3.20,20161227160232 Received: from unknown (HELO mse01.zte.com.cn) (10.30.3.20) by localhost with (AES256-SHA encrypted) SMTP; 27 Dec 2016 08:02:32 -0000 Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id uBR84hB8014009; Tue, 27 Dec 2016 16:04:43 +0800 (GMT-8) (envelope-from tang.junhui@zte.com.cn) Received: from localhost.localdomain ([10.118.202.203]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2016122716044648-13730 ; Tue, 27 Dec 2016 16:04:46 +0800 From: tang.junhui@zte.com.cn To: christophe.varoqui@opensvc.com, hare@suse.de, bmarzins@redhat.com, mwilck@suse.com, bart.vanassche@sandisk.com Date: Tue, 27 Dec 2016 16:03:23 +0800 Message-Id: <1482825809-9528-7-git-send-email-tang.junhui@zte.com.cn> In-Reply-To: <1482825809-9528-1-git-send-email-tang.junhui@zte.com.cn> References: <1482825809-9528-1-git-send-email-tang.junhui@zte.com.cn> X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2016-12-27 16:04:46, Serialize by Router on notes_smtp/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2016-12-27 16:04:27, Serialize complete at 2016-12-27 16:04:27 X-MAIL: mse01.zte.com.cn uBR84hB8014009 X-HQIP: 127.0.0.1 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 199 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 27 Dec 2016 08:05:30 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 27 Dec 2016 08:05:30 +0000 (UTC) for IP:'63.217.80.70' DOMAIN:'mx5.zte.com.cn' HELO:'mx5.zte.com.cn' FROM:'tang.junhui@zte.com.cn' RCPT:'' X-RedHat-Spam-Score: -4.997 (BAYES_50, DCC_REPUT_00_12, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, SPF_PASS) 63.217.80.70 mx5.zte.com.cn 63.217.80.70 mx5.zte.com.cn X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-loop: dm-devel@redhat.com Cc: zhang.kai16@zte.com.cn, dm-devel@redhat.com, tang.junhui@zte.com.cn, tang.wenjun3@zte.com.cn Subject: [dm-devel] [PATCH 06/12] multipathd: move uev_discard() to uevent.c and change its name to uevent_can_discard() 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 From: tang.junhui Move uev_discard() form uevent processing thread to uevent listening thread to discard unnecessary uevents as soon as possible. Change-Id: Iaac159ffe3930e53c3325d1069c3ed497e440c0c Signed-off-by: tang.wenjun --- libmultipath/uevent.c | 28 ++++++++++++++++++++++++++++ multipathd/main.c | 25 ------------------------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/libmultipath/uevent.c b/libmultipath/uevent.c index 181b3b8..ac49cac 100644 --- a/libmultipath/uevent.c +++ b/libmultipath/uevent.c @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -80,6 +81,28 @@ struct uevent * alloc_uevent (void) return uev; } +bool +uevent_can_discard(char *devpath) +{ + char *tmp; + char a[11], b[11]; + + /* + * keep only block devices, discard partitions + */ + tmp = strstr(devpath, "/block/"); + if (tmp == NULL){ + condlog(4, "no /block/ in '%s'", devpath); + return true; + } + if (sscanf(tmp, "/block/%10s", a) != 1 || + sscanf(tmp, "/block/%10[^/]/%10s", a, b) == 2) { + condlog(4, "discard event on %s", devpath); + return true; + } + return false; +} + void service_uevq(struct list_head *tmpq) { @@ -527,6 +550,11 @@ int uevent_listen(struct udev *udev) uev = uevent_from_udev_device(dev); if (!uev) continue; + if (uevent_can_discard(uev->devpath)) { + udev_device_unref(uev->udev); + FREE(uev); + continue; + } list_add_tail(&uev->node, &uevlisten_tmp); events++; continue; diff --git a/multipathd/main.c b/multipathd/main.c index 68c8e17..51f7b60 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -1087,28 +1087,6 @@ uxsock_trigger (char * str, char ** reply, int * len, void * trigger_data) return r; } -static int -uev_discard(char * devpath) -{ - char *tmp; - char a[11], b[11]; - - /* - * keep only block devices, discard partitions - */ - tmp = strstr(devpath, "/block/"); - if (tmp == NULL){ - condlog(4, "no /block/ in '%s'", devpath); - return 1; - } - if (sscanf(tmp, "/block/%10s", a) != 1 || - sscanf(tmp, "/block/%10[^/]/%10s", a, b) == 2) { - condlog(4, "discard event on %s", devpath); - return 1; - } - return 0; -} - int uev_trigger (struct uevent * uev, void * trigger_data) { @@ -1118,9 +1096,6 @@ uev_trigger (struct uevent * uev, void * trigger_data) vecs = (struct vectors *)trigger_data; - if (uev_discard(uev->devpath)) - return 0; - pthread_cleanup_push(config_cleanup, NULL); pthread_mutex_lock(&config_lock); if (running_state != DAEMON_IDLE &&