static RGWMetadataTopHandler md_top_handler;
-static const std::string mdlog_history_oid = "meta.history";
-
-struct RGWMetadataLogHistory {
- epoch_t oldest_realm_epoch;
- std::string oldest_period_id;
-
- void encode(bufferlist& bl) const {
- ENCODE_START(1, 1, bl);
- ::encode(oldest_realm_epoch, bl);
- ::encode(oldest_period_id, bl);
- ENCODE_FINISH(bl);
- }
- void decode(bufferlist::iterator& p) {
- DECODE_START(1, p);
- ::decode(oldest_realm_epoch, p);
- ::decode(oldest_period_id, p);
- DECODE_FINISH(p);
- }
-};
-WRITE_CLASS_ENCODER(RGWMetadataLogHistory)
-
-
RGWMetadataManager::RGWMetadataManager(CephContext *_cct, RGWRados *_store)
: cct(_cct), store(_store)
{
handlers.clear();
}
+const std::string RGWMetadataLogHistory::oid = "meta.history";
+
namespace {
-int read_history(RGWRados *store, RGWMetadataLogHistory *state)
+int read_history(RGWRados *store, RGWMetadataLogHistory *state,
+ RGWObjVersionTracker *objv_tracker)
{
RGWObjectCtx ctx{store};
auto& pool = store->get_zone_params().log_pool;
- const auto& oid = mdlog_history_oid;
+ const auto& oid = RGWMetadataLogHistory::oid;
bufferlist bl;
- int ret = rgw_get_system_obj(store, ctx, pool, oid, bl, nullptr, nullptr);
+ int ret = rgw_get_system_obj(store, ctx, pool, oid, bl, objv_tracker, nullptr);
if (ret < 0) {
return ret;
}
}
int write_history(RGWRados *store, const RGWMetadataLogHistory& state,
- bool exclusive = false)
+ RGWObjVersionTracker *objv_tracker, bool exclusive = false)
{
bufferlist bl;
state.encode(bl);
auto& pool = store->get_zone_params().log_pool;
- const auto& oid = mdlog_history_oid;
+ const auto& oid = RGWMetadataLogHistory::oid;
return rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(),
- exclusive, nullptr, real_time{});
+ exclusive, objv_tracker, real_time{});
}
using Cursor = RGWPeriodHistory::Cursor;
{
// read the mdlog history
RGWMetadataLogHistory state;
- int ret = read_history(store, &state);
+ RGWObjVersionTracker objv;
+ int ret = read_history(store, &state, &objv);
if (ret == -ENOENT) {
// initialize the mdlog history and write it
state.oldest_period_id = cursor.get_period().get_id();
constexpr bool exclusive = true; // don't overwrite
- int ret = write_history(store, state, exclusive);
+ int ret = write_history(store, state, &objv, exclusive);
if (ret < 0 && ret != -EEXIST) {
ldout(cct, 1) << "failed to write mdlog history: "
<< cpp_strerror(ret) << dendl;
Cursor RGWMetadataManager::read_oldest_log_period() const
{
RGWMetadataLogHistory state;
- int ret = read_history(store, &state);
+ int ret = read_history(store, &state, nullptr);
if (ret < 0) {
ldout(store->ctx(), 1) << "failed to read mdlog history: "
<< cpp_strerror(ret) << dendl;
};
WRITE_CLASS_ENCODER(RGWMetadataLogData)
+struct RGWMetadataLogHistory {
+ epoch_t oldest_realm_epoch;
+ std::string oldest_period_id;
+
+ void encode(bufferlist& bl) const {
+ ENCODE_START(1, 1, bl);
+ ::encode(oldest_realm_epoch, bl);
+ ::encode(oldest_period_id, bl);
+ ENCODE_FINISH(bl);
+ }
+ void decode(bufferlist::iterator& p) {
+ DECODE_START(1, p);
+ ::decode(oldest_realm_epoch, p);
+ ::decode(oldest_period_id, p);
+ DECODE_FINISH(p);
+ }
+
+ static const std::string oid;
+};
+WRITE_CLASS_ENCODER(RGWMetadataLogHistory)
+
class RGWMetadataManager {
map<string, RGWMetadataHandler *> handlers;
CephContext *cct;