55
66#include < boost/functional/hash.hpp>
77
8- #include " homeobject/common .hpp"
8+ #include " homeobject_impl .hpp"
99
1010namespace homeobject {
1111
@@ -19,11 +19,37 @@ struct BlobRoute {
1919 auto operator <=>(BlobRoute const &) const = default ;
2020 sisl::blob to_blob () const { return sisl::blob{uintptr_cast (const_cast < BlobRoute* >(this )), sizeof (*this )}; }
2121};
22+
23+ // used for gc to quickly identify all the blob in the move_to chunk
24+ struct BlobRouteByChunk {
25+ // homestore::chunk_num_t == uint16_t
26+ uint16_t chunk;
27+ shard_id_t shard;
28+ blob_id_t blob;
29+ auto operator <=>(BlobRouteByChunk const &) const = default ;
30+ sisl::blob to_blob () const {
31+ return sisl::blob{uintptr_cast (const_cast < BlobRouteByChunk* >(this )), sizeof (*this )};
32+ }
33+ };
2234#pragma pack()
2335
2436} // namespace homeobject
2537
2638namespace fmt {
39+ template <>
40+ struct formatter < homeobject::BlobRouteByChunk > {
41+ template < typename ParseContext >
42+ constexpr auto parse (ParseContext& ctx) {
43+ return ctx.begin ();
44+ }
45+
46+ template < typename FormatContext >
47+ auto format (homeobject::BlobRouteByChunk const & r, FormatContext& ctx) {
48+ return format_to (ctx.out (), " {:04x}:{:04x}:{:012x}:{:016x}" , r.chunk , (r.shard >> homeobject::shard_width),
49+ (r.shard & homeobject::shard_mask), r.blob );
50+ }
51+ };
52+
2753template <>
2854struct formatter < homeobject::BlobRoute > {
2955 template < typename ParseContext >
@@ -37,6 +63,7 @@ struct formatter< homeobject::BlobRoute > {
3763 (r.shard & homeobject::shard_mask), r.blob );
3864 }
3965};
66+
4067} // namespace fmt
4168
4269template <>
@@ -45,3 +72,10 @@ struct std::hash< homeobject::BlobRoute > {
4572 return boost::hash_value< homeobject::blob_id_t >(std::make_pair (r.shard , r.blob ));
4673 }
4774};
75+
76+ template <>
77+ struct std ::hash< homeobject::BlobRouteByChunk > {
78+ std::size_t operator ()(homeobject::BlobRouteByChunk const & r) const noexcept {
79+ return boost::hash_value< homeobject::blob_id_t >(std::make_pair (r.shard , r.blob ));
80+ }
81+ };
0 commit comments