return;
}
- initialize_pool(on_finish, later);
+ bool succeeded = initialize_pool(on_finish, later);
+ if (!succeeded) {
+ return ;
+ }
ldout(cct,1) << "pool " << m_log_pool_name << " has " << m_total_log_entries
<< " log entries, " << m_free_log_entries << " of which are free."
virtual void append_scheduled_ops(void) = 0;
virtual void schedule_append_ops(pwl::GenericLogOperations &ops, C_BlockIORequestT *req) = 0;
virtual void remove_pool_file() = 0;
- virtual void initialize_pool(Context *on_finish,
+ virtual bool initialize_pool(Context *on_finish,
pwl::DeferredContexts &later) = 0;
virtual void collect_read_extents(
uint64_t read_buffer_offset, LogMapEntry<GenericWriteLogEntry> map_entry,
ldout(cct, 10) << dendl;
using klass = InitRequest<I>;
- Context *ctx = create_context_callback<
- klass, &klass::handle_init_image_cache>(this);
+ Context *ctx = create_async_context_callback(m_image_ctx,
+ create_context_callback<klass, &klass::handle_init_image_cache>(this));
m_image_cache->init(ctx);
}
}
template <typename I>
-void WriteLog<I>::initialize_pool(Context *on_finish, pwl::DeferredContexts &later) {
+bool WriteLog<I>::initialize_pool(Context *on_finish, pwl::DeferredContexts &later) {
CephContext *cct = m_image_ctx.cct;
TOID(struct WriteLogPoolRoot) pool_root;
ceph_assert(ceph_mutex_is_locked_by_me(m_lock));
m_cache_state->empty = true;
/* TODO: filter/replace errnos that are meaningless to the caller */
on_finish->complete(-errno);
- return;
+ return false;
}
m_cache_state->present = true;
m_cache_state->clean = true;
if (num_small_writes <= 2) {
lderr(cct) << "num_small_writes needs to > 2" << dendl;
on_finish->complete(-EINVAL);
- return;
+ return false;
}
this->m_bytes_allocated_cap = effective_pool_size;
/* Log ring empty */
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;
+ return false;
} TX_FINALLY {
} TX_END;
} else {
lderr(cct) << "failed to open pool (" << this->m_log_pool_name << "): "
<< pmemobj_errormsg() << dendl;
on_finish->complete(-errno);
- return;
+ return false;
}
pool_root = POBJ_ROOT(m_log_pool, struct WriteLogPoolRoot);
if (D_RO(pool_root)->header.layout_version != RWL_POOL_VERSION) {
<< D_RO(pool_root)->header.layout_version
<< " expected " << RWL_POOL_VERSION << dendl;
on_finish->complete(-EINVAL);
- return;
+ return false;
}
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;
+ return false;
}
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->clean = this->m_dirty_log_entries.empty();
m_cache_state->empty = m_log_entries.empty();
}
+ return true;
}
/*
C_BlockIORequestT *req) override;
Context *construct_flush_entry_ctx(
const std::shared_ptr<pwl::GenericLogEntry> log_entry) override;
- void initialize_pool(Context *on_finish, pwl::DeferredContexts &later) override;
+ bool initialize_pool(Context *on_finish, pwl::DeferredContexts &later) override;
void write_data_to_buffer(
std::shared_ptr<pwl::WriteLogEntry> ws_entry,
pwl::WriteLogCacheEntry *pmem_entry) override;
}
template <typename I>
-int WriteLog<I>::create_and_open_bdev() {
+bool WriteLog<I>::initialize_pool(Context *on_finish,
+ pwl::DeferredContexts &later) {
CephContext *cct = m_image_ctx.cct;
bdev = BlockDevice::create(cct, this->m_log_pool_name, aio_cache_cb,
m_cache_state->empty = true;
/* TODO: filter/replace errnos that are meaningless to the caller */
on_finish->complete(-errno);
- return;
+ return false;
}
r = create_and_open_bdev();
m_cache_state->clean = this->m_dirty_log_entries.empty();
m_cache_state->empty = m_log_entries.empty();
}
+ return true;
}
template <typename I>
using AbstractWriteLog<ImageCtxT>::m_first_valid_entry;
using AbstractWriteLog<ImageCtxT>::m_bytes_allocated;
- void initialize_pool(Context *on_finish,
+ bool initialize_pool(Context *on_finish,
pwl::DeferredContexts &later) override;
void process_work() override;
void append_scheduled_ops(void) override;