Skip to contentSkip to conversation

udev rules: introduce rules for cluster-md to confirm device

PATCH Superseded Guoqing Jiang 4 participants 11 messages Aug 1, 2017 – Aug 3, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 udev rules: introduce rules for cluster-md to confirm device

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.

---
 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
Makefile +4 -2
index 021d3ad..0977f27 100644
@@ -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
 
-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-raid-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 
+	@for file in 01-md-raid-creating.rules 63-md-raid-arrays.rules 64-md-raid-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/$$file ; \
udev-md-clustered-confirm-device.rules new file +20 -0
new file mode 100644
index 0000000..d763e27
@@ -0,0 +1,20 @@
+# do not edit this file, it will be overwritten on update
+
+SUBSYSTEM!="block", GOTO="clustermd_end"
+
+# handle md arrays
+KERNEL!="md*", GOTO="clustermd_end"
+ENV{DEVTYPE}!="disk", GOTO="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=="change", ENV{EVENT}=="ADD_DEVICE", ENV{DEVICE_UUID}=="?*", ENV{RAID_DISK}=="?*", \
+PROGRAM="BINDIR/blkid -o device -t UUID_SUB=$env{DEVICE_UUID}", RESULT!="", \
+RUN+="BINDIR/mdadm --manage $env{DEVNAME} --cluster-confirm $env{RAID_DISK}:$result"
+
+ACTION=="change", ENV{EVENT}=="ADD_DEVICE", ENV{DEVICE_UUID}=="?*", ENV{RAID_DISK}=="?*", \
+PROGRAM="BINDIR/blkid -o device -t UUID_SUB=$env{DEVICE_UUID}", RESULT=="", \
+RUN+="BINDIR/mdadm --manage $env{DEVNAME} --cluster-confirm $env{RAID_DISK}:missing"
+
+LABEL="clustermd_end"
Signature · 1 line
2.10.0
#1 lore raw
Quoted 58 lines · Guoqing Jiang

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.

---
 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
Makefile +4 -2
index 021d3ad..0977f27 100644
@@ -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
 
-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-raid-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 
+	@for file in 01-md-raid-creating.rules 63-md-raid-arrays.rules 64-md-raid-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/$$file ; \
udev-md-clustered-confirm-device.rules new file +20 -0
new file mode 100644
index 0000000..d763e27
@@ -0,0 +1,20 @@
+# do not edit this file, it will be overwritten on update
+
+SUBSYSTEM!="block", GOTO="clustermd_end"
+
+# handle md arrays
+KERNEL!="md*", GOTO="clustermd_end"
+ENV{DEVTYPE}!="disk", GOTO="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=="change", ENV{EVENT}=="ADD_DEVICE", ENV{DEVICE_UUID}=="?*", ENV{RAID_DISK}=="?*", \
+PROGRAM="BINDIR/blkid -o device -t UUID_SUB=$env{DEVICE_UUID}", RESULT!="", \
+RUN+="BINDIR/mdadm --manage $env{DEVNAME} --cluster-confirm $env{RAID_DISK}:$result"
+
+ACTION=="change", ENV{EVENT}=="ADD_DEVICE", ENV{DEVICE_UUID}=="?*", ENV{RAID_DISK}=="?*", \
+PROGRAM="BINDIR/blkid -o device -t UUID_SUB=$env{DEVICE_UUID}", RESULT=="", \
+RUN+="BINDIR/mdadm --manage $env{DEVNAME} --cluster-confirm $env{RAID_DISK}:missing"
+
+LABEL="clustermd_end"
Signature · 1 line
2.10.0

This can run "blkid" twice, which seems wasteful.
I think it would be best to skip to the end if ACTION != "change" and if
event != ADD_DEVICE etc.
Then
PROGRAM="BINDIR/blkid -o device -t UUID_SUB=$env{DEVICE_UUID}", ENV{".mdadm.blkid"} = "$result"

Then have two rules which tests ENV{".mdadm.blkid"} and run one of the two mdadm commands.

NeilBrown

#2 lore raw
Quoted 66 lines · NeilBrown
Quoted 58 lines · Guoqing Jiang

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.

---
  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

Makefile +4 -2
index 021d3ad..0977f27 100644
@@ -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
 
-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-raid-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
+	@for file in 01-md-raid-creating.rules 63-md-raid-arrays.rules 64-md-raid-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/$$file ; \
udev-md-clustered-confirm-device.rules new file +20 -0
new file mode 100644
index 0000000..d763e27
@@ -0,0 +1,20 @@
+# do not edit this file, it will be overwritten on update
+
+SUBSYSTEM!="block", GOTO="clustermd_end"
+
+# handle md arrays
+KERNEL!="md*", GOTO="clustermd_end"
+ENV{DEVTYPE}!="disk", GOTO="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=="change", ENV{EVENT}=="ADD_DEVICE", ENV{DEVICE_UUID}=="?*", ENV{RAID_DISK}=="?*", \
+PROGRAM="BINDIR/blkid -o device -t UUID_SUB=$env{DEVICE_UUID}", RESULT!="", \
+RUN+="BINDIR/mdadm --manage $env{DEVNAME} --cluster-confirm $env{RAID_DISK}:$result"
+
+ACTION=="change", ENV{EVENT}=="ADD_DEVICE", ENV{DEVICE_UUID}=="?*", ENV{RAID_DISK}=="?*", \
+PROGRAM="BINDIR/blkid -o device -t UUID_SUB=$env{DEVICE_UUID}", RESULT=="", \
+RUN+="BINDIR/mdadm --manage $env{DEVNAME} --cluster-confirm $env{RAID_DISK}:missing"
+
+LABEL="clustermd_end"
Signature · 1 line
2.10.0

This can run "blkid" twice, which seems wasteful.
I think it would be best to skip to the end if ACTION != "change" and if
event != ADD_DEVICE etc.
Then
PROGRAM="BINDIR/blkid -o device -t UUID_SUB=$env{DEVICE_UUID}", ENV{".mdadm.blkid"} = "$result"

Quoted 2 lines

Then have two rules which tests ENV{".mdadm.blkid"} and run one of the two mdadm commands.

Thanks for the suggestion! I will send v2 soon.

Cheers,
Guoqing

#3 lore raw

PATCH v2 1/1 udev rules: introduce rules for cluster-md to confirm device

In reply to Guoqing Jiang

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.

---
 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
Makefile +4 -2
index 021d3ad..0977f27 100644
@@ -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
 
-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-raid-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 
+	@for file in 01-md-raid-creating.rules 63-md-raid-arrays.rules 64-md-raid-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/$$file ; \
udev-md-clustered-confirm-device.rules new file +20 -0
new file mode 100644
index 0000000..08ac74a
@@ -0,0 +1,20 @@
+# do not edit this file, it will be overwritten on update
+
+SUBSYSTEM!="block", GOTO="clustermd_end"
+
+# handle md arrays
+KERNEL!="md*", GOTO="clustermd_end"
+ENV{DEVTYPE}!="disk", GOTO="clustermd_end"
+ACTION!="change", GOTO="clustermd_end"
+ENV{EVENT}!="ADD_DEVICE", GOTO="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=="change", ENV{EVENT}=="ADD_DEVICE", ENV{DEVICE_UUID}=="?*", ENV{RAID_DISK}=="?*", \
+PROGRAM="BINDIR/blkid -o device -t UUID_SUB=$env{DEVICE_UUID}", ENV{device} = "$result"
+
+ENV{device}!="", RUN+="BINDIR/mdadm --manage $env{DEVNAME} --cluster-confirm $env{RAID_DISK}:$env{device}"
+ENV{device}=="", RUN+="BINDIR/mdadm --manage $env{DEVNAME} --cluster-confirm $env{RAID_DISK}:missing"
+
+LABEL="clustermd_end"
Signature · 1 line
2.10.0
#4 lore raw
Quoted 36 lines · Guoqing Jiang

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.

---
 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
Makefile +4 -2
index 021d3ad..0977f27 100644
@@ -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
 
-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-raid-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 
+	@for file in 01-md-raid-creating.rules 63-md-raid-arrays.rules 64-md-raid-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/$$file ; \
udev-md-clustered-confirm-device.rules new file +0 -0
new file mode 100644
index 0000000..08ac74a

udev-md-clustered-confirm-device.rules line 9

Quoted 9 lines
udev-md-clustered-confirm-device.rules new file +9 -0
@@ -0,0 +1,20 @@
+# do not edit this file, it will be overwritten on update
+
+SUBSYSTEM!="block", GOTO="clustermd_end"
+
+# handle md arrays
+KERNEL!="md*", GOTO="clustermd_end"
+ENV{DEVTYPE}!="disk", GOTO="clustermd_end"
+ACTION!="change", GOTO="clustermd_end"
+ENV{EVENT}!="ADD_DEVICE", GOTO="clustermd_end"

Move these here is good.

udev-md-clustered-confirm-device.rules line 14

Quoted 5 lines
udev-md-clustered-confirm-device.rules new file +5 -0
+
+# Based on the received UUID, node confirms the device if
+# it is found by blkid, otherwise the node reports it is
+# missing.
+ACTION=="change", ENV{EVENT}=="ADD_DEVICE", ENV{DEVICE_UUID}=="?*", ENV{RAID_DISK}=="?*", \

leaving them here as well is careless. Maybe move the tests on DEVICE_UUID and RAID_DISK up to the "goto" section too.

udev-md-clustered-confirm-device.rules line 15

Quoted 1 line
udev-md-clustered-confirm-device.rules new file +1 -0
+PROGRAM="BINDIR/blkid -o device -t UUID_SUB=$env{DEVICE_UUID}", ENV{device} = "$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

Quoted 7 lines
udev-md-clustered-confirm-device.rules new file +5 -0
+
+ENV{device}!="", RUN+="BINDIR/mdadm --manage $env{DEVNAME} --cluster-confirm $env{RAID_DISK}:$env{device}"
+ENV{device}=="", RUN+="BINDIR/mdadm --manage $env{DEVNAME} --cluster-confirm $env{RAID_DISK}:missing"
+
+LABEL="clustermd_end"
Signature · 1 line
2.10.0
#5 lore raw
Quoted 50 lines · NeilBrown
Quoted 36 lines · Guoqing Jiang

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.

---
  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

Makefile +4 -2
index 021d3ad..0977f27 100644
@@ -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
 
-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-raid-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
+	@for file in 01-md-raid-creating.rules 63-md-raid-arrays.rules 64-md-raid-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/$$file ; \
udev-md-clustered-confirm-device.rules new file +0 -0
new file mode 100644
index 0000000..08ac74a

udev-md-clustered-confirm-device.rules line 9

Quoted 9 lines
udev-md-clustered-confirm-device.rules new file +9 -0
@@ -0,0 +1,20 @@
+# do not edit this file, it will be overwritten on update
+
+SUBSYSTEM!="block", GOTO="clustermd_end"
+
+# handle md arrays
+KERNEL!="md*", GOTO="clustermd_end"
+ENV{DEVTYPE}!="disk", GOTO="clustermd_end"
+ACTION!="change", GOTO="clustermd_end"
+ENV{EVENT}!="ADD_DEVICE", GOTO="clustermd_end"

Move these here is good.

Quoted 7 lines

udev-md-clustered-confirm-device.rules line 14

Quoted 5 lines
udev-md-clustered-confirm-device.rules new file +5 -0
+
+# Based on the received UUID, node confirms the device if
+# it is found by blkid, otherwise the node reports it is
+# missing.
+ACTION=="change", ENV{EVENT}=="ADD_DEVICE", ENV{DEVICE_UUID}=="?*", ENV{RAID_DISK}=="?*", \

leaving them here as well is careless. Maybe move the tests on DEVICE_UUID and RAID_DISK up to the "goto" section too.

Ok, I will move them above.

ENV{DEVICE_UUID}!="?*", GOTO="clustermd_end"
ENV{RAID_DISK}!="?*", GOTO="clustermd_end"

Quoted 4 lines

udev-md-clustered-confirm-device.rules line 15

Quoted 1 line
udev-md-clustered-confirm-device.rules new file +1 -0
+PROGRAM="BINDIR/blkid -o device -t UUID_SUB=$env{DEVICE_UUID}", ENV{device} = "$result"

I don't think using a generic environment name like "device" is a good idea.
This will get included in the udev database.

Hmm, yes, I can see it by run "udevadm info -e", not good ...

Quoted 4 lines

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.

Thanks for detailed explanation, I didn't know that.

Best Regards,
Guoqing

#6 lore raw

PATCH v3 1/1 udev rules: introduce rules for cluster-md to confirm device

In reply to Guoqing Jiang

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.

---
 Makefile                               |  6 ++++--
 udev-md-clustered-confirm-device.rules | 21 +++++++++++++++++++++
 2 files changed, 25 insertions(+), 2 deletions(-)
 create mode 100644 udev-md-clustered-confirm-device.rules
Makefile +4 -2
index 021d3ad..0977f27 100644
@@ -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
 
-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-raid-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 
+	@for file in 01-md-raid-creating.rules 63-md-raid-arrays.rules 64-md-raid-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/$$file ; \
udev-md-clustered-confirm-device.rules new file +21 -0
new file mode 100644
index 0000000..3e5381e
@@ -0,0 +1,21 @@
+# do not edit this file, it will be overwritten on update
+
+SUBSYSTEM!="block", GOTO="clustermd_end"
+
+# handle md arrays
+KERNEL!="md*", GOTO="clustermd_end"
+ENV{DEVTYPE}!="disk", GOTO="clustermd_end"
+ACTION!="change", GOTO="clustermd_end"
+ENV{EVENT}!="ADD_DEVICE", GOTO="clustermd_end"
+ENV{DEVICE_UUID}!="?*", GOTO="clustermd_end"
+ENV{RAID_DISK}!="?*", GOTO="clustermd_end"
+
+# Based on the received UUID, node confirms the device if
+# it is found by blkid, otherwise the node reports it is
+# missing.
+PROGRAM="BINDIR/blkid -o device -t UUID_SUB=$env{DEVICE_UUID}", ENV{.md.newdevice} = "$result"
+
+ENV{.md.newdevice}!="", RUN+="BINDIR/mdadm --manage $env{DEVNAME} --cluster-confirm $env{RAID_DISK}:$env{.md.newdevice}"
+ENV{.md.newdevice}=="", RUN+="BINDIR/mdadm --manage $env{DEVNAME} --cluster-confirm $env{RAID_DISK}:missing"
+
+LABEL="clustermd_end"
Signature · 1 line
2.10.0
Applied
#7 lore raw
Quoted 6 lines · Guoqing Jiang

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.

Quoted 6 lines
---
  Makefile                               |  6 ++++--
  udev-md-clustered-confirm-device.rules | 21 +++++++++++++++++++++
  2 files changed, 25 insertions(+), 2 deletions(-)

create mode 100644 udev-md-clustered-confirm-device.rules

Looks reasonable to me - and thanks Neil for the previous reviews.

Applied!

Jes

#8 lore raw
In reply to Guoqing Jiang
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Guoqing" == Guoqing Jiang <[email protected]> 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 <[email protected]> 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 [email protected]
Guoqing> More majordomo info at http://vger.kernel.org/majordomo-info.html

#9 lore raw
Quoted 28 lines · John Stoffel
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Guoqing" == Guoqing Jiang <[email protected]> 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 <[email protected]> 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

Quoted 5 lines

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.

Well, I named it as "udev-md-clustered-*" to align with the name of existed udev rules, it also means the array is clustered. And clustermd is a convenient/short name to use.

But not a big deal, I am open to the name if you have better idea, :-) .

Thanks,
Guoqing

#10 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Guoqing" == Guoqing Jiang <[email protected]> writes:

Quoted 1 line · John Stoffel
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Guoqing" == Guoqing Jiang <[email protected]> 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.

Quoted 1 line
Quoted 1 line

Guoqing> Signed-off-by: Guoqing Jiang <[email protected]> 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

Quoted 1 line
Quoted 1 line

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

Quoted 1 line
Quoted 1 line

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

Quoted 7 lines
Quoted 7 lines

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> Well, I named it as "udev-md-clustered-*" to align with the Guoqing> name of existed udev rules, it also means the array is Guoqing> clustered. And clustermd is a convenient/short name to use.

I think mdcluster is better than clustermd, but that's only because it's the same order as udev-md-clustered-* but we're both just bike shedding here. :-)

Guoqing> But not a big deal, I am open to the name if you have better Guoqing> idea, :-) .

Not really. Appreciate your nice reply to my semi-inane comment.