From mboxrd@z Thu Jan 1 00:00:00 1970 From: NeilBrown Subject: Re: [PATCH V2] udev rules: introduce rules for cluster-md to confirm device Date: Wed, 02 Aug 2017 07:15:43 +1000 Message-ID: <87bmnzugzk.fsf@notabene.neil.brown.name> References: <20170801031504.8452-1-gqjiang@suse.com> <20170801081956.29777-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: <20170801081956.29777-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..08ac74a > --- /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" > +ACTION!=3D"change", GOTO=3D"clustermd_end" > +ENV{EVENT}!=3D"ADD_DEVICE", GOTO=3D"clustermd_end" Move these here is good. > + > +# 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"?*", \ leaving them here as well is careless. Maybe move the tests on DEVICE_UUID and RAID_DISK up to the "goto" section too. > +PROGRAM=3D"BINDIR/blkid -o device -t UUID_SUB=3D$env{DEVICE_UUID}", ENV{= device} =3D "$result" I don't think using a generic environment name like "device" is a good idea. This will get included in the udev database. At least include "md" or "mdadm" in the name so people know what it means. In my example I put a "." at the start. This cause the name to be excluded from the udev database. NeilBrown > + > +ENV{device}!=3D"", RUN+=3D"BINDIR/mdadm --manage $env{DEVNAME} --cluster= -confirm $env{RAID_DISK}:$env{device}" > +ENV{device}=3D=3D"", RUN+=3D"BINDIR/mdadm --manage $env{DEVNAME} --clust= er-confirm $env{RAID_DISK}:missing" > + > +LABEL=3D"clustermd_end" > --=20 > 2.10.0 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEG8Yp69OQ2HB7X0l6Oeye3VZigbkFAlmA74IACgkQOeye3VZi gbkZIBAAk8M47JSXiOuPih8VHM+1iHvc6Kpshqn+gYi28brLiYm8bJVBGo5ofmku QnCWqggId0otV7rqYbbyobUWjttPeBN2Z2a6P2GA+cJB5oAAvc6ZwoyZiEA19v2E 6yYCJn6VMaY2fvUDQP+OJryGXj+cCKS6CvsJ3RRjrSBidhyIdnGjP4/z7S55GoIR 5HxmqMPPGcHbDSXHcTQ2VgTktnCY19MLd4aRkBBuNil/ONV+rxzQTqQ3/EwBl5Nl /2yM3+nqXJfybbQPoZ5B0BAeyE26n8YWroCwK+cR0UIn0/RZ5Ked0+CJ5LnBHW6L AukoMYFWKLKUSJefiU4+HSSGvuK3Id2ynPKlzjkeS4CI2PYRvzAHkH+n3o90oiXu ggl3g36OfXZ1sbqIKlBgMKRWHRNk7a8n5XpRGf/DrjJQN75lDPXWUvd50prxDFUY X4jpIcBEIq6pb4I6cq7s1BJAiT/3xhqnbfcrHuQi0Ky0ElMs+/IdeXauECTAqq50 gY1dDyvhL9Q2yNwaV35BS7Xw9fyBAuynZx+6mC77peDmFwzNOQf18kON/sPPsmqm eeChUZhZKGJkaN4khRpGCLDq+pox0Tk4N1rqX3/2xpqYIuwOk4t8OAdXwnhV2+61 4AMCXLf6bx+nFQvNos/4ZgMLs1sF2ClzjyAGUHvhQRfz0OyyB48= =Wnch -----END PGP SIGNATURE----- --=-=-=--