diff options
author | David Zafman <dzafman@redhat.com> | 2017-03-30 20:18:38 +0200 |
---|---|---|
committer | David Zafman <dzafman@redhat.com> | 2017-04-17 16:58:30 +0200 |
commit | 0264bbddb7616e55e7ea90b6f5a834275ebe8985 (patch) | |
tree | bc9ec1a0897d7b2409e82c5a649347207c5e1e2c | |
parent | common: Bump ratio for backfillfull from 85% to 90% (diff) | |
download | ceph-0264bbddb7616e55e7ea90b6f5a834275ebe8985.tar.xz ceph-0264bbddb7616e55e7ea90b6f5a834275ebe8985.zip |
osd: For testing full disks add injectfull socket command
Signed-off-by: David Zafman <dzafman@redhat.com>
-rw-r--r-- | src/osd/OSD.cc | 33 | ||||
-rw-r--r-- | src/osd/OSD.h | 1 |
2 files changed, 33 insertions, 1 deletions
diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 167c0c1ff3a..8799b7933a3 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -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; } diff --git a/src/osd/OSD.h b/src/osd/OSD.h index e593d552a6b..29bacb60879 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -461,6 +461,7 @@ public: LogClient &log_client; LogChannelRef clog; PGRecoveryStats &pg_recovery_stats; + int64_t injectfull; private: Messenger *&cluster_messenger; Messenger *&client_messenger; |