#define dout_context cct
#define dout_subsys ceph_subsys_osd
#undef dout_prefix
-#define dout_prefix *_dout << "snap_mapper."
+#define dout_prefix *_dout << "snap_mapper "
using std::make_pair;
using std::map;
const set<snapid_t> *old_snaps_check,
MapCacher::Transaction<std::string, ceph::buffer::list> *t)
{
- dout(20) << __func__ << " " << oid << " " << new_snaps
+ dout(20) << *this << __func__ << " " << oid << " " << new_snaps
<< " was " << (old_snaps_check ? *old_snaps_check : set<snapid_t>())
<< dendl;
ceph_assert(check(oid));
object_snaps out;
int r = get_snaps(oid, &out);
if (r != -ENOENT) {
- derr << __func__ << " found existing snaps mapped on " << oid
+ derr << *this << __func__ << " found existing snaps mapped on " << oid
<< ", removing" << dendl;
ceph_assert(!cct->_conf->osd_debug_verify_snaps);
remove_oid(oid, t);
}
if (g_conf()->subsys.should_gather<ceph_subsys_osd, 20>()) {
for (auto& i : to_add) {
- dout(20) << __func__ << " set " << i.first << dendl;
+ dout(20) << *this << __func__ << " set " << i.first << dendl;
}
}
backend.set_keys(to_add, t);
void SnapMapper::reset_prefix_itr(snapid_t snap, const char *s)
{
if (prefix_itr_snap == CEPH_NOSNAP) {
- dout(10) << __func__ << "::from <CEPH_NOSNAP> to <" << snap << "> ::" << s << dendl;
+ dout(10) << *this << __func__ << "::from <CEPH_NOSNAP> to <" << snap << "> ::" << s << dendl;
}
else if (snap == CEPH_NOSNAP) {
- dout(10) << __func__ << "::from <"<< prefix_itr_snap << "> to <CEPH_NOSNAP> ::" << s << dendl;
+ dout(10) << *this << __func__ << "::from <"<< prefix_itr_snap << "> to <CEPH_NOSNAP> ::" << s << dendl;
}
else if (prefix_itr_snap == snap) {
- dout(10) << __func__ << "::with the same snapid <" << snap << "> ::" << s << dendl;
+ dout(10) << *this << __func__ << "::with the same snapid <" << snap << "> ::" << s << dendl;
}
else {
// This is unexpected!!
- dout(10) << __func__ << "::from <"<< prefix_itr_snap << "> to <" << snap << "> ::" << s << dendl;
+ dout(10) << *this << __func__ << "::from <"<< prefix_itr_snap << "> to <" << snap << "> ::" << s << dendl;
}
prefix_itr_snap = snap;
prefix_itr = prefixes.begin();
pair<string, ceph::buffer::list> next;
// access RocksDB (an expensive operation!)
int r = backend.get_next(pos, &next);
- dout(20) << __func__ << " get_next(" << pos << ") returns " << r
+ dout(20) << *this << __func__ << " get_next(" << pos << ") returns " << r
<< " " << next.first << dendl;
if (r != 0) {
return out; // Done
break; // Done with this prefix
}
- dout(20) << __func__ << " " << next.first << dendl;
+ dout(20) << *this << __func__ << " found " << next.first << dendl;
pair<snapid_t, hobject_t> next_decoded(from_raw(next));
ceph_assert(next_decoded.first == snap);
ceph_assert(check(next_decoded.second));
-
out.push_back(next_decoded.second);
+
pos = next.first;
}
if (out.size() >= max) {
- dout(20) << fmt::format("{}: reached max of: {} returning",
- __func__, out.size())
+ dout(20) << *this << fmt::format("{}: reached max of: {} returning",
+ __func__, out.size())
<< dendl;
return out;
}
snapid_t snap,
unsigned max)
{
- dout(20) << __func__ << "::snapid=" << snap << dendl;
+ dout(20) << *this << __func__ << "snapid=" << snap << dendl;
// if max would be 0, we return ENOENT and the caller would mistakenly
// trim the snaptrim queue
objs = get_objects_by_prefixes(snap, max);
if (unlikely(objs.size() > 0)) {
- derr << __func__ << "::New Clone-Objects were added to Snap " << snap
+ derr << *this << __func__ << " New Clone-Objects were added to Snap " << snap
<< " after trimming was started" << dendl;
}
reset_prefix_itr(CEPH_NOSNAP, "Trim was completed successfully");
const hobject_t &oid,
MapCacher::Transaction<std::string, ceph::buffer::list> *t)
{
- dout(20) << __func__ << " " << oid << dendl;
+ dout(20) << *this << __func__ << " " << oid << dendl;
ceph_assert(check(oid));
return _remove_oid(oid, t);
}
const hobject_t &oid,
MapCacher::Transaction<std::string, ceph::buffer::list> *t)
{
- dout(20) << __func__ << " " << oid << dendl;
+ dout(20) << *this << __func__ << " " << oid << dendl;
object_snaps out;
int r = get_snaps(oid, &out);
if (r < 0)
}
if (g_conf()->subsys.should_gather<ceph_subsys_osd, 20>()) {
for (auto& i : to_remove) {
- dout(20) << __func__ << "::rm " << i << dendl;
+ dout(20) << *this << __func__ << "::rm " << i << dendl;
}
}
backend.remove_keys(to_remove, t);
i.soid,
_t);
if (r)
- dout(20) << __func__ << " remove_oid " << i.soid << " failed with " << r << dendl;
+ dout(20) << *this << __func__ << " remove_oid " << i.soid << " failed with " << r << dendl;
// On removal tolerate missing key corruption
ceph_assert(r == 0 || r == -ENOENT);
} else if (i.is_update()) {
try {
decode(snaps, p);
} catch (...) {
- dout(20) << __func__ << " decode snaps failure on " << i << dendl;
+ dout(20) << *this << __func__ << " decode snaps failure on " << i << dendl;
snaps.clear();
}
std::set<snapid_t> _snaps(snaps.begin(), snaps.end());
class SnapMapper : public Scrub::SnapMapReaderI {
friend class MapperVerifier; // unit-test support
friend class DirectMapper; // unit-test support
+ friend std::ostream& operator<<(std::ostream &lhs, const SnapMapper &sm);
+
public:
CephContext* cct;
struct object_snaps {
WRITE_CLASS_ENCODER(SnapMapper::object_snaps)
WRITE_CLASS_ENCODER(SnapMapper::Mapping)
+inline std::ostream& operator<<(std::ostream& os, const SnapMapper& sm)
+{
+ os << fmt::format(" [pg_id:{:x}, match:{}, mask_bits:{}, "
+ "last_key_checked:{}, pool:{}, shard:{}, "
+ "shard_prefix: {}, prefixes: {}] ",
+ sm.match, sm.match, sm.mask_bits, sm.last_key_checked,
+ sm.pool, sm.shard.id, sm.shard_prefix, sm.prefixes);
+ return os;
+}
+
#endif