From patchwork Mon Aug 29 11:09:18 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: 9303611 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 602116077C for ; Mon, 29 Aug 2016 11:14:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51A34285AA for ; Mon, 29 Aug 2016 11:14:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 46004285F4; Mon, 29 Aug 2016 11:14:09 +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 1EE36285AA for ; Mon, 29 Aug 2016 11:14:07 +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 u7TBASdP017653; Mon, 29 Aug 2016 07:10:29 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u7TBAR0D026983 for ; Mon, 29 Aug 2016 07:10:27 -0400 Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7TBARgT011975 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Mon, 29 Aug 2016 07:10:27 -0400 Received: from mx5.zte.com.cn (mx5.zte.com.cn [63.217.80.70]) by mx1.redhat.com (Postfix) with ESMTP id A24EA8A4DD for ; Mon, 29 Aug 2016 11:10:25 +0000 (UTC) Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Websense Email Security Gateway with ESMTP id CFC0417F6922D; Mon, 29 Aug 2016 19:10:19 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id u7TBAEWi096851; Mon, 29 Aug 2016 19:10:14 +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 2016082919101676-761066 ; Mon, 29 Aug 2016 19:10:16 +0800 From: tang.junhui@zte.com.cn To: christophe varoqui Date: Mon, 29 Aug 2016 19:09:18 +0800 Message-Id: <1472468958-11300-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-08-29 19:10:16, Serialize by Router on notes_smtp/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2016-08-29 19:10:02, Serialize complete at 2016-08-29 19:10:02 X-MAIL: mse01.zte.com.cn u7TBAEWi096851 X-Greylist: Sender IP whitelisted by DNSRBL, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 29 Aug 2016 11:10:25 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 29 Aug 2016 11:10:25 +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: -3.428 (BAYES_50, DCC_REPUT_00_12, RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2, 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.23 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-loop: dm-devel@redhat.com Cc: zhang.kai16@zte.com.cn, dm-devel@redhat.com, "tang.junhui" Subject: [dm-devel] [PATCH] kpartx: partitions of mapped devices cannot be created in redhat OS 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" Environment variables such as DM_TABLE_STATE are used in kpartx.rules which exported by "dmsetup export" in previous udev rules in SuSE OS, however, there is no such command "dmsetup export" in redhat OS, so these environment variables are not initialized and partitions cannot be created. This patch replace "dmsetup export" with "dmsetup info" to get the status of mapped device, which can work well both in SuSE and redhat OS. Signed-off-by: tang.junhui --- kpartx/kpartx.rules | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kpartx/kpartx.rules b/kpartx/kpartx.rules index 1713f3c..8c8b836 100644 --- a/kpartx/kpartx.rules +++ b/kpartx/kpartx.rules @@ -7,8 +7,12 @@ KERNEL!="dm-*", GOTO="kpartx_end" ACTION=="remove", GOTO="kpartx_end" -ENV{DM_TABLE_STATE}!="LIVE", GOTO="kpartx_end" -ENV{DM_DEPS}=="0", GOTO="kpartx_end" +ENV{DMSETUP_SBIN_PATH}="/sbin" +TEST!="$env{DMSETUP_SBIN_PATH}/dmsetup", ENV{DMSETUP_SBIN_PATH}="/usr/sbin" +IMPORT{program}="$env{DMSETUP_SBIN_PATH}/dmsetup info -j %M -m %m -c --nameprefixes --noheadings --rows -o tables_loaded,device_count" + +ENV{DM_TABLES_LOADED}!="Live", GOTO="kpartx_end" +ENV{DM_DEVICE_COUNT}=="0", GOTO="kpartx_end" ENV{DM_UUID}=="?*", IMPORT{program}=="kpartx_id %M %m $env{DM_UUID}" @@ -37,7 +41,7 @@ ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", \ # Create dm tables for partitions ENV{DM_ACTION}=="PATH_FAILED|PATH_REINSTATED", GOTO="kpartx_end" ENV{DM_NR_VALID_PATHS}=="0", GOTO="kpartx_end" -ENV{DM_STATE}!="SUSPENDED", ENV{DM_UUID}=="mpath-*", \ +ENV{DM_SUSPENDED}!="Suspended", ENV{DM_UUID}=="mpath-*", \ RUN+="/sbin/kpartx -u -p -part /dev/$name" LABEL="kpartx_end"