From: Sage Weil Date: Mon, 17 Oct 2016 21:10:38 +0000 (-0400) Subject: osd: add MOSDBackoff message type X-Git-Tag: v12.0.1~441^2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8da82431f6dba4e1075e9e1f5ad8a7c740d87ca0;p=ceph.git osd: add MOSDBackoff message type Signed-off-by: Sage Weil --- diff --git a/src/common/ceph_strings.cc b/src/common/ceph_strings.cc index 08ed2715df49..1c13be4f884f 100644 --- a/src/common/ceph_strings.cc +++ b/src/common/ceph_strings.cc @@ -238,3 +238,13 @@ const char *ceph_pool_op_name(int op) } return "???"; } + +const char *ceph_osd_backoff_op_name(int op) +{ + switch (op) { + case CEPH_OSD_BACKOFF_OP_BLOCK: return "block"; + case CEPH_OSD_BACKOFF_OP_ACK_BLOCK: return "ack-block"; + case CEPH_OSD_BACKOFF_OP_UNBLOCK: return "unblock"; + } + return "???"; +} diff --git a/src/include/ceph_fs.h b/src/include/ceph_fs.h index ffc510813b90..2d1486d94c73 100644 --- a/src/include/ceph_fs.h +++ b/src/include/ceph_fs.h @@ -127,13 +127,13 @@ struct ceph_dir_layout { #define CEPH_MSG_OSD_OP 42 #define CEPH_MSG_OSD_OPREPLY 43 #define CEPH_MSG_WATCH_NOTIFY 44 +#define CEPH_MSG_OSD_BACKOFF 61 /* FSMap subscribers (see all MDS clusters at once) */ #define CEPH_MSG_FS_MAP 45 /* FSMapUser subscribers (get MDS clusters name->ID mapping) */ #define CEPH_MSG_FS_MAP_USER 103 - /* watch-notify operations */ enum { CEPH_WATCH_EVENT_NOTIFY = 1, /* notifying watcher */ diff --git a/src/include/rados.h b/src/include/rados.h index c045c360a68d..02a7f8c632e6 100644 --- a/src/include/rados.h +++ b/src/include/rados.h @@ -472,6 +472,14 @@ enum { const char *ceph_osd_alloc_hint_flag_name(int f); +enum { + CEPH_OSD_BACKOFF_OP_BLOCK = 1, + CEPH_OSD_BACKOFF_OP_ACK_BLOCK = 2, + CEPH_OSD_BACKOFF_OP_UNBLOCK = 3, +}; + +const char *ceph_osd_backoff_op_name(int op); + /* * an individual object operation. each may be accompanied by some data * payload diff --git a/src/messages/MOSDBackoff.h b/src/messages/MOSDBackoff.h new file mode 100644 index 000000000000..e501269b7ef7 --- /dev/null +++ b/src/messages/MOSDBackoff.h @@ -0,0 +1,66 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2017 Red Hat + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + + +#ifndef CEPH_MOSDBACKOFF_H +#define CEPH_MOSDBACKOFF_H + +#include "msg/Message.h" +#include "osd/osd_types.h" + +class MOSDBackoff : public Message { +public: + uint8_t op = 0; ///< CEPH_OSD_BACKOFF_OP_* + uint64_t id = 0; ///< unique id within this session + hobject_t begin, end; ///< [) range to block, unless ==, block single obj + epoch_t osd_epoch = 0; + + MOSDBackoff() : Message(CEPH_MSG_OSD_BACKOFF) {} + MOSDBackoff(uint8_t op_, uint64_t id_, + hobject_t begin_, hobject_t end_, epoch_t ep) + : Message(CEPH_MSG_OSD_BACKOFF), + op(op_), + id(id_), + begin(begin_), + end(end_), + osd_epoch(ep) { } + + void encode_payload(uint64_t features) override { + ::encode(op, payload); + ::encode(id, payload); + ::encode(begin, payload); + ::encode(end, payload); + ::encode(osd_epoch, payload); + } + + void decode_payload() override { + auto p = payload.begin(); + ::decode(op, p); + ::decode(id, p); + ::decode(begin, p); + ::decode(end, p); + ::decode(osd_epoch, p); + } + + const char *get_type_name() const override { return "osd_backoff"; } + + void print(ostream& out) const override { + out << "osd_backoff(" << ceph_osd_backoff_op_name(op) + << " id " << id + << " [" << begin << "," << end << ")" + << " epoch " << osd_epoch << ")"; + } +}; + +#endif diff --git a/src/msg/Message.cc b/src/msg/Message.cc index a9fa275648fa..a226ecbca72c 100644 --- a/src/msg/Message.cc +++ b/src/msg/Message.cc @@ -82,6 +82,7 @@ using namespace std; #include "messages/MOSDRepScrub.h" #include "messages/MOSDPGScan.h" #include "messages/MOSDPGBackfill.h" +#include "messages/MOSDBackoff.h" #include "messages/MRemoveSnaps.h" @@ -460,6 +461,9 @@ Message *decode_message(CephContext *cct, int crcflags, case MSG_OSD_PG_UPDATE_LOG_MISSING_REPLY: m = new MOSDPGUpdateLogMissingReply(); break; + case CEPH_MSG_OSD_BACKOFF: + m = new MOSDBackoff; + break; case CEPH_MSG_OSD_MAP: m = new MOSDMap;