Bug 86930

Summary: systemd tries to swapon devices which have already been swapon'd
Product: systemd Reporter: William A. Kennington III <william>
Component: generalAssignee: systemd-bugs
Status: RESOLVED FIXED QA Contact: systemd-bugs
Severity: normal    
Priority: medium CC: ben.r.xiao
Version: unspecified   
Hardware: All   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description William A. Kennington III 2014-12-02 11:04:53 UTC
This is a regression from version 216 -> 217 related to the old bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1017509

I'm running test cases for nixos which specifies swap devices in the fstab and I'm noticing transient failures of the swap target like this:
http://hydra.nixos.org/build/17657871/log/raw
http://hydra.nixos.org/build/17656870/log/raw
http://hydra.nixos.org/build/17657013/log/raw

We started noticing these transient failures after pushing systemd from 212 -> 217.

This was also observed by an archlinux user:
https://archlinux.org.ru/forum/topic/14196/
Comment 1 William A. Kennington III 2014-12-02 22:42:25 UTC
(In reply to William A. Kennington III from comment #0)
> This is a regression from version 216 -> 217 related to the old bug:
> https://bugzilla.redhat.com/show_bug.cgi?id=1017509
> 
> I'm running test cases for nixos which specifies swap devices in the fstab
> and I'm noticing transient failures of the swap target like this:
> http://hydra.nixos.org/build/17657871/log/raw
> http://hydra.nixos.org/build/17656870/log/raw
> http://hydra.nixos.org/build/17657013/log/raw
> 
> We started noticing these transient failures after pushing systemd from 212
> -> 217.
> 
> This was also observed by an archlinux user:
> https://archlinux.org.ru/forum/topic/14196/

Actually, the correct old bug report is this:
https://bugs.freedesktop.org/show_bug.cgi?id=69835
Comment 2 Benjamin Xiao 2014-12-05 09:47:37 UTC
I can confirm this on Debian testing with systemd 215-7

Seems like systemd-fstab-generator and systemd-gpt-auto-generator are competing with each other.

In the freedesktop documentation, it says that systemd should run the fstab generated unit file first before using the gpt auto generated unit file. However, it seems like they're running at the same time, resulting in a race condition. Sometimes swap is mounted via the fstab entry and other times it's mounted via the gpt-auto-generator.

This isn't a problem for people who don't mess around with the fstab entry and leave it as default. But for people who have SSD drives and enable the discard option for their swap partition via fstab, this becomes problematic since it isn't guaranteed that fstab will run first and apply the discard. Indeed sometimes my swap gets automounted and the fstab mount will fail with "Device or resource busy".
Comment 3 William A. Kennington III 2014-12-05 22:02:27 UTC
Well no, this is still problematic because it causes the swap.target to fail when in reality it should be succeeded. There is no reason it should generate two swap mounts for the same swap device.
Comment 4 Benjamin Xiao 2014-12-05 22:47:03 UTC
(In reply to William A. Kennington III from comment #3)
> Well no, this is still problematic because it causes the swap.target to fail
> when in reality it should be succeeded. There is no reason it should
> generate two swap mounts for the same swap device.

Of course, this should definitely be fixed because that's incorrect behavior.
Comment 5 Zbigniew Jedrzejewski-Szmek 2015-02-15 15:54:02 UTC
This should be fixed by http://cgit.freedesktop.org/systemd/systemd/commit/?id=37cf8fe. Can you check?
Comment 6 Lennart Poettering 2017-10-27 18:16:03 UTC
Pretty sure this works correctly now. Closing.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.