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

stage-1: retry mounting ZFS root a few times #89353

Merged
merged 1 commit into from Aug 22, 2020

Conversation

wizeman
Copy link
Member

@wizeman wizeman commented Jun 2, 2020

Motivation for this change

This is a workaround for #25383.
I've been running my ZFS and non-ZFS systems with this change for years but had forgotten to submit a PR.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

local n=0
while true; do
mount "/mnt-root$mountPoint" && break
if [ "$fsType" != cifs -o "$n" -ge 10 ]; then fail; break; fi
if [ \( "$fsType" != cifs -a "$fsType" != zfs \) -o "$n" -ge 10 ]; then fail; break; fi
Copy link
Member

Choose a reason for hiding this comment

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

I assume upstream does not have this problem because they use zpool import instead of mount: https://github.com/openzfs/zfs/blob/master/contrib/dracut/90zfs/mount-zfs.sh.in#L59

Copy link
Member Author

@wizeman wizeman Jun 4, 2020

Choose a reason for hiding this comment

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

No, they use zpool import to import/open the pool (like we do) but then they also mount the dataset/filesystem (like we do), see https://github.com/openzfs/zfs/blob/99b281f1ae3833826b4e3cee4126a4ea5e6de987/contrib/dracut/90zfs/mount-zfs.sh.in#L80 and https://github.com/openzfs/zfs/blob/99b281f1ae3833826b4e3cee4126a4ea5e6de987/contrib/dracut/90zfs/zfs-lib.sh.in#L76

Note that upstream doesn't retry mounting like I am doing here, and for sure mount returning Device or resource busy sporadically while mounting the root filesystem like in #25383 seems like a bug in ZFS (which I'm not sure has been fixed), but I think it doesn't hurt to do what I'm doing: it will fix the boot failure in case the bug resurfaces again, while only making the boot hang 10 seconds later in case there is a real mount problem.

Copy link
Member

Choose a reason for hiding this comment

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

Can you also link to the issue in the code, so in future we know why it was added?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, thanks!

@Lassulus Lassulus merged commit 6a2c730 into NixOS:master Aug 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants