]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/Newstore: Check onode.omap_head in valid() and next()
authorXiaoxi Chen <xiaoxi.chen@intel.com>
Wed, 15 Apr 2015 16:10:08 +0000 (00:10 +0800)
committerSage Weil <sage@redhat.com>
Tue, 1 Sep 2015 17:39:38 +0000 (13:39 -0400)
The db iter will be set to KeyValueDB::Iterator() if onode.omap_head
not present. In that case if we touch the db iter we will get a segmentation
fault.

Prevent to touch the db iter when onode.omap_head is invalid(equals to 0).

Signed-off-by: Xiaoxi Chen <xiaoxi.chen@intel.com>
src/os/newstore/NewStore.cc

index ba8c72b1525be1779cf8f9681f5c9243075ed3e6..4582774677326e493c74f8ad2ea24ad157d7efa0 100644 (file)
@@ -1541,7 +1541,7 @@ int NewStore::OmapIteratorImpl::lower_bound(const string& to)
 bool NewStore::OmapIteratorImpl::valid()
 {
   RWLock::RLocker l(c->lock);
-  if (it->valid() && it->raw_key().second <= tail) {
+  if (o->onode.omap_head && it->valid() && it->raw_key().second <= tail) {
     return true;
   } else {
     return false;
@@ -1551,8 +1551,12 @@ bool NewStore::OmapIteratorImpl::valid()
 int NewStore::OmapIteratorImpl::next()
 {
   RWLock::RLocker l(c->lock);
-  it->next();
-  return 0;
+  if (o->onode.omap_head) {
+    it->next();
+    return 0;
+  } else {
+    return -1;
+  }
 }
 
 string NewStore::OmapIteratorImpl::key()