From: "Thomas Bächler" <thomas@archlinux.org>
To: linux-raid@vger.kernel.org
Cc: "Thomas Bächler" <thomas@archlinux.org>
Subject: [PATCH 2/2] udev: Work around race condition on array activation
Date: Tue, 18 Aug 2015 13:51:33 +0200 [thread overview]
Message-ID: <1439898693-936-3-git-send-email-thomas@archlinux.org> (raw)
In-Reply-To: <1439898693-936-1-git-send-email-thomas@archlinux.org>
When an array is activated, it is possible for the md/array_state property to be "clean",
while the array is not accessible. This leads to a situation where systemd is told to
activate the block device unit while it is not ready yet.
This causes a race condition in combination with the LVM2 udev rules: Since ID_FS_TYPE is not
set yet, LVM2 does not look at the device. When a change event occurs later, ID_FS_TYPE is set
to LVM2_member and LVM2 sets SYSTEMD_WANTS to call a service to activate the LVM volume.
However, systemd has already activated the device at that time and the change to SYSTEMD_WANTS
is ignored.
To solve this, in addition to checking md/array_state, also check the size property: If size
is 0, the array is not ready and should not be treated as such.
---
udev-md-raid-arrays.rules | 1 +
1 file changed, 1 insertion(+)
diff --git a/udev-md-raid-arrays.rules b/udev-md-raid-arrays.rules
index 90d1aa5..08f3cad 100644
--- a/udev-md-raid-arrays.rules
+++ b/udev-md-raid-arrays.rules
@@ -15,6 +15,7 @@ ENV{DEVTYPE}=="partition", GOTO="md_ignore_state"
ATTR{md/metadata_version}=="external:[A-Za-z]*", ATTR{md/array_state}=="inactive", GOTO="md_ignore_state"
TEST!="md/array_state", ENV{SYSTEMD_READY}="0", GOTO="md_end"
ATTR{md/array_state}=="|clear|inactive", ENV{SYSTEMD_READY}="0", GOTO="md_end"
+ATTR{size}=="0", ENV{SYSTEMD_READY}="0", GOTO="md_end"
LABEL="md_ignore_state"
ENV{SYSTEMD_READY}="1"
--
2.5.0
prev parent reply other threads:[~2015-08-18 11:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-18 11:51 [PATCH 0/2] mdadm: Fix udev rule interaction with systemd Thomas Bächler
2015-08-18 11:51 ` [PATCH 1/2] udev: Set SYSTEMD_READY to 1 when the array becomes active Thomas Bächler
2015-08-18 11:51 ` Thomas Bächler [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1439898693-936-3-git-send-email-thomas@archlinux.org \
--to=thomas@archlinux.org \
--cc=linux-raid@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).