summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRadoslaw Zarzynski <rzarzyns@redhat.com>2022-12-10 23:42:06 +0100
committerRadoslaw Zarzynski <rzarzyns@redhat.com>2023-02-28 17:22:05 +0100
commit30db140344ea93adc3042bd8f7034ccc484fdaa0 (patch)
tree7a2280f4a1c233232a21ab8f78805fd0f42c3208 /src
parentcrimson/osd: dissect head whiteout removal into SnapTrimObjSubEvent::remove_h... (diff)
downloadceph-30db140344ea93adc3042bd8f7034ccc484fdaa0.tar.xz
ceph-30db140344ea93adc3042bd8f7034ccc484fdaa0.zip
crimson/osd: dissect snapset update into SnapTrimObjSubEvent::update_head()
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/crimson/osd/osd_operations/snaptrim_event.cc74
-rw-r--r--src/crimson/osd/osd_operations/snaptrim_event.h5
2 files changed, 46 insertions, 33 deletions
diff --git a/src/crimson/osd/osd_operations/snaptrim_event.cc b/src/crimson/osd/osd_operations/snaptrim_event.cc
index f1aaa48bf81..ccccda5d185 100644
--- a/src/crimson/osd/osd_operations/snaptrim_event.cc
+++ b/src/crimson/osd/osd_operations/snaptrim_event.cc
@@ -362,6 +362,46 @@ SnapTrimObjSubEvent::adjust_snaps(
coid, new_snaps, pg->snap_mapper, pg->osdriver, txn);
}
+void SnapTrimObjSubEvent::update_head(
+ ObjectContextRef obc,
+ ObjectContextRef head_obc,
+ ceph::os::Transaction& txn,
+ std::vector<pg_log_entry_t>& log_entries
+) {
+ const auto head_oid = coid.get_head();
+ obc->ssc->snapset.snaps.clear();
+ logger().info("{}: writing updated snapset on {}, snapset is {}",
+ *this, head_oid, obc->ssc->snapset);
+ log_entries.emplace_back(
+ pg_log_entry_t{
+ pg_log_entry_t::MODIFY,
+ head_oid,
+ osd_op_p.at_version,
+ head_obc->obs.oi.version,
+ 0,
+ osd_reqid_t(),
+ obc->obs.oi.mtime,
+ 0}
+ );
+
+ head_obc->obs.oi.prior_version = head_obc->obs.oi.version;
+ head_obc->obs.oi.version = osd_op_p.at_version;
+
+ std::map<std::string, ceph::bufferlist, std::less<>> attrs;
+ ceph::bufferlist bl;
+ encode(obc->ssc->snapset, bl);
+ attrs[SS_ATTR] = std::move(bl);
+
+ bl.clear();
+ encode(head_obc->obs.oi, bl,
+ pg->get_osdmap()->get_features(CEPH_ENTITY_TYPE_OSD, nullptr));
+ attrs[OI_ATTR] = std::move(bl);
+ txn.setattrs(
+ pg->get_collection_ref()->get_cid(),
+ ghobject_t{head_oid, ghobject_t::NO_GEN, shard_id_t::NO_SHARD},
+ attrs);
+}
+
SnapTrimObjSubEvent::interruptible_future<
SnapTrimObjSubEvent::remove_or_update_ret_t>
SnapTrimObjSubEvent::remove_or_update(
@@ -419,40 +459,8 @@ SnapTrimObjSubEvent::remove_or_update(
if (obc->ssc->snapset.clones.empty() && head_obc->obs.oi.is_whiteout()) {
remove_head_whiteout(obc, head_obc, txn, log_entries);
} else {
- const auto head_oid = coid.get_head();
- obc->ssc->snapset.snaps.clear();
- logger().info("{}: writing updated snapset on {}, snapset is {}",
- *this, head_oid, obc->ssc->snapset);
- log_entries.emplace_back(
- pg_log_entry_t{
- pg_log_entry_t::MODIFY,
- head_oid,
- osd_op_p.at_version,
- head_obc->obs.oi.version,
- 0,
- osd_reqid_t(),
- obc->obs.oi.mtime,
- 0}
- );
-
- head_obc->obs.oi.prior_version = head_obc->obs.oi.version;
- head_obc->obs.oi.version = osd_op_p.at_version;
-
- std::map<std::string, ceph::bufferlist, std::less<>> attrs;
- ceph::bufferlist bl;
- encode(obc->ssc->snapset, bl);
- attrs[SS_ATTR] = std::move(bl);
-
- bl.clear();
- encode(head_obc->obs.oi, bl,
- pg->get_osdmap()->get_features(CEPH_ENTITY_TYPE_OSD, nullptr));
- attrs[OI_ATTR] = std::move(bl);
- txn.setattrs(
- pg->get_collection_ref()->get_cid(),
- ghobject_t{head_oid, ghobject_t::NO_GEN, shard_id_t::NO_SHARD},
- attrs);
+ update_head(obc, head_obc, txn, log_entries);
}
-
// Stats reporting - Set number of objects trimmed
if (num_objects_before_trim > delta_stats.num_objects) {
//int64_t num_objects_trimmed =
diff --git a/src/crimson/osd/osd_operations/snaptrim_event.h b/src/crimson/osd/osd_operations/snaptrim_event.h
index c7509165997..408f529b788 100644
--- a/src/crimson/osd/osd_operations/snaptrim_event.h
+++ b/src/crimson/osd/osd_operations/snaptrim_event.h
@@ -143,6 +143,11 @@ private:
const std::set<snapid_t>& new_snaps,
ceph::os::Transaction& txn,
std::vector<pg_log_entry_t>& log_entries);
+ void update_head(
+ ObjectContextRef obc,
+ ObjectContextRef head_obc,
+ ceph::os::Transaction& txn,
+ std::vector<pg_log_entry_t>& log_entries);
using remove_or_update_ret_t =
std::pair<ceph::os::Transaction, std::vector<pg_log_entry_t>>;