bcachefs: Bias reads more in favor of faster device
authorKent Overstreet <kent.overstreet@linux.dev>
Sat, 23 Nov 2024 21:47:10 +0000 (16:47 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sat, 21 Dec 2024 06:36:19 +0000 (01:36 -0500)
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>
fs/bcachefs/extents.c

index 98bb680b3860b0fef85941c5eab1e07370857e7c..83aeceb688479160de7f74ab7b1cc6669d2df29a 100644 (file)
@@ -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;