<< "the pool allows ec overwrites but is not stored in "
<< "bluestore, so deep scrubbing will not detect bitrot";
}
- PG::_create(rctx.transaction, pgid, pgid.get_split_bits(pp->get_pg_num()));
- PG::_init(rctx.transaction, pgid, pp);
+ create_pg_collection(
+ rctx.transaction, pgid, pgid.get_split_bits(pp->get_pg_num()));
+ init_pg_ondisk(rctx.transaction, pgid, pp);
int role = startmap->calc_pg_role(whoami, acting, acting.size());
if (!pp->is_replicated() && role != pgid.shard) {
void PG::upgrade(ObjectStore *store)
{
- dout(0) << __func__ << " " << info_struct_v << " -> " << latest_struct_v
+ dout(0) << __func__ << " " << info_struct_v << " -> " << pg_latest_struct_v
<< dendl;
ceph_assert(info_struct_v <= 10);
ObjectStore::Transaction t;
ceph_assert(info_struct_v == 10);
// update infover_key
- if (info_struct_v < latest_struct_v) {
+ if (info_struct_v < pg_latest_struct_v) {
map<string,bufferlist> v;
- __u8 ver = latest_struct_v;
+ __u8 ver = pg_latest_struct_v;
encode(ver, v[string(infover_key)]);
t.omap_setkeys(coll, pgmeta_oid, v);
}
#pragma GCC diagnostic pop
#pragma GCC diagnostic warning "-Wpragmas"
-void PG::_create(ObjectStore::Transaction& t, spg_t pgid, int bits)
-{
- coll_t coll(pgid);
- t.create_collection(coll, bits);
-}
-
-void PG::_init(ObjectStore::Transaction& t, spg_t pgid, const pg_pool_t *pool)
-{
- coll_t coll(pgid);
-
- if (pool) {
- // Give a hint to the PG collection
- bufferlist hint;
- uint32_t pg_num = pool->get_pg_num();
- uint64_t expected_num_objects_pg = pool->expected_num_objects / pg_num;
- encode(pg_num, hint);
- encode(expected_num_objects_pg, hint);
- uint32_t hint_type = ObjectStore::Transaction::COLL_HINT_EXPECTED_NUM_OBJECTS;
- t.collection_hint(coll, hint_type, hint);
- }
-
- ghobject_t pgmeta_oid(pgid.make_pgmeta_oid());
- t.touch(coll, pgmeta_oid);
- map<string,bufferlist> values;
- __u8 struct_v = latest_struct_v;
- encode(struct_v, values[string(infover_key)]);
- t.omap_setkeys(coll, pgmeta_oid, values);
-}
-
void PG::prepare_write(
pg_info_t &info,
pg_info_t &last_written_info,
info_struct_v);
ceph_assert(r >= 0);
- if (info_struct_v < compat_struct_v) {
+ if (info_struct_v < pg_compat_struct_v) {
derr << "PG needs upgrade, but on-disk data is too old; upgrade to"
<< " an older version first." << dendl;
ceph_abort_msg("PG too old to upgrade");
return 0;
});
- if (info_struct_v < latest_struct_v) {
+ if (info_struct_v < pg_latest_struct_v) {
upgrade(store);
}
if (!osd->try_finish_pg_delete(this, pool.info.get_pg_num())) {
dout(1) << __func__ << " raced with merge, reinstantiating" << dendl;
ch = osd->store->create_new_collection(coll);
- _create(t,
+ create_pg_collection(t,
info.pgid,
info.pgid.get_split_bits(pool.info.get_pg_num()));
- _init(t, info.pgid, &pool.info);
+ init_pg_ondisk(t, info.pgid, &pool.info);
recovery_state.reset_last_persisted();
} else {
recovery_state.set_delete_complete();
static int peek_map_epoch(ObjectStore *store, spg_t pgid, epoch_t *pepoch);
static int get_latest_struct_v() {
- return latest_struct_v;
+ return pg_latest_struct_v;
}
static int get_compat_struct_v() {
- return compat_struct_v;
+ return pg_compat_struct_v;
}
static int read_info(
ObjectStore *store, spg_t pgid, const coll_t &coll,
protected:
__u8 info_struct_v = 0;
- static const __u8 latest_struct_v = 10;
- // v10 is the new past_intervals encoding
- // v9 was fastinfo_key addition
- // v8 was the move to a per-pg pgmeta object
- // v7 was SnapMapper addition in 86658392516d5175b2756659ef7ffaaf95b0f8ad
- // (first appeared in cuttlefish).
- static const __u8 compat_struct_v = 10;
void upgrade(ObjectStore *store);
protected:
void do_pending_flush();
public:
- static void _create(ObjectStore::Transaction& t, spg_t pgid, int bits);
- static void _init(ObjectStore::Transaction& t,
- spg_t pgid, const pg_pool_t *pool);
-
virtual void prepare_write(
pg_info_t &info,
pg_info_t &last_written_info,
const pg_pool_t *pool,
ObjectStore::Transaction &t) override {
coll_t target = coll_t(child);
- PG::_create(t, child, split_bits);
+ create_pg_collection(t, child, split_bits);
t.split_collection(
coll,
split_bits,
seed,
target);
- PG::_init(t, child, pool);
+ init_pg_ondisk(t, child, pool);
}
private:
#include "common/Formatter.h"
#include "OSDMap.h"
#include "osd_types.h"
+#include "os/Transaction.h"
using std::list;
using std::make_pair;
return 0;
}
+void create_pg_collection(
+ ceph::os::Transaction& t, spg_t pgid, int bits)
+{
+ coll_t coll(pgid);
+ t.create_collection(coll, bits);
+}
+
+void init_pg_ondisk(
+ ceph::os::Transaction& t,
+ spg_t pgid,
+ const pg_pool_t *pool)
+{
+ coll_t coll(pgid);
+ if (pool) {
+ // Give a hint to the PG collection
+ bufferlist hint;
+ uint32_t pg_num = pool->get_pg_num();
+ uint64_t expected_num_objects_pg = pool->expected_num_objects / pg_num;
+ encode(pg_num, hint);
+ encode(expected_num_objects_pg, hint);
+ uint32_t hint_type = ceph::os::Transaction::COLL_HINT_EXPECTED_NUM_OBJECTS;
+ t.collection_hint(coll, hint_type, hint);
+ }
+
+ ghobject_t pgmeta_oid(pgid.make_pgmeta_oid());
+ t.touch(coll, pgmeta_oid);
+ map<string,bufferlist> values;
+ __u8 struct_v = pg_latest_struct_v;
+ encode(struct_v, values[string(infover_key)]);
+ t.omap_setkeys(coll, pgmeta_oid, values);
+}
static const string_view epoch_key = "_epoch"sv;
static const string_view fastinfo_key = "_fastinfo"sv;
+static const __u8 pg_latest_struct_v = 10;
+// v10 is the new past_intervals encoding
+// v9 was fastinfo_key addition
+// v8 was the move to a per-pg pgmeta object
+// v7 was SnapMapper addition in 86658392516d5175b2756659ef7ffaaf95b0f8ad
+// (first appeared in cuttlefish).
+static const __u8 pg_compat_struct_v = 10;
+
int prepare_info_keymap(
CephContext* cct,
map<string,bufferlist> *km,
PerfCounters *logger = nullptr,
DoutPrefixProvider *dpp = nullptr);
+namespace ceph::os {
+ class Transaction;
+};
+
+void create_pg_collection(
+ ceph::os::Transaction& t, spg_t pgid, int bits);
+
+void init_pg_ondisk(
+ ceph::os::Transaction& t, spg_t pgid, const pg_pool_t *pool);
+
// omap specific stats
struct omap_stat_t {
int large_omap_objects;
if (!dry_run) {
ObjectStore::Transaction t;
ch = store->create_new_collection(coll);
- PG::_create(
+ create_pg_collection(
t, pgid,
pgid.get_split_bits(ms.osdmap.get_pg_pool(pgid.pool())->get_pg_num()));
- PG::_init(t, pgid, NULL);
+ init_pg_ondisk(t, pgid, NULL);
// mark this coll for removal until we're done
map<string,bufferlist> values;