From 870be9524d5a85e6be7803b3f4eae71fd93cb530 Mon Sep 17 00:00:00 2001
From: V3n3RiX <venerix@koprulu.sector>
Date: Mon, 10 Jul 2023 10:26:59 +0100
Subject: gentoo auto-resync : 10:07:2023 - 10:26:59

---
 sys-fs/Manifest.gz                                 | Bin 22558 -> 22557 bytes
 sys-fs/bees/Manifest                               |  13 +--
 sys-fs/bees/bees-0.10.ebuild                       | 112 +++++++++++++++++++++
 sys-fs/bees/bees-0.8.ebuild                        | 109 --------------------
 sys-fs/bees/bees-0.9.3.ebuild                      | 112 +++++++++++++++++++++
 sys-fs/bees/bees-0.9.ebuild                        | 106 -------------------
 sys-fs/bees/bees-9999.ebuild                       |  20 ++--
 ...le-Work-around-kernel-memory-fragmentatio.patch |  34 +++++++
 sys-fs/bees/metadata.xml                           |  11 +-
 9 files changed, 282 insertions(+), 235 deletions(-)
 create mode 100644 sys-fs/bees/bees-0.10.ebuild
 delete mode 100644 sys-fs/bees/bees-0.8.ebuild
 create mode 100644 sys-fs/bees/bees-0.9.3.ebuild
 delete mode 100644 sys-fs/bees/bees-0.9.ebuild
 create mode 100644 sys-fs/bees/files/0001-HACK-crucible-Work-around-kernel-memory-fragmentatio.patch

(limited to 'sys-fs')

diff --git a/sys-fs/Manifest.gz b/sys-fs/Manifest.gz
index 87614779bebc..74d3de2e52cd 100644
Binary files a/sys-fs/Manifest.gz and b/sys-fs/Manifest.gz differ
diff --git a/sys-fs/bees/Manifest b/sys-fs/bees/Manifest
index 199d9a4e1ffe..a1d71c8b535c 100644
--- a/sys-fs/bees/Manifest
+++ b/sys-fs/bees/Manifest
@@ -1,6 +1,7 @@
-DIST bees-0.8.tar.gz 166890 BLAKE2B 26c7563ed1433526371d45e5f2f9e4f2a749e18f0d97e7a2ee445ef9d4cdf49210c8a96f756c04d19337497d12eacde28430f9ad64df198ff44c901b1bfc36c2 SHA512 92208ee186de18e764fab42f3de4e518047a21f4ed2429040a706fe7a45e0b2d39d1e468beefc92553659fc4587f4894a33d5a26bfd59278923208db3acc7da0
-DIST bees-0.9.tar.gz 176570 BLAKE2B f210afc342debb9fcdaba977ecccee9c07929197ccda942566634ef4d08c8bd11edb67ea50e05b046771faad212a9c3e01fc98c74dc759785afa588ba1d68b06 SHA512 dce90fc6f1741356331cc8c43536ea497c41a702be1b2bc2196f9ad0d5083d7255f15d529cf2804e4f36675ccc4a1d11d25ee266071a984199706ae2cd285c43
-EBUILD bees-0.8.ebuild 4040 BLAKE2B f4a1c0cfc7ad8d9256aeba8c001e6cd3f3d863d92548d8e9152595fb9a20764f3323f1e99835a3de2fbb16d2f8cc1225c75fee4d5e70050ebb6283410efb8341 SHA512 cad1a01cc87c132ca50b6167e2e40e971225d604b041aae30432033ac5dcbdf2ddce1200bae03dee2e5c2ba4050716773ecb190302d06992e62ca84e0bdba65b
-EBUILD bees-0.9.ebuild 3945 BLAKE2B 10c9022ed7d1588985fb2c1e67d36d1882e4ef9f5c834ceb658b223388bd65bf267f004523cbf4e1e45142a6bf1a1e11eb9c5a0277e6eb683d695f5ad6a5c7b1 SHA512 1bf9d8c6a77c4bf1346e10113d78deab7b0c10518b1e222456eef3e6f621fc089619850700042decdd35bce521c072550f03a6b753f9c9424bae877cbcf7d7fb
-EBUILD bees-9999.ebuild 3946 BLAKE2B e35281b82660f40e58e8ea9886862fdefc1286c18437525e5dedcd4e455cc76eac15343cfc8f4747e36ae159c60522b601fe7f9cebee06c1a8f94206a4d6614f SHA512 dae9e22f96297d4857b89633a2398ab66db30d859596c544817c9f62e89b7ad35c359e98f80a17afb2fae53cc060d06650efa4d638cf437d501f77149394830c
-MISC metadata.xml 622 BLAKE2B fc27438101691a12742484547df8b94fc3d22822cc3aefe81468e435a917373c25c5736506bfa2cf637bc265a3686c7f03d7431eaf54e5405f7ad2738390e872 SHA512 382ea31887a310f375bed14aa88d433831964b080faf3c7fb209a0d73b1d0d3da38a8e222ceda267b4ada4e81fa36cad94d4ddf180e7a2f39dfe3e9439b60321
+AUX 0001-HACK-crucible-Work-around-kernel-memory-fragmentatio.patch 1183 BLAKE2B 784ad6e8150a5d791c839c04060aa1116f72a29c0e2f4d1d790d6e1fb1d56b5a6ced843f38ac56930a63426ed7e9c5506f81c1f7189728937e0ee49f9f5af079 SHA512 29ac086a2c84d7eb89090498849b2e01e99da62c3ce49b5c4d36f071a3a8ff506e15b227a2303c01da25bdc4572e5dc1129767df496897de8ca2bed579dd3017
+DIST bees-0.10.tar.gz 177509 BLAKE2B 269cf65d5250a07297dfaee6c0fd6bc25199d63fe423d63ce39df8bcdb64d6f8110a0e03d0dc7dc1b105a8886f2a9364da8878481546eaa8dbf3dc46abc569ed SHA512 77a4ae3d66430c2d9dc0351c16c60bad95f21e238fc00f5f5787f55929ba75ee25212ac4bb4a3e4a9419cec27bbcfd2987aa925a54bc2872609b38a698dbedc3
+DIST bees-0.9.3.tar.gz 177265 BLAKE2B f0363771647ee07b12afe3ef44c1453e4677e12b051e33a81517a6044a459237b72712a09b31895147cd171a649ba15fc75676f34df46c9520248eae09e193e1 SHA512 5517773478cd56915ec3aee6542f6128a0f72b10aa96708d20778a76a427890bdfd9d8ba775b9dff3395d2e203fa2995070f9aca509b8150b9a9bcf076828ebb
+EBUILD bees-0.10.ebuild 4077 BLAKE2B 8208983c244fd03a1c615b485011bb1fefbdffe91b0d1846aec7a13775c9c1da06dd895092f847a9da0ce2e1a88dac10611f0f2a35df1589042e58a70f11b1a4 SHA512 41bc775e23be08cc87fd06da485b1101e3924dca1ab00150e4abbc50bcfc2b892a08bce0560403e9830a70fac9be0ea669f8017c71a78a414ab5cf1f580644e7
+EBUILD bees-0.9.3.ebuild 4076 BLAKE2B dad615a8ad7fada7c1cd31a5cffa6fad2cdcbc1cf241cc6e602d927cd9c182289d944663365cbeaa27a2f14f89cd8150e7c7196c19b5bbd4cb2580dae80bc19c SHA512 53a60088a2e078e1dec4899d77961c51976f941ca3952de32ddacdb6c03b4e6350d977f159b7a845ec45901bb4cb77b19ca9aebeec2ef1cc7867740df74adbbb
+EBUILD bees-9999.ebuild 4077 BLAKE2B 8208983c244fd03a1c615b485011bb1fefbdffe91b0d1846aec7a13775c9c1da06dd895092f847a9da0ce2e1a88dac10611f0f2a35df1589042e58a70f11b1a4 SHA512 41bc775e23be08cc87fd06da485b1101e3924dca1ab00150e4abbc50bcfc2b892a08bce0560403e9830a70fac9be0ea669f8017c71a78a414ab5cf1f580644e7
+MISC metadata.xml 529 BLAKE2B 69ea069e33d1af7c2c38aa7f8fc61516f23c586ad162d9581859829b084c8da3ef76278173e1ac3afa1ef432355ab14f2ecc01d07f039f8447c20cc27b22d633 SHA512 cb9ba7a32c6a8269f7303ebd41bf0e21f4325560b40bba10aff08a05d07170f9f0e35e687e688f6793c0abf994c9b23f90a47b9d32544636f2d6b5ab51140bd3
diff --git a/sys-fs/bees/bees-0.10.ebuild b/sys-fs/bees/bees-0.10.ebuild
new file mode 100644
index 000000000000..1b164eb56b08
--- /dev/null
+++ b/sys-fs/bees/bees-0.10.ebuild
@@ -0,0 +1,112 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit linux-info systemd toolchain-funcs
+
+DESCRIPTION="Best-Effort Extent-Same, a btrfs dedup agent"
+HOMEPAGE="https://github.com/Zygo/bees"
+
+if [[ ${PV} == 9999 ]] ; then
+	inherit git-r3
+	EGIT_REPO_URI="https://github.com/Zygo/bees.git"
+else
+	SRC_URI="https://github.com/Zygo/bees/archive/v${PV}.tar.gz -> ${P}.tar.gz"
+	KEYWORDS="~amd64 ~arm64"
+fi
+
+LICENSE="GPL-3"
+SLOT="0"
+IUSE=""
+
+DEPEND="
+	>=sys-apps/util-linux-2.30.2
+	>=sys-fs/btrfs-progs-4.20.2
+"
+RDEPEND="${DEPEND}"
+
+CONFIG_CHECK="~BTRFS_FS"
+ERROR_BTRFS_FS="CONFIG_BTRFS_FS: bees does currently only work with btrfs"
+
+PATCHES=(
+	"${FILESDIR}/0001-HACK-crucible-Work-around-kernel-memory-fragmentatio.patch"
+)
+
+pkg_pretend() {
+	if [[ ${MERGE_TYPE} != buildonly ]]; then
+		if kernel_is -lt 4 11; then
+			ewarn "With kernel versions below 4.11, bees may severely degrade system performance"
+			ewarn "and responsiveness. Especially, the kernel may deadlock while bees is"
+			ewarn "running, it's recommended to run at least kernel 4.11."
+			ewarn
+		elif kernel_is -lt 4 14 29; then
+			ewarn "With kernel versions below 4.14.29, bees may generate a lot of bogus WARN_ON()"
+			ewarn "messages in the kernel log. These messages can be ignored and this is fixed"
+			ewarn "with more recent kernels:"
+			ewarn "# WARNING: CPU: 3 PID: 18172 at fs/btrfs/backref.c:1391 find_parent_nodes+0xc41/0x14e0"
+			ewarn
+		elif kernel_is -lt 5 7 0; then
+			ewarn "With kernel versions below 5.4.96 and 5.7, the kernel may hold file system"
+			ewarn "locks for a long time while at the same time CPU usage increases when bees is"
+			ewarn "operating. bees tries to avoid this behavior by excluding very common extents"
+			ewarn "from deduplication. This has only a minimal impact on dedupe effectiveness."
+			ewarn
+		fi
+		if kernel_is -lt 5 1 0; then
+			ewarn "IMPORTANT: With kernel versions below 5.1.0, you may experience data corruption"
+			ewarn "due to bees using compression in btrfs. You are adviced to use a chronologically"
+			ewarn "later kernel, that includes older LTS versions released after 5.0.4:"
+			ewarn "Fixed in: 5.1+, 5.0.4+, 4.19.31+, 4.14.108+, 4.9.165+, 4.4.177+, 3.18.137+"
+			ewarn "# commit 8e92821 btrfs: fix corruption reading shared and compressed extents after hole punching"
+			ewarn
+		fi
+		if kernel_is -lt 5 4 19; then
+			ewarn "With kernel versions below 5.4.19, bees may trigger a btrfs bug when running"
+			ewarn "btrfs-balance in parallel. This may lead to meta-data corruption in the worst"
+			ewarn "case. Especially, kernels 5.1.21 and 5.2.21 should be avoided. Kernels 5.0.x"
+			ewarn "after 5.0.21 should be safe. In the best case, affected kernels may force"
+			ewarn "the device RO without writing corrupted meta-data. More details:"
+			ewarn "https://github.com/Zygo/bees/blob/master/docs/btrfs-kernel.md"
+			ewarn
+		fi
+		if kernel_is -gt 5 15 106; then
+			if kernel_is -lt 6 3 10; then
+				ewarn "With kernel versions 5.15.107 or later, there is a memory fragmentation"
+				ewarn "issue with LOGICAL_INO which can lead to cache thrashing and cause IO"
+				ewarn "latency spikes. This version ships with a work-around at the cost of not"
+				ewarn "handling highly duplicated filesystems that well. More details:"
+				ewarn "https://github.com/Zygo/bees/issues/260"
+				ewarn
+			fi
+		fi
+
+		elog "Bees recommends running the latest current kernel for performance and"
+		elog "reliability reasons, see README.md."
+	fi
+}
+
+src_prepare() {
+	default
+	sed -i 's/ -Werror//' makeflags || die
+}
+
+src_configure() {
+	tc-export CC CXX AR
+	cat >localconf <<-EOF || die
+		ETC_PREFIX="${EPREFIX}/etc"
+		LIBEXEC_PREFIX="${EPREFIX}/usr/libexec"
+		PREFIX="${EPREFIX}/usr"
+		SYSTEMD_SYSTEM_UNIT_DIR="$(systemd_get_systemunitdir)"
+		DEFAULT_MAKE_TARGET=all
+	EOF
+	if [[ ${PV} != "9999" ]] ; then
+		echo BEES_VERSION=v${PV} >>localconf || die
+	fi
+}
+
+src_compile() {
+	default
+	# localconf quotes leak in the systemd unit but are still needed for spaces
+	sed -i 's/"//g' scripts/beesd@.service || die
+}
diff --git a/sys-fs/bees/bees-0.8.ebuild b/sys-fs/bees/bees-0.8.ebuild
deleted file mode 100644
index 8c6ac6117418..000000000000
--- a/sys-fs/bees/bees-0.8.ebuild
+++ /dev/null
@@ -1,109 +0,0 @@
-# Copyright 1999-2023 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=7
-
-inherit linux-info systemd toolchain-funcs
-
-DESCRIPTION="Best-Effort Extent-Same, a btrfs dedup agent"
-HOMEPAGE="https://github.com/Zygo/bees"
-
-if [[ ${PV} == 9999 ]] ; then
-	inherit git-r3
-	EGIT_REPO_URI="https://github.com/Zygo/bees.git"
-else
-	SRC_URI="https://github.com/Zygo/bees/archive/v${PV}.tar.gz -> ${P}.tar.gz"
-	KEYWORDS="~amd64 ~arm64"
-fi
-
-LICENSE="GPL-3"
-SLOT="0"
-IUSE="tools"
-
-DEPEND="
-	>=sys-apps/util-linux-2.30.2
-	>=sys-fs/btrfs-progs-4.20.2
-"
-RDEPEND="${DEPEND}"
-
-CONFIG_CHECK="~BTRFS_FS"
-ERROR_BTRFS_FS="CONFIG_BTRFS_FS: bees does currently only work with btrfs"
-
-pkg_pretend() {
-	if [[ ${MERGE_TYPE} != buildonly ]]; then
-		if kernel_is -lt 4 11; then
-			ewarn "With kernel versions below 4.11, bees may severely degrade system performance"
-			ewarn "and responsiveness. Especially, the kernel may deadlock while bees is"
-			ewarn "running, it's recommended to run at least kernel 4.11."
-			ewarn
-		elif kernel_is -lt 4 14 29; then
-			ewarn "With kernel versions below 4.14.29, bees may generate a lot of bogus WARN_ON()"
-			ewarn "messages in the kernel log. These messages can be ignored and this is fixed"
-			ewarn "with more recent kernels:"
-			ewarn "# WARNING: CPU: 3 PID: 18172 at fs/btrfs/backref.c:1391 find_parent_nodes+0xc41/0x14e0"
-			ewarn
-		elif kernel_is -lt 5 7 0; then
-			ewarn "With kernel versions below 5.4.96 and 5.7, the kernel may hold file system"
-			ewarn "locks for a long time while at the same time CPU usage increases when bees is"
-			ewarn "operating. bees tries to avoid this behavior by excluding very common extents"
-			ewarn "from deduplication. This has only a minimal impact on dedupe effectiveness."
-			ewarn
-		fi
-		if kernel_is -lt 5 1 0; then
-			ewarn "IMPORTANT: With kernel versions below 5.1.0, you may experience data corruption"
-			ewarn "due to bees using compression in btrfs. You are adviced to use a chronologically"
-			ewarn "later kernel, that includes older LTS versions released after 5.0.4:"
-			ewarn "Fixed in: 5.1+, 5.0.4+, 4.19.31+, 4.14.108+, 4.9.165+, 4.4.177+, 3.18.137+"
-			ewarn "# commit 8e92821 btrfs: fix corruption reading shared and compressed extents after hole punching"
-			ewarn
-		fi
-		if kernel_is -lt 5 4 19; then
-			ewarn "With kernel versions below 5.4.19, bees may trigger a btrfs bug when running"
-			ewarn "btrfs-balance in parallel. This may lead to meta-data corruption in the worst"
-			ewarn "case. Especially, kernels 5.1.21 and 5.2.21 should be avoided. Kernels 5.0.x"
-			ewarn "after 5.0.21 should be safe. In the best case, affected kernels may force"
-			ewarn "the device RO without writing corrupted meta-data. More details:"
-			ewarn "https://github.com/Zygo/bees/blob/master/docs/btrfs-kernel.md"
-			ewarn
-		fi
-		if kernel_is -ge 5 4 0; then
-			ewarn "With kernel version 5.4 or later, the kernel may hang when multiple threads"
-			ewarn "are running LOGICAL_INO and dedupe ioctl. This is not exclusively triggered"
-			ewarn "by bees but also other software running such operations, bees will just more"
-			ewarn "likely trigger this bug. You can work around this issue by reducing the"
-			ewarn "thread count of bees to 1."
-			ewarn
-		fi
-
-		elog "Bees recommends running the latest current kernel for performance and"
-		elog "reliability reasons, see README.md."
-	fi
-}
-
-src_prepare() {
-	default
-	sed -i 's/ -Werror//' makeflags || die
-}
-
-src_configure() {
-	tc-export CC CXX AR
-	cat >localconf <<-EOF || die
-		ETC_PREFIX="${EPREFIX}/etc"
-		LIBEXEC_PREFIX="${EPREFIX}/usr/libexec"
-		PREFIX="${EPREFIX}/usr"
-		SYSTEMD_SYSTEM_UNIT_DIR="$(systemd_get_systemunitdir)"
-		DEFAULT_MAKE_TARGET=all
-	EOF
-	if [[ ${PV} != "9999" ]] ; then
-		echo BEES_VERSION=v${PV} >>localconf || die
-	fi
-	if use tools; then
-		echo OPTIONAL_INSTALL_TARGETS=install_tools >>localconf || die
-	fi
-}
-
-src_compile() {
-	default
-	# localconf quotes leak in the systemd unit but are still needed for spaces
-	sed -i 's/"//g' scripts/beesd@.service || die
-}
diff --git a/sys-fs/bees/bees-0.9.3.ebuild b/sys-fs/bees/bees-0.9.3.ebuild
new file mode 100644
index 000000000000..a1b15c2ef627
--- /dev/null
+++ b/sys-fs/bees/bees-0.9.3.ebuild
@@ -0,0 +1,112 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit linux-info systemd toolchain-funcs
+
+DESCRIPTION="Best-Effort Extent-Same, a btrfs dedup agent"
+HOMEPAGE="https://github.com/Zygo/bees"
+
+if [[ ${PV} == 9999 ]] ; then
+	inherit git-r3
+	EGIT_REPO_URI="https://github.com/Zygo/bees.git"
+else
+	SRC_URI="https://github.com/Zygo/bees/archive/v${PV}.tar.gz -> ${P}.tar.gz"
+	KEYWORDS="amd64 ~arm64"
+fi
+
+LICENSE="GPL-3"
+SLOT="0"
+IUSE=""
+
+DEPEND="
+	>=sys-apps/util-linux-2.30.2
+	>=sys-fs/btrfs-progs-4.20.2
+"
+RDEPEND="${DEPEND}"
+
+CONFIG_CHECK="~BTRFS_FS"
+ERROR_BTRFS_FS="CONFIG_BTRFS_FS: bees does currently only work with btrfs"
+
+PATCHES=(
+	"${FILESDIR}/0001-HACK-crucible-Work-around-kernel-memory-fragmentatio.patch"
+)
+
+pkg_pretend() {
+	if [[ ${MERGE_TYPE} != buildonly ]]; then
+		if kernel_is -lt 4 11; then
+			ewarn "With kernel versions below 4.11, bees may severely degrade system performance"
+			ewarn "and responsiveness. Especially, the kernel may deadlock while bees is"
+			ewarn "running, it's recommended to run at least kernel 4.11."
+			ewarn
+		elif kernel_is -lt 4 14 29; then
+			ewarn "With kernel versions below 4.14.29, bees may generate a lot of bogus WARN_ON()"
+			ewarn "messages in the kernel log. These messages can be ignored and this is fixed"
+			ewarn "with more recent kernels:"
+			ewarn "# WARNING: CPU: 3 PID: 18172 at fs/btrfs/backref.c:1391 find_parent_nodes+0xc41/0x14e0"
+			ewarn
+		elif kernel_is -lt 5 7 0; then
+			ewarn "With kernel versions below 5.4.96 and 5.7, the kernel may hold file system"
+			ewarn "locks for a long time while at the same time CPU usage increases when bees is"
+			ewarn "operating. bees tries to avoid this behavior by excluding very common extents"
+			ewarn "from deduplication. This has only a minimal impact on dedupe effectiveness."
+			ewarn
+		fi
+		if kernel_is -lt 5 1 0; then
+			ewarn "IMPORTANT: With kernel versions below 5.1.0, you may experience data corruption"
+			ewarn "due to bees using compression in btrfs. You are adviced to use a chronologically"
+			ewarn "later kernel, that includes older LTS versions released after 5.0.4:"
+			ewarn "Fixed in: 5.1+, 5.0.4+, 4.19.31+, 4.14.108+, 4.9.165+, 4.4.177+, 3.18.137+"
+			ewarn "# commit 8e92821 btrfs: fix corruption reading shared and compressed extents after hole punching"
+			ewarn
+		fi
+		if kernel_is -lt 5 4 19; then
+			ewarn "With kernel versions below 5.4.19, bees may trigger a btrfs bug when running"
+			ewarn "btrfs-balance in parallel. This may lead to meta-data corruption in the worst"
+			ewarn "case. Especially, kernels 5.1.21 and 5.2.21 should be avoided. Kernels 5.0.x"
+			ewarn "after 5.0.21 should be safe. In the best case, affected kernels may force"
+			ewarn "the device RO without writing corrupted meta-data. More details:"
+			ewarn "https://github.com/Zygo/bees/blob/master/docs/btrfs-kernel.md"
+			ewarn
+		fi
+		if kernel_is -gt 5 15 106; then
+			if kernel_is -lt 6 3 10; then
+				ewarn "With kernel versions 5.15.107 or later, there is a memory fragmentation"
+				ewarn "issue with LOGICAL_INO which can lead to cache thrashing and cause IO"
+				ewarn "latency spikes. This version ships with a work-around at the cost of not"
+				ewarn "handling highly duplicated filesystems that well. More details:"
+				ewarn "https://github.com/Zygo/bees/issues/260"
+				ewarn
+			fi
+		fi
+
+		elog "Bees recommends running the latest current kernel for performance and"
+		elog "reliability reasons, see README.md."
+	fi
+}
+
+src_prepare() {
+	default
+	sed -i 's/ -Werror//' makeflags || die
+}
+
+src_configure() {
+	tc-export CC CXX AR
+	cat >localconf <<-EOF || die
+		ETC_PREFIX="${EPREFIX}/etc"
+		LIBEXEC_PREFIX="${EPREFIX}/usr/libexec"
+		PREFIX="${EPREFIX}/usr"
+		SYSTEMD_SYSTEM_UNIT_DIR="$(systemd_get_systemunitdir)"
+		DEFAULT_MAKE_TARGET=all
+	EOF
+	if [[ ${PV} != "9999" ]] ; then
+		echo BEES_VERSION=v${PV} >>localconf || die
+	fi
+}
+
+src_compile() {
+	default
+	# localconf quotes leak in the systemd unit but are still needed for spaces
+	sed -i 's/"//g' scripts/beesd@.service || die
+}
diff --git a/sys-fs/bees/bees-0.9.ebuild b/sys-fs/bees/bees-0.9.ebuild
deleted file mode 100644
index 4834204acfcf..000000000000
--- a/sys-fs/bees/bees-0.9.ebuild
+++ /dev/null
@@ -1,106 +0,0 @@
-# Copyright 1999-2023 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=8
-
-inherit linux-info systemd toolchain-funcs
-
-DESCRIPTION="Best-Effort Extent-Same, a btrfs dedup agent"
-HOMEPAGE="https://github.com/Zygo/bees"
-
-if [[ ${PV} == 9999 ]] ; then
-	inherit git-r3
-	EGIT_REPO_URI="https://github.com/Zygo/bees.git"
-else
-	SRC_URI="https://github.com/Zygo/bees/archive/v${PV}.tar.gz -> ${P}.tar.gz"
-	KEYWORDS="amd64 ~arm64"
-fi
-
-LICENSE="GPL-3"
-SLOT="0"
-IUSE=""
-
-DEPEND="
-	>=sys-apps/util-linux-2.30.2
-	>=sys-fs/btrfs-progs-4.20.2
-"
-RDEPEND="${DEPEND}"
-
-CONFIG_CHECK="~BTRFS_FS"
-ERROR_BTRFS_FS="CONFIG_BTRFS_FS: bees does currently only work with btrfs"
-
-pkg_pretend() {
-	if [[ ${MERGE_TYPE} != buildonly ]]; then
-		if kernel_is -lt 4 11; then
-			ewarn "With kernel versions below 4.11, bees may severely degrade system performance"
-			ewarn "and responsiveness. Especially, the kernel may deadlock while bees is"
-			ewarn "running, it's recommended to run at least kernel 4.11."
-			ewarn
-		elif kernel_is -lt 4 14 29; then
-			ewarn "With kernel versions below 4.14.29, bees may generate a lot of bogus WARN_ON()"
-			ewarn "messages in the kernel log. These messages can be ignored and this is fixed"
-			ewarn "with more recent kernels:"
-			ewarn "# WARNING: CPU: 3 PID: 18172 at fs/btrfs/backref.c:1391 find_parent_nodes+0xc41/0x14e0"
-			ewarn
-		elif kernel_is -lt 5 7 0; then
-			ewarn "With kernel versions below 5.4.96 and 5.7, the kernel may hold file system"
-			ewarn "locks for a long time while at the same time CPU usage increases when bees is"
-			ewarn "operating. bees tries to avoid this behavior by excluding very common extents"
-			ewarn "from deduplication. This has only a minimal impact on dedupe effectiveness."
-			ewarn
-		fi
-		if kernel_is -lt 5 1 0; then
-			ewarn "IMPORTANT: With kernel versions below 5.1.0, you may experience data corruption"
-			ewarn "due to bees using compression in btrfs. You are adviced to use a chronologically"
-			ewarn "later kernel, that includes older LTS versions released after 5.0.4:"
-			ewarn "Fixed in: 5.1+, 5.0.4+, 4.19.31+, 4.14.108+, 4.9.165+, 4.4.177+, 3.18.137+"
-			ewarn "# commit 8e92821 btrfs: fix corruption reading shared and compressed extents after hole punching"
-			ewarn
-		fi
-		if kernel_is -lt 5 4 19; then
-			ewarn "With kernel versions below 5.4.19, bees may trigger a btrfs bug when running"
-			ewarn "btrfs-balance in parallel. This may lead to meta-data corruption in the worst"
-			ewarn "case. Especially, kernels 5.1.21 and 5.2.21 should be avoided. Kernels 5.0.x"
-			ewarn "after 5.0.21 should be safe. In the best case, affected kernels may force"
-			ewarn "the device RO without writing corrupted meta-data. More details:"
-			ewarn "https://github.com/Zygo/bees/blob/master/docs/btrfs-kernel.md"
-			ewarn
-		fi
-		if kernel_is -ge 5 4 0; then
-			ewarn "With kernel version 5.4 or later, the kernel may hang when multiple threads"
-			ewarn "are running LOGICAL_INO and dedupe ioctl. This is not exclusively triggered"
-			ewarn "by bees but also other software running such operations, bees will just more"
-			ewarn "likely trigger this bug. You can work around this issue by reducing the"
-			ewarn "thread count of bees to 1."
-			ewarn
-		fi
-
-		elog "Bees recommends running the latest current kernel for performance and"
-		elog "reliability reasons, see README.md."
-	fi
-}
-
-src_prepare() {
-	default
-	sed -i 's/ -Werror//' makeflags || die
-}
-
-src_configure() {
-	tc-export CC CXX AR
-	cat >localconf <<-EOF || die
-		ETC_PREFIX="${EPREFIX}/etc"
-		LIBEXEC_PREFIX="${EPREFIX}/usr/libexec"
-		PREFIX="${EPREFIX}/usr"
-		SYSTEMD_SYSTEM_UNIT_DIR="$(systemd_get_systemunitdir)"
-		DEFAULT_MAKE_TARGET=all
-	EOF
-	if [[ ${PV} != "9999" ]] ; then
-		echo BEES_VERSION=v${PV} >>localconf || die
-	fi
-}
-
-src_compile() {
-	default
-	# localconf quotes leak in the systemd unit but are still needed for spaces
-	sed -i 's/"//g' scripts/beesd@.service || die
-}
diff --git a/sys-fs/bees/bees-9999.ebuild b/sys-fs/bees/bees-9999.ebuild
index f84aba717799..1b164eb56b08 100644
--- a/sys-fs/bees/bees-9999.ebuild
+++ b/sys-fs/bees/bees-9999.ebuild
@@ -29,6 +29,10 @@ RDEPEND="${DEPEND}"
 CONFIG_CHECK="~BTRFS_FS"
 ERROR_BTRFS_FS="CONFIG_BTRFS_FS: bees does currently only work with btrfs"
 
+PATCHES=(
+	"${FILESDIR}/0001-HACK-crucible-Work-around-kernel-memory-fragmentatio.patch"
+)
+
 pkg_pretend() {
 	if [[ ${MERGE_TYPE} != buildonly ]]; then
 		if kernel_is -lt 4 11; then
@@ -66,13 +70,15 @@ pkg_pretend() {
 			ewarn "https://github.com/Zygo/bees/blob/master/docs/btrfs-kernel.md"
 			ewarn
 		fi
-		if kernel_is -ge 5 4 0; then
-			ewarn "With kernel version 5.4 or later, the kernel may hang when multiple threads"
-			ewarn "are running LOGICAL_INO and dedupe ioctl. This is not exclusively triggered"
-			ewarn "by bees but also other software running such operations, bees will just more"
-			ewarn "likely trigger this bug. You can work around this issue by reducing the"
-			ewarn "thread count of bees to 1."
-			ewarn
+		if kernel_is -gt 5 15 106; then
+			if kernel_is -lt 6 3 10; then
+				ewarn "With kernel versions 5.15.107 or later, there is a memory fragmentation"
+				ewarn "issue with LOGICAL_INO which can lead to cache thrashing and cause IO"
+				ewarn "latency spikes. This version ships with a work-around at the cost of not"
+				ewarn "handling highly duplicated filesystems that well. More details:"
+				ewarn "https://github.com/Zygo/bees/issues/260"
+				ewarn
+			fi
 		fi
 
 		elog "Bees recommends running the latest current kernel for performance and"
diff --git a/sys-fs/bees/files/0001-HACK-crucible-Work-around-kernel-memory-fragmentatio.patch b/sys-fs/bees/files/0001-HACK-crucible-Work-around-kernel-memory-fragmentatio.patch
new file mode 100644
index 000000000000..0ceb5cbfc79e
--- /dev/null
+++ b/sys-fs/bees/files/0001-HACK-crucible-Work-around-kernel-memory-fragmentatio.patch
@@ -0,0 +1,34 @@
+From 10c2006e627b5bda74f9f8aca1a574aa0e0e1eaa Mon Sep 17 00:00:00 2001
+From: Kai Krakow <kai@kaishome.de>
+Date: Sun, 9 Jul 2023 12:24:40 +0200
+Subject: [PATCH] HACK: crucible: Work around kernel memory fragmentation
+
+According to @Zygo:
+
+> This will drastically reduce the number of reflinks bees can handle
+> to a single extent, but that size is beyond more than enough for most
+> filesystems. Making the buffer smaller may also reduce the size of
+> vmallocs which might be aggravating the kernel's memory manager.
+
+Link: https://github.com/Zygo/bees/issues/260#issuecomment-1627586574
+Signed-off-by: Kai Krakow <kai@kaishome.de>
+---
+ include/crucible/fs.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/include/crucible/fs.h b/include/crucible/fs.h
+index 6d1780b..5da7da0 100644
+--- a/include/crucible/fs.h
++++ b/include/crucible/fs.h
+@@ -65,7 +65,7 @@ namespace crucible {
+ 	};
+ 
+ 	struct BtrfsIoctlLogicalInoArgs {
+-		BtrfsIoctlLogicalInoArgs(uint64_t logical, size_t buf_size = 16 * 1024 * 1024);
++		BtrfsIoctlLogicalInoArgs(uint64_t logical, size_t buf_size = 64 * 1024);
+ 
+ 		uint64_t get_flags() const;
+ 		void set_flags(uint64_t new_flags);
+-- 
+2.39.3
+
diff --git a/sys-fs/bees/metadata.xml b/sys-fs/bees/metadata.xml
index 29a9cccdbdf5..c7b55c3b67c7 100644
--- a/sys-fs/bees/metadata.xml
+++ b/sys-fs/bees/metadata.xml
@@ -9,11 +9,8 @@
 		<email>proxy-maint@gentoo.org</email>
 		<name>Proxy Maintainers</name>
 	</maintainer>
-<use>
-	<flag name="tools">Build extra tools useful for debugging (fiemap, fiewalk)</flag>
-</use>
-<upstream>
-	<bugs-to>https://github.com/Zygo/bees/issues</bugs-to>
-	<remote-id type="github">Zygo/bees</remote-id>
-</upstream>
+	<upstream>
+		<bugs-to>https://github.com/Zygo/bees/issues</bugs-to>
+		<remote-id type="github">Zygo/bees</remote-id>
+	</upstream>
 </pkgmetadata>
-- 
cgit v1.2.3