Commit 9a5232ef authored by Kent Overstreet's avatar Kent Overstreet
Browse files

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: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 8f3aaa5d
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -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);
+1 −0
Original line number Diff line number Diff line
@@ -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;