summaryrefslogtreecommitdiff
path: root/fs/bcachefs/alloc_background.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2022-12-15 04:52:11 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:09:52 +0300
commit350175bf9b0fe5da12a2fd8bfd453a49f038ceb4 (patch)
tree6118c2363f0ee7570b8d9ac6440b13217b8c322e /fs/bcachefs/alloc_background.h
parentf3a37e76cade1469871c4309584ebbc358becf40 (diff)
downloadlinux-350175bf9b0fe5da12a2fd8bfd453a49f038ceb4.tar.xz
bcachefs: Improved nocow locking
This improves the nocow lock table so that hash table entries have multiple locks, and locks specify which bucket they're for - i.e. we can now resolve hash collisions. This is important because the allocator has to skip buckets that are locked in the nocow lock table, and previously hash collisions would cause it to spuriously skip unlocked buckets. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/alloc_background.h')
-rw-r--r--fs/bcachefs/alloc_background.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/bcachefs/alloc_background.h b/fs/bcachefs/alloc_background.h
index d4957b4557bf..a0c3c47b49b5 100644
--- a/fs/bcachefs/alloc_background.h
+++ b/fs/bcachefs/alloc_background.h
@@ -23,6 +23,16 @@ static inline bool bch2_dev_bucket_exists(struct bch_fs *c, struct bpos pos)
pos.offset < ca->mi.nbuckets;
}
+static inline u64 bucket_to_u64(struct bpos bucket)
+{
+ return (bucket.inode << 48) | bucket.offset;
+}
+
+static inline struct bpos u64_to_bucket(u64 bucket)
+{
+ return POS(bucket >> 48, bucket & ~(~0ULL << 48));
+}
+
static inline u8 alloc_gc_gen(struct bch_alloc_v4 a)
{
return a.gen - a.oldest_gen;