summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/buckets.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-02-14 00:07:38 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:29 -0400
commit66d90823857ed9196ef52361518ab703e468c53b (patch)
treeacebc578be81944928e7e01b2e3a9fbbdf95732c /fs/bcachefs/buckets.h
parent5735608c14e791c10ebcb6a20fab1c8fa4cf3123 (diff)
downloadlinux-66d90823857ed9196ef52361518ab703e468c53b.tar.gz
linux-66d90823857ed9196ef52361518ab703e468c53b.tar.bz2
linux-66d90823857ed9196ef52361518ab703e468c53b.zip
bcachefs: Kill struct bucket_mark
This switches struct bucket to using a lock, instead of cmpxchg. And now that the protected members no longer need to fit into a u64, we can expand the sector counts to 32 bits. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/buckets.h')
-rw-r--r--fs/bcachefs/buckets.h24
1 files changed, 10 insertions, 14 deletions
diff --git a/fs/bcachefs/buckets.h b/fs/bcachefs/buckets.h
index 7ae1feadf4c0..31a56f1f4fca 100644
--- a/fs/bcachefs/buckets.h
+++ b/fs/bcachefs/buckets.h
@@ -15,20 +15,16 @@
for (_b = (_buckets)->b + (_buckets)->first_bucket; \
_b < (_buckets)->b + (_buckets)->nbuckets; _b++)
-#define bucket_cmpxchg(g, new, expr) \
-({ \
- struct bucket *_g = g; \
- u64 _v = atomic64_read(&(g)->_mark.v); \
- struct bucket_mark _old; \
- \
- do { \
- (new).v.counter = _old.v.counter = _v; \
- expr; \
- } while ((_v = atomic64_cmpxchg(&(_g)->_mark.v, \
- _old.v.counter, \
- (new).v.counter)) != _old.v.counter);\
- _old; \
-})
+static inline void bucket_unlock(struct bucket *b)
+{
+ smp_store_release(&b->lock, 0);
+}
+
+static inline void bucket_lock(struct bucket *b)
+{
+ while (xchg(&b->lock, 1))
+ cpu_relax();
+}
static inline struct bucket_array *gc_bucket_array(struct bch_dev *ca)
{