int ImageCtx::get_flags(librados::snap_t _snap_id, uint64_t *_flags) const
{
+ assert(snap_lock.is_locked());
if (_snap_id == CEPH_NOSNAP) {
*_flags = flags;
return 0;
return -ENOENT;
}
+ bool ImageCtx::test_flags(uint64_t test_flags) const
+ {
+ RWLock::RLocker l(snap_lock);
+ uint64_t snap_flags;
+ get_flags(snap_id, &snap_flags);
+ return ((snap_flags & test_flags) == test_flags);
+ }
+
const parent_info* ImageCtx::get_parent_info(snap_t in_snap_id) const
{
assert(snap_lock.is_locked());
// isn't guarded by other locks below
// (size, features, image locks, etc)
Mutex cache_lock; // used as client_lock for the ObjectCacher
- RWLock snap_lock; // protects snapshot-related member variables and features
+ RWLock snap_lock; // protects snapshot-related member variables, features, and flags
RWLock parent_lock; // protects parent_md and parent
Mutex refresh_lock; // protects refresh_seq and last_refresh
RWLock object_map_lock; // protects object map updates
uint64_t *out_features) const;
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;
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;
std::string get_parent_image_id(librados::snap_t in_snap_id) const;
{
// 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.flags & RBD_FLAG_OBJECT_MAP_INVALID) != 0)) {
+ m_image_ctx.test_flags(RBD_FLAG_OBJECT_MAP_INVALID)) {
return true;
}
}
void ObjectMap::invalidate() {
- if ((m_image_ctx.flags & RBD_FLAG_OBJECT_MAP_INVALID) != 0) {
+ assert(m_image_ctx.snap_lock.is_wlocked());
+ uint64_t flags;
+ m_image_ctx.get_flags(m_image_ctx.snap_id, &flags);
+ if ((flags & RBD_FLAG_OBJECT_MAP_INVALID) != 0) {
return;
}
}
bool ObjectMap::Request::invalidate() {
- if ((m_image_ctx.flags & RBD_FLAG_OBJECT_MAP_INVALID) != 0) {
+ if (m_image_ctx.test_flags(RBD_FLAG_OBJECT_MAP_INVALID)) {
return true;
}
CephContext *cct = m_image_ctx.cct;
- RWLock::WLocker l(m_image_ctx.md_lock);
+ RWLock::WLocker snap_locker(m_image_ctx.snap_lock);
lderr(cct) << &m_image_ctx << " invalidating object map" << dendl;
m_state = STATE_INVALIDATE;
}
{
- RWLock::RLocker l(ictx->md_lock);
+ RWLock::WLocker l(ictx->snap_lock);
if (ictx->object_map != NULL) {
ictx->object_map->rollback(snap_id);
}