Bug 1490039

Summary: Using nbd for swap causes dependency problems
Product: [Fedora] Fedora Reporter: Göran Uddeborg <goeran>
Component: nbdAssignee: Robin Lee <robinlee.sysu>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 26CC: danielmyoung, enslaver, i, robinlee.sysu, wtogami, xjakub
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: nbd-3.16.2-1.fc27 nbd-3.16.2-1.fc26 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-09-30 06:52:20 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
My modified service file none

Description Göran Uddeborg 2017-09-09 15:07:13 UTC
Created attachment 1324090 [details]
My modified service file

Description of problem:
I have a diskless box where I try to use nbd for swap partition.  Out of the box, this causes a timeout and failure on startup.  When systemd tries to start the dev-nbd0.swap unit, it waits for dev-nbd0.device, but that apparently doesn't start up, so there is a timeout.  The nbd unit comes up much later, so even if there wasn't the timeout, there would be no swap space available.

I tried to add a dependency from dev-nbd0.swap to nbd, but that causes a loop: nbd depends on sysinit.target which depends on swap.target which depends on dev-nbd0.swap which would then close the loop with my attempted dependency on nbd.

Related to this: there is a Before=dev-%i.device entry in the nbd@.service file, but that is ignored according to systemd:

sep 05 10:56:11 pluto systemd[1]: nbd: Dependency Before=dev-nbd0.device ignored (.device units cannot be delayed)


Version-Release number of selected component (if applicable):
nbd-3.16.1-1.fc26.x86_64


How reproducible:
Every time


Steps to Reproduce:
1. Enable nbd
2. Add an entry to swap on /dev/nbd0 in /etc/fstab


Additional info:
After some experimentation, I've come up with an alternative systemd service file for nbd which seems to work correctly.  See the attachment for the details.  The key difference from the distributed one is that my version do not include default dependencies.  Instead it lists a number of "lower level" dependencies I believe are needed.  In addition, it also retriggers udevadm for the device after coming up, so systemd will be aware the device is ready.  I'm not sure if this latter problem could also be avoided with the appropriate dependencies; I haven't found out how if so.

I'm not sure if this is the best solution, or even if it is correct.  It seems to work in my use case.

Comment 1 Robin Lee 2017-09-23 06:54:33 UTC
Forwarded upstream: https://github.com/NetworkBlockDevice/nbd/issues/55

Comment 2 Fedora Update System 2017-09-24 09:38:46 UTC
nbd-3.16.2-1.fc26 has been submitted as an update to Fedora 26. https://bodhi.fedoraproject.org/updates/FEDORA-2017-be2432ba4e

Comment 3 Fedora Update System 2017-09-24 09:39:11 UTC
nbd-3.16.2-1.fc27 has been submitted as an update to Fedora 27. https://bodhi.fedoraproject.org/updates/FEDORA-2017-3dd9359533

Comment 4 Fedora Update System 2017-09-24 20:53:48 UTC
nbd-3.16.2-1.fc27 has been pushed to the Fedora 27 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-3dd9359533

Comment 5 Fedora Update System 2017-09-25 06:21:08 UTC
nbd-3.16.2-1.fc26 has been pushed to the Fedora 26 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-be2432ba4e

Comment 6 Fedora Update System 2017-09-30 06:52:20 UTC
nbd-3.16.2-1.fc27 has been pushed to the Fedora 27 stable repository. If problems still persist, please make note of it in this bug report.

Comment 7 Fedora Update System 2017-10-04 22:22:09 UTC
nbd-3.16.2-1.fc26 has been pushed to the Fedora 26 stable repository. If problems still persist, please make note of it in this bug report.