diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-01-26 13:36:30 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:52 -0400 |
commit | 01efebd8f13c41341754a2f0b431aa81209f8f30 (patch) | |
tree | 27cf04088e255dacc1241d9b702358cfffaca2c9 /fs/bcachefs/nocow_locking.c | |
parent | 3482dd6a250397fe1dc088a16bc9e50d72f217e6 (diff) |
bcachefs: Add an assert to bch2_bucket_nocow_unlock()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/nocow_locking.c')
-rw-r--r-- | fs/bcachefs/nocow_locking.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/bcachefs/nocow_locking.c b/fs/bcachefs/nocow_locking.c index 53e5bc9fd585..396357cd8f2f 100644 --- a/fs/bcachefs/nocow_locking.c +++ b/fs/bcachefs/nocow_locking.c @@ -18,6 +18,8 @@ bool bch2_bucket_nocow_is_locked(struct bucket_nocow_lock_table *t, struct bpos return false; } +#define sign(v) (v < 0 ? -1 : v > 0 ? 1 : 0) + void bch2_bucket_nocow_unlock(struct bucket_nocow_lock_table *t, struct bpos bucket, int flags) { u64 dev_bucket = bucket_to_u64(bucket); @@ -27,6 +29,8 @@ void bch2_bucket_nocow_unlock(struct bucket_nocow_lock_table *t, struct bpos buc for (i = 0; i < ARRAY_SIZE(l->b); i++) if (l->b[i] == dev_bucket) { + BUG_ON(sign(atomic_read(&l->l[i])) != lock_val); + if (!atomic_sub_return(lock_val, &l->l[i])) closure_wake_up(&l->wait); return; |