]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: helper to retrieve the correct error code for read-only op
authorJason Dillaman <dillaman@redhat.com>
Thu, 6 Sep 2018 21:15:50 +0000 (17:15 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 3 Oct 2018 15:25:32 +0000 (11:25 -0400)
When the exclusive lock is unlocked, the error code should be
-EBLACKLISTED when the client is blacklisted, otherwise -EROFS.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit a84fbb2565fb603ea809487d920461d14442d188)

src/librbd/ExclusiveLock.cc
src/librbd/ExclusiveLock.h
src/test/librbd/mock/MockExclusiveLock.h

index 5821548f17b5c852016f2a5390aa1ed063097555..b224a7504b43bfb2c42b3831e8668b7011d12c75 100644 (file)
@@ -90,6 +90,14 @@ void ExclusiveLock<I>::unblock_requests() {
   ldout(m_image_ctx.cct, 20) << dendl;
 }
 
+template <typename I>
+int ExclusiveLock<I>::get_unlocked_op_error() const {
+  if (m_image_ctx.image_watcher->is_blacklisted()) {
+    return -EBLACKLISTED;
+  }
+  return -EROFS;
+}
+
 template <typename I>
 void ExclusiveLock<I>::init(uint64_t features, Context *on_init) {
   assert(m_image_ctx.owner_lock.is_locked());
index 0aaad091ea786c74fe4be16edb8497297d2ac652..3c5ebab33a38dbe3d3d71a71b0967bd115ebe9b0 100644 (file)
@@ -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);
 
index 4c9d2995891b24d84d2acd37e443f223eaf38ff9..f8eeb0d20a850e4aaece10dee73b13f106f042b7 100644 (file)
@@ -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*());
 };