From mboxrd@z Thu Jan 1 00:00:00 1970 From: "John Stoffel" Subject: Re: [PATCH v3] udev rules: introduce rules for cluster-md to confirm device Date: Wed, 2 Aug 2017 21:43:49 -0400 Message-ID: <22914.32725.983017.495207@quad.stoffel.home> References: <20170801031504.8452-1-gqjiang@suse.com> <20170802020541.3412-1-gqjiang@suse.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20170802020541.3412-1-gqjiang@suse.com> Sender: linux-raid-owner@vger.kernel.org To: Guoqing Jiang Cc: linux-raid@vger.kernel.org, jes.sorensen@gmail.com, neilb@suse.com List-Id: linux-raid.ids >>>>> "Guoqing" == Guoqing Jiang writes: Guoqing> For cluster scenario, add device is different with native raid. Guoqing> When a node issues adds a device, then the node will broadcast Guoqing> a message with UUID to other nodes in the cluster. If receiving Guoqing> node can find the device with the specific UUID, it must confirm Guoqing> the device, otherwise reports it is missing. Guoqing> Signed-off-by: Guoqing Jiang Guoqing> --- Guoqing> Makefile | 6 ++++-- Guoqing> udev-md-clustered-confirm-device.rules | 21 +++++++++++++++++++++ Guoqing> 2 files changed, 25 insertions(+), 2 deletions(-) Guoqing> create mode 100644 udev-md-clustered-confirm-device.rules Guoqing> diff --git a/Makefile b/Makefile Guoqing> index 021d3ad..0977f27 100644 Guoqing> --- a/Makefile Guoqing> +++ b/Makefile Guoqing> @@ -256,8 +256,10 @@ install-man: mdadm.8 md.4 mdadm.conf.5 mdmon.8 Guoqing> $(INSTALL) -D -m 644 md.4 $(DESTDIR)$(MAN4DIR)/md.4 Guoqing> $(INSTALL) -D -m 644 mdadm.conf.5 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5 Guoqing> -install-udev: udev-md-raid-arrays.rules udev-md-raid-assembly.rules udev-md-raid-creating.rules Guoqing> - @for file in 01-md-raid-creating.rules 63-md-raid-arrays.rules 64-md-raid-assembly.rules ; \ Guoqing> +install-udev: udev-md-raid-arrays.rules udev-md-raid-assembly.rules udev-md-raid-creating.rules \ Guoqing> + udev-md-clustered-confirm-device.rules You have udev-md-clustered-.... here, but down below you use clustermd-end in your names. Which I find slightly annoying because they're different. Just me being annoying here. :-) I didn't check if the other raid rules have this issue as well. Guoqing> + @for file in 01-md-raid-creating.rules 63-md-raid-arrays.rules 64-md-raid-assembly.rules \ Guoqing> + 69-md-clustered-confirm-device.rules ; \ Guoqing> do sed -e 's,BINDIR,$(BINDIR),g' udev-$${file#??-} > .install.tmp.1 && \ Guoqing> $(ECHO) $(INSTALL) -D -m 644 udev-$${file#??-} $(DESTDIR)$(UDEVDIR)/rules.d/$$file ; \ Guoqing> $(INSTALL) -D -m 644 .install.tmp.1 $(DESTDIR)$(UDEVDIR)/rules.d/$$file ; \ Guoqing> diff --git a/udev-md-clustered-confirm-device.rules b/udev-md-clustered-confirm-device.rules Guoqing> new file mode 100644 Guoqing> index 0000000..3e5381e Guoqing> --- /dev/null Guoqing> +++ b/udev-md-clustered-confirm-device.rules Guoqing> @@ -0,0 +1,21 @@ Guoqing> +# do not edit this file, it will be overwritten on update Guoqing> + Guoqing> +SUBSYSTEM!="block", GOTO="clustermd_end" Guoqing> + Guoqing> +# handle md arrays Guoqing> +KERNEL!="md*", GOTO="clustermd_end" Guoqing> +ENV{DEVTYPE}!="disk", GOTO="clustermd_end" Guoqing> +ACTION!="change", GOTO="clustermd_end" Guoqing> +ENV{EVENT}!="ADD_DEVICE", GOTO="clustermd_end" Guoqing> +ENV{DEVICE_UUID}!="?*", GOTO="clustermd_end" Guoqing> +ENV{RAID_DISK}!="?*", GOTO="clustermd_end" Guoqing> + Guoqing> +# Based on the received UUID, node confirms the device if Guoqing> +# it is found by blkid, otherwise the node reports it is Guoqing> +# missing. Guoqing> +PROGRAM="BINDIR/blkid -o device -t UUID_SUB=$env{DEVICE_UUID}", ENV{.md.newdevice} = "$result" Guoqing> + Guoqing> +ENV{.md.newdevice}!="", RUN+="BINDIR/mdadm --manage $env{DEVNAME} --cluster-confirm $env{RAID_DISK}:$env{.md.newdevice}" Guoqing> +ENV{.md.newdevice}=="", RUN+="BINDIR/mdadm --manage $env{DEVNAME} --cluster-confirm $env{RAID_DISK}:missing" Guoqing> + Guoqing> +LABEL="clustermd_end" Guoqing> -- Guoqing> 2.10.0 Guoqing> -- Guoqing> To unsubscribe from this list: send the line "unsubscribe linux-raid" in Guoqing> the body of a message to majordomo@vger.kernel.org Guoqing> More majordomo info at http://vger.kernel.org/majordomo-info.html