mirror of
https://github.com/ceph/ceph
synced 2025-02-24 11:37:37 +00:00
librbd/cache/pwl/rwl: add pmemobj_close() during error handle
After create/open pmem device, add pmemobj_close() during error handle. Merge the same error handle to the end of function. Signed-off-by: Yin Congmin <congmin.yin@intel.com>
This commit is contained in:
parent
3407262de6
commit
265cedbf36
19
src/librbd/cache/pwl/rwl/WriteLog.cc
vendored
19
src/librbd/cache/pwl/rwl/WriteLog.cc
vendored
@ -261,6 +261,7 @@ void WriteLog<I>::remove_pool_file() {
|
||||
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) {
|
||||
@ -292,8 +293,7 @@ bool WriteLog<I>::initialize_pool(Context *on_finish, pwl::DeferredContexts &lat
|
||||
}
|
||||
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 */
|
||||
@ -318,8 +318,8 @@ bool WriteLog<I>::initialize_pool(Context *on_finish, pwl::DeferredContexts &lat
|
||||
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 {
|
||||
@ -339,14 +339,12 @@ bool WriteLog<I>::initialize_pool(Context *on_finish, pwl::DeferredContexts &lat
|
||||
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;
|
||||
@ -371,6 +369,11 @@ bool WriteLog<I>::initialize_pool(Context *on_finish, pwl::DeferredContexts &lat
|
||||
m_cache_state->empty = m_log_entries.empty();
|
||||
}
|
||||
return true;
|
||||
|
||||
err_close_pool:
|
||||
pmemobj_close(m_log_pool);
|
||||
on_finish->complete(r);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
|
8
src/librbd/cache/pwl/ssd/WriteLog.cc
vendored
8
src/librbd/cache/pwl/ssd/WriteLog.cc
vendored
@ -210,7 +210,7 @@ bool WriteLog<I>::initialize_pool(Context *on_finish,
|
||||
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);
|
||||
@ -226,13 +226,13 @@ bool WriteLog<I>::initialize_pool(Context *on_finish,
|
||||
<< 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;
|
||||
@ -249,7 +249,7 @@ bool WriteLog<I>::initialize_pool(Context *on_finish,
|
||||
}
|
||||
return true;
|
||||
|
||||
error_handle:
|
||||
err_close_bdev:
|
||||
bdev->close();
|
||||
delete bdev;
|
||||
on_finish->complete(-EINVAL);
|
||||
|
Loading…
Reference in New Issue
Block a user