From: xie xingguo Date: Wed, 2 Mar 2016 16:38:36 +0000 (+0800) Subject: mon: OSDMonitor: add a guard for prepare_remove_snaps() X-Git-Tag: v11.0.0~850^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=be07a418b50cc56f02914bc63c82a2e881910803;p=ceph.git mon: OSDMonitor: add a guard for prepare_remove_snaps() Method preprocess_remove_snaps() is designed to fast check whether we can safely handle a remove-snaps-request without changing the osdmap. The original design is to be able to handle snaps from multiple pools, including those snaps even from a non-existent pool by simply skipping over them. However, this method will quit on successfully detecting any vaild snap which is truly needed to be removed and forward this request to prepare_remove_snaps() for further processing. From the above analysis, the prepare_remove_snaps() method will theoretically also encounter some snaps which possibly belong to non-existent pools. This pr solves the above problem by adding a sanity check against pool existense associated with the specified snap to be removed, which shall be considered as a defensive move and makes prepare_remove_snaps() stronger. Signed-off-by: xie xingguo --- diff --git a/qa/workunits/cephtool/test.sh b/qa/workunits/cephtool/test.sh index 1d70ba9e4813..05f7f0b5f660 100755 --- a/qa/workunits/cephtool/test.sh +++ b/qa/workunits/cephtool/test.sh @@ -1235,6 +1235,7 @@ function test_mon_osd_pool() ceph osd pool mksnap data datasnap rados -p data lssnap | grep datasnap ceph osd pool rmsnap data datasnap + expect_false ceph osd pool rmsnap pool_fake snapshot ceph osd pool delete data data --yes-i-really-really-mean-it ceph osd pool create data2 10 diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 1ef1670293b1..2f3e02f07728 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -2414,6 +2414,12 @@ bool OSDMonitor::prepare_remove_snaps(MonOpRequestRef op) for (map >::iterator p = m->snaps.begin(); p != m->snaps.end(); ++p) { + + if (!osdmap.have_pg_pool(p->first)) { + dout(10) << " ignoring removed_snaps " << p->second << " on non-existent pool " << p->first << dendl; + continue; + } + pg_pool_t& pi = osdmap.pools[p->first]; for (vector::iterator q = p->second.begin(); q != p->second.end();