]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/services/svc_mdlog.h
57103efb464f40b02b04255c95d19f5b1cc4c42e
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
5 * Ceph - scalable distributed file system
7 * Copyright (C) 2019 Red Hat, Inc.
9 * This is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License version 2.1, as published by the Free Software
12 * Foundation. See file COPYING.
19 #include "rgw/rgw_service.h"
20 #include "rgw/rgw_period_history.h"
21 #include "rgw/rgw_period_puller.h"
23 #include "svc_meta_be.h"
27 class RGWMetadataLogHistory
;
39 class RGWSI_MDLog
: public RGWServiceInstance
41 friend class mdlog::ReadHistoryCR
;
42 friend class mdlog::WriteHistoryCR
;
44 // maintain a separate metadata log for each period
45 std::map
<std::string
, RGWMetadataLog
> md_logs
;
47 // use the current period's log for mutating operations
48 RGWMetadataLog
* current_log
{nullptr};
52 // pulls missing periods for period_history
53 std::unique_ptr
<RGWPeriodPuller
> period_puller
;
54 // maintains a connected history of periods
55 std::unique_ptr
<RGWPeriodHistory
> period_history
;
58 RGWSI_MDLog(CephContext
*cct
, bool run_sync
);
59 virtual ~RGWSI_MDLog();
62 RGWSI_RADOS
*rados
{nullptr};
63 RGWSI_Zone
*zone
{nullptr};
64 RGWSI_SysObj
*sysobj
{nullptr};
65 RGWSI_MDLog
*mdlog
{nullptr};
66 RGWSI_Cls
*cls
{nullptr};
69 int init(RGWSI_RADOS
*_rados_svc
,
70 RGWSI_Zone
*_zone_svc
,
71 RGWSI_SysObj
*_sysobj_svc
,
74 int do_start(optional_yield y
, const DoutPrefixProvider
*dpp
) override
;
76 // traverse all the way back to the beginning of the period history, and
77 // return a cursor to the first period in a fully attached history
78 RGWPeriodHistory::Cursor
find_oldest_period(const DoutPrefixProvider
*dpp
, optional_yield y
);
80 /// initialize the oldest log period if it doesn't exist, and attach it to
81 /// our current history
82 RGWPeriodHistory::Cursor
init_oldest_log_period(optional_yield y
, const DoutPrefixProvider
*dpp
);
84 /// read the oldest log period, and return a cursor to it in our existing
86 RGWPeriodHistory::Cursor
read_oldest_log_period(optional_yield y
, const DoutPrefixProvider
*dpp
) const;
88 /// read the oldest log period asynchronously and write its result to the
89 /// given cursor pointer
90 RGWCoroutine
* read_oldest_log_period_cr(const DoutPrefixProvider
*dpp
,
91 RGWPeriodHistory::Cursor
*period
,
92 RGWObjVersionTracker
*objv
) const;
94 /// try to advance the oldest log period when the given period is trimmed,
95 /// using a rados lock to provide atomicity
96 RGWCoroutine
* trim_log_period_cr(const DoutPrefixProvider
*dpp
,
97 RGWPeriodHistory::Cursor period
,
98 RGWObjVersionTracker
*objv
) const;
99 int read_history(RGWMetadataLogHistory
*state
, RGWObjVersionTracker
*objv_tracker
,optional_yield y
, const DoutPrefixProvider
*dpp
) const;
100 int write_history(const DoutPrefixProvider
*dpp
,
101 const RGWMetadataLogHistory
& state
,
102 RGWObjVersionTracker
*objv_tracker
,
103 optional_yield y
, bool exclusive
= false);
105 int add_entry(const DoutPrefixProvider
*dpp
, const string
& hash_key
, const string
& section
, const string
& key
, bufferlist
& bl
);
107 int get_shard_id(const string
& hash_key
, int *shard_id
);
109 RGWPeriodHistory
*get_period_history() {
110 return period_history
.get();
113 int pull_period(const DoutPrefixProvider
*dpp
, const std::string
& period_id
, RGWPeriod
& period
, optional_yield y
);
115 /// find or create the metadata log for the given period
116 RGWMetadataLog
* get_log(const std::string
& period
);