-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Dependency related additions to the systemd generator #9649
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a commit that tweaks the if statement whitespace. It seemed easier to do that than to explain what I was thinking. That can be squashed when it comes time to merge or if you're respinning the PR anyway.
I am concerned that this will break if you have multiple datasets with the same mountpoint. As I said before: #9611 (comment)
However, if we have two datasets with the same mountpoint and one is noauto and one is “on”, we would have a problem. The unit name comes from the mountpoint (and AFAIK this is required). We would need to give precedence to the auto one. The current code handles this by skipping all noauto mounts. But once we lift that, it will be a problem.
The code currently refuses to overwrite existing mount files. If we changed that to only apply for noauto, then the auto one would overwrite if it came later, but would not be overwritten if it came first. This would achieve the right result without making the generator take two passes.
Can you change it to behave like that? Having multiple datasets with the same mountpoint will be very common with Ubuntu's zsys utility for root-on-ZFS setups, and not just for mountpoint=/.
Is there a particular reason we need an option to filter out the noauto mountpoints, as opposed to just always creating them? If nothing Wants= them, they're not going to have any effect anyway, right? Or is there an issue in the following scenario: if I have a canmount=noauto, mountpoint=/foo and a canmount=yes, mountpoint=/foo/bar, will the foo-bar.mount Wants foo.mount and mount /foo against the expressed noauto? Can you test that scenario? If that does not happen, then I think we can just always create the canmount=noauto units and eliminate that option.
Why is it that you want the option to NOT mount all the canmount=on datasets? I'm still not understanding your use case there. Can you try explaining that one more time?
Ah, I was wondering what the preferred formatting there was. Apparently I also managed to be inconsistent about it 🙃
I will veto the overwrite feature - noauto or not - as this could also overwrite existing units created by non-zfs generators.
Exactly. Please see the initial post, including a systemd manpage quote...
Enabling this behaviour basically makes systemd aware of the zfs mount points but causes minimal change in behaviour otherwise. The point is to make systemd aware of these possible mount points but only make systemd mount things that are directly needed by something, i.e. for daemons like libvirt. Leaving the mount handling for datasets not directly required by other things has many possible use cases, such as I still have open questions around the config variables, such as whether we should have some error handling around missing or especially invalid values, renaming, etc. |
Good point, a ZFS
Another great point! That concept would work. As long as all the
I tested, with ext4 in Given that
Do you personally have a use case for not mounting all the datasets with |
Sorry about the delayed response.
This is in regards to having multiple datasets with the same mountpoint, but the comment is true more generally: systemd doesn't "understand" the idea that a mountpoint might be mounted by different filesystems in any way (at least that I know of). I don't think we should try to shoehorn this into ZFS either.
I agree---a mountpoint should unambiguously specify a dataset/filesystem from the systemd perspective, unless we have some better understanding of the mechanism systemd handles this. In particular, I think we should detect if:
and abort making any
I'm not thrilled about this. There is going to be someone who complains about this. But I also don't think it's worth a fight.
Again, I don't see why we want to hack this in for zfs in particular. @InsanePrawn is there a reason you cannot just mask the mount files if you don't want them mounted? As an aside, the "right" way to do this would be filesystem agnostic. One candidate would be having putting some property like |
The following is getting somewhat far afield from this particular PR, but it may be worthwhile to support the equivalents of following at some point:
The other options don't seem to make sense for ZFS: https://www.freedesktop.org/software/systemd/man/systemd.mount.html#fstab
Again, I'm coming at this from the perspective that we should match the "stock" (i.e. fstab generator) behavior as much as possible. |
I came from a perspective of balancing "stock" behavior of I also think adding support for the As for As for the late-mounting behavior, the more I think about it, the more sure I am that systemd should implement a |
Upon further reading,
Agreed.
Agreed, mostly. I think it's okay to have systemd-specific properties used only for systemd, and likewise for anything else. Perhaps they should be user properties. I'm not sure what we should name them. Using e.g.
Indeed, but either way, I still want to hear a use case articulated by @InsanePrawn or whoever has such a use case.
I'm still struggling to understand why someone wants to mount a local filesystem at boot but does not want it to be wanted by To recap my understanding of the current status... I'd like to see the following changes:
|
@rlaager I think we're basically on the same page, but I'd like to add one more behavior to this list of requests:
|
I have no objection to that. Is there a way to easily implement that in sh without making this two-pass? It's undoubtedly going to involve the sort being first by |
We're starting to push the limits of shell script, but you could do something like if [ -e "${mountfile}" ] ; then
if [ "$(head -n1 "$mountfile")" = "# Automatically generated by zfs-mount-generator" ] ; then
if [ "${p_canmount}" = "on" ; then
#overwrite
elif # mountfile is a link to /dev/null or is not WantedBy=local-fs.target
continue # to next dataset
elif
ln -sf /dev/null "${mountfile}"
fi
else
continue #to next dataset
fi
fi Of course this isn't even remotely tested. We might also want to clean up all the /dev/null symlinks afterwards. We should also probably put Also, this is starting to get to the point that it should be compiled. It's fine to add this, and I actually think we should get a good script implementation together before rewriting it in C so we can iterate faster. This is definitely out of scope for this PR, though. |
It might make sense to rewrite the generator in Python, either as a permanent solution or as a middle step on the way to C. |
Given how early in the boot systemd generators are run (i.e., first thing after PID1 is called), |
Hello again, sorry I went MIA for a little, RL caught up with me. Now, where were we?
It looks like one could just pour the contents of those properties' values into corresponding lines in the generated units, right?
What about
Alright, to summarize, one would want that because Let's get into an example, my workstation at work. Okay, fine, then just don't use the generator on such a server, right? Some might argue the cryptstore datasets should be I am aware all of this is based on abusing the difference between
Sigh. They will mount if any other (ZFS or not) mount unit below their mount point ever gets activated. That might be the right thing to do in a lot of cases, and I'd be okay with making it the new default, but please give me the option to toggle this, even if it's as a user property.
See two paragraphs above. :)
What about keeping a list of mount units (file names, as they're the escaped version of the mount path?) of noauto units already generated by us this run.
By only tracking noauto datasets that we wrote, we avoid a whole bunch of problems like overwriting/deleting foreign mount units. The first problem I see with this is the lack of arrays in POSIX shell. Sigh. |
Yes.
That's not bad. I'd probably drop the "generator" for less typing, so
I have a couple of alternatives I'd like to explore. A) Is it possible/easy to create additional target units? Could you create a cryptstore.target that Wants= the mount units for cryptstore and its children? Then they could be noauto and you could unlock/mount them with something like B) Your proposed solution uses a global (system-wide) setting to fix a local problem with one dataset hierarchy. What if, instead, we had a user property which meant "don't wants this in local-fs.target"? User properties are inherited, so you would only need to set this on the cryptstore dataset and its children would automatically inherit it. They would get mount units and cryptstore would get the keyload unit, but they would not be automatically pulled in at boot. This seems like it would address both of your scenarios with more local granularity. It wouldn't interfere with stock (Ubuntu installer or HOWTO) root-on-ZFS datasets.
What's your use case here (for not wanting noauto units to be created at all)? |
I'm not exactly sure what you're trying to accomplish here, my goal is to have the cryptstore not handled through systemd.
This might be an acceptable compromise. Given the fact that using inheritance, I could supposedly set it on my root dataset and therefore get the desired effect on the entire pool, I would be open to this, although it's not as nice for the backup host use case, received (user) properties and all.
Side note: Nothing I proposed so far breaks or interferes with anything either, as I've kept the current behaviour the default.
As I said: If they're created and something else below them is activated, so will they. The only way to avoid this is to not create them. Imagine dataset My overall use case here is to use the systemd generator only for satisfying a couple of service dependencies and keeping its nose out of my zfs for the rest of the day. I think that's the use case for most of the few people who activate it in the first place anyway. I'm willing to take some initial setup, like setting a config value or a property, but I won't accept solutions where I'm expected to go around masking units or something else whenever a new (encryption root?) dataset shows up. |
Your previously stated goal was that you didn't want to mount cryptstore automatically on boot. That's reasonable. I don't see a huge difference between
Creating one target unit is roughly the same amount of work as editing a toggle in I'm not sure if the target idea even works anyway, but it sounds like we're converging on a different solution, so this is moot.
In the backup use case, you'd just set it on the dataset that contains all the backups (in my case, e.g. the dataset for
Sure, but that's not what's at issue. I've proposed a solution to your use case that doesn't break those scenarios. Your proposed solution to your use case does break those scenarios, or requires a bunch more manual work to create all the relevant
Right, that's the obviously correct thing to do most of the time and matches the stock behavior for By the way, I think my reading of In light of all of the above, here is my current proposal:
Thoughts? Thoughts on a name for item 2? What about @InsanePrawn would then do something like:
This would be inherited by its children, so all of those would get mount units, but would not be |
I basically agree with @rlaager. I'll add a couple things:
I wanted @rlaager :
I still think the target is a good idea. It expresses the goal of mounting things in terms of "when". In fact, your point 3 could be called I think that, with that one additional behavior, we'd really be at an ideal solution. |
There's a feature request for that, which has been open for some time: #2901
It would still be necessary to create the target unit by hand, so I'm not sure that the ZFS user property is saving you much. Another concern that I have is that this creates a new "target" option in the systemd namespace that has no analog in mount units, mount options, or the fstab generator. (Worst case, if systemd later adds a "target" option, we have a mess.) I'm not completely against it, though. There is a certain elegance to this proposal, since it addresses point 3. |
30a01b0
to
5c8d15a
Compare
Hey guys, I've rebased, squashed and modified my commits a little. Here's how far I currently got. Current StatusDONE
Done, though only tested outside the generator script.
Done!
Done. The only things that change de-facto are the
I think that even if systemd upstream agrees that being able to override the target is a useful thing to do and possibly even implements it for /etc/fstab, How long do we wait for an answer from systemd upstream before we just take a vote on TODO:
I haven't started working on this yet. Shell variable arrays would help with doing this single pass, but we'd be making this generator depend on bash. Anyone got opinions on this? the
Haven't worked on this yet but I have renamed
I'll add this in the coming days.
Future work as in future PRs as far as I'm concerned :)
Same question. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How long do we wait for an answer from systemd upstream before we just take a vote on
org.openzfs.systemd:target
?
Has anyone proposed this to upstream systemd? I don't think we need to implement this in ZFS now. But if someone wants it, a good first step would be to propose the idea to upstream systemd as x-systemd.target
, or similar, for /etc/fstab
.
From @aerusso, "If there are multiple
canmount=noauto
datasets [for the samemountpoint
], do not write units for any of them."I haven't started working on this yet. Shell variable arrays would help with doing this single pass, but we'd be making this generator depend on bash. Anyone got opinions on this? the
printf
substitution in thesort
line could also be replaced with a simple$'\t'
if we had the luxury of bashisms.
/bin/sh
is definitely not always bash
(e.g. on Debian), so if we require bash
, we'll have to be explicit about it with /bin/bash
. If we can't do it without bashisms, maybe we should just skip it for the first round of changes and try to implement it in a C rewrite?
Haven't worked on this yet but I have renamed
req_dir
towants_dir
in preparation for this. I'd prefer if the behaviour for the unset property matched one of the settings
Me too, but this might need some more testing. I'm concerned that if the cache gets out of date (e.g. a filesystem is deleted but not from the cache), it seems like it would drop the boot into emergency mode. (I'm not sure, though.) If we make it match the behavior of "on", then we lose the Before=local-fs.target
, which might be bad in a different way (e.g. services will start expecting local filesystems to be mounted and they're not).
Revisit
automount
andidle-timeout
properties in the future (or now, if someone wants to test)?Future work as in future PRs as far as I'm concerned :)
Seems reasonable.
I did here. @poettering has tagged it, but there has been no discussion. I agree we can move forward with a partial solution, but I would really like to get at least some cross-project buy in. EDIT: He's responded in the positive. I think the ideal way forward is for someone (and I guess that will be me) to implement the functionality in systemd, and get it merged. Then double back and implement the feature here. Don't let that block progress on orthogonal features here, though. We should decide on what namespace the systemd bits should live in. Do we want |
5c8d15a
to
f04c103
Compare
Silences a warning about an intentionally unquoted variable. Fixes a warning caused by strings split across lines by slightly refactoring keyloadcmd. Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
c84645c
to
b4783a0
Compare
Rebased to include #9970 and
done. But I do feel obligated to point out: % grep org.open-zfs. -r --exclude-dir=.git 2>/dev/null
include/sys/fs/zfs.h: * (e.g. "org.open-zfs:") to avoid conflicting names being developed
man/man5/zpool-features.5:GUID org.open-zfs:large_blocks
module/zcommon/zfeature_common.c: "org.open-zfs:large_blocks", "large_blocks",
tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/zfs_sysfs_live.ksh:pool_feature_attr="/sys/module/zfs/features.pool/org.open-zfs:large_blocks/guid" EDIT: Then again tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c: fnvlist_add_string(props, "org.openzfs:launch", "September 17th, 2013");
tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c: fnvlist_add_string(props, "org.openzfs:launch", "September 17th, 2013");
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.list_user_props.ksh:TESTPROP="org.openzfs:test_property" |
@InsanePrawn thanks for updating this. Yes, the domains and needed certs are something we're working to sort out, although I expect it will take us a little bit. Luckily |
@aerusso If it looks good to you, can you change your review to approved? Also, FWIW, I tested this on a root-on-ZFS setup. I'm not saying you shouldn't test it too, of course. :) Insaneprawn:
I have proposed flipping that around. The openzfs.org domain was not available initially, which is why the dashed version was used first. We'll see what happens there.
I have submitted PR #10003 for that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It boots on two of my machines, one zfs-on-root, both having some encrypted datasets. LGTM
Codecov Report
@@ Coverage Diff @@
## master #9649 +/- ##
==========================================
- Coverage 79% 67% -13%
==========================================
Files 385 303 -82
Lines 122384 105074 -17310
==========================================
- Hits 96936 69969 -26967
- Misses 25448 35105 +9657
Continue to review full report at Codecov.
|
This commit refactors the systemd mount generators and makes the following major changes: - The generator now generates units for datasets marked canmount=noauto, too. These units are NOT WantedBy local-fs.target. If there are multiple noauto datasets for a path, no noauto unit will be created. Datasets with canmount=on are prioritized. - Introduces handling of new user properties which are now included in the zfs-list.cache files: - org.openzfs.systemd:requires: List of units to require for this mount unit - org.openzfs.systemd:requires-mounts-for: List of mounts to require by this mount unit - org.openzfs.systemd:before: List of units to order after this mount unit - org.openzfs.systemd:after: List of units to order before this mount unit - org.openzfs.systemd:wanted-by: List of units to add a Wants dependency on this mount unit to - org.openzfs.systemd:required-by: List of units to add a Requires dependency on this mount unit to - org.openzfs.systemd:nofail: Toggles between a wants and a requires dependency. - org.openzfs.systemd:ignore: Do not generate a mount unit for this dataset. Consult the updated man page for detailed documentation. - Restructures and extends the zfs-mount-generator(8) man page with the above properties, information on unit ordering and a license header. Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
b4783a0
to
16c076a
Compare
@InsanePrawn Thanks for all your work on this! This has been a long process, but you've made something really nice here. |
This commit refactors the systemd mount generators and makes the following major changes: - The generator now generates units for datasets marked canmount=noauto, too. These units are NOT WantedBy local-fs.target. If there are multiple noauto datasets for a path, no noauto unit will be created. Datasets with canmount=on are prioritized. - Introduces handling of new user properties which are now included in the zfs-list.cache files: - org.openzfs.systemd:requires: List of units to require for this mount unit - org.openzfs.systemd:requires-mounts-for: List of mounts to require by this mount unit - org.openzfs.systemd:before: List of units to order after this mount unit - org.openzfs.systemd:after: List of units to order before this mount unit - org.openzfs.systemd:wanted-by: List of units to add a Wants dependency on this mount unit to - org.openzfs.systemd:required-by: List of units to add a Requires dependency on this mount unit to - org.openzfs.systemd:nofail: Toggles between a wants and a requires dependency. - org.openzfs.systemd:ignore: Do not generate a mount unit for this dataset. Consult the updated man page for detailed documentation. - Restructures and extends the zfs-mount-generator(8) man page with the above properties, information on unit ordering and a license header. Reviewed-by: Richard Laager <rlaager@wiktel.com> Reviewed-by: Antonio Russo <antonio.e.russo@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: InsanePrawn <insane.prawny@gmail.com> Closes #9649
Merged as: ecbbdac Systemd mount generator: Generate noauto units; add control properties @InsanePrawn @rlaager @aerusso thank you for all your work on this. |
Silences a warning about an intentionally unquoted variable. Fixes a warning caused by strings split across lines by slightly refactoring keyloadcmd. Reviewed-by: Richard Laager <rlaager@wiktel.com> Reviewed-by: Antonio Russo <antonio.e.russo@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: InsanePrawn <insane.prawny@gmail.com> Closes openzfs#9649
This commit refactors the systemd mount generators and makes the following major changes: - The generator now generates units for datasets marked canmount=noauto, too. These units are NOT WantedBy local-fs.target. If there are multiple noauto datasets for a path, no noauto unit will be created. Datasets with canmount=on are prioritized. - Introduces handling of new user properties which are now included in the zfs-list.cache files: - org.openzfs.systemd:requires: List of units to require for this mount unit - org.openzfs.systemd:requires-mounts-for: List of mounts to require by this mount unit - org.openzfs.systemd:before: List of units to order after this mount unit - org.openzfs.systemd:after: List of units to order before this mount unit - org.openzfs.systemd:wanted-by: List of units to add a Wants dependency on this mount unit to - org.openzfs.systemd:required-by: List of units to add a Requires dependency on this mount unit to - org.openzfs.systemd:nofail: Toggles between a wants and a requires dependency. - org.openzfs.systemd:ignore: Do not generate a mount unit for this dataset. Consult the updated man page for detailed documentation. - Restructures and extends the zfs-mount-generator(8) man page with the above properties, information on unit ordering and a license header. Reviewed-by: Richard Laager <rlaager@wiktel.com> Reviewed-by: Antonio Russo <antonio.e.russo@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: InsanePrawn <insane.prawny@gmail.com> Closes openzfs#9649
Silences a warning about an intentionally unquoted variable. Fixes a warning caused by strings split across lines by slightly refactoring keyloadcmd. Reviewed-by: Richard Laager <rlaager@wiktel.com> Reviewed-by: Antonio Russo <antonio.e.russo@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: InsanePrawn <insane.prawny@gmail.com> Closes openzfs#9649
This commit refactors the systemd mount generators and makes the following major changes: - The generator now generates units for datasets marked canmount=noauto, too. These units are NOT WantedBy local-fs.target. If there are multiple noauto datasets for a path, no noauto unit will be created. Datasets with canmount=on are prioritized. - Introduces handling of new user properties which are now included in the zfs-list.cache files: - org.openzfs.systemd:requires: List of units to require for this mount unit - org.openzfs.systemd:requires-mounts-for: List of mounts to require by this mount unit - org.openzfs.systemd:before: List of units to order after this mount unit - org.openzfs.systemd:after: List of units to order before this mount unit - org.openzfs.systemd:wanted-by: List of units to add a Wants dependency on this mount unit to - org.openzfs.systemd:required-by: List of units to add a Requires dependency on this mount unit to - org.openzfs.systemd:nofail: Toggles between a wants and a requires dependency. - org.openzfs.systemd:ignore: Do not generate a mount unit for this dataset. Consult the updated man page for detailed documentation. - Restructures and extends the zfs-mount-generator(8) man page with the above properties, information on unit ordering and a license header. Reviewed-by: Richard Laager <rlaager@wiktel.com> Reviewed-by: Antonio Russo <antonio.e.russo@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: InsanePrawn <insane.prawny@gmail.com> Closes openzfs#9649
Silences a warning about an intentionally unquoted variable. Fixes a warning caused by strings split across lines by slightly refactoring keyloadcmd. Reviewed-by: Richard Laager <rlaager@wiktel.com> Reviewed-by: Antonio Russo <antonio.e.russo@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: InsanePrawn <insane.prawny@gmail.com> Closes openzfs#9649
This commit refactors the systemd mount generators and makes the following major changes: - The generator now generates units for datasets marked canmount=noauto, too. These units are NOT WantedBy local-fs.target. If there are multiple noauto datasets for a path, no noauto unit will be created. Datasets with canmount=on are prioritized. - Introduces handling of new user properties which are now included in the zfs-list.cache files: - org.openzfs.systemd:requires: List of units to require for this mount unit - org.openzfs.systemd:requires-mounts-for: List of mounts to require by this mount unit - org.openzfs.systemd:before: List of units to order after this mount unit - org.openzfs.systemd:after: List of units to order before this mount unit - org.openzfs.systemd:wanted-by: List of units to add a Wants dependency on this mount unit to - org.openzfs.systemd:required-by: List of units to add a Requires dependency on this mount unit to - org.openzfs.systemd:nofail: Toggles between a wants and a requires dependency. - org.openzfs.systemd:ignore: Do not generate a mount unit for this dataset. Consult the updated man page for detailed documentation. - Restructures and extends the zfs-mount-generator(8) man page with the above properties, information on unit ordering and a license header. Reviewed-by: Richard Laager <rlaager@wiktel.com> Reviewed-by: Antonio Russo <antonio.e.russo@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: InsanePrawn <insane.prawny@gmail.com> Closes openzfs#9649
Silences a warning about an intentionally unquoted variable. Fixes a warning caused by strings split across lines by slightly refactoring keyloadcmd. Reviewed-by: Richard Laager <rlaager@wiktel.com> Reviewed-by: Antonio Russo <antonio.e.russo@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: InsanePrawn <insane.prawny@gmail.com> Closes #9649
This commit refactors the systemd mount generators and makes the following major changes: - The generator now generates units for datasets marked canmount=noauto, too. These units are NOT WantedBy local-fs.target. If there are multiple noauto datasets for a path, no noauto unit will be created. Datasets with canmount=on are prioritized. - Introduces handling of new user properties which are now included in the zfs-list.cache files: - org.openzfs.systemd:requires: List of units to require for this mount unit - org.openzfs.systemd:requires-mounts-for: List of mounts to require by this mount unit - org.openzfs.systemd:before: List of units to order after this mount unit - org.openzfs.systemd:after: List of units to order before this mount unit - org.openzfs.systemd:wanted-by: List of units to add a Wants dependency on this mount unit to - org.openzfs.systemd:required-by: List of units to add a Requires dependency on this mount unit to - org.openzfs.systemd:nofail: Toggles between a wants and a requires dependency. - org.openzfs.systemd:ignore: Do not generate a mount unit for this dataset. Consult the updated man page for detailed documentation. - Restructures and extends the zfs-mount-generator(8) man page with the above properties, information on unit ordering and a license header. Reviewed-by: Richard Laager <rlaager@wiktel.com> Reviewed-by: Antonio Russo <antonio.e.russo@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: InsanePrawn <insane.prawny@gmail.com> Closes #9649
Silences a warning about an intentionally unquoted variable. Fixes a warning caused by strings split across lines by slightly refactoring keyloadcmd. Reviewed-by: Richard Laager <rlaager@wiktel.com> Reviewed-by: Antonio Russo <antonio.e.russo@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: InsanePrawn <insane.prawny@gmail.com> Closes openzfs#9649
This commit refactors the systemd mount generators and makes the following major changes: - The generator now generates units for datasets marked canmount=noauto, too. These units are NOT WantedBy local-fs.target. If there are multiple noauto datasets for a path, no noauto unit will be created. Datasets with canmount=on are prioritized. - Introduces handling of new user properties which are now included in the zfs-list.cache files: - org.openzfs.systemd:requires: List of units to require for this mount unit - org.openzfs.systemd:requires-mounts-for: List of mounts to require by this mount unit - org.openzfs.systemd:before: List of units to order after this mount unit - org.openzfs.systemd:after: List of units to order before this mount unit - org.openzfs.systemd:wanted-by: List of units to add a Wants dependency on this mount unit to - org.openzfs.systemd:required-by: List of units to add a Requires dependency on this mount unit to - org.openzfs.systemd:nofail: Toggles between a wants and a requires dependency. - org.openzfs.systemd:ignore: Do not generate a mount unit for this dataset. Consult the updated man page for detailed documentation. - Restructures and extends the zfs-mount-generator(8) man page with the above properties, information on unit ordering and a license header. Reviewed-by: Richard Laager <rlaager@wiktel.com> Reviewed-by: Antonio Russo <antonio.e.russo@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: InsanePrawn <insane.prawny@gmail.com> Closes openzfs#9649
Needs some detail work, e.g. default values for the config vars.
As discovered in #9611, there is still some potentially desirable behaviours that the systemd generator does or does not show:
Motivation and Context
Admins might not want the default behaviour of systemd mounting every canmount=on dataset with a valid mount point during boot (e.g. to utilize .automount units). Added code to disable the symlinking based on a variable, leaving it enabled by default (same as old behaviour)
Added code to conditionally create .mount units for datasets with canmount=noauto, disabled by default (same as old behaviour)
Caveats: Currently no default values for those config strings. Might want to discuss whether to check for 'yes' or 'no' for every variable to achieve the best possible default behaviour.
Description
Looking for feedback! Is this the right file to store this config? Currently just sourcing it as a shell script, anything nicer? Config variable names - I think at least
ZFS_SYSTEMD_NOAUTO_UNITS
needs a rename. Suggestions?Skip symlinking altogether if config var is set. Currently always skips symlink creation for canmount=noauto datasets. Seems sane to me.
I've left the creation of these units disabled by default, as they would get pulled in by mount units of descending paths (which can come from outside ZFS!).
This seems like the right thing to do in most situations, but I'd rather have a switch to control this rather than having to change pool configs or layouts to accommodate the generator, especially since this would be a breaking change.
from
man systemd.mount
:How Has This Been Tested?
Very manually on my Debian 9 server. The variables seem to function correctly.
Types of changes
Checklist:
Signed-off-by
.