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

Fix Linux kernel directories detection #13096

Merged
merged 1 commit into from
Feb 16, 2022
Merged

Fix Linux kernel directories detection #13096

merged 1 commit into from
Feb 16, 2022

Conversation

szubersk
Copy link
Contributor

@szubersk szubersk commented Feb 12, 2022

Motivation and Context

Close #9935

Description

Most modern Linux distributions have separate locations for bare
source (source) and prebuilt (build) files. Additionally, there are
source and build symlinks in /lib/modules/$(KERNEL_VERSION)
pointing to them. The directory search order is now:

  • configure command line values if both --with-linux and
    --with-linux-obj were defined

  • If only --with-linux was defined, --with-linux-obj is assumed
    to have the same value as --with-linux

  • If neither --with-linux nor --with-linux-obj were defined
    autodetection is used:

    • /lib/modules/$(uname -r)/{source,build} respectively, if exist.

    • If only /lib/modules/$(uname -r)/build exists, it is assumed
      to be both source and build directory.

    • The first directory in /lib/modules with the highest version
      number according to sort -V which contains both source and
      build symlinks/directories. If module directory contains only
      build component, it is assumed to be both source and build
      directory.

    • Last resort: the first directory matching /usr/src/kernels/*
      and /usr/src/linux-* with the highest version number according
      to sort -V is assumed to be both source and build directory.

This fix should be cherry-picked to zfs-0.8-release and zfs-2.0-release branches with high priority as it fixes build problems in the upstream.

How Has This Been Tested?

make -j1 deb-utils deb-dkms on

  • zfs-0.8-release + vanilla 5.9.16 kernel
  • zfs-2.0-release + Debian bullseye kernel (5.10 + patches)

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)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@szubersk
Copy link
Contributor Author

Now it's ready-ready.

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.

Where each distribution locates its kernel headers and objects has changed somewhat since these checks were originally written, so thanks for revisiting this logic in the context of issue 9935. What's proposed here looks good, and it's really nice to see a human readable explanation of the detection logic. Let's add it to the comment right before ZFS_AC_KERNEL.

config/kernel.m4 Outdated Show resolved Hide resolved
Most modern Linux distributions have separate locations for bare
source and prebuilt ("build") files. Additionally, there are `source`
and `build` symlinks in `/lib/modules/$(KERNEL_VERSION)` pointing to
them. The order of directory search is now:
- `configure` command line values if both `--with-linux` and
  `--with-linux-obj` were defined
- If only `--with-linux` was defined, `--with-linux-obj` is assumed
  to have the same value as `--with-linux`
- If neither `--with-linux` nor `--with-linux-obj` were defined
  autodetection is used:
  - `/lib/modules/$(uname -r)/{source,build}` respectively, if exist
  - The first directory in `/lib/modules` with the highest version
    number according to `sort -V` which contains `source` and `build`
    symlinks/directories
  - The first directory matching `/usr/src/kernels/*` and
    `/usr/src/linux-*` with the highest version number according to
    `sort -V`. Here the source and prebuilt directories are assumed
    to be the same.

Signed-off-by: szubersk <szuberskidamian@gmail.com>
@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Feb 14, 2022
@szubersk
Copy link
Contributor Author

Where each distribution locates its kernel headers and objects has changed somewhat since these checks were originally written, so thanks for revisiting this logic in the context of issue 9935. What's proposed here looks good, and it's really nice to see a human readable explanation of the detection logic. Let's add it to the comment right before ZFS_AC_KERNEL.

Understood. I hit a lot of quirks myself while testing this PR. I hope all Linux distros are going to switch to /lib/modules/$(KERNEL_VERSION)/{source,build} convention (hello Ubuntu).

@behlendorf behlendorf merged commit 72f3c8b into openzfs:master Feb 16, 2022
@szubersk szubersk deleted the szubersk-kernel-detection branch February 18, 2022 20:19
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Feb 24, 2022
Most modern Linux distributions have separate locations for bare
source and prebuilt ("build") files. Additionally, there are `source`
and `build` symlinks in `/lib/modules/$(KERNEL_VERSION)` pointing to
them. The order of directory search is now:
- `configure` command line values if both `--with-linux` and
  `--with-linux-obj` were defined
- If only `--with-linux` was defined, `--with-linux-obj` is assumed
  to have the same value as `--with-linux`
- If neither `--with-linux` nor `--with-linux-obj` were defined
  autodetection is used:
  - `/lib/modules/$(uname -r)/{source,build}` respectively, if exist
  - The first directory in `/lib/modules` with the highest version
    number according to `sort -V` which contains `source` and `build`
    symlinks/directories
  - The first directory matching `/usr/src/kernels/*` and
    `/usr/src/linux-*` with the highest version number according to
    `sort -V`. Here the source and prebuilt directories are assumed
    to be the same.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes openzfs#9935
Closes openzfs#13096
behlendorf pushed a commit that referenced this pull request Feb 24, 2022
Fix `zfs-dkms` installation on Debian-derived distributions by
aligning the directory detection logic to #13096.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes #11449
Closes #13141
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Feb 24, 2022
Fix `zfs-dkms` installation on Debian-derived distributions by
aligning the directory detection logic to openzfs#13096.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes openzfs#11449
Closes openzfs#13141
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
Most modern Linux distributions have separate locations for bare
source and prebuilt ("build") files. Additionally, there are `source`
and `build` symlinks in `/lib/modules/$(KERNEL_VERSION)` pointing to
them. The order of directory search is now:
- `configure` command line values if both `--with-linux` and
  `--with-linux-obj` were defined
- If only `--with-linux` was defined, `--with-linux-obj` is assumed
  to have the same value as `--with-linux`
- If neither `--with-linux` nor `--with-linux-obj` were defined
  autodetection is used:
  - `/lib/modules/$(uname -r)/{source,build}` respectively, if exist
  - The first directory in `/lib/modules` with the highest version
    number according to `sort -V` which contains `source` and `build`
    symlinks/directories
  - The first directory matching `/usr/src/kernels/*` and
    `/usr/src/linux-*` with the highest version number according to
    `sort -V`. Here the source and prebuilt directories are assumed
    to be the same.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes openzfs#9935
Closes openzfs#13096
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
Fix `zfs-dkms` installation on Debian-derived distributions by
aligning the directory detection logic to openzfs#13096.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes openzfs#11449
Closes openzfs#13141
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
Most modern Linux distributions have separate locations for bare
source and prebuilt ("build") files. Additionally, there are `source`
and `build` symlinks in `/lib/modules/$(KERNEL_VERSION)` pointing to
them. The order of directory search is now:
- `configure` command line values if both `--with-linux` and
  `--with-linux-obj` were defined
- If only `--with-linux` was defined, `--with-linux-obj` is assumed
  to have the same value as `--with-linux`
- If neither `--with-linux` nor `--with-linux-obj` were defined
  autodetection is used:
  - `/lib/modules/$(uname -r)/{source,build}` respectively, if exist
  - The first directory in `/lib/modules` with the highest version
    number according to `sort -V` which contains `source` and `build`
    symlinks/directories
  - The first directory matching `/usr/src/kernels/*` and
    `/usr/src/linux-*` with the highest version number according to
    `sort -V`. Here the source and prebuilt directories are assumed
    to be the same.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes openzfs#9935
Closes openzfs#13096
nicman23 pushed a commit to nicman23/zfs that referenced this pull request Aug 22, 2022
Fix `zfs-dkms` installation on Debian-derived distributions by
aligning the directory detection logic to openzfs#13096.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes openzfs#11449
Closes openzfs#13141
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Aug 30, 2022
Most modern Linux distributions have separate locations for bare
source and prebuilt ("build") files. Additionally, there are `source`
and `build` symlinks in `/lib/modules/$(KERNEL_VERSION)` pointing to
them. The order of directory search is now:
- `configure` command line values if both `--with-linux` and
  `--with-linux-obj` were defined
- If only `--with-linux` was defined, `--with-linux-obj` is assumed
  to have the same value as `--with-linux`
- If neither `--with-linux` nor `--with-linux-obj` were defined
  autodetection is used:
  - `/lib/modules/$(uname -r)/{source,build}` respectively, if exist
  - The first directory in `/lib/modules` with the highest version
    number according to `sort -V` which contains `source` and `build`
    symlinks/directories
  - The first directory matching `/usr/src/kernels/*` and
    `/usr/src/linux-*` with the highest version number according to
    `sort -V`. Here the source and prebuilt directories are assumed
    to be the same.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes openzfs#9935
Closes openzfs#13096
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Aug 30, 2022
Fix `zfs-dkms` installation on Debian-derived distributions by
aligning the directory detection logic to openzfs#13096.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes openzfs#11449
Closes openzfs#13141
lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Sep 1, 2022
Most modern Linux distributions have separate locations for bare
source and prebuilt ("build") files. Additionally, there are `source`
and `build` symlinks in `/lib/modules/$(KERNEL_VERSION)` pointing to
them. The order of directory search is now:
- `configure` command line values if both `--with-linux` and
  `--with-linux-obj` were defined
- If only `--with-linux` was defined, `--with-linux-obj` is assumed
  to have the same value as `--with-linux`
- If neither `--with-linux` nor `--with-linux-obj` were defined
  autodetection is used:
  - `/lib/modules/$(uname -r)/{source,build}` respectively, if exist
  - The first directory in `/lib/modules` with the highest version
    number according to `sort -V` which contains `source` and `build`
    symlinks/directories
  - The first directory matching `/usr/src/kernels/*` and
    `/usr/src/linux-*` with the highest version number according to
    `sort -V`. Here the source and prebuilt directories are assumed
    to be the same.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes openzfs#9935
Closes openzfs#13096
lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Sep 1, 2022
Fix `zfs-dkms` installation on Debian-derived distributions by
aligning the directory detection logic to openzfs#13096.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes openzfs#11449
Closes openzfs#13141
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Sep 23, 2022
Most modern Linux distributions have separate locations for bare
source and prebuilt ("build") files. Additionally, there are `source`
and `build` symlinks in `/lib/modules/$(KERNEL_VERSION)` pointing to
them. The order of directory search is now:
- `configure` command line values if both `--with-linux` and
  `--with-linux-obj` were defined
- If only `--with-linux` was defined, `--with-linux-obj` is assumed
  to have the same value as `--with-linux`
- If neither `--with-linux` nor `--with-linux-obj` were defined
  autodetection is used:
  - `/lib/modules/$(uname -r)/{source,build}` respectively, if exist
  - The first directory in `/lib/modules` with the highest version
    number according to `sort -V` which contains `source` and `build`
    symlinks/directories
  - The first directory matching `/usr/src/kernels/*` and
    `/usr/src/linux-*` with the highest version number according to
    `sort -V`. Here the source and prebuilt directories are assumed
    to be the same.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes openzfs#9935
Closes openzfs#13096
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Sep 23, 2022
Fix `zfs-dkms` installation on Debian-derived distributions by
aligning the directory detection logic to openzfs#13096.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes openzfs#11449
Closes openzfs#13141
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Sep 23, 2022
Most modern Linux distributions have separate locations for bare
source and prebuilt ("build") files. Additionally, there are `source`
and `build` symlinks in `/lib/modules/$(KERNEL_VERSION)` pointing to
them. The order of directory search is now:
- `configure` command line values if both `--with-linux` and
  `--with-linux-obj` were defined
- If only `--with-linux` was defined, `--with-linux-obj` is assumed
  to have the same value as `--with-linux`
- If neither `--with-linux` nor `--with-linux-obj` were defined
  autodetection is used:
  - `/lib/modules/$(uname -r)/{source,build}` respectively, if exist
  - The first directory in `/lib/modules` with the highest version
    number according to `sort -V` which contains `source` and `build`
    symlinks/directories
  - The first directory matching `/usr/src/kernels/*` and
    `/usr/src/linux-*` with the highest version number according to
    `sort -V`. Here the source and prebuilt directories are assumed
    to be the same.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes openzfs#9935
Closes openzfs#13096
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Sep 23, 2022
Fix `zfs-dkms` installation on Debian-derived distributions by
aligning the directory detection logic to openzfs#13096.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes openzfs#11449
Closes openzfs#13141
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Sep 23, 2022
Most modern Linux distributions have separate locations for bare
source and prebuilt ("build") files. Additionally, there are `source`
and `build` symlinks in `/lib/modules/$(KERNEL_VERSION)` pointing to
them. The order of directory search is now:
- `configure` command line values if both `--with-linux` and
  `--with-linux-obj` were defined
- If only `--with-linux` was defined, `--with-linux-obj` is assumed
  to have the same value as `--with-linux`
- If neither `--with-linux` nor `--with-linux-obj` were defined
  autodetection is used:
  - `/lib/modules/$(uname -r)/{source,build}` respectively, if exist
  - The first directory in `/lib/modules` with the highest version
    number according to `sort -V` which contains `source` and `build`
    symlinks/directories
  - The first directory matching `/usr/src/kernels/*` and
    `/usr/src/linux-*` with the highest version number according to
    `sort -V`. Here the source and prebuilt directories are assumed
    to be the same.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes openzfs#9935
Closes openzfs#13096
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Sep 23, 2022
Fix `zfs-dkms` installation on Debian-derived distributions by
aligning the directory detection logic to openzfs#13096.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes openzfs#11449
Closes openzfs#13141
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Sep 23, 2022
Fix `zfs-dkms` installation on Debian-derived distributions by
aligning the directory detection logic to openzfs#13096.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes openzfs#11449
Closes openzfs#13141
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Sep 23, 2022
Fix `zfs-dkms` installation on Debian-derived distributions by
aligning the directory detection logic to openzfs#13096.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes openzfs#11449
Closes openzfs#13141
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Sep 23, 2022
Fix `zfs-dkms` installation on Debian-derived distributions by
aligning the directory detection logic to openzfs#13096.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes openzfs#11449
Closes openzfs#13141
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.

Installing zfs from the repo will not build on the kernel
2 participants