Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple systemd/dracut fixes/changes #8510

Merged
merged 1 commit into from
Apr 3, 2019

Conversation

c0d3z3r0
Copy link
Contributor

@c0d3z3r0 c0d3z3r0 commented Mar 17, 2019

Motivation and Context / Description

  1. Remove hard dependency on bash

    zfs-import-* services have a hard dependency on bash while not everyone
    has bash installed. At this point /bin/sh is sufficient, so use that.

  2. Fix systemd-import services

    On debian systemd complains about missing /bin/awk because it actually
    is located at /usr/bin/awk. It is not a good idea to hardcode binary
    paths because linux distros use different paths. According to systemd's
    man page it is absolutely safe to miss paths for binary located at
    standard locations (/bin, /sbin, /usr/bin, ...).

    Further, replace this more or less complicated awk command by egrep.

  3. Move dracut specifics to dracut mount unit

    Dracut depends on BOOTFS environment variable to be set after pool
    import. This dracut specific systemd ExecStartPost command should not be
    called for any non-dracut systems, so let's move it to a static systemd
    unit that gets pulled in by the generated mount unit.

At the moment, the new systemd service does not get installed / packaged. I did not get this to work... any hint from you would be great :-) Update: Fixed.

How Has This Been Tested?

Tested WITHOUT dracut! Maybe someome with a dracut (test) setup can test this?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (a change to man pages or other documentation)

Checklist:

@c0d3z3r0 c0d3z3r0 force-pushed the for-upstream/systemd_service branch from 90adaaa to ca7e86e Compare March 17, 2019 23:17
@c0d3z3r0
Copy link
Contributor Author

c0d3z3r0 commented Mar 18, 2019 via email

etc/systemd/system/zfs-import-cache.service.in Outdated Show resolved Hide resolved
@c0d3z3r0 c0d3z3r0 force-pushed the for-upstream/systemd_service branch from ca7e86e to 6bdc0c7 Compare March 18, 2019 19:50
@c0d3z3r0
Copy link
Contributor Author

c0d3z3r0 commented Mar 18, 2019 via email

@cwedgwood
Copy link
Contributor

@behlendorf -m1 does not work here because of the negative match. (AFAIK. I can‘t test this right now.) When there are multiple matches, how should we know which one is the right one? Hoping the first one is always correct does not really sound right to me..

head -1 perhaps? it doesn't solve the 'right one' issue but at least would be consistent with what we have/had so far

@behlendorf
Copy link
Contributor

at least would be consistent with what we have/had so far.

On a properly configured system there should only be one match. But when that's not the case picking the first one at least allows us to do something sensible. Let's at least keep the behavior consistent until we can do something better. I'd be OK with head -1.

@behlendorf behlendorf added the Status: Revision Needed Changes are required for the PR to be accepted label Mar 19, 2019
@c0d3z3r0 c0d3z3r0 force-pushed the for-upstream/systemd_service branch from 6bdc0c7 to 51c4ca0 Compare March 20, 2019 18:19
@c0d3z3r0
Copy link
Contributor Author

I added head -1 now. Packaging still does not work; the tests are complaining about that, too. :/

@c0d3z3r0 c0d3z3r0 force-pushed the for-upstream/systemd_service branch 5 times, most recently from a98d6d9 to 517b5ff Compare March 21, 2019 21:27
@c0d3z3r0
Copy link
Contributor Author

c0d3z3r0 commented Mar 21, 2019

The packaging issue is resolved now, too

@rlaager
Copy link
Member

rlaager commented Mar 22, 2019

I added head -1 now. Packaging still does not work; the tests are complaining about that, too. :/

This is a bit pedantic, but technically speaking, the head -1 should be on the commit that changes it to grep. I see it's there on the last commit, but I missed it the first time through when reviewing.

@c0d3z3r0 c0d3z3r0 force-pushed the for-upstream/systemd_service branch from 517b5ff to c49a150 Compare March 22, 2019 19:20
@c0d3z3r0
Copy link
Contributor Author

I added head -1 now. Packaging still does not work; the tests are complaining about that, too. :/

This is a bit pedantic, but technically speaking, the head -1 should be on the commit that changes it to grep. I see it's there on the last commit, but I missed it the first time through when reviewing.

Full ACK. Fixed

@behlendorf behlendorf added Status: Code Review Needed Ready for review and testing and removed Status: Revision Needed Changes are required for the PR to be accepted labels Mar 22, 2019
@c0d3z3r0 c0d3z3r0 force-pushed the for-upstream/systemd_service branch from c49a150 to ee0578b Compare March 22, 2019 20:41
@rlaager
Copy link
Member

rlaager commented Mar 24, 2019

In thinking about this some more, a grep | head is ripe for replacement by awk. This avoids a second fork(). Why not just keep the existing approach, but remove the hard-coded /bin/?

@c0d3z3r0
Copy link
Contributor Author

c0d3z3r0 commented Mar 24, 2019

@rlaager

In thinking about this some more, a grep | head is ripe for replacement by awk. This avoids a second fork(). Why not just keep the existing approach, but remove the hard-coded /bin/?

grep | head is still better readable than awk '$1 != \"-\" {print; exit}') and two forks instead of one at this point does not make that big difference.

@rlaager @behlendorf
I just read the grep man page again and realized I was wrong.... -m1 does work with a negative match. I simply stumbled over that double negation in When the -v or --invert-match option is also used, grep stops after outputting NUM **non-matching** lines., where "non-matching" means lines that do not match the (inverted match!) regex.

Proof:

$ echo -e '-\n-\nrpool/ROOT\ndpool/ROOT' | grep -m1 -v '^-$'
rpool/ROOT

I will change this to grep -v -m 1 ...

@c0d3z3r0 c0d3z3r0 force-pushed the for-upstream/systemd_service branch from ee0578b to 4573ea8 Compare March 24, 2019 10:49
@c0d3z3r0 c0d3z3r0 force-pushed the for-upstream/systemd_service branch from 827a79f to 1042ed3 Compare March 25, 2019 19:40
Copy link
Contributor

@behlendorf behlendorf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The contrib/dracut/90zfs module directory does seem like a reasonable place to put these. I'm not an expert in this area either, but I'm OK with adding them here.

configure.ac Outdated Show resolved Hide resolved
contrib/dracut/90zfs/Makefile.am Outdated Show resolved Hide resolved
contrib/dracut/90zfs/module-setup.sh.in Outdated Show resolved Hide resolved
@c0d3z3r0 c0d3z3r0 force-pushed the for-upstream/systemd_service branch 2 times, most recently from 90e2ec9 to c1fb1e7 Compare March 26, 2019 07:17
@c0d3z3r0 c0d3z3r0 force-pushed the for-upstream/systemd_service branch 2 times, most recently from 741ae90 to 8e7e99b Compare March 28, 2019 18:48
Copy link
Contributor

@behlendorf behlendorf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@c0d3z3r0 thanks for sorting this out. I'm happy with the updated version, but it would be great if we could get a few more reviewers who are familiar with this area to approve it too.

@behlendorf behlendorf requested a review from rlaager March 29, 2019 22:06
behlendorf pushed a commit that referenced this pull request Mar 29, 2019
zfs-import-* services have a hard dependency on bash while not
everyone has bash installed. At this point /bin/sh is sufficient,
so use that.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Michael Niewöhner <foss@mniewoehner.de>
Issue #8510
behlendorf pushed a commit that referenced this pull request Mar 29, 2019
On debian, systemd complains about missing /bin/awk because it
actually is located at /usr/bin/awk. It is not a good idea to
hardcode binary paths because different linux distros use different
paths. According to systemd's man page it is absolutely safe to
miss paths for binaries located at standard locations (/bin,
/sbin, /usr/bin, ...).

Further, replace this more or less complicated awk command by
grep.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Michael Niewöhner <foss@mniewoehner.de>
Issue #8510
@behlendorf
Copy link
Contributor

I've cherry picked the first two simple commits in to master since there's no reason to hold them up any longer. @c0d3z3r0 would you mind rebasing only your last commit on master while we allow some time for additional reviewers. Thanks.

e03b25a Fix systemd-import services
3b26189 Remove hard dependency on bash

Dracut depends on the environment variable BOOTFS to be set after pool
import. This dracut specific systemd ExecStartPost command should not be
called for any non-dracut systems, so let's move it to a static systemd
unit that.

Signed-off-by: Michael Niewöhner <foss@mniewoehner.de>
@c0d3z3r0 c0d3z3r0 force-pushed the for-upstream/systemd_service branch from 8e7e99b to 74204e8 Compare March 29, 2019 22:36
@rlaager rlaager dismissed their stale review March 29, 2019 23:18

My review was for commits which no longer exist on this PR.

@rlaager
Copy link
Member

rlaager commented Mar 29, 2019

I removed my stale review. I don't see anything that jumps out at me as wrong, but I am not familiar with dracut, so I can't give a useful approval here.

@codecov
Copy link

codecov bot commented Mar 30, 2019

Codecov Report

Merging #8510 into master will decrease coverage by 0.1%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8510      +/-   ##
==========================================
- Coverage   78.76%   78.66%   -0.11%     
==========================================
  Files         381      381              
  Lines      117499   117499              
==========================================
- Hits        92553    92426     -127     
- Misses      24946    25073     +127
Flag Coverage Δ
#kernel 79.28% <ø> (-0.02%) ⬇️
#user 67.25% <ø> (-0.02%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e03b25a...74204e8. Read the comment docs.

Copy link
Contributor

@prometheanfire prometheanfire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested fine

For some reason I didn't have zfs.target enabled and that caused zfs-mount to not start. I don't see a change in this commit that would have done that though (probably one of the other dracut commits)

@c0d3z3r0
Copy link
Contributor Author

c0d3z3r0 commented Mar 31, 2019

@prometheanfire

tested fine

Thank you!

For some reason I didn't have zfs.target enabled and that caused zfs-mount to not start. I don't see a change in this commit that would have done that though (probably one of the other dracut commits)

Do you mean zfs.target in the rootfs / after initramfs (etc/systemd/system/zfs.target.in)? I could not find any usage of zfs.target in contrib/dracut

@prometheanfire
Copy link
Contributor

ya, after initram

@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Apr 1, 2019
@behlendorf
Copy link
Contributor

Thanks everybody. I'll go ahead and get this merged this tomorrow. If you have any remaining concerns please post before then.

@behlendorf behlendorf merged commit ce4432c into openzfs:master Apr 3, 2019
@c0d3z3r0 c0d3z3r0 deleted the for-upstream/systemd_service branch April 3, 2019 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants