]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bcachefs: Improve want_cached_ptr()
authorKent Overstreet <kent.overstreet@linux.dev>
Sun, 4 May 2025 19:01:34 +0000 (15:01 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 5 May 2025 18:16:20 +0000 (14:16 -0400)
If promote target isn't set, rebalance should still leave a cached copy
on the faster device.

Fall back to foreground_target if it's set, or allow a cached copy on
any device if neither are set.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/extents.c

index dca2b8425cc05f435203af57d0a081722af003a0..e597fb9c98236c6058483edf4dd7f8e5ff8d4141 100644 (file)
@@ -1056,8 +1056,9 @@ bch2_extent_has_ptr(struct bkey_s_c k1, struct extent_ptr_decoded p1, struct bke
 static bool want_cached_ptr(struct bch_fs *c, struct bch_io_opts *opts,
                            struct bch_extent_ptr *ptr)
 {
-       if (!opts->promote_target ||
-           !bch2_dev_in_target(c, ptr->dev, opts->promote_target))
+       unsigned target = opts->promote_target ?: opts->foreground_target;
+
+       if (target && !bch2_dev_in_target(c, ptr->dev, target))
                return false;
 
        struct bch_dev *ca = bch2_dev_rcu_noerror(c, ptr->dev);