cls::rbd::SnapshotInfo snapshot_info{snap.id, snap.snapshot_namespace,
snap.name, snap.image_size,
- snap.timestamp};
+ snap.timestamp, snap.child_count};
encode(snapshot_info, *out);
return 0;
}
WRITE_CLASS_ENCODER(cls_rbd_parent)
struct cls_rbd_snap {
- snapid_t id;
+ snapid_t id = CEPH_NOSNAP;
string name;
- uint64_t image_size;
- uint8_t protection_status;
+ uint64_t image_size = 0;
+ uint8_t protection_status = RBD_PROTECTION_STATUS_UNPROTECTED;
cls_rbd_parent parent;
- uint64_t flags;
+ uint64_t flags = 0;
utime_t timestamp;
cls::rbd::SnapshotNamespace snapshot_namespace = {
cls::rbd::UserSnapshotNamespace{}};
+ uint32_t child_count = 0;
/// true if we have a parent
bool has_parent() const {
return parent.exists();
}
- cls_rbd_snap() : id(CEPH_NOSNAP), image_size(0),
- protection_status(RBD_PROTECTION_STATUS_UNPROTECTED),
- flags(0), timestamp(utime_t())
- {}
void encode(bufferlist& bl) const {
- ENCODE_START(6, 1, bl);
+ ENCODE_START(7, 1, bl);
encode(id, bl);
encode(name, bl);
encode(image_size, bl);
encode(flags, bl);
encode(snapshot_namespace, bl);
encode(timestamp, bl);
+ encode(child_count, bl);
ENCODE_FINISH(bl);
}
void decode(bufferlist::iterator& p) {
- DECODE_START(6, p);
+ DECODE_START(7, p);
decode(id, p);
decode(name, p);
decode(image_size, p);
if (struct_v >= 6) {
decode(timestamp, p);
}
+ if (struct_v >= 7) {
+ decode(child_count, p);
+ }
DECODE_FINISH(p);
}
void dump(Formatter *f) const {
default:
ceph_abort();
}
+ f->dump_unsigned("child_count", child_count);
}
static void generate_test_instances(list<cls_rbd_snap*>& o) {
o.push_back(new cls_rbd_snap);
t->name = "snap";
t->image_size = 123456;
t->flags = 31;
+ t->child_count = 543;
o.push_back(t);
t = new cls_rbd_snap;
t->id = 2;
encode(name, bl);
encode(image_size, bl);
encode(timestamp, bl);
+ encode(child_count, bl);
ENCODE_FINISH(bl);
}
decode(name, it);
decode(image_size, it);
decode(timestamp, it);
+ decode(child_count, it);
DECODE_FINISH(it);
}
void SnapshotInfo::generate_test_instances(std::list<SnapshotInfo*> &o) {
o.push_back(new SnapshotInfo(1ULL, UserSnapshotNamespace{}, "snap1", 123,
- {123456, 0}));
+ {123456, 0}, 12));
o.push_back(new SnapshotInfo(2ULL,
GroupSnapshotNamespace{567, "group1", "snap1"},
- "snap1", 123, {123456, 0}));
+ "snap1", 123, {123456, 0}, 987));
o.push_back(new SnapshotInfo(3ULL, TrashSnapshotNamespace{"snap1"},
- "12345", 123, {123456, 0}));
+ "12345", 123, {123456, 0}, 429));
}
void SnapshotNamespace::encode(bufferlist& bl) const {
std::string name;
uint64_t image_size = 0;
utime_t timestamp;
+ uint32_t child_count = 0;
SnapshotInfo() {
}
SnapshotInfo(snapid_t id,
const cls::rbd::SnapshotNamespace& snapshot_namespace,
const std::string& name, uint64_t image_size,
- const utime_t& timestamp)
+ const utime_t& timestamp, uint32_t child_count)
: id(id), snapshot_namespace(snapshot_namespace),
- name(name), image_size(image_size), timestamp(timestamp) {
+ name(name), image_size(image_size), timestamp(timestamp),
+ child_count(child_count) {
}
void encode(bufferlist& bl) const;
for (size_t i = 0; i < m_snapc.snaps.size(); ++i) {
m_snap_infos.push_back({m_snapc.snaps[i],
{cls::rbd::UserSnapshotNamespace{}},
- snap_names[i], snap_sizes[i], {}});
+ snap_names[i], snap_sizes[i], {}, 0});
}
send_v1_get_locks();
for (size_t i = 0; i < m_snapc.snaps.size(); ++i) {
m_snap_infos.push_back({m_snapc.snaps[i],
{cls::rbd::UserSnapshotNamespace{}},
- snap_names[i], snap_sizes[i], {}});
+ snap_names[i], snap_sizes[i], {}, 0});
}
send_v2_get_snap_timestamps();