Skip to content

Commit

Permalink
Merge pull request #7765 from athanatos/wip-lost-unfound-repop
Browse files Browse the repository at this point in the history
Repop and lost-unfound overhaul

Reviewed-by: Sage Weil <sage@redhat.com>
  • Loading branch information
athanatos committed Feb 29, 2016
2 parents 5f82cbe + e7edf20 commit 306c7bf
Show file tree
Hide file tree
Showing 34 changed files with 1,754 additions and 778 deletions.
10 changes: 10 additions & 0 deletions src/common/dout.h
Expand Up @@ -39,6 +39,14 @@ inline std::ostream& operator<<(std::ostream& out, _bad_endl_use_dendl_t) {
return out;
}

class DoutPrefixProvider {
public:
virtual string gen_prefix() const = 0;
virtual CephContext *get_cct() const = 0;
virtual unsigned get_subsys() const = 0;
virtual ~DoutPrefixProvider() {}
};

// generic macros
#define dout_prefix *_dout

Expand All @@ -58,6 +66,8 @@ inline std::ostream& operator<<(std::ostream& out, _bad_endl_use_dendl_t) {
#define ldout(cct, v) dout_impl(cct, dout_subsys, v) dout_prefix
#define lderr(cct) dout_impl(cct, ceph_subsys_, -1) dout_prefix

#define ldpp_dout(dpp, v) if (dpp) dout_impl(dpp->get_cct(), dpp->get_subsys(), v) (*_dout << dpp->gen_prefix())

#define lgeneric_subdout(cct, sub, v) dout_impl(cct, ceph_subsys_##sub, v) *_dout
#define lgeneric_dout(cct, v) dout_impl(cct, ceph_subsys_, v) *_dout
#define lgeneric_derr(cct) dout_impl(cct, ceph_subsys_, -1) *_dout
Expand Down
2 changes: 2 additions & 0 deletions src/include/ceph_features.h
Expand Up @@ -73,6 +73,7 @@
#define CEPH_FEATURE_MON_STATEFUL_SUB (1ULL<<57) /* stateful mon subscription */
#define CEPH_FEATURE_MON_ROUTE_OSDMAP (1ULL<<57) /* peon sends osdmaps */
#define CEPH_FEATURE_OSDSUBOP_NO_SNAPCONTEXT (1ULL<<57) /* overlap, drop unused SnapContext in v12 */
#define CEPH_FEATURE_SERVER_JEWEL (1ULL<<57) /* overlap, features introduced in jewel */
#define CEPH_FEATURE_CRUSH_TUNABLES5 (1ULL<<58) /* chooseleaf stable mode */
// duplicated since it was introduced at the same time as CEPH_FEATURE_CRUSH_TUNABLES5
#define CEPH_FEATURE_NEW_OSDOPREPLY_ENCODING (1ULL<<58) /* New, v7 encoding */
Expand Down Expand Up @@ -172,6 +173,7 @@ static inline unsigned long long ceph_sanitize_features(unsigned long long f) {
CEPH_FEATURE_MON_STATEFUL_SUB | \
CEPH_FEATURE_MON_ROUTE_OSDMAP | \
CEPH_FEATURE_CRUSH_TUNABLES5 | \
CEPH_FEATURE_SERVER_JEWEL | \
0ULL)

#define CEPH_FEATURES_SUPPORTED_DEFAULT CEPH_FEATURES_ALL
Expand Down
1 change: 1 addition & 0 deletions src/include/rados.h
Expand Up @@ -144,6 +144,7 @@ extern const char *ceph_osd_state_name(int s);
#define CEPH_OSDMAP_NOTIERAGENT (1<<13) /* disable tiering agent */
#define CEPH_OSDMAP_NOREBALANCE (1<<14) /* block osd backfill unless pg is degraded */
#define CEPH_OSDMAP_SORTBITWISE (1<<15) /* use bitwise hobject_t sort */
#define CEPH_OSDMAP_REQUIRE_JEWEL (1<<16) /* require jewel for booting osds */

/*
* The error code to return when an OSD can't handle a write
Expand Down
82 changes: 82 additions & 0 deletions src/messages/MOSDPGUpdateLogMissing.h
@@ -0,0 +1,82 @@
// -*- 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) 2004-2006 Sage Weil <sage@newdream.net>
*
* 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_MOSDPGUPDATELOGMISSING_H
#define CEPH_MOSDPGUPDATELOGMISSING_H

#include "msg/Message.h"

class MOSDPGUpdateLogMissing : public Message {

static const int HEAD_VERSION = 1;
static const int COMPAT_VERSION = 1;


public:
epoch_t map_epoch;
spg_t pgid;
shard_id_t from;
ceph_tid_t rep_tid;
list<pg_log_entry_t> entries;

epoch_t get_epoch() const { return map_epoch; }
spg_t get_pgid() const { return pgid; }
epoch_t get_query_epoch() const { return map_epoch; }
ceph_tid_t get_tid() const { return rep_tid; }

MOSDPGUpdateLogMissing() :
Message(MSG_OSD_PG_UPDATE_LOG_MISSING, HEAD_VERSION, COMPAT_VERSION) { }
MOSDPGUpdateLogMissing(
const list<pg_log_entry_t> &entries,
spg_t pgid,
shard_id_t from,
epoch_t epoch,
ceph_tid_t rep_tid)
: Message(MSG_OSD_PG_UPDATE_LOG_MISSING, HEAD_VERSION, COMPAT_VERSION),
map_epoch(epoch),
pgid(pgid),
from(from),
rep_tid(rep_tid),
entries(entries) {}

private:
~MOSDPGUpdateLogMissing() {}

public:
const char *get_type_name() const { return "PGUpdateLogMissing"; }
void print(ostream& out) const {
out << "pg_update_log_missing(" << pgid << " epoch " << map_epoch
<< " rep_tid " << rep_tid
<< " entries " << entries << ")";
}

void encode_payload(uint64_t features) {
::encode(map_epoch, payload);
::encode(pgid, payload);
::encode(from, payload);
::encode(rep_tid, payload);
::encode(entries, payload);
}
void decode_payload() {
bufferlist::iterator p = payload.begin();
::decode(map_epoch, p);
::decode(pgid, p);
::decode(from, p);
::decode(rep_tid, p);
::decode(entries, p);
}
};

#endif
87 changes: 87 additions & 0 deletions src/messages/MOSDPGUpdateLogMissingReply.h
@@ -0,0 +1,87 @@
// -*- 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) 2004-2006 Sage Weil <sage@newdream.net>
*
* 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_MOSDPGUPDATELOGMISSINGREPLY_H
#define CEPH_MOSDPGUPDATELOGMISSINGREPLY_H

#include "msg/Message.h"

class MOSDPGUpdateLogMissingReply : public Message {

static const int HEAD_VERSION = 1;
static const int COMPAT_VERSION = 1;


public:
epoch_t map_epoch;
spg_t pgid;
shard_id_t from;
ceph_tid_t rep_tid;

epoch_t get_epoch() const { return map_epoch; }
spg_t get_pgid() const { return pgid; }
epoch_t get_query_epoch() const { return map_epoch; }
ceph_tid_t get_tid() const { return rep_tid; }
pg_shard_t get_from() const {
return pg_shard_t(get_source().num(), from);
}

MOSDPGUpdateLogMissingReply() :
Message(
MSG_OSD_PG_UPDATE_LOG_MISSING_REPLY,
HEAD_VERSION,
COMPAT_VERSION)
{}
MOSDPGUpdateLogMissingReply(
spg_t pgid,
shard_id_t from,
epoch_t epoch,
ceph_tid_t rep_tid)
: Message(
MSG_OSD_PG_UPDATE_LOG_MISSING_REPLY,
HEAD_VERSION,
COMPAT_VERSION),
map_epoch(epoch),
pgid(pgid),
from(from),
rep_tid(rep_tid)
{}

private:
~MOSDPGUpdateLogMissingReply() {}

public:
const char *get_type_name() const { return "PGUpdateLogMissingReply"; }
void print(ostream& out) const {
out << "pg_update_log_missing_reply(" << pgid << " epoch " << map_epoch
<< " rep_tid " << rep_tid << ")";
}

void encode_payload(uint64_t features) {
::encode(map_epoch, payload);
::encode(pgid, payload);
::encode(from, payload);
::encode(rep_tid, payload);
}
void decode_payload() {
bufferlist::iterator p = payload.begin();
::decode(map_epoch, p);
::decode(pgid, p);
::decode(from, p);
::decode(rep_tid, p);
}
};

#endif
2 changes: 2 additions & 0 deletions src/messages/Makefile.am
Expand Up @@ -91,6 +91,8 @@ noinst_HEADERS += \
messages/MOSDPGQuery.h \
messages/MOSDPGRemove.h \
messages/MOSDPGScan.h \
messages/MOSDPGUpdateLogMissing.h \
messages/MOSDPGUpdateLogMissingReply.h \
messages/MOSDECSubOpWrite.h \
messages/MOSDECSubOpWriteReply.h \
messages/MOSDECSubOpRead.h \
Expand Down
20 changes: 20 additions & 0 deletions src/mon/OSDMonitor.cc
Expand Up @@ -125,6 +125,9 @@ void OSDMonitor::create_initial()
// new clusters should sort bitwise by default.
newmap.set_flag(CEPH_OSDMAP_SORTBITWISE);

// new cluster should require jewel by default
newmap.set_flag(CEPH_OSDMAP_REQUIRE_JEWEL);

// encode into pending incremental
newmap.encode(pending_inc.fullmap, mon->quorum_features | CEPH_FEATURE_RESERVED);
pending_inc.full_crc = newmap.get_crc();
Expand Down Expand Up @@ -1871,6 +1874,16 @@ bool OSDMonitor::preprocess_boot(MonOpRequestRef op)
goto ignore;
}

if (osdmap.test_flag(CEPH_OSDMAP_REQUIRE_JEWEL) &&
!(m->get_connection()->get_features() & CEPH_FEATURE_SERVER_JEWEL)) {
mon->clog->info() << "disallowing boot of OSD "
<< m->get_orig_source_inst()
<< " because the osdmap requires"
<< " CEPH_FEATURE_SERVER_JEWEL"
<< " but the osd lacks CEPH_FEATURE_SERVER_JEWEL\n";
goto ignore;
}

if (osdmap.test_flag(CEPH_OSDMAP_SORTBITWISE) &&
!(m->osd_features & CEPH_FEATURE_OSD_BITWISE_HOBJ_SORT)) {
mon->clog->info() << "disallowing boot of OSD "
Expand Down Expand Up @@ -6152,6 +6165,13 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
ss << "not all up OSDs have OSD_BITWISE_HOBJ_SORT feature";
err = -EPERM;
}
} else if (key == "require_jewel_osds") {
if (osdmap.get_up_osd_features() & CEPH_FEATURE_SERVER_JEWEL) {
return prepare_set_flag(op, CEPH_OSDMAP_REQUIRE_JEWEL);
} else {
ss << "not all up OSDs have CEPH_FEATURE_SERVER_JEWEL feature";
err = -EPERM;
}
} else {
ss << "unrecognized flag '" << key << "'";
err = -EINVAL;
Expand Down
9 changes: 9 additions & 0 deletions src/msg/Message.cc
Expand Up @@ -170,6 +170,9 @@ using namespace std;
#include "messages/MOSDECSubOpRead.h"
#include "messages/MOSDECSubOpReadReply.h"

#include "messages/MOSDPGUpdateLogMissing.h"
#include "messages/MOSDPGUpdateLogMissingReply.h"

#define DEBUGLVL 10 // debug level of output

#define dout_subsys ceph_subsys_ms
Expand Down Expand Up @@ -437,6 +440,12 @@ Message *decode_message(CephContext *cct, int crcflags,
case MSG_OSD_REPOPREPLY:
m = new MOSDRepOpReply();
break;
case MSG_OSD_PG_UPDATE_LOG_MISSING:
m = new MOSDPGUpdateLogMissing();
break;
case MSG_OSD_PG_UPDATE_LOG_MISSING_REPLY:
m = new MOSDPGUpdateLogMissingReply();
break;

case CEPH_MSG_OSD_MAP:
m = new MOSDMap;
Expand Down
2 changes: 2 additions & 0 deletions src/msg/Message.h
Expand Up @@ -116,6 +116,8 @@

#define MSG_OSD_REPOP 112
#define MSG_OSD_REPOPREPLY 113
#define MSG_OSD_PG_UPDATE_LOG_MISSING 114
#define MSG_OSD_PG_UPDATE_LOG_MISSING_REPLY 115


// *** MDS ***
Expand Down
19 changes: 19 additions & 0 deletions src/os/ObjectStore.h
Expand Up @@ -408,6 +408,8 @@ class ObjectStore {

OP_SETALLOCHINT = 39, // cid, oid, object_size, write_size
OP_COLL_HINT = 40, // cid, type, bl

OP_TRY_RENAME = 41, // oldcid, oldoid, newoid
};

// Transaction hint type
Expand Down Expand Up @@ -1415,6 +1417,23 @@ class ObjectStore {
}
data.ops++;
}
void try_rename(coll_t cid, const ghobject_t& oldoid,
const ghobject_t& oid) {
if (use_tbl) {
__u32 op = OP_TRY_RENAME;
::encode(op, tbl);
::encode(cid, tbl);
::encode(oldoid, tbl);
::encode(oid, tbl);
} else {
Op* _op = _get_next_op();
_op->op = OP_TRY_RENAME;
_op->cid = _get_coll_id(cid);
_op->oid = _get_object_id(oldoid);
_op->dest_oid = _get_object_id(oid);
}
data.ops++;
}

// NOTE: Collection attr operations are all DEPRECATED. new
// backends need not implement these at all.
Expand Down
14 changes: 14 additions & 0 deletions src/os/Transaction.cc
Expand Up @@ -323,6 +323,20 @@ void ObjectStore::Transaction::_build_actions_from_tbl()
}
break;

case Transaction::OP_TRY_RENAME:
{
coll_t cid;
ghobject_t oldoid;
ghobject_t newoid;

::decode(cid, p);
::decode(oldoid, p);
::decode(newoid, p);

try_rename(cid, oldoid, newoid);
}
break;

case Transaction::OP_COLL_SETATTR:
{
coll_t cid;
Expand Down
11 changes: 11 additions & 0 deletions src/os/bluestore/BlueStore.cc
Expand Up @@ -4492,6 +4492,17 @@ void BlueStore::_txc_add_transaction(TransContext *txc, Transaction *t)
}
break;

case Transaction::OP_TRY_RENAME:
{
const ghobject_t& noid = i.get_oid(op->dest_oid);
OnodeRef no = c->get_onode(noid, true);
r = _rename(txc, c, o, no, noid);
if (r == -ENOENT)
r = 0;
o.reset();
}
break;

case Transaction::OP_OMAP_CLEAR:
{
r = _omap_clear(txc, c, o);
Expand Down

0 comments on commit 306c7bf

Please sign in to comment.