]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd: For testing full disks add injectfull socket command
authorDavid Zafman <dzafman@redhat.com>
Thu, 30 Mar 2017 18:18:38 +0000 (11:18 -0700)
committerDavid Zafman <dzafman@redhat.com>
Mon, 17 Apr 2017 14:58:30 +0000 (07:58 -0700)
Signed-off-by: David Zafman <dzafman@redhat.com>
src/osd/OSD.cc
src/osd/OSD.h

index 167c0c1ff3ab4469552f31d12f2c15c3d2c29d31..8799b7933a3d40fe5472e469dc47f51b731a91c5 100644 (file)
@@ -221,6 +221,7 @@ OSDService::OSDService(OSD *osd) :
   whoami(osd->whoami), store(osd->store),
   log_client(osd->log_client), clog(osd->clog),
   pg_recovery_stats(osd->pg_recovery_stats),
+  injectfull(0),
   cluster_messenger(osd->cluster_messenger),
   client_messenger(osd->client_messenger),
   logger(osd->logger),
@@ -753,9 +754,10 @@ void OSDService::check_full_status(const osd_stat_t &osd_stat)
   }
 
   enum s_names new_state;
+  // If testing with injectfull, let's keep determined state as FAILSAFE
   if (ratio > failsafe_ratio) {
     new_state = FAILSAFE;
-  } else if (ratio > full_ratio) {
+  } else if (ratio > full_ratio || injectfull) {
     new_state = FULL;
   } else if (ratio > nearfull_ratio) {
     new_state = NEARFULL;
@@ -806,6 +808,16 @@ bool OSDService::need_fullness_update()
 bool OSDService::check_failsafe_full()
 {
   Mutex::Locker l(full_status_lock);
+
+  if (injectfull) {
+    // injectfull is either a count of the number of times to return full
+    // or if -1 then always return full
+    if (injectfull > 0)
+      --injectfull;
+    dout(5) << __func__ << " Injected full OSD (" << (injectfull < 0 ? "set" : std::to_string(injectfull)) << ")" << dendl;
+    return true;
+  }
+
   if (cur_state == FAILSAFE)
     return true;
   return false;
@@ -826,6 +838,14 @@ bool OSDService::is_full()
 bool OSDService::too_full_for_backfill(ostream &ss)
 {
   Mutex::Locker l(full_status_lock);
+  if (injectfull) {
+    // injectfull is either a count of the number of times to return full
+    // or if -1 then always return full
+    if (injectfull > 0)
+      --injectfull;
+    ss << "Injected full OSD (" << (injectfull < 0 ? string("set") : std::to_string(injectfull)) << ")";
+    return true;
+  }
   double max_ratio;
   max_ratio = cct->_conf->osd_backfill_full_ratio;
   ss << "current usage is " << cur_ratio << ", which is greater than max allowed ratio " << max_ratio;
@@ -2629,6 +2649,13 @@ void OSD::final_init()
    test_ops_hook,
    "Trigger a scheduled scrub ");
   assert(r == 0);
+  r = admin_socket->register_command(
+   "injectfull",
+   "injectfull " \
+   "name=count,type=CephInt,req=false ",
+   test_ops_hook,
+   "Inject a full disk (optional count times)");
+  assert(r == 0);
 }
 
 void OSD::create_logger()
@@ -4851,6 +4878,10 @@ void TestOpsSocketHook::test_ops(OSDService *service, ObjectStore *store,
     pg->unlock();
     return;
   }
+  if (command == "injectfull") {
+    cmd_getval(service->cct, cmdmap, "count", service->injectfull, (int64_t)-1);
+    return;
+  }
   ss << "Internal error - command=" << command;
 }
 
index e593d552a6b19c931867f133b71a3de63d19165a..29bacb608795dc6eee00f1f6ca20418e937cfa9c 100644 (file)
@@ -461,6 +461,7 @@ public:
   LogClient &log_client;
   LogChannelRef clog;
   PGRecoveryStats &pg_recovery_stats;
+  int64_t injectfull;
 private:
   Messenger *&cluster_messenger;
   Messenger *&client_messenger;