]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
librbd: introduce RBD_LOCK_MODE_EXCLUSIVE_TRANSIENT 67279/head
authorIlya Dryomov <idryomov@gmail.com>
Tue, 23 Dec 2025 13:27:18 +0000 (14:27 +0100)
committerIlya Dryomov <idryomov@gmail.com>
Thu, 12 Feb 2026 17:04:09 +0000 (18:04 +0100)
commitb8e1b4414ece83e331d6ba395b8e214f5728e5c2
treeac3bb91e300cc8681d4a4786713651a5ba6375b8
parent047692467af7c8e3cce967e439f7b02faead2b2f
librbd: introduce RBD_LOCK_MODE_EXCLUSIVE_TRANSIENT

The existing StandardPolicy that exposed as RBD_LOCK_MODE_EXCLUSIVE
argument to rbd_lock_acquire() disables automatic exclusive lock
transitions with "permanent" semantics: any request to release the lock
causes the peer to error out immediately.  Such a lock owner can
perform maintenance operations that are proxied from other peers, but
any write-like I/O issued by other peers will fail with EROFS.

This isn't suitable for use cases where one of the peers wants to
manage exclusive lock manually (i.e. rbd_lock_acquire() is used) but
the lock is acquired only for very short periods of time.  The rest of
the time the lock is expected to be held by other peers that stay in
the default "auto" mode (AutomaticPolicy) and run as usual, completely
unconcerned with each other or the manual-mode peer.  However, these
peers get acutely aware of the manual-mode peer because when it grabs
the lock with RBD_LOCK_MODE_EXCLUSIVE their I/O gets disrupted: higher
layers translate EROFS into generic EIO, filesystems shut down, etc.

Add a new TransientPolicy exposed as RBD_LOCK_MODE_EXCLUSIVE_TRANSIENT
to allow disabling automatic exclusive lock transitions with semantics
that would cause the other peers to block waiting for the lock to be
released by the manual-mode peer.  This is intended to be a low-level
interface -- no attempt to safeguard against potential misuse causing
e.g. indefinite blocking is made.

It's possible to switch between RBD_LOCK_MODE_EXCLUSIVE and
RBD_LOCK_MODE_EXCLUSIVE_TRANSIENT modes of operation both while the
lock is held and after it's released.

Fixes: https://tracker.ceph.com/issues/73824
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit 8740544c51781211b82ac45d4bc93b9eb9623e76)
13 files changed:
src/include/rbd/librbd.h
src/librbd/CMakeLists.txt
src/librbd/exclusive_lock/AutomaticPolicy.h
src/librbd/exclusive_lock/StandardPolicy.cc
src/librbd/exclusive_lock/StandardPolicy.h
src/librbd/exclusive_lock/TransientPolicy.cc [new file with mode: 0644]
src/librbd/exclusive_lock/TransientPolicy.h [new file with mode: 0644]
src/librbd/internal.cc
src/pybind/rbd/c_rbd.pxd
src/pybind/rbd/mock_rbd.pxi
src/pybind/rbd/rbd.pyx
src/test/librbd/test_librbd.cc
src/test/pybind/test_rbd.py