[systemd-devel] Errorneous detection of degraded array
NeilBrown
neilb at suse.com
Wed Feb 8 04:10:57 UTC 2017
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 at suse.com>
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 at .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 at suse.com>
---
systemd/mdadm-last-resort at .service | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/systemd/mdadm-last-resort at .service b/systemd/mdadm-last-resort at .service
index e93d72b2b45e..f9d4d12738a3 100644
--- a/systemd/mdadm-last-resort at .service
+++ b/systemd/mdadm-last-resort at .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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20170208/b97c5a5f/attachment.sig>
More information about the systemd-devel
mailing list