From d586d4dcef6fd29b0d77c22b00887178a49091fb Mon Sep 17 00:00:00 2001 From: birkb Date: Tue, 30 Jan 2024 20:55:34 +0100 Subject: [PATCH] drbd kernel driver added - out-of-tree kernel driver added with version 9.2.7 - package splitted into utils.nix and driver.nix - small deprecation fix for the package test - Release Notes for 24.05 updated Signed-off-by: birkb --- .../manual/release-notes/rl-2405.section.md | 2 + nixos/tests/drbd.nix | 6 +- pkgs/os-specific/linux/drbd/default.nix | 128 ------------------ pkgs/os-specific/linux/drbd/driver.nix | 57 ++++++++ pkgs/top-level/all-packages.nix | 2 +- pkgs/top-level/linux-kernels.nix | 2 + 6 files changed, 65 insertions(+), 132 deletions(-) delete mode 100644 pkgs/os-specific/linux/drbd/default.nix create mode 100644 pkgs/os-specific/linux/drbd/driver.nix diff --git a/nixos/doc/manual/release-notes/rl-2405.section.md b/nixos/doc/manual/release-notes/rl-2405.section.md index b347992031d9..96ed7f577d23 100644 --- a/nixos/doc/manual/release-notes/rl-2405.section.md +++ b/nixos/doc/manual/release-notes/rl-2405.section.md @@ -150,3 +150,5 @@ The pre-existing [services.ankisyncd](#opt-services.ankisyncd.enable) has been m - QtMultimedia has changed its default backend to `QT_MEDIA_BACKEND=ffmpeg` (previously `gstreamer` on Linux or `darwin` on MacOS). The previous native backends remain available but are now minimally maintained. Refer to [upstream documentation](https://doc.qt.io/qt-6/qtmultimedia-index.html#ffmpeg-as-the-default-backend) for further details about each platform. + +- The `drbd` out-of-tree Linux kernel driver has been added in version `9.2.7`. With it the DRBD 9.x features can be used instead of the 8.x features provided by the `8.4.11` in-tree driver. diff --git a/nixos/tests/drbd.nix b/nixos/tests/drbd.nix index bede7206d706..defbad693393 100644 --- a/nixos/tests/drbd.nix +++ b/nixos/tests/drbd.nix @@ -31,11 +31,11 @@ import ./make-test-python.nix ( } on drbd1 { - address ${nodes.drbd1.config.networking.primaryIPAddress}:${toString drbdPort}; + address ${nodes.drbd1.networking.primaryIPAddress}:${toString drbdPort}; } on drbd2 { - address ${nodes.drbd2.config.networking.primaryIPAddress}:${toString drbdPort}; + address ${nodes.drbd2.networking.primaryIPAddress}:${toString drbdPort}; } } ''; @@ -45,7 +45,7 @@ import ./make-test-python.nix ( { name = "drbd"; meta = with pkgs.lib.maintainers; { - maintainers = [ ryantm astro ]; + maintainers = [ ryantm astro birkb ]; }; nodes.drbd1 = drbdConfig; diff --git a/pkgs/os-specific/linux/drbd/default.nix b/pkgs/os-specific/linux/drbd/default.nix deleted file mode 100644 index 0c5acd0ac064..000000000000 --- a/pkgs/os-specific/linux/drbd/default.nix +++ /dev/null @@ -1,128 +0,0 @@ -{ lib -, stdenv -, docbook_xml_dtd_44 -, docbook_xml_dtd_45 -, docbook_xsl -, asciidoctor -, fetchurl -, flex -, kmod -, libxslt -, nixosTests -, perl -, systemd - -# drbd-utils are compiled twice, once with forOCF = true to extract -# its OCF definitions for use in the ocf-resource-agents derivation, -# then again with forOCF = false, where the ocf-resource-agents is -# provided as the OCF_ROOT. -, forOCF ? false -, ocf-resource-agents -}: - -stdenv.mkDerivation rec { - pname = "drbd"; - version = "9.19.1"; - - src = fetchurl { - url = "https://pkg.linbit.com/downloads/drbd/utils/${pname}-utils-${version}.tar.gz"; - sha256 = "1l99kcrb0j85wxxmrdihpx9bk1a4sdi7wlp5m1x5l24k8ck1m5cf"; - }; - - nativeBuildInputs = [ - flex - libxslt - docbook_xsl - asciidoctor - ]; - - buildInputs = [ - perl - # perlPackages.Po4a used by ja documentation - ]; - - configureFlags = [ - "--libdir=${placeholder "out"}/lib" - "--sbindir=${placeholder "out"}/bin" - "--localstatedir=/var" - "--sysconfdir=/etc" - "--without-distro" - ]; - - makeFlags = [ - "SOURCE_DATE_EPOCH=1" - "WANT_DRBD_REPRODUCIBLE_BUILD=1" - ] ++ lib.optional (!forOCF) "OCF_ROOT=${ocf-resource-agents}/usr/lib/ocf}"; - - installFlags = [ - "prefix=" - "DESTDIR=${placeholder "out"}" - "localstatedir=/var" - "DRBD_LIB_DIR=/var/lib" - "INITDIR=/etc/init.d" - "udevrulesdir=/etc/udev/rules.d" - "sysconfdir=/etc" - "sbindir=/bin" - "datadir=" - "LIBDIR=/lib/drbd" - "mandir=/share/man" - ]; - - postPatch = '' - patchShebangs . - substituteInPlace user/v84/drbdadm_usage_cnt.c \ - --replace '"/lib/drbd");' \ - '"${placeholder "out"}/lib/drbd");' - substituteInPlace user/v9/drbdsetup_linux.c \ - --replace 'ret = system("/sbin/modprobe drbd");' \ - 'ret = system("${kmod}/bin/modprobe drbd");' - substituteInPlace user/v84/drbdsetup.c \ - --replace 'system("/sbin/modprobe drbd")' \ - 'system("${kmod}/bin/modprobe drbd")' - substituteInPlace documentation/ra2refentry.xsl \ - --replace "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" \ - "${docbook_xml_dtd_44}/xml/dtd/docbook/docbookx.dtd" - function patch_docbook45() { - substituteInPlace $1 \ - --replace "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" \ - "${docbook_xml_dtd_45}/xml/dtd/docbook/docbookx.dtd" - } - patch_docbook45 documentation/v9/drbd.conf.xml.in - patch_docbook45 documentation/v9/drbdsetup.xml.in - patch_docbook45 documentation/v84/drbdsetup.xml - patch_docbook45 documentation/v84/drbd.conf.xml - # The ja documentation is disabled because: - # make[1]: Entering directory '/build/drbd-utils-9.16.0/documentation/ja/v84' - # /nix/store/wyx2nn2pjcn50lc95c6qgsgm606rn0x2-perl5.32.1-po4a-0.62/bin/po4a-translate -f docbook -M utf-8 -L utf-8 -keep 0 -m ../../v84/drbdsetup.xml -p drbdsetup.xml.po -l drbdsetup.xml - # Use of uninitialized value $args[1] in sprintf at /nix/store/wyx2nn2pjcn50lc95c6qgsgm606rn0x2-perl5.32.1-po4a-0.62/lib/perl5/site_perl/Locale/Po4a/Common.pm line 134. - # Invalid po file drbdsetup.xml.po: - substituteInPlace Makefile.in \ - --replace 'DOC_DIRS := documentation/v9 documentation/ja/v9' \ - 'DOC_DIRS := documentation/v9' \ - --replace 'DOC_DIRS += documentation/v84 documentation/ja/v84' \ - 'DOC_DIRS += documentation/v84' \ - --replace '$(MAKE) -C documentation/ja/v9 doc' \ - "" \ - --replace '$(MAKE) -C documentation/ja/v84 doc' \ - "" - substituteInPlace user/v9/drbdtool_common.c \ - --replace 'add_component_to_path("/lib/drbd");' \ - 'add_component_to_path("${placeholder "out"}/lib/drbd");' - ''; - - preConfigure = '' - export PATH=${systemd}/sbin:$PATH - ''; - - enableParallelBuilding = true; - - passthru.tests.drbd = nixosTests.drbd; - - meta = with lib; { - homepage = "https://linbit.com/drbd/"; - description = "Distributed Replicated Block Device, a distributed storage system for Linux (userspace utilities)"; - license = licenses.gpl2Plus; - platforms = platforms.linux; - maintainers = with maintainers; [ ryantm astro ]; - }; -} diff --git a/pkgs/os-specific/linux/drbd/driver.nix b/pkgs/os-specific/linux/drbd/driver.nix new file mode 100644 index 000000000000..efc771905e53 --- /dev/null +++ b/pkgs/os-specific/linux/drbd/driver.nix @@ -0,0 +1,57 @@ +{ stdenv, lib, fetchurl, kernel, flex, coccinelle, python3 }: + +stdenv.mkDerivation rec { + name = "drbd-${version}-${kernel.version}"; + version = "9.2.7"; + + src = fetchurl { + url = "https://pkg.linbit.com//downloads/drbd/9/drbd-${version}.tar.gz"; + sha256 = "1355ns10z0fjgqsdpf09qfy01j8lg2n7zy4kclmar3s798n3mh56"; + }; + + hardeningDisable = [ "pic" ]; + + nativeBuildInputs = [ + kernel.moduleBuildDependencies + flex + coccinelle + python3 + ]; + + makeFlags = [ + "KDIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" + "SPAAS=false" + ]; + + # 6.4 and newer provide a in-tree version of the handshake module https://www.kernel.org/doc/html/v6.4/networking/tls-handshake.html + installPhase = '' + runHook preInstall + install -D drbd/drbd.ko -t $out/lib/modules/${kernel.modDirVersion}/kernel/drivers/block/drbd + install -D drbd/drbd_transport_tcp.ko -t $out/lib/modules/${kernel.modDirVersion}/kernel/drivers/block/drbd + install -D drbd/drbd_transport_lb-tcp.ko -t $out/lib/modules/${kernel.modDirVersion}/kernel/drivers/block/drbd + install -D drbd/drbd_transport_rdma.ko -t $out/lib/modules/${kernel.modDirVersion}/kernel/drivers/block/drbd + ${lib.optionalString (lib.versionOlder kernel.version "6.4") '' + install -D drbd/drbd-kernel-compat/handshake/handshake.ko -t $out/lib/modules/${kernel.modDirVersion}/kernel/drivers/block/drbd + ''} + runHook postInstall + ''; + + postPatch = '' + patchShebangs . + substituteInPlace Makefile --replace 'SHELL=/bin/bash' 'SHELL=${builtins.getEnv "SHELL"}' + ''; + + enableParallelBuilding = true; + + meta = with lib; { + homepage = "https://github.com/LINBIT/drbd"; + description = "LINBIT DRBD kernel module"; + license = licenses.gpl2Plus; + platforms = platforms.linux; + maintainers = with maintainers; [ birkb ]; + longDescription = '' + DRBD is a software-based, shared-nothing, replicated storage solution + mirroring the content of block devices (hard disks, partitions, logical volumes, and so on) between hosts. + ''; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 26f01082edd5..53e8a6d7583a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -27800,7 +27800,7 @@ with pkgs; dmraid = callPackage ../os-specific/linux/dmraid { lvm2 = lvm2_dmeventd; }; - drbd = callPackage ../os-specific/linux/drbd { }; + drbd = callPackage ../os-specific/linux/drbd/utils.nix { }; dropwatch = callPackage ../os-specific/linux/dropwatch { }; diff --git a/pkgs/top-level/linux-kernels.nix b/pkgs/top-level/linux-kernels.nix index c8cd917c1510..41c47ae3ddd2 100644 --- a/pkgs/top-level/linux-kernels.nix +++ b/pkgs/top-level/linux-kernels.nix @@ -574,6 +574,8 @@ in { hid-tmff2 = callPackage ../os-specific/linux/hid-tmff2 { }; + drbd = callPackage ../os-specific/linux/drbd/driver.nix { }; + } // lib.optionalAttrs config.allowAliases { ati_drivers_x11 = throw "ati drivers are no longer supported by any kernel >=4.1"; # added 2021-05-18; hid-nintendo = throw "hid-nintendo was added in mainline kernel version 5.16"; # Added 2023-07-30