]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librbd: don't set objectmap invalid when load objectmap timed out
authorsongweibin <song.weibin@zte.com.cn>
Thu, 19 Mar 2020 12:51:59 +0000 (20:51 +0800)
committerJason Dillaman <dillaman@redhat.com>
Mon, 20 Jul 2020 22:36:57 +0000 (18:36 -0400)
Add a new configuration option of `rbd_invalidate_object_map_on_timeout`,
if disabled and timed out to open/update object map, donot invalidating
object map and return -ETIMEDOUT to APP.

Signed-off-by: songweibin <song.weibin@zte.com.cn>
src/common/options.cc
src/librbd/object_map/RefreshRequest.cc
src/librbd/object_map/Request.cc
src/librbd/object_map/Request.h

index 3ff9807aca282bb1684a0f92cdb6398eb2e84da2..de44c6629188322fbdb7275735307e4afb0d255f 100644 (file)
@@ -7364,6 +7364,10 @@ static std::vector<Option> get_rbd_options() {
     .set_default(true)
     .set_description("validate new image names for RBD compatibility"),
 
+    Option("rbd_invalidate_object_map_on_timeout", Option::TYPE_BOOL, Option::LEVEL_DEV)
+    .set_default(true)
+    .set_description("true if object map should be invalidated when load or update timeout"),
+
     Option("rbd_auto_exclusive_lock_until_manual_request", Option::TYPE_BOOL, Option::LEVEL_ADVANCED)
     .set_default(true)
     .set_description("automatically acquire/release exclusive lock until it is explicitly requested"),
index d9febda66daaa82179f1e17209a1afd0a7ccebb2..0f6b81923e0031f5d010b3aa0a1c657e9f62dece 100644 (file)
@@ -133,6 +133,11 @@ Context *RefreshRequest<I>::handle_load(int *ret_val) {
     return nullptr;
   } else if (*ret_val < 0) {
     lderr(cct) << "failed to load object map: " << oid << dendl;
+    if (*ret_val == -ETIMEDOUT &&
+        !cct->_conf.get_val<bool>("rbd_invalidate_object_map_on_timeout")) {
+      return m_on_finish;
+    }
+
     send_invalidate();
     return nullptr;
   }
index e323251878afb2c45acf20d6e304e49eacf79cef..6677882eae54a8790179c17acfef095db3dfb8d4 100644 (file)
@@ -22,7 +22,11 @@ bool Request::should_complete(int r) {
   switch (m_state)
   {
   case STATE_REQUEST:
-    if (r < 0) {
+    if (r == -ETIMEDOUT &&
+        !cct->_conf.get_val<bool>("rbd_invalidate_object_map_on_timeout")) {
+      m_state = STATE_TIMEOUT;
+      return true;
+    } else if (r < 0) {
       lderr(cct) << "failed to update object map: " << cpp_strerror(r)
                 << dendl;
       return invalidate();
index aef8800dd8ace38e683f3a6d78b254539582370e..7e9bfb88dfde0dac69ace1f14bf1cb5439247b40 100644 (file)
@@ -41,6 +41,9 @@ protected:
 
 private:
   /**
+   *              STATE_TIMEOUT --------\
+   *                   ^                |
+   *                   |                v
    * <start> ---> STATE_REQUEST ---> <finish>
    *                   |                ^
    *                   v                |
@@ -48,6 +51,7 @@ private:
    */
   enum State {
     STATE_REQUEST,
+    STATE_TIMEOUT,
     STATE_INVALIDATE
   };