Skip to content

Commit fc48d88

Browse files
committed
mds/SimpleLock: add has_xlock_by()
This replaces get_xlock_by() in cases where only a not-nullptr check is needed; this eliminates costly implicit reference counter manipulations. Signed-off-by: Max Kellermann <[email protected]>
1 parent 99f58a5 commit fc48d88

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/mds/LocalLockC.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class LocalLockC : public SimpleLock {
3030
}
3131

3232
bool can_xlock_local() const {
33-
return !is_wrlocked() && (get_xlock_by() == MutationRef());
33+
return !is_wrlocked() && !has_xlock_by();
3434
}
3535

3636
bool can_wrlock() const {

src/mds/SimpleLock.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ class SimpleLock {
420420

421421
// xlock
422422
void get_xlock(MutationRef who, client_t client) {
423-
ceph_assert(get_xlock_by() == MutationRef());
423+
ceph_assert(!has_xlock_by());
424424
ceph_assert(state == LOCK_XLOCK || is_locallock() ||
425425
state == LOCK_LOCK /* if we are a peer */);
426426
parent->get(MDSCacheObject::PIN_LOCK);
@@ -465,6 +465,9 @@ class SimpleLock {
465465
MutationRef get_xlock_by() const {
466466
return have_more() ? more()->xlock_by : MutationRef();
467467
}
468+
bool has_xlock_by() const noexcept {
469+
return have_more() && more()->xlock_by;
470+
}
468471

469472
// lease
470473
bool is_leased() const {

0 commit comments

Comments
 (0)