Skip to content

Commit 23cd20e

Browse files
committed
librbd: assert on parent in ImageCtx destructor
... and switch to in-class initializers while at it. Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 409d36c commit 23cd20e

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

src/librbd/ImageCtx.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ librados::IoCtx duplicate_io_ctx(librados::IoCtx& io_ctx) {
112112
old_format(false),
113113
order(0), size(0), features(0),
114114
format_string(NULL),
115-
id(image_id), parent(NULL),
115+
id(image_id),
116116
stripe_unit(0), stripe_count(0), flags(0),
117117
readahead(),
118118
total_bytes_read(0),
@@ -157,6 +157,7 @@ librados::IoCtx duplicate_io_ctx(librados::IoCtx& io_ctx) {
157157
ImageCtx::~ImageCtx() {
158158
ldout(cct, 10) << this << " " << __func__ << dendl;
159159

160+
ceph_assert(parent == nullptr);
160161
ceph_assert(config_watcher == nullptr);
161162
ceph_assert(image_watcher == NULL);
162163
ceph_assert(exclusive_lock == NULL);

src/librbd/ImageCtx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ namespace librbd {
163163
std::string header_oid;
164164
std::string id; // only used for new-format images
165165
ParentImageInfo parent_md;
166-
ImageCtx *parent;
166+
ImageCtx *parent = nullptr;
167167
ImageCtx *child = nullptr;
168168
MigrationInfo migration_info;
169169
cls::rbd::GroupSpec group_spec;

src/librbd/image/RefreshParentRequest.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ RefreshParentRequest<I>::RefreshParentRequest(
2828
const MigrationInfo &migration_info, Context *on_finish)
2929
: m_child_image_ctx(child_image_ctx), m_parent_md(parent_md),
3030
m_migration_info(migration_info), m_on_finish(on_finish),
31-
m_parent_image_ctx(nullptr), m_parent_snap_id(CEPH_NOSNAP),
32-
m_error_result(0) {
31+
m_parent_snap_id(CEPH_NOSNAP), m_error_result(0) {
3332
}
3433

3534
template <typename I>

src/librbd/image/RefreshParentRequest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class RefreshParentRequest {
6767
MigrationInfo m_migration_info;
6868
Context *m_on_finish;
6969

70-
ImageCtxT *m_parent_image_ctx;
70+
ImageCtxT *m_parent_image_ctx = nullptr;
7171
uint64_t m_parent_snap_id;
7272

7373
int m_error_result;

0 commit comments

Comments
 (0)