@@ -15,60 +15,65 @@ using std::vector;
1515using ceph::bufferlist;
1616
1717namespace {
18+
19+ // / the 'to_str()' representation of an hobject, if created with the specific
20+ // / parameters, prefixed with 'prefix'.
21+ std::string virtual_hobject_w_prefix (std::string_view prefix,
22+ const std::string& key,
23+ snapid_t snap,
24+ uint32_t hash,
25+ int64_t pool)
26+ {
27+ return fmt::format (" {}_{}" , prefix,
28+ hobject_t (object_t (), key, snap, hash, pool, " " ).to_str ());
29+ }
30+
31+ // / the 'to_str()' representation of an hobject, if created with the specific
32+ // / parameters, prefixed with 'prefix'.
33+ std::string virtual_hobject_w_prefix (std::string_view prefix,
34+ const librados::object_id_t & oid,
35+ uint32_t hash,
36+ int64_t pool) {
37+ return fmt::format (" {}_{}" , prefix,
38+ hobject_t (object_t {oid.name }, oid.locator , oid.snap , hash,
39+ pool, oid.nspace )
40+ .to_str ());
41+ }
42+
1843string first_object_key (int64_t pool)
1944{
20- auto hoid = hobject_t (object_t (), " " , CEPH_NOSNAP, 0x00000000 , pool, " " );
21- hoid.build_hash_cache ();
22- return " SCRUB_OBJ_" + hoid.to_str ();
45+ return virtual_hobject_w_prefix (" SCRUB_OBJ" , " " , CEPH_NOSNAP, 0x00000000 ,
46+ pool);
2347}
2448
2549// the object_key should be unique across pools
2650string to_object_key (int64_t pool, const librados::object_id_t & oid)
2751{
28- auto hoid = hobject_t (object_t (oid.name ),
29- oid.locator , // key
30- oid.snap ,
31- 0 , // hash
32- pool,
33- oid.nspace );
34- hoid.build_hash_cache ();
35- return " SCRUB_OBJ_" + hoid.to_str ();
52+ return virtual_hobject_w_prefix (" SCRUB_OBJ" , oid, 0x00000000 , pool);
3653}
3754
3855string last_object_key (int64_t pool)
3956{
40- auto hoid = hobject_t (object_t (), " " , CEPH_NOSNAP, 0xffffffff , pool, " " );
41- hoid.build_hash_cache ();
42- return " SCRUB_OBJ_" + hoid.to_str ();
57+ return virtual_hobject_w_prefix (" SCRUB_OBJ" , " " , CEPH_NOSNAP, 0xffffffff ,
58+ pool);
4359}
4460
4561string first_snap_key (int64_t pool)
4662{
4763 // scrub object is per spg_t object, so we can misuse the hash (pg.seed) for
4864 // representing the minimal and maximum keys. and this relies on how
4965 // hobject_t::to_str() works: hex(pool).hex(revhash).
50- auto hoid = hobject_t (object_t (), " " , 0 , 0x00000000 , pool, " " );
51- hoid.build_hash_cache ();
52- return " SCRUB_SS_" + hoid.to_str ();
66+ return virtual_hobject_w_prefix (" SCRUB_SS" , " " , 0 , 0x00000000 , pool);
5367}
5468
5569string to_snap_key (int64_t pool, const librados::object_id_t & oid)
5670{
57- auto hoid = hobject_t (object_t (oid.name ),
58- oid.locator , // key
59- oid.snap ,
60- 0x77777777 , // hash
61- pool,
62- oid.nspace );
63- hoid.build_hash_cache ();
64- return " SCRUB_SS_" + hoid.to_str ();
71+ return virtual_hobject_w_prefix (" SCRUB_SS" , oid, 0x77777777 , pool);
6572}
6673
6774string last_snap_key (int64_t pool)
6875{
69- auto hoid = hobject_t (object_t (), " " , 0 , 0xffffffff , pool, " " );
70- hoid.build_hash_cache ();
71- return " SCRUB_SS_" + hoid.to_str ();
76+ return virtual_hobject_w_prefix (" SCRUB_SS" , " " , 0 , 0xffffffff , pool);
7277}
7378
7479} // namespace
0 commit comments