gentoo-overlay/sys-kernel/hardened-kernel/files/linux-6.12/0112-bcachefs-Bias-reads-mo...

40 lines
1.3 KiB
Diff

From 2c9a60bc315537ac764ee026635daf588c1beb9b Mon Sep 17 00:00:00 2001
From: Kent Overstreet <kent.overstreet@linux.dev>
Date: Sat, 23 Nov 2024 16:47:10 -0500
Subject: [PATCH 112/233] bcachefs: Bias reads more in favor of faster device
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Per reports of performance issues on mixed multi device filesystems
where we're issuing too much IO to the spinning rust - tweak this
algorithm.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Signed-off-by: Alexander Miroshnichenko <alex@millerson.name>
---
fs/bcachefs/extents.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/fs/bcachefs/extents.c b/fs/bcachefs/extents.c
index 98bb680b3860..83aeceb68847 100644
--- a/fs/bcachefs/extents.c
+++ b/fs/bcachefs/extents.c
@@ -89,6 +89,14 @@ static inline bool ptr_better(struct bch_fs *c,
u64 l1 = dev_latency(c, p1.ptr.dev);
u64 l2 = dev_latency(c, p2.ptr.dev);
+ /*
+ * Square the latencies, to bias more in favor of the faster
+ * device - we never want to stop issuing reads to the slower
+ * device altogether, so that we can update our latency numbers:
+ */
+ l1 *= l1;
+ l2 *= l2;
+
/* Pick at random, biased in favor of the faster device: */
return bch2_rand_range(l1 + l2) > l1;
--
2.45.2