]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: add object state accessor to ObjectMap
authorJason Dillaman <dillaman@redhat.com>
Fri, 17 Jul 2015 19:04:10 +0000 (15:04 -0400)
committerJason Dillaman <dillaman@redhat.com>
Tue, 28 Jul 2015 20:35:20 +0000 (16:35 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/ObjectMap.cc
src/librbd/ObjectMap.h

index 9da30cc2e08521be5ec3804e271a0e6ef41a772c..3505041d6775364a15ff4d2838119a3ddaa37b2d 100644 (file)
@@ -33,6 +33,13 @@ std::string ObjectMap::object_map_name(const std::string &image_id,
   return oid;
 }
 
+uint8_t ObjectMap::operator[](uint64_t object_no) const
+{
+  assert(m_image_ctx.object_map_lock.is_locked());
+  assert(object_no < m_object_map.size());
+  return m_object_map[object_no];
+}
+
 bool ObjectMap::enabled() const
 {
   RWLock::RLocker l(m_image_ctx.object_map_lock);
@@ -137,8 +144,8 @@ bool ObjectMap::object_may_exist(uint64_t object_no) const
   }
   assert(object_no < m_object_map.size());
 
-  bool exists = (m_object_map[object_no] == OBJECT_EXISTS ||
-                m_object_map[object_no] == OBJECT_PENDING);
+  uint8_t state = (*this)[object_no];
+  bool exists = (state == OBJECT_EXISTS || state == OBJECT_PENDING);
   ldout(m_image_ctx.cct, 20) << &m_image_ctx << " object_may_exist: "
                             << "object_no=" << object_no << " r=" << exists
                             << dendl;
index 20eb304a73b86066de68eac74fa6d4f8acf07a92..2192f8421c98065263c8f0c0a51bba61c788acec 100644 (file)
@@ -24,6 +24,8 @@ public:
   static std::string object_map_name(const std::string &image_id,
                                     uint64_t snap_id);
 
+  uint8_t operator[](uint64_t object_no) const;
+
   int lock();
   int unlock();