Skip to content

Commit

Permalink
Merge pull request ceph#58693 from xxhdx1985126/wip-crimson-clear-tem…
Browse files Browse the repository at this point in the history
…p-objects-startup

crimson/osd: clear ondisk temp objects on startup

Reviewed-by: Matan Breizman <[email protected]>
  • Loading branch information
Matan-B committed Aug 7, 2024
2 parents 76a6bbe + cbdecc1 commit d8caee9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
29 changes: 29 additions & 0 deletions src/crimson/osd/pg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,35 @@ Context *PG::on_clean()
return nullptr;
}

seastar::future<> PG::clear_temp_objects()
{
logger().info("{} {}", __func__, pgid);
ghobject_t _next;
ceph::os::Transaction t;
auto max_size = local_conf()->osd_target_transaction_size;
while(true) {
auto [objs, next] = co_await shard_services.get_store().list_objects(
coll_ref, _next, ghobject_t::get_max(), max_size);
if (objs.empty()) {
if (!t.empty()) {
co_await shard_services.get_store().do_transaction(
coll_ref, std::move(t));
}
break;
}
for (auto &obj : objs) {
if (obj.hobj.is_temp()) {
t.remove(coll_ref->get_cid(), obj);
}
}
_next = next;
if (t.get_num_ops() >= max_size) {
co_await shard_services.get_store().do_transaction(
coll_ref, t.claim_and_reset());
}
}
}

PG::interruptible_future<seastar::stop_iteration> PG::trim_snap(
snapid_t to_trim,
bool needs_pause)
Expand Down
1 change: 1 addition & 0 deletions src/crimson/osd/pg.h
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ class PG : public boost::intrusive_ref_counter<
ObjectContextRef obc,
const std::error_code e,
ceph_tid_t rep_tid);
seastar::future<> clear_temp_objects();

private:

Expand Down
6 changes: 4 additions & 2 deletions src/crimson/osd/pg_shard_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ seastar::future<> PGShardManager::load_pgs(crimson::os::FuturizedStore& store)
pgid
).then([pgid, &per_shard_state](auto &&pg) {
logger().info("load_pgs: loaded {}", pgid);
per_shard_state.pg_map.pg_loaded(pgid, std::move(pg));
return seastar::now();
return pg->clear_temp_objects(
).then([&per_shard_state, pg, pgid] {
per_shard_state.pg_map.pg_loaded(pgid, std::move(pg));
});
});
});
});
Expand Down

0 comments on commit d8caee9

Please sign in to comment.