diff options
author | Georgy Yakovlev <gyakovlev@gentoo.org> | 2021-06-03 19:12:24 -0700 |
---|---|---|
committer | Georgy Yakovlev <gyakovlev@gentoo.org> | 2021-06-03 19:12:24 -0700 |
commit | 4826c2e6f797cfeab33aad2542d402916653fd91 (patch) | |
tree | d208a30659f1fce8f6e5eb9f732e549703126d05 /sys-fs | |
parent | sys-fs/zfs-kmod: revbump 2.0.4, add 5.12 support and fixes (diff) | |
download | gentoo-4826c2e6f797cfeab33aad2542d402916653fd91.tar.gz gentoo-4826c2e6f797cfeab33aad2542d402916653fd91.tar.bz2 gentoo-4826c2e6f797cfeab33aad2542d402916653fd91.zip |
sys-fs/zfs: revbump 2.0.4, add scrub timers
to use with systemd
Pr: https://github.com/openzfs/zfs/pull/12193
Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
Diffstat (limited to 'sys-fs')
-rw-r--r-- | sys-fs/zfs/files/2.0.4-scrub-timers.patch | 97 | ||||
-rw-r--r-- | sys-fs/zfs/zfs-2.0.4-r1.ebuild | 230 |
2 files changed, 327 insertions, 0 deletions
diff --git a/sys-fs/zfs/files/2.0.4-scrub-timers.patch b/sys-fs/zfs/files/2.0.4-scrub-timers.patch new file mode 100644 index 000000000000..6aae1e4de596 --- /dev/null +++ b/sys-fs/zfs/files/2.0.4-scrub-timers.patch @@ -0,0 +1,97 @@ +From e23d7e03637e377591a480d87630b746cdaa377f Mon Sep 17 00:00:00 2001 +From: Georgy Yakovlev <gyakovlev@gentoo.org> +Date: Sat, 22 May 2021 22:27:39 -0700 +Subject: [PATCH] systemd: add weekly and monthly scrub timers + +timers can be enabled as follows: + +systemctl enable zfs-scrub-weekly@rpool.timer --now +systemctl enable zfs-scrub-monthly@datapool.timer --now + +Each timer will pull in zfs-scrub@${poolname}.service, which is not +schedule-specific. + +Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org> +--- + etc/systemd/system/Makefile.am | 5 ++++- + etc/systemd/system/zfs-scrub-monthly@.timer.in | 12 ++++++++++++ + etc/systemd/system/zfs-scrub-weekly@.timer.in | 12 ++++++++++++ + etc/systemd/system/zfs-scrub@.service.in | 12 ++++++++++++ + 4 files changed, 40 insertions(+), 1 deletion(-) + create mode 100644 etc/systemd/system/zfs-scrub-monthly@.timer.in + create mode 100644 etc/systemd/system/zfs-scrub-weekly@.timer.in + create mode 100644 etc/systemd/system/zfs-scrub@.service.in + +diff --git a/etc/systemd/system/Makefile.am b/etc/systemd/system/Makefile.am +index c374a52ac..5e65e1db4 100644 +--- a/etc/systemd/system/Makefile.am ++++ b/etc/systemd/system/Makefile.am +@@ -12,7 +12,10 @@ systemdunit_DATA = \ + zfs-volume-wait.service \ + zfs-import.target \ + zfs-volumes.target \ +- zfs.target ++ zfs.target \ ++ zfs-scrub-monthly@.timer \ ++ zfs-scrub-weekly@.timer \ ++ zfs-scrub@.service + + SUBSTFILES += $(systemdpreset_DATA) $(systemdunit_DATA) + +diff --git a/etc/systemd/system/zfs-scrub-monthly@.timer.in b/etc/systemd/system/zfs-scrub-monthly@.timer.in +new file mode 100644 +index 000000000..4c585f45f +--- /dev/null ++++ b/etc/systemd/system/zfs-scrub-monthly@.timer.in +@@ -0,0 +1,12 @@ ++[Unit] ++Description=Monthly zpool scrub timer for %i ++Documentation=man:zpool-scrub(8) ++ ++[Timer] ++OnCalendar=monthly ++AccuracySec=1h ++Persistent=true ++Unit=zfs-scrub@%i.service ++ ++[Install] ++WantedBy=timers.target +diff --git a/etc/systemd/system/zfs-scrub-weekly@.timer.in b/etc/systemd/system/zfs-scrub-weekly@.timer.in +new file mode 100644 +index 000000000..b2454be2c +--- /dev/null ++++ b/etc/systemd/system/zfs-scrub-weekly@.timer.in +@@ -0,0 +1,12 @@ ++[Unit] ++Description=Weekly zpool scrub timer for %i ++Documentation=man:zpool-scrub(8) ++ ++[Timer] ++OnCalendar=weekly ++AccuracySec=1h ++Persistent=true ++Unit=zfs-scrub@%i.service ++ ++[Install] ++WantedBy=timers.target +diff --git a/etc/systemd/system/zfs-scrub@.service.in b/etc/systemd/system/zfs-scrub@.service.in +new file mode 100644 +index 000000000..720901165 +--- /dev/null ++++ b/etc/systemd/system/zfs-scrub@.service.in +@@ -0,0 +1,12 @@ ++[Unit] ++Description=zpool scrub on %i ++Documentation=man:zpool-scrub(8) ++Requires=zfs.target ++After=zfs.target ++ConditionPathIsDirectory=/sys/module/zfs ++ ++[Service] ++Nice=19 ++IOSchedulingClass=idle ++KillSignal=SIGINT ++ExecStart=@sbindir@/zpool scrub %i +-- +2.31.1 + diff --git a/sys-fs/zfs/zfs-2.0.4-r1.ebuild b/sys-fs/zfs/zfs-2.0.4-r1.ebuild new file mode 100644 index 000000000000..e22f834e451b --- /dev/null +++ b/sys-fs/zfs/zfs-2.0.4-r1.ebuild @@ -0,0 +1,230 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +DISTUTILS_OPTIONAL=1 +DISTUTILS_USE_SETUPTOOLS=manual +PYTHON_COMPAT=( python3_{7,8,9} ) + +inherit autotools bash-completion-r1 distutils-r1 flag-o-matic linux-info pam systemd toolchain-funcs udev usr-ldscript + +DESCRIPTION="Userland utilities for ZFS Linux kernel module" +HOMEPAGE="https://github.com/openzfs/zfs" + +if [[ ${PV} == "9999" ]] ; then + inherit git-r3 linux-mod + EGIT_REPO_URI="https://github.com/openzfs/zfs.git" +else + MY_P="${P/_rc/-rc}" + SRC_URI="https://github.com/openzfs/${PN}/releases/download/${MY_P}/${MY_P}.tar.gz" + KEYWORDS="~amd64 ~arm64 ~ppc64" + S="${WORKDIR}/${P%_rc?}" +fi + +LICENSE="BSD-2 CDDL MIT" +# just libzfs soname major for now. +# possible candidates: libuutil, libzpool, libnvpair. Those do not provide stable abi, but are considered. +SLOT="0/4" +IUSE="custom-cflags debug kernel-builtin minimal nls pam python +rootfs test-suite static-libs" + +DEPEND=" + net-libs/libtirpc[static-libs?] + sys-apps/util-linux[static-libs?] + sys-libs/zlib[static-libs(+)?] + virtual/awk + virtual/libudev[static-libs(-)?] + dev-libs/openssl:0=[static-libs?] + !minimal? ( ${PYTHON_DEPS} ) + pam? ( sys-libs/pam ) + python? ( + virtual/python-cffi[${PYTHON_USEDEP}] + ) +" + +BDEPEND="virtual/awk + virtual/pkgconfig + nls? ( sys-devel/gettext ) + python? ( + dev-python/setuptools[${PYTHON_USEDEP}] + ) +" + +RDEPEND="${DEPEND} + !kernel-builtin? ( ~sys-fs/zfs-kmod-${PV} ) + !prefix? ( virtual/udev ) + sys-fs/udev-init-scripts + rootfs? ( + app-arch/cpio + app-misc/pax-utils + !<sys-kernel/genkernel-3.5.1.1 + ) + test-suite? ( + sys-apps/kmod[tools] + sys-apps/util-linux + sys-devel/bc + sys-block/parted + sys-fs/lsscsi + sys-fs/mdadm + sys-process/procps + ) +" + +REQUIRED_USE=" + !minimal? ( ${PYTHON_REQUIRED_USE} ) + python? ( !minimal ) + test-suite? ( !minimal ) +" + +RESTRICT="test" + +PATCHES=( + "${FILESDIR}/bash-completion-sudo.patch" + "${FILESDIR}/2.0.4-scrub-timers.patch" +) + +pkg_setup() { + if use kernel_linux && use test-suite; then + linux-info_pkg_setup + + if ! linux_config_exists; then + ewarn "Cannot check the linux kernel configuration." + else + if use test-suite; then + if linux_chkconfig_present BLK_DEV_LOOP; then + eerror "The ZFS test suite requires loop device support enabled." + eerror "Please enable it:" + eerror " CONFIG_BLK_DEV_LOOP=y" + eerror "in /usr/src/linux/.config or" + eerror " Device Drivers --->" + eerror " Block devices --->" + eerror " [X] Loopback device support" + fi + fi + fi + fi +} + +src_prepare() { + default + eautoreconf + # Set revision number + sed -i "s/\(Release:\)\(.*\)1/\1\2${PR}-gentoo/" META || die "Could not set Gentoo release" + + if use python; then + pushd contrib/pyzfs >/dev/null || die + distutils-r1_src_prepare + popd >/dev/null || die + fi + + # prevent errors showing up on zfs-mount stop, #647688 + # openrc will unmount all filesystems anyway. + sed -i "/^ZFS_UNMOUNT=/ s/yes/no/" "etc/default/zfs.in" || die +} + +src_configure() { + use custom-cflags || strip-flags + use minimal || python_setup + + local myconf=( + --bindir="${EPREFIX}/bin" + --enable-shared + --enable-systemd + --enable-sysvinit + --localstatedir="${EPREFIX}/var" + --sbindir="${EPREFIX}/sbin" + --with-config=user + --with-dracutdir="${EPREFIX}/usr/lib/dracut" + --with-linux="${KV_DIR}" + --with-linux-obj="${KV_OUT_DIR}" + --with-udevdir="$(get_udevdir)" + --with-pamconfigsdir="${EPREFIX}/unwanted_files" + --with-pammoduledir="$(getpam_mod_dir)" + --with-systemdunitdir="$(systemd_get_systemunitdir)" + --with-systemdpresetdir="${EPREFIX}/lib/systemd/system-preset" + --with-vendor=gentoo + $(use_enable debug) + $(use_enable nls) + $(use_enable pam) + $(use_enable python pyzfs) + $(use_enable static-libs static) + $(usex minimal --without-python --with-python="${EPYTHON}") + ) + + econf "${myconf[@]}" +} + +src_compile() { + default + if use python; then + pushd contrib/pyzfs >/dev/null || die + distutils-r1_src_compile + popd >/dev/null || die + fi +} + +src_install() { + default + + gen_usr_ldscript -a nvpair uutil zfsbootenv zfs zfs_core zpool + + use pam && { rm -rv "${ED}/unwanted_files" || die ; } + + use test-suite || { rm -r "${ED}/usr/share/zfs" || die ; } + + if ! use static-libs; then + find "${ED}/" -name '*.la' -delete || die + fi + + dobashcomp contrib/bash_completion.d/zfs + bashcomp_alias zfs zpool + + # strip executable bit from conf.d file + fperms 0644 /etc/conf.d/zfs + + if use python; then + pushd contrib/pyzfs >/dev/null || die + distutils-r1_src_install + popd >/dev/null || die + fi + + # enforce best available python implementation + use minimal || python_fix_shebang "${ED}/bin" +} + +pkg_postinst() { + if use rootfs; then + if ! has_version sys-kernel/genkernel && ! has_version sys-kernel/dracut; then + elog "root on zfs requires initramfs to boot" + elog "the following packages known to provide one and tested on regular basis:" + elog " sys-kernel/dracut" + elog " sys-kernel/genkernel" + fi + fi + + if ! use kernel-builtin && [[ ${PV} = "9999" ]]; then + einfo "Adding ${P} to the module database to ensure that the" + einfo "kernel modules and userland utilities stay in sync." + update_moduledb + fi + + if systemd_is_booted || has_version sys-apps/systemd; then + einfo "Please refer to ${EROOT}/lib/systemd/system-preset/50-zfs.preset" + einfo "for default zfs systemd service configuration" + else + [[ -e "${EROOT}/etc/runlevels/boot/zfs-import" ]] || \ + einfo "You should add zfs-import to the boot runlevel." + [[ -e "${EROOT}/etc/runlevels/boot/zfs-mount" ]]|| \ + einfo "You should add zfs-mount to the boot runlevel." + [[ -e "${EROOT}/etc/runlevels/default/zfs-share" ]] || \ + einfo "You should add zfs-share to the default runlevel." + [[ -e "${EROOT}/etc/runlevels/default/zfs-zed" ]] || \ + einfo "You should add zfs-zed to the default runlevel." + fi +} + +pkg_postrm() { + if ! use kernel-builtin && [[ ${PV} == "9999" ]]; then + remove_moduledb + fi +} |