template <typename I>
bool WriteLog<I>::initialize_pool(Context *on_finish, pwl::DeferredContexts &later) {
CephContext *cct = m_image_ctx.cct;
+ int r = -EINVAL;
TOID(struct WriteLogPoolRoot) pool_root;
ceph_assert(ceph_mutex_is_locked_by_me(m_lock));
if (access(this->m_log_pool_name.c_str(), F_OK) != 0) {
}
if (num_small_writes <= 2) {
lderr(cct) << "num_small_writes needs to > 2" << dendl;
- on_finish->complete(-EINVAL);
- return false;
+ goto err_close_pool;
}
this->m_bytes_allocated_cap = effective_pool_size;
/* Log ring empty */
this->m_total_log_entries = 0;
this->m_free_log_entries = 0;
lderr(cct) << "failed to initialize pool (" << this->m_log_pool_name << ")" << dendl;
- on_finish->complete(-pmemobj_tx_errno());
- return false;
+ r = -pmemobj_tx_errno();
+ goto err_close_pool;
} TX_FINALLY {
} TX_END;
} else {
lderr(cct) << "Pool layout version is "
<< D_RO(pool_root)->header.layout_version
<< " expected " << RWL_LAYOUT_VERSION << dendl;
- on_finish->complete(-EINVAL);
- return false;
+ goto err_close_pool;
}
if (D_RO(pool_root)->block_size != MIN_WRITE_ALLOC_SIZE) {
lderr(cct) << "Pool block size is " << D_RO(pool_root)->block_size
<< " expected " << MIN_WRITE_ALLOC_SIZE << dendl;
- on_finish->complete(-EINVAL);
- return false;
+ goto err_close_pool;
}
this->m_log_pool_size = D_RO(pool_root)->pool_size;
this->m_flushed_sync_gen = D_RO(pool_root)->flushed_sync_gen;
m_cache_state->empty = m_log_entries.empty();
}
return true;
+
+err_close_pool:
+ pmemobj_close(m_log_pool);
+ on_finish->complete(r);
+ return false;
}
/*
r = bdev->read(0, MIN_WRITE_ALLOC_SSD_SIZE, &bl, &ioctx, false);
if (r < 0) {
lderr(cct) << "Read ssd cache superblock failed " << dendl;
- goto error_handle;
+ goto err_close_bdev;
}
auto p = bl.cbegin();
decode(superblock, p);
<< pool_root.layout_version
<< " expected " << SSD_LAYOUT_VERSION
<< dendl;
- goto error_handle;
+ goto err_close_bdev;
}
if (pool_root.block_size != MIN_WRITE_ALLOC_SSD_SIZE) {
lderr(cct) << "Pool block size is " << pool_root.block_size
<< " expected " << MIN_WRITE_ALLOC_SSD_SIZE
<< dendl;
- goto error_handle;
+ goto err_close_bdev;
}
this->m_log_pool_size = pool_root.pool_size;
}
return true;
-error_handle:
+err_close_bdev:
bdev->close();
delete bdev;
on_finish->complete(-EINVAL);