mirror of
https://github.com/ceph/ceph
synced 2025-03-29 15:03:39 +00:00
Merge pull request #23941 from trociny/wip-23445
librbd: flatten operation should use object map Reviewed-by: Jason Dillaman <dillaman@redhat.com>
This commit is contained in:
commit
d43ff1caf3
@ -110,6 +110,32 @@ bool ObjectMap<I>::object_may_exist(uint64_t object_no) const
|
||||
return exists;
|
||||
}
|
||||
|
||||
template <typename I>
|
||||
bool ObjectMap<I>::object_may_not_exist(uint64_t object_no) const
|
||||
{
|
||||
ceph_assert(m_image_ctx.snap_lock.is_locked());
|
||||
|
||||
// Fall back to default logic if object map is disabled or invalid
|
||||
if (!m_image_ctx.test_features(RBD_FEATURE_OBJECT_MAP,
|
||||
m_image_ctx.snap_lock)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool flags_set;
|
||||
int r = m_image_ctx.test_flags(RBD_FLAG_OBJECT_MAP_INVALID,
|
||||
m_image_ctx.snap_lock, &flags_set);
|
||||
if (r < 0 || flags_set) {
|
||||
return true;
|
||||
}
|
||||
|
||||
RWLock::RLocker l(m_image_ctx.object_map_lock);
|
||||
uint8_t state = (*this)[object_no];
|
||||
bool nonexistent = (state != OBJECT_EXISTS && state != OBJECT_EXISTS_CLEAN);
|
||||
ldout(m_image_ctx.cct, 20) << "object_no=" << object_no << " r="
|
||||
<< nonexistent << dendl;
|
||||
return nonexistent;
|
||||
}
|
||||
|
||||
template <typename I>
|
||||
bool ObjectMap<I>::update_required(const ceph::BitVector<2>::Iterator& it,
|
||||
uint8_t new_state) {
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
void close(Context *on_finish);
|
||||
bool set_object_map(ceph::BitVector<2> &target_object_map);
|
||||
bool object_may_exist(uint64_t object_no) const;
|
||||
bool object_may_not_exist(uint64_t object_no) const;
|
||||
|
||||
void aio_save(Context *on_finish);
|
||||
void aio_resize(uint64_t new_size, uint8_t default_object_state,
|
||||
|
@ -40,6 +40,15 @@ public:
|
||||
return -ERESTART;
|
||||
}
|
||||
|
||||
{
|
||||
RWLock::RLocker snap_lock(image_ctx.snap_lock);
|
||||
if (image_ctx.object_map != nullptr &&
|
||||
!image_ctx.object_map->object_may_not_exist(m_object_no)) {
|
||||
// can skip because the object already exists
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
bufferlist bl;
|
||||
string oid = image_ctx.get_object_name(m_object_no);
|
||||
auto req = new io::ObjectWriteRequest<I>(&image_ctx, oid, m_object_no, 0,
|
||||
|
Loading…
Reference in New Issue
Block a user