]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: add is_unmanaged_snaps_mode() to pg_pool_t; use more consistently
authorGreg Farnum <gregory.farnum@dreamhost.com>
Wed, 25 Apr 2012 20:07:42 +0000 (13:07 -0700)
committerSage Weil <sage@newdream.net>
Tue, 1 May 2012 00:24:35 +0000 (17:24 -0700)
Create an is_unmanaged_snaps_mode() function to parallel
is_pool_snaps_mode(), and replace all the checks directly referencing
removed_snaps or snaps with calls to these functions.
Fixes #2345.

Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
src/mon/OSDMonitor.cc
src/osd/osd_types.cc
src/osd/osd_types.h

index d7ea76585f35b88dcfb129846f3920b9e11bd889..c7f1564d98d039e8a5e0016da15a5119717f12cc 100644 (file)
@@ -2466,7 +2466,7 @@ bool OSDMonitor::prepare_pool_op(MPoolOp *m)
   switch (m->op) {
   case POOL_OP_CREATE_SNAP:
   case POOL_OP_DELETE_SNAP:
-    if (!pp.removed_snaps.empty()) {
+    if (pp.is_unmanaged_snaps_mode()) {
       ret = -EINVAL;
       goto out;
     }
@@ -2474,7 +2474,7 @@ bool OSDMonitor::prepare_pool_op(MPoolOp *m)
 
   case POOL_OP_CREATE_UNMANAGED_SNAP:
   case POOL_OP_DELETE_UNMANAGED_SNAP:
-    if (!pp.snaps.empty()) {
+    if (pp.is_pool_snaps_mode()) {
       ret = -EINVAL;
       goto out;
     }
index b9bc50c8cf4db8afe457cb043b2944828849c0c6..7c019a0af95059720327387e7e948c62fb1040ea 100644 (file)
@@ -504,6 +504,11 @@ bool pg_pool_t::is_pool_snaps_mode() const
   return removed_snaps.empty() && get_snap_seq() > 0;
 }
 
+bool pg_pool_t::is_unmanaged_snaps_mode() const
+{
+  return removed_snaps.size() && get_snap_seq() > 0;
+}
+
 bool pg_pool_t::is_removed_snap(snapid_t s) const
 {
   if (is_pool_snaps_mode())
@@ -540,7 +545,7 @@ snapid_t pg_pool_t::snap_exists(const char *s) const
 
 void pg_pool_t::add_snap(const char *n, utime_t stamp)
 {
-  assert(removed_snaps.empty());
+  assert(!is_unmanaged_snaps_mode());
   snapid_t s = get_snap_seq() + 1;
   snap_seq = s;
   snaps[s].snapid = s;
@@ -551,7 +556,7 @@ void pg_pool_t::add_snap(const char *n, utime_t stamp)
 void pg_pool_t::add_unmanaged_snap(uint64_t& snapid)
 {
   if (removed_snaps.empty()) {
-    assert(snaps.empty());
+    assert(!is_pool_snaps_mode());
     removed_snaps.insert(snapid_t(1));
     snap_seq = 1;
   }
@@ -567,7 +572,7 @@ void pg_pool_t::remove_snap(snapid_t s)
 
 void pg_pool_t::remove_unmanaged_snap(snapid_t s)
 {
-  assert(snaps.empty());
+  assert(is_unmanaged_snaps_mode());
   removed_snaps.insert(s);
   snap_seq = snap_seq + 1;
   removed_snaps.insert(get_snap_seq());
index 493219cb9f650341ae29b8ec9d0b9e4197171b70..d85ecb314bf0125c3ea7bf353b7c8dd5e031edc1 100644 (file)
@@ -667,8 +667,10 @@ struct pg_pool_t {
    *    - removal governed by removed_snaps
    *
    * we know which mode we're using based on whether removed_snaps is empty.
+   * If nothing has been created, both functions report false.
    */
   bool is_pool_snaps_mode() const;
+  bool is_unmanaged_snaps_mode() const;
   bool is_removed_snap(snapid_t s) const;
 
   /*