Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 517218 - sys-fs/mdadm-3.3.1 - /lib/udev/rules.d/64-md-raid-assembly.rules is a systemd service file
Summary: sys-fs/mdadm-3.3.1 - /lib/udev/rules.d/64-md-raid-assembly.rules is a systemd...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL: http://marc.info/?l=linux-raid&m=1405...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-16 07:52 UTC by Mark R. Pariente
Modified: 2014-07-17 09:21 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
mdadm-3.3.1 build log (mdadm-3.3.1-build-log.txt,27.07 KB, text/plain)
2014-07-16 18:39 UTC, Mark R. Pariente
Details
mdadm-3.3.1.ebuid.patch (mdadm-3.3.1.ebuild.patch,652 bytes, patch)
2014-07-17 06:57 UTC, Samuli Suominen (RETIRED)
Details | Diff
mdadm-3.3.1-parallel-make.patch (mdadm-3.3.1-parallel-make.patch,2.52 KB, patch)
2014-07-17 06:58 UTC, Samuli Suominen (RETIRED)
Details | Diff
mdadm-3.3.1-parallel-make.patch (mdadm-3.3.1-parallel-make.patch,1.88 KB, patch)
2014-07-17 08:43 UTC, Samuli Suominen (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark R. Pariente 2014-07-16 07:52:21 UTC
After upgrading to mdadm-3.3.1 my RAID array(s) wouldn't assemble automatically on boot any more (using systemd). Traced down the issue potentially to the udev rule file being busted. See:

# cat /lib/udev/rules.d/64-md-raid-assembly.rules
#  This file is part of mdadm.
#
#  mdadm is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.

[Unit]
Description=MD Metadata Monitor on /dev/%I
DefaultDependencies=no
Before=initrd-switch-root.target

[Service]
# mdmon should never complain due to lack of a platform,
# that is mdadm's job if at all.
Environment=IMSM_NO_PLATFORM=1
# The mdmon starting in the initramfs (with dracut at least)
# cannot see sysfs after root is mounted, so we will have to
# 'takeover'.  As the '--offroot --takeover' don't hurt when
# not necessary, are are useful with root-on-md in dracut,
# have them always present.
ExecStart=/sbin/mdmon --offroot --takeover %I
Type=forking
# Don't set the PIDFile.  It isn't necessary (systemd can work
# it out) and systemd will remove it when transitioning from
# initramfs to rootfs.
#PIDFile=/run/mdadm/%I.pid
KillMode=none
offroot ${DEVLINKS}"
ACTION=="add|change", ENV{MD_STARTED}=="*unsafe*", ENV{MD_FOREIGN}=="no", ENV{SYSTEMD_WANTS}+="mdadm-last-resort@$env{MD_DEVICE}.timer"
ACTION=="remove", ENV{ID_PATH}=="?*", RUN+="/sbin/mdadm -If $name --path $env{ID_PATH}"
ACTION=="remove", ENV{ID_PATH}!="?*", RUN+="/sbin/mdadm -If $name"

LABEL="md_inc_end"

This looks more like a systemd service file rather than an udev rule file. Downgrading to 3.3-r4 fixes the array auto assembly at boot. The udev rule file also looks saner now:

# cat /lib/udev/rules.d/64-md-raid-assembly.rules
# do not edit this file, it will be overwritten on update

# assemble md arrays

SUBSYSTEM!="block", GOTO="md_inc_end"

# handle potential components of arrays (the ones supported by md)
ENV{ID_FS_TYPE}=="ddf_raid_member|isw_raid_member|linux_raid_member", GOTO="md_inc"
GOTO="md_inc_end"

LABEL="md_inc"

# remember you can limit what gets auto/incrementally assembled by
# mdadm.conf(5)'s 'AUTO' and selectively whitelist using 'ARRAY'
ACTION=="add", RUN+="/sbin/mdadm --incremental $devnode --offroot"
ACTION=="remove", ENV{ID_PATH}=="?*", RUN+="/sbin/mdadm -If $name --path $env{ID_PATH}"
ACTION=="remove", ENV{ID_PATH}!="?*", RUN+="/sbin/mdadm -If $name"

LABEL="md_inc_end"
Comment 1 Samuli Suominen (RETIRED) gentoo-dev 2014-07-16 08:02:45 UTC
Looks fine here,

ssuominen@null ~/gentoo-x86/sys-fs/mdadm $ qfile -v /lib/udev/rules.d/64-md-raid-assembly.rules
sys-fs/mdadm-3.3.1 (/lib/udev/rules.d/64-md-raid-assembly.rules)
ssuominen@null ~/gentoo-x86/sys-fs/mdadm $ cat /lib/udev/rules.d/64-md-raid-assembly.rules
# do not edit this file, it will be overwritten on update

# Don't process any events if anaconda is running as anaconda brings up
# raid devices manually
ENV{ANACONDA}=="?*", GOTO="md_inc_end"
# assemble md arrays

SUBSYSTEM!="block", GOTO="md_inc_end"

# handle potential components of arrays (the ones supported by md)
ENV{ID_FS_TYPE}=="linux_raid_member", GOTO="md_inc"

# "noiswmd" on kernel command line stops mdadm from handling
#  "isw" (aka IMSM - Intel RAID).
# "nodmraid" on kernel command line stops mdadm from handling
#  "isw" or "ddf".
IMPORT{cmdline}="noiswmd"
IMPORT{cmdline}="nodmraid"

ENV{nodmraid}=="?*", GOTO="md_inc_end"
ENV{ID_FS_TYPE}=="ddf_raid_member", GOTO="md_inc"
ENV{noiswmd}=="?*", GOTO="md_inc_end"
ENV{ID_FS_TYPE}=="isw_raid_member", GOTO="md_inc"
GOTO="md_inc_end"

LABEL="md_inc"

# remember you can limit what gets auto/incrementally assembled by
# mdadm.conf(5)'s 'AUTO' and selectively whitelist using 'ARRAY'
ACTION=="add|change", IMPORT{program}="/sbin/mdadm --incremental --export $devnode --offroot ${DEVLINKS}"
ACTION=="add|change", ENV{MD_STARTED}=="*unsafe*", ENV{MD_FOREIGN}=="no", ENV{SYSTEMD_WANTS}+="mdadm-last-resort@$env{MD_DEVICE}.timer"
ACTION=="remove", ENV{ID_PATH}=="?*", RUN+="/sbin/mdadm -If $name --path $env{ID_PATH}"
ACTION=="remove", ENV{ID_PATH}!="?*", RUN+="/sbin/mdadm -If $name"

LABEL="md_inc_end"
Comment 2 Samuli Suominen (RETIRED) gentoo-dev 2014-07-16 08:04:27 UTC
Do you have sys-apps/systemd installed?  Just wondering howto reproduce.
Comment 3 Mark R. Pariente 2014-07-16 09:23:22 UTC
Yes, I do use systemd:

[ebuild   R    ] sys-apps/systemd-215-r1:0/2  USE="acl filecaps firmware-loader gudev introspection kmod pam policykit python seccomp ssl -audit -cryptsetup -doc -elfutils -gcrypt -http (-kdbus) -lzma -qrcode (-selinux) {-test} -vanilla" ABI_X86="(64) -32 (-x32)" PYTHON_SINGLE_TARGET="python2_7 -python3_2 -python3_3" PYTHON_TARGETS="python2_7 python3_3 -python3_2" 0 kB

[ebuild     R  ] sys-fs/mdadm-3.3.1 [3.3-r4] USE="-static" 0 kB
Comment 4 Jeroen Roovers (RETIRED) gentoo-dev 2014-07-16 11:33:03 UTC
I just built it for fun and lib/udev/rules.d/63-md-raid-arrays.rules definitely is what it should be.
Comment 5 Mark R. Pariente 2014-07-16 18:39:58 UTC
Created attachment 380840 [details]
mdadm-3.3.1 build log
Comment 6 Mark R. Pariente 2014-07-16 18:41:49 UTC
The issue is with /lib/udev/rules.d/64-md-raid-assembly.rules not /lib/udev/rules.d/63-md-raid-arrays.rules. Could you check to see if that one looks OK too?

I just tried to emerge mdadm-3.3.1 again and still see the same issue - attaching full build log.
Comment 7 Samuli Suominen (RETIRED) gentoo-dev 2014-07-17 04:13:00 UTC
Yes, both .rules look OK (but I don't have sys-apps/systemd installed)
Have you tried compiling with MAKEOPTS="-j1"?
CCing systemd@ if they can reproduce
Comment 8 Samuli Suominen (RETIRED) gentoo-dev 2014-07-17 04:15:21 UTC
In Makefile, I see "file" and "$$file" and .install.tmp used in for -loops over and over again, but I just fail to see how it can have this outcome :/
Comment 9 Samuli Suominen (RETIRED) gentoo-dev 2014-07-17 04:30:53 UTC
Can you try editing the ebuild and see if...

Changing this line...

mdadm_emake DESTDIR="${D}" install install-systemd

to split lines...

mdadm_emake DESTDIR="${D}" install
mdadm_emake DESTDIR="${D}" install-systemd

solves the problem?
Comment 10 Mark R. Pariente 2014-07-17 05:53:45 UTC
Great suggestions. Both MAKEOPTS="-j1" AND splitting the mdadm_emake line into two lines fixes the issue. I'm typically running with MAKEOPTS="-j9" in /etc/portage/make.conf, I guess I should add sys-fs/mdadm to package.env for MAKEOPTS="-j1". Thanks for your help!
Comment 11 Mark R. Pariente 2014-07-17 05:56:14 UTC
I guess as a general solution though it might be nice to split the mdadm_emake line on portage since it works fine with MAKEOPTS="-jN" and I'd imagine a decent number of folks would hit this bug.
Comment 12 Samuli Suominen (RETIRED) gentoo-dev 2014-07-17 06:57:40 UTC
Created attachment 380866 [details, diff]
mdadm-3.3.1.ebuid.patch

ebuild patch to apply -parallel-make.patch
Comment 13 Samuli Suominen (RETIRED) gentoo-dev 2014-07-17 06:58:32 UTC
Created attachment 380868 [details, diff]
mdadm-3.3.1-parallel-make.patch

patch for the previous ebuild, goes to files/ directory
Comment 14 Samuli Suominen (RETIRED) gentoo-dev 2014-07-17 06:59:44 UTC
I'll split the lines for mdadm-3.3.1-r1.ebuild, but before you emerge/sync, could you do a quick test and see if the attach patches fix the problem as well?
so that I can then send them to upstream mailing list, so this will be fixed for everyone, not just for gentoo
Comment 15 Samuli Suominen (RETIRED) gentoo-dev 2014-07-17 07:04:27 UTC
+*mdadm-3.3.1-r1 (17 Jul 2014)
+
+  17 Jul 2014; Samuli Suominen <ssuominen@gentoo.org> +mdadm-3.3.1-r1.ebuild:
+  Fix corruption of udev rules and/or systemd service files because of parallel
+  make wrt #517218 by splitting installation of targets "install" and "install-
+  systemd" to separate lines. Thanks to Mark R. Pariente for reporting.


(but please still test the attached patches...)
Comment 16 Samuli Suominen (RETIRED) gentoo-dev 2014-07-17 07:37:24 UTC
Reported to upstream here,

http://marc.info/?l=linux-raid&m=140558222313576&w=2
Comment 17 Samuli Suominen (RETIRED) gentoo-dev 2014-07-17 08:43:25 UTC
Created attachment 380878 [details, diff]
mdadm-3.3.1-parallel-make.patch

Upstream said this should be enough to fix the problem (change only filename, not the variable)

But since I can't reproduce the bug, not even with -j9 on my machine (parallel make is like that, it's tricky...), I can't verify it
Comment 18 Mark R. Pariente 2014-07-17 09:21:02 UTC
Samuli, thanks for the patches. I can confirm that mdadm-3.3.1-parallel-make.patch (attachment 380878 [details, diff]) fixes the problem, udev rule file is as expected with MAKEOPTS="-j9".