On Tue, Jan 31 2017, Andrei Borzenkov wrote: > >>>> Changing the >>>> Conflicts=sys-devices-virtual-block-%i.device >>>> lines to >>>> ConditionPathExists=/sys/devices/virtual/block/%i >>>> might make the problem go away, without any negative consequences. >>>> >>> >>> Ugly, but yes, may be this is the only way using current systemd. >>> > > This won't work. sysfs node appears as soon as the very first array > member is found and array is still inactive, while what we need is > condition "array is active". Of course, you are right. A suitable "array is active" test is the existence of .../md/sync_action which appears when an array is activated (except for RAID0 and Linear, which don't need last-resort support). So this is what I propose to post upstream. Could you please confirm that it works for you? It appears to work for me. Thanks, NeilBrown From: NeilBrown <neilb@xxxxxxxx> Date: Wed, 8 Feb 2017 15:01:05 +1100 Subject: [PATCH] systemd/mdadm-last-resort: use ConditionPathExists instead of Conflicts Commit cec72c071bbe ("systemd/mdadm-last-resort: add Conflicts to .service file.") added a 'Conflicts' directive to the mdadm-last-resort@.service file in the hope that this would make sure the service didn't run after the device was active, even if the timer managed to get started, which is possible in race conditions. This seemed to work is testing, but it isn't clear why, and it is known to cause problems. If systemd happens to know that the mentioned device is a dependency of a mount point, the Conflicts can unmount that mountpoint, which is certainly not wanted. So remove the "Conflicts" and instead use ConditionPathExists=!/sys/devices/virtual/block/%i/md/sync_action The "sync_action" file exists for any array which require last-resort handling, and only appear when the array is activated. So it is safe to reliy on it to determine if the last-resort is really needed. Fixes: cec72c071bbe ("systemd/mdadm-last-resort: add Conflicts to .service file.") Signed-off-by: NeilBrown <neilb@xxxxxxxx> --- systemd/mdadm-last-resort@.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/systemd/mdadm-last-resort@.service b/systemd/mdadm-last-resort@.service index e93d72b2b45e..f9d4d12738a3 100644 --- a/systemd/mdadm-last-resort@.service +++ b/systemd/mdadm-last-resort@.service @@ -1,7 +1,7 @@ [Unit] Description=Activate md array even though degraded DefaultDependencies=no -Conflicts=sys-devices-virtual-block-%i.device +ConditionPathExists=!/sys/devices/virtual/block/%i/md/sync_action [Service] Type=oneshot -- 2.11.0
Attachment:
signature.asc
Description: PGP signature