public inbox for initramfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrei Borzenkov <arvidjaar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH] Order root fsck after dracut-pre-mount.service
Date: Sat, 22 Nov 2014 19:43:40 +0300	[thread overview]
Message-ID: <1416674620-1024-1-git-send-email-arvidjaar@gmail.com> (raw)

Currently root fsck runs concurrently with dracut-pre-mount and so
races with resume from disk (started by dracut-pre-mount). This leads
to data corruption if fsck changes filesystem.

Make sure root fsck runs after dracut-pre-mount.service.

Details including console logs:
https://bugzilla.suse.com/show_bug.cgi?id=906592

Signed-off-by: Andrei Borzenkov <arvidjaar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

---
 modules.d/98systemd/rootfs-generator.sh | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/modules.d/98systemd/rootfs-generator.sh b/modules.d/98systemd/rootfs-generator.sh
index 9523729..a2d26b9 100755
--- a/modules.d/98systemd/rootfs-generator.sh
+++ b/modules.d/98systemd/rootfs-generator.sh
@@ -32,6 +32,22 @@ generator_wait_for_dev()
     fi
 }
 
+generator_fsck_after_pre_mount()
+{
+    local _name
+
+    [ -z "$1" ] && return 0
+
+    _name=$(dev_unit_name "$1")
+    [ -d /run/systemd/generator/systemd-fsck@${_name}.service.d ] || mkdir -p /run/systemd/generator/systemd-fsck@${_name}.service.d
+    if ! [ -f /run/systemd/generator/systemd-fsck@${_name}.service.d/after-pre-mount.conf ]; then
+        {
+            echo "[Unit]"
+            echo "After=dracut-pre-mount.service"
+        } > /run/systemd/generator/systemd-fsck@${_name}.service.d/after-pre-mount.conf
+    fi
+}
+
 root=$(getarg root=)
 case "$root" in
     block:LABEL=*|LABEL=*)
@@ -58,6 +74,9 @@ case "$root" in
         rootok=1 ;;
 esac
 
-[ "${root%%:*}" = "block" ] && generator_wait_for_dev "${root#block:}"
+if [ "${root%%:*}" = "block" ]; then
+    generator_wait_for_dev "${root#block:}"
+    generator_fsck_after_pre_mount "${root#block:}"
+fi
 
 exit 0
-- 
tg: (778b354..) u/root-fsck-after-pre-mount (depends on: master)

                 reply	other threads:[~2014-11-22 16:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1416674620-1024-1-git-send-email-arvidjaar@gmail.com \
    --to=arvidjaar-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.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