]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
mds: MDSCacheObject wait mask and SimpleLock wait shift wip-lusov-wait-shift 55668/head
authorLeonid Usov <leonid.usov@ibm.com>
Tue, 20 Feb 2024 12:43:43 +0000 (14:43 +0200)
committerLeonid Usov <leonid.usov@ibm.com>
Thu, 22 Feb 2024 14:53:39 +0000 (16:53 +0200)
commit401ebcb2ce42e240689c483634f49983fb4a8464
tree716a1f9510ab51dabe598a5a1bcf19b7265ea68b
parent49d060c71fc12b312d90d8e91e323693ccfb8b0f
mds: MDSCacheObject wait mask and SimpleLock wait shift

MDSCacheObject waiting interface accepts a wait mask to queue waiters.
The mask is used to prioritize waiters, so lower absolute mask values will be invoked first.

SimpleLock used to create a different wait mask per lock type, thus prioritizing locks,
but the approach proved to be unfair and #8965 changed the waiting to be FIFO
per wanted wait bit. This change made the spreading of lock wait masks per lock type
redundant.
Until now it wasn't an issue, but adding a new lock type we found out that the 64 bit mask
space was already exhausted given that each lock used up 4 bits from the mask

Further, there was a magic number `8` added to the lock mask shift offset,
which apparently was meant to accommodate for custom high-priority wait bits
of the lock's parent object, but this wasn't properly communicated via interfaces
and caused an overlap of the first lock's WAIT_RD bit with the fourth private
wait bit of CInode::WAIT_FLOCK;

This change optimizes the usage of the available wait tag 64 bit space,
aiming to maintain backward compatibility with the current implementation.
The approach is to split the 64bits of the wait tag into a 16 bit ID and
a 48 bit MASK fields. The ID field will be matched literally, while the MASK
field will be matched by an intersection.

With this apprach we can encode the lock ordinal into the ID field and use just
four bits from the MASK field to distinguish between the different lock wait flags.

Since the ID field occupies the most significant 2 bytes, the comparision of
different lock tags will yield the same results as it does today, when higher
lock ids were occupying higher bit offsets.

Signed-off-by: Leonid Usov <leonid.usov@ibm.com>
15 files changed:
src/mds/CDentry.cc
src/mds/CDentry.h
src/mds/CDir.cc
src/mds/CDir.h
src/mds/CInode.cc
src/mds/CInode.h
src/mds/Locker.cc
src/mds/MDCache.cc
src/mds/MDSCacheObject.cc
src/mds/MDSCacheObject.h
src/mds/MDSWaitable.h [new file with mode: 0644]
src/mds/SimpleLock.cc
src/mds/SimpleLock.h
src/test/mds/CMakeLists.txt
src/test/mds/TestMDSWaitable.cc [new file with mode: 0644]