Minor cleanup, no reason for the caller to have to this.

Signed-off-by: Kent Overstreet <[email protected]>
---
 fs/bcachefs/alloc_background.c | 32 +++++++++++++-------------------
 fs/bcachefs/lru.c              |  6 +++---
 fs/bcachefs/lru.h              | 11 ++++++++++-
 3 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c
index a35455802280..e1061524bdf5 100644
--- a/fs/bcachefs/alloc_background.c
+++ b/fs/bcachefs/alloc_background.c
@@ -889,26 +889,20 @@ int bch2_trigger_alloc(struct btree_trans *trans,
                    !new_a->io_time[READ])
                        new_a->io_time[READ] = bch2_current_io_time(c, READ);
 
-               u64 old_lru = alloc_lru_idx_read(*old_a);
-               u64 new_lru = alloc_lru_idx_read(*new_a);
-               if (old_lru != new_lru) {
-                       ret = bch2_lru_change(trans, new.k->p.inode,
-                                             bucket_to_u64(new.k->p),
-                                             old_lru, new_lru);
-                       if (ret)
-                               goto err;
-               }
+               ret = bch2_lru_change(trans, new.k->p.inode,
+                                     bucket_to_u64(new.k->p),
+                                     alloc_lru_idx_read(*old_a),
+                                     alloc_lru_idx_read(*new_a));
+               if (ret)
+                       goto err;
 
-               old_lru = alloc_lru_idx_fragmentation(*old_a, ca);
-               new_lru = alloc_lru_idx_fragmentation(*new_a, ca);
-               if (old_lru != new_lru) {
-                       ret = bch2_lru_change(trans,
-                                       BCH_LRU_FRAGMENTATION_START,
-                                       bucket_to_u64(new.k->p),
-                                       old_lru, new_lru);
-                       if (ret)
-                               goto err;
-               }
+               ret = bch2_lru_change(trans,
+                                     BCH_LRU_FRAGMENTATION_START,
+                                     bucket_to_u64(new.k->p),
+                                     alloc_lru_idx_fragmentation(*old_a, ca),
+                                     alloc_lru_idx_fragmentation(*new_a, ca));
+               if (ret)
+                       goto err;
 
                if (old_a->gen != new_a->gen) {
                        ret = bch2_bucket_gen_update(trans, new.k->p, 
new_a->gen);
diff --git a/fs/bcachefs/lru.c b/fs/bcachefs/lru.c
index ce794d55818f..8ec16ae8daa6 100644
--- a/fs/bcachefs/lru.c
+++ b/fs/bcachefs/lru.c
@@ -59,9 +59,9 @@ int bch2_lru_set(struct btree_trans *trans, u16 lru_id, u64 
dev_bucket, u64 time
        return __bch2_lru_set(trans, lru_id, dev_bucket, time, KEY_TYPE_set);
 }
 
-int bch2_lru_change(struct btree_trans *trans,
-                   u16 lru_id, u64 dev_bucket,
-                   u64 old_time, u64 new_time)
+int __bch2_lru_change(struct btree_trans *trans,
+                     u16 lru_id, u64 dev_bucket,
+                     u64 old_time, u64 new_time)
 {
        if (old_time == new_time)
                return 0;
diff --git a/fs/bcachefs/lru.h b/fs/bcachefs/lru.h
index f31a6cf1514c..2facc0758cb3 100644
--- a/fs/bcachefs/lru.h
+++ b/fs/bcachefs/lru.h
@@ -46,7 +46,16 @@ void bch2_lru_pos_to_text(struct printbuf *, struct bpos);
 
 int bch2_lru_del(struct btree_trans *, u16, u64, u64);
 int bch2_lru_set(struct btree_trans *, u16, u64, u64);
-int bch2_lru_change(struct btree_trans *, u16, u64, u64, u64);
+int __bch2_lru_change(struct btree_trans *, u16, u64, u64, u64);
+
+static inline int bch2_lru_change(struct btree_trans *trans,
+                     u16 lru_id, u64 dev_bucket,
+                     u64 old_time, u64 new_time)
+{
+       return old_time != new_time
+               ? __bch2_lru_change(trans, lru_id, dev_bucket, old_time, 
new_time)
+               : 0;
+}
 
 struct bkey_buf;
 int bch2_lru_check_set(struct btree_trans *, u16, u64, struct bkey_s_c, struct 
bkey_buf *);
-- 
2.45.2


Reply via email to