From: Xiaoxi Chen Date: Wed, 15 Apr 2015 16:10:08 +0000 (+0800) Subject: os/Newstore: Check onode.omap_head in valid() and next() X-Git-Tag: v9.1.0~242^2~64 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=65877832f8d8d542a179c184937d1dc28a059475;p=ceph.git os/Newstore: Check onode.omap_head in valid() and next() 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 --- diff --git a/src/os/newstore/NewStore.cc b/src/os/newstore/NewStore.cc index ba8c72b1525..45827746773 100644 --- a/src/os/newstore/NewStore.cc +++ b/src/os/newstore/NewStore.cc @@ -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()