From: Jason Dillaman Date: Thu, 6 Sep 2018 21:15:50 +0000 (-0400) Subject: librbd: helper to retrieve the correct error code for read-only op X-Git-Tag: v14.0.1~228^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=a84fbb2565fb603ea809487d920461d14442d188;p=ceph-ci.git librbd: helper to retrieve the correct error code for read-only op When the exclusive lock is unlocked, the error code should be -EBLACKLISTED when the client is blacklisted, otherwise -EROFS. Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/ExclusiveLock.cc b/src/librbd/ExclusiveLock.cc index 588ab6085e3..c2b2ef00364 100644 --- a/src/librbd/ExclusiveLock.cc +++ b/src/librbd/ExclusiveLock.cc @@ -90,6 +90,14 @@ void ExclusiveLock::unblock_requests() { ldout(m_image_ctx.cct, 20) << dendl; } +template +int ExclusiveLock::get_unlocked_op_error() const { + if (m_image_ctx.image_watcher->is_blacklisted()) { + return -EBLACKLISTED; + } + return -EROFS; +} + template void ExclusiveLock::init(uint64_t features, Context *on_init) { ceph_assert(m_image_ctx.owner_lock.is_locked()); diff --git a/src/librbd/ExclusiveLock.h b/src/librbd/ExclusiveLock.h index 0aaad091ea7..3c5ebab33a3 100644 --- a/src/librbd/ExclusiveLock.h +++ b/src/librbd/ExclusiveLock.h @@ -24,6 +24,8 @@ public: void block_requests(int r); void unblock_requests(); + int get_unlocked_op_error() const; + void init(uint64_t features, Context *on_init); void shut_down(Context *on_shutdown); diff --git a/src/test/librbd/mock/MockExclusiveLock.h b/src/test/librbd/mock/MockExclusiveLock.h index 4c9d2995891..f8eeb0d20a8 100644 --- a/src/test/librbd/mock/MockExclusiveLock.h +++ b/src/test/librbd/mock/MockExclusiveLock.h @@ -29,6 +29,7 @@ struct MockExclusiveLock { MOCK_METHOD0(accept_requests, bool()); MOCK_METHOD0(accept_ops, bool()); + MOCK_METHOD0(get_unlocked_op_error, int()); MOCK_METHOD0(start_op, Context*()); };