The alloc trigger normally makes sure fragmentation_lru is correct, but
we don't run triggers here, so we have to manually construct it.

Signed-off-by: Daniel Hill <[email protected]>
---
 fs/bcachefs/btree_gc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c
index 6c52f116098f..43ada059b109 100644
--- a/fs/bcachefs/btree_gc.c
+++ b/fs/bcachefs/btree_gc.c
@@ -1456,12 +1456,15 @@ static int bch2_alloc_write_key(struct btree_trans 
*trans,
        a->v = new;
 
        /*
-        * The trigger normally makes sure this is set, but we're not running
+        * The trigger normally makes sure these are set, but we're not running
         * triggers:
         */
        if (a->v.data_type == BCH_DATA_cached && !a->v.io_time[READ])
                a->v.io_time[READ] = max_t(u64, 1, 
atomic64_read(&c->io_clock[READ].now));
 
+       a->v.fragmentation_lru = alloc_lru_idx_fragmentation(a->v,
+                                               bch_dev_bkey_exists(c, 
a->k.p.inode));
+
        ret = bch2_trans_update(trans, iter, &a->k_i, BTREE_TRIGGER_NORUN);
 fsck_err:
        return ret;
-- 
2.43.0


Reply via email to