mirror of
https://github.com/ceph/ceph
synced 2025-03-25 11:48:05 +00:00
librbd: invalidating snapshot object maps should set snapshot flag
Instead of setting the HEAD image flag to indicate an invalid object map, set the flag for the specific snapshot that is invalid. Signed-off-by: Jason Dillaman <dillaman@redhat.com>
This commit is contained in:
parent
ba4bb22bc1
commit
ba77bda554
@ -494,6 +494,28 @@ namespace librbd {
|
||||
return ((snap_flags & test_flags) == test_flags);
|
||||
}
|
||||
|
||||
int ImageCtx::update_flags(snap_t in_snap_id, uint64_t flag, bool enabled)
|
||||
{
|
||||
assert(snap_lock.is_wlocked());
|
||||
uint64_t *_flags;
|
||||
if (in_snap_id == CEPH_NOSNAP) {
|
||||
_flags = &flags;
|
||||
} else {
|
||||
map<snap_t, SnapInfo>::iterator it = snap_info.find(in_snap_id);
|
||||
if (it == snap_info.end()) {
|
||||
return -ENOENT;
|
||||
}
|
||||
_flags = &it->second.flags;
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
(*_flags) |= flag;
|
||||
} else {
|
||||
(*_flags) &= ~flag;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const parent_info* ImageCtx::get_parent_info(snap_t in_snap_id) const
|
||||
{
|
||||
assert(snap_lock.is_locked());
|
||||
|
@ -174,6 +174,7 @@ namespace librbd {
|
||||
bool test_features(uint64_t test_features) const;
|
||||
int get_flags(librados::snap_t in_snap_id, uint64_t *flags) const;
|
||||
bool test_flags(uint64_t test_flags) const;
|
||||
int update_flags(librados::snap_t in_snap_id, uint64_t flag, bool enabled);
|
||||
|
||||
const parent_info* get_parent_info(librados::snap_t in_snap_id) const;
|
||||
int64_t get_parent_pool_id(librados::snap_t in_snap_id) const;
|
||||
|
@ -335,10 +335,12 @@ void ObjectMap::invalidate() {
|
||||
|
||||
CephContext *cct = m_image_ctx.cct;
|
||||
lderr(cct) << &m_image_ctx << " invalidating object map" << dendl;
|
||||
m_image_ctx.flags |= RBD_FLAG_OBJECT_MAP_INVALID;
|
||||
m_image_ctx.update_flags(m_image_ctx.snap_id, RBD_FLAG_OBJECT_MAP_INVALID,
|
||||
true);
|
||||
|
||||
librados::ObjectWriteOperation op;
|
||||
cls_client::set_flags(&op, m_image_ctx.flags, RBD_FLAG_OBJECT_MAP_INVALID);
|
||||
cls_client::set_flags(&op, m_image_ctx.snap_id, m_image_ctx.flags,
|
||||
RBD_FLAG_OBJECT_MAP_INVALID);
|
||||
|
||||
int r = m_image_ctx.md_ctx.operate(m_image_ctx.header_oid, &op);
|
||||
if (r < 0) {
|
||||
@ -393,12 +395,16 @@ bool ObjectMap::Request::invalidate() {
|
||||
CephContext *cct = m_image_ctx.cct;
|
||||
RWLock::WLocker snap_locker(m_image_ctx.snap_lock);
|
||||
|
||||
// requests shouldn't be running while using snapshots
|
||||
assert(m_image_ctx.snap_id == CEPH_NOSNAP);
|
||||
|
||||
lderr(cct) << &m_image_ctx << " invalidating object map" << dendl;
|
||||
m_state = STATE_INVALIDATE;
|
||||
m_image_ctx.flags |= RBD_FLAG_OBJECT_MAP_INVALID;
|
||||
|
||||
librados::ObjectWriteOperation op;
|
||||
cls_client::set_flags(&op, m_image_ctx.flags, RBD_FLAG_OBJECT_MAP_INVALID);
|
||||
cls_client::set_flags(&op, CEPH_NOSNAP, m_image_ctx.flags,
|
||||
RBD_FLAG_OBJECT_MAP_INVALID);
|
||||
|
||||
librados::AioCompletion *rados_completion = create_callback_completion();
|
||||
int r = m_image_ctx.md_ctx.aio_operate(m_image_ctx.header_oid,
|
||||
|
Loading…
Reference in New Issue
Block a user