From mboxrd@z Thu Jan 1 00:00:00 1970 From: NeilBrown Subject: Re: [PATCH] udev rules: introduce rules for cluster-md to confirm device Date: Tue, 01 Aug 2017 14:40:12 +1000 Message-ID: <87o9rzvr2r.fsf@notabene.neil.brown.name> References: <20170801031504.8452-1-gqjiang@suse.com> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Return-path: In-Reply-To: <20170801031504.8452-1-gqjiang@suse.com> Sender: linux-raid-owner@vger.kernel.org To: linux-raid@vger.kernel.org Cc: jes.sorensen@gmail.com, Guoqing Jiang List-Id: linux-raid.ids --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Tue, Aug 01 2017, Guoqing Jiang wrote: > For cluster scenario, add device is different with native raid. > When a node issues adds a device, then the node will broadcast > a message with UUID to other nodes in the cluster. If receiving > node can find the device with the specific UUID, it must confirm > the device, otherwise reports it is missing. > > Signed-off-by: Guoqing Jiang > --- > Makefile | 6 ++++-- > udev-md-clustered-confirm-device.rules | 20 ++++++++++++++++++++ > 2 files changed, 24 insertions(+), 2 deletions(-) > create mode 100644 udev-md-clustered-confirm-device.rules > > diff --git a/Makefile b/Makefile > index 021d3ad..0977f27 100644 > --- a/Makefile > +++ b/Makefile > @@ -256,8 +256,10 @@ install-man: mdadm.8 md.4 mdadm.conf.5 mdmon.8 > $(INSTALL) -D -m 644 md.4 $(DESTDIR)$(MAN4DIR)/md.4 > $(INSTALL) -D -m 644 mdadm.conf.5 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5 >=20=20 > -install-udev: udev-md-raid-arrays.rules udev-md-raid-assembly.rules udev= -md-raid-creating.rules > - @for file in 01-md-raid-creating.rules 63-md-raid-arrays.rules 64-md-ra= id-assembly.rules ; \ > +install-udev: udev-md-raid-arrays.rules udev-md-raid-assembly.rules udev= -md-raid-creating.rules \ > + udev-md-clustered-confirm-device.rules=20 > + @for file in 01-md-raid-creating.rules 63-md-raid-arrays.rules 64-md-ra= id-assembly.rules \ > + 69-md-clustered-confirm-device.rules ; \ > do sed -e 's,BINDIR,$(BINDIR),g' udev-$${file#??-} > .install.tmp.1 && \ > $(ECHO) $(INSTALL) -D -m 644 udev-$${file#??-} $(DESTDIR)$(UDEVDIR)/= rules.d/$$file ; \ > $(INSTALL) -D -m 644 .install.tmp.1 $(DESTDIR)$(UDEVDIR)/rules.d/$$f= ile ; \ > diff --git a/udev-md-clustered-confirm-device.rules b/udev-md-clustered-c= onfirm-device.rules > new file mode 100644 > index 0000000..d763e27 > --- /dev/null > +++ b/udev-md-clustered-confirm-device.rules > @@ -0,0 +1,20 @@ > +# do not edit this file, it will be overwritten on update > + > +SUBSYSTEM!=3D"block", GOTO=3D"clustermd_end" > + > +# handle md arrays > +KERNEL!=3D"md*", GOTO=3D"clustermd_end" > +ENV{DEVTYPE}!=3D"disk", GOTO=3D"clustermd_end" > + > +# Based on the received UUID, node confirms the device if > +# it is found by blkid, otherwise the node reports it is > +# missing. > +ACTION=3D=3D"change", ENV{EVENT}=3D=3D"ADD_DEVICE", ENV{DEVICE_UUID}=3D= =3D"?*", ENV{RAID_DISK}=3D=3D"?*", \ > +PROGRAM=3D"BINDIR/blkid -o device -t UUID_SUB=3D$env{DEVICE_UUID}", RESU= LT!=3D"", \ > +RUN+=3D"BINDIR/mdadm --manage $env{DEVNAME} --cluster-confirm $env{RAID_= DISK}:$result" > + > +ACTION=3D=3D"change", ENV{EVENT}=3D=3D"ADD_DEVICE", ENV{DEVICE_UUID}=3D= =3D"?*", ENV{RAID_DISK}=3D=3D"?*", \ > +PROGRAM=3D"BINDIR/blkid -o device -t UUID_SUB=3D$env{DEVICE_UUID}", RESU= LT=3D=3D"", \ > +RUN+=3D"BINDIR/mdadm --manage $env{DEVNAME} --cluster-confirm $env{RAID_= DISK}:missing" > + > +LABEL=3D"clustermd_end" > --=20 > 2.10.0 This can run "blkid" twice, which seems wasteful. I think it would be best to skip to the end if ACTION !=3D "change" and if event !=3D ADD_DEVICE etc. Then PROGRAM=3D"BINDIR/blkid -o device -t UUID_SUB=3D$env{DEVICE_UUID}", ENV{".= mdadm.blkid"} =3D "$result" Then have two rules which tests ENV{".mdadm.blkid"} and run one of the two mdadm commands. NeilBrown --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEG8Yp69OQ2HB7X0l6Oeye3VZigbkFAlmABi4ACgkQOeye3VZi gbk/zRAAvJ5h+YGAvS2P7gd0bHLt01ct4OJEPdLkYH4iHtP7uARmEgiSohjnfPQE wZPgp6ogOYT3joKqkyJM1MJMxe0lY53MEhLe31CggVLDxvMKv+29xBQ2y0h/Dc1b 8MvKklHODH6h81mPaWgILAN1TPGhR+5FSxll4zBj3Seq6cHUj+j5AinpAYqe1rh7 WF8LeJyaD04uynPNofHC3hfuDVpo1YXw1dDxlVPGWmexLCHWJAvypUko7E6h6HcC /xCKbrpIh09Pba7lraphSXeHTkPma63kVE54qxlGSoK/QJtxUwqDvclcI6Nq7OO4 ecNRRiKvGvbr47LRxGe0x9IAiNtOSmo773ipLqTf6CBYO8hsdN7gMyYH4gtGh+UZ /+Lx5v3OufWrToe7wTL9kPKJdfv3aHvL3d13tuxQf3ZBtjeAaP5pIteixVu/9u2V pJvAm/hxlK1ZsJk8IS5ip7Ig0sVTmCgiOLsapCdoNCvYQesk/KGBodCyuus1ojHx hCXFAeIIOd9gOzGfEtZXpuLcXFX4g7MtoPq1WRN15w2BRkf5ovsOu8ISoHg713KQ YiostXLQENLEMfTytkBQNxASQMrfBxm9touBDJFzeD+JN2hUN/764dSriKOUBrqC HPwjJ28wBDSF+evn9hGYPTfbzlcMlZrKHRfiSfqkxMkrDuSEjbI= =0QzS -----END PGP SIGNATURE----- --=-=-=--