diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-12-21 10:33:53 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2025-01-10 07:38:41 +0300 |
commit | 9a5232ef0a9f9dcc8d1645b361296772b03a3525 (patch) | |
tree | 486dc8fd73cdc3d622ead8a428b18d286b0d2a6b | |
parent | 8f3aaa5d5d4e915c2486eafca84840d04b517b72 (diff) | |
download | linux-9a5232ef0a9f9dcc8d1645b361296772b03a3525.tar.xz |
bcachefs: six locks: write locks can now be held recursively
This is needed for the interior update locking rework, where we'll be
holding node write locks for the duration of the update - which is
needed for synchronizing with online check_allocations.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/six.c | 17 | ||||
-rw-r--r-- | fs/bcachefs/six.h | 1 |
2 files changed, 13 insertions, 5 deletions
diff --git a/fs/bcachefs/six.c b/fs/bcachefs/six.c index 617d07e53b20..537bf049618f 100644 --- a/fs/bcachefs/six.c +++ b/fs/bcachefs/six.c @@ -616,8 +616,6 @@ void six_unlock_ip(struct six_lock *lock, enum six_lock_type type, unsigned long if (type != SIX_LOCK_write) six_release(&lock->dep_map, ip); - else - lock->seq++; if (type == SIX_LOCK_intent && lock->intent_lock_recurse) { @@ -625,6 +623,15 @@ void six_unlock_ip(struct six_lock *lock, enum six_lock_type type, unsigned long return; } + if (type == SIX_LOCK_write && + lock->write_lock_recurse) { + --lock->write_lock_recurse; + return; + } + + if (type == SIX_LOCK_write) + lock->seq++; + do_six_unlock_type(lock, type); } EXPORT_SYMBOL_GPL(six_unlock_ip); @@ -735,13 +742,13 @@ void six_lock_increment(struct six_lock *lock, enum six_lock_type type) atomic_add(l[type].lock_val, &lock->state); } break; + case SIX_LOCK_write: + lock->write_lock_recurse++; + fallthrough; case SIX_LOCK_intent: EBUG_ON(!(atomic_read(&lock->state) & SIX_LOCK_HELD_intent)); lock->intent_lock_recurse++; break; - case SIX_LOCK_write: - BUG(); - break; } } EXPORT_SYMBOL_GPL(six_lock_increment); diff --git a/fs/bcachefs/six.h b/fs/bcachefs/six.h index 68d46fd7f391..c142e06b7a3a 100644 --- a/fs/bcachefs/six.h +++ b/fs/bcachefs/six.h @@ -137,6 +137,7 @@ struct six_lock { atomic_t state; u32 seq; unsigned intent_lock_recurse; + unsigned write_lock_recurse; struct task_struct *owner; unsigned __percpu *readers; raw_spinlock_t wait_lock; |