]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: fix rare races with pool updates
authorSage Weil <sage@newdream.net>
Mon, 24 Oct 2011 18:41:29 +0000 (11:41 -0700)
committerSage Weil <sage@newdream.net>
Tue, 25 Oct 2011 16:53:18 +0000 (09:53 -0700)
Signed-off-by: Sage Weil <sage@newdream.net>
src/mon/OSDMonitor.cc

index c070ef24ad0920b45a4ece8d5205d27eba966f11..15186a0e0ce2d238960ffc70b7ed0458b18efda4 100644 (file)
@@ -1934,7 +1934,8 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
          unsigned n = strtol(start, &end, 10);
          if (*end == '\0') {
            if (m->cmd[4] == "size") {
-             pending_inc.new_pools[pool] = *p;
+             if (pending_inc.new_pools.count(pool) == 0)
+               pending_inc.new_pools[pool] = *p;
              pending_inc.new_pools[pool].size = n;
              pending_inc.new_pools[pool].last_change = pending_inc.epoch;
              ss << "set pool " << pool << " size to " << n;
@@ -1956,7 +1957,8 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
                ss << "currently creating pgs, wait";
                err = -EAGAIN;
              } else {
-               pending_inc.new_pools[pool] = osdmap.pools[pool];
+               if (pending_inc.new_pools.count(pool) == 0)
+                 pending_inc.new_pools[pool] = *p;
                pending_inc.new_pools[pool].pg_num = n;
                pending_inc.new_pools[pool].last_change = pending_inc.epoch;
                ss << "set pool " << pool << " pg_num to " << n;
@@ -1973,7 +1975,8 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
                ss << "still creating pgs, wait";
                err = -EAGAIN;
              } else {
-               pending_inc.new_pools[pool] = osdmap.pools[pool];
+               if (pending_inc.new_pools.count(pool) == 0)
+                 pending_inc.new_pools[pool] = *p;
                pending_inc.new_pools[pool].pgp_num = n;
                pending_inc.new_pools[pool].last_change = pending_inc.epoch;
                ss << "set pool " << pool << " pgp_num to " << n;
@@ -1983,7 +1986,8 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
              }
            } else if (m->cmd[4] == "crush_ruleset") {
              if (osdmap.crush.rule_exists(n)) {
-               pending_inc.new_pools[pool] = osdmap.pools[pool];
+               if (pending_inc.new_pools.count(pool) == 0)
+                 pending_inc.new_pools[pool] = *p;
                pending_inc.new_pools[pool].crush_ruleset = n;
                pending_inc.new_pools[pool].last_change = pending_inc.epoch;
                ss << "set pool " << pool << " crush_ruleset to " << n;