From: Kent Overstreet Date: Sun, 20 Oct 2024 06:14:53 +0000 (-0400) Subject: bcachefs: kill __bch2_bkey_sectors_need_rebalance() X-Git-Tag: v6.14-rc1~204^2~227 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=282faf952474a3125d3f3fd7d32ae77f8b4c96c3;p=thirdparty%2Fkernel%2Flinux.git bcachefs: kill __bch2_bkey_sectors_need_rebalance() Single caller, fold into bch2_bkey_sectors_need_rebalance() Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/extents.c b/fs/bcachefs/extents.c index 6ad5ff7c82390..5ec0fec597f77 100644 --- a/fs/bcachefs/extents.c +++ b/fs/bcachefs/extents.c @@ -1442,16 +1442,19 @@ incompressible: return rewrite_ptrs; } -static u64 __bch2_bkey_sectors_need_rebalance(struct bch_fs *c, struct bkey_s_c k, - unsigned target, unsigned compression) +u64 bch2_bkey_sectors_need_rebalance(struct bch_fs *c, struct bkey_s_c k) { + const struct bch_extent_rebalance *opts = bch2_bkey_rebalance_opts(k); + if (!opts) + return 0; + struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k); const union bch_extent_entry *entry; struct extent_ptr_decoded p; u64 sectors = 0; - if (compression) { - unsigned compression_type = bch2_compression_opt_to_type(compression); + if (opts->compression) { + unsigned compression_type = bch2_compression_opt_to_type(opts->compression); bkey_for_each_ptr_decode(k.k, ptrs, p, entry) { if (p.crc.compression_type == BCH_COMPRESSION_TYPE_incompressible || @@ -1465,22 +1468,16 @@ static u64 __bch2_bkey_sectors_need_rebalance(struct bch_fs *c, struct bkey_s_c } } incompressible: - if (target && bch2_target_accepts_data(c, BCH_DATA_user, target)) { + if (opts->target && + bch2_target_accepts_data(c, BCH_DATA_user, opts->target)) { bkey_for_each_ptr_decode(k.k, ptrs, p, entry) - if (!p.ptr.cached && !bch2_dev_in_target(c, p.ptr.dev, target)) + if (!p.ptr.cached && !bch2_dev_in_target(c, p.ptr.dev, opts->target)) sectors += p.crc.compressed_size; } return sectors; } -u64 bch2_bkey_sectors_need_rebalance(struct bch_fs *c, struct bkey_s_c k) -{ - const struct bch_extent_rebalance *r = bch2_bkey_rebalance_opts(k); - - return r ? __bch2_bkey_sectors_need_rebalance(c, k, r->target, r->compression) : 0; -} - int bch2_bkey_set_needs_rebalance(struct bch_fs *c, struct bkey_i *_k, struct bch_io_opts *opts) {