summaryrefslogtreecommitdiff
path: root/libbcachefs/lru.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-02-17 17:51:22 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-02-17 17:51:22 -0500
commit46a6b9210c927ab46fd1227cb6f641be0b4a7505 (patch)
treec7aea129fe8213eaefe90ac34090835d59598c7e /libbcachefs/lru.h
parentc1677df62edb8be05caf7a6862b599f8e74c404f (diff)
Update bcachefs sources to 1b14994029 bcachefs: Fragmentation LRUv0.27
Diffstat (limited to 'libbcachefs/lru.h')
-rw-r--r--libbcachefs/lru.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/libbcachefs/lru.h b/libbcachefs/lru.h
index b8d9848c..78a60769 100644
--- a/libbcachefs/lru.h
+++ b/libbcachefs/lru.h
@@ -22,6 +22,27 @@ static inline u64 lru_pos_time(struct bpos pos)
return pos.inode & ~(~0ULL << LRU_TIME_BITS);
}
+#define BCH_LRU_TYPES() \
+ x(read) \
+ x(fragmentation)
+
+enum bch_lru_type {
+#define x(n) BCH_LRU_##n,
+ BCH_LRU_TYPES()
+#undef x
+};
+
+#define BCH_LRU_FRAGMENTATION_START ((1U << 16) - 1)
+
+static inline enum bch_lru_type lru_type(struct bkey_s_c l)
+{
+ u16 lru_id = l.k->p.inode >> 48;
+
+ if (lru_id == BCH_LRU_FRAGMENTATION_START)
+ return BCH_LRU_fragmentation;
+ return BCH_LRU_read;
+}
+
int bch2_lru_invalid(const struct bch_fs *, struct bkey_s_c, unsigned, struct printbuf *);
void bch2_lru_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);