]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: add 'mds compat rm_* id' commands to adjust mdsmap compat set
authorSage Weil <sage@newdream.net>
Fri, 6 Aug 2010 16:56:34 +0000 (09:56 -0700)
committerSage Weil <sage@newdream.net>
Fri, 6 Aug 2010 16:56:34 +0000 (09:56 -0700)
This'll be helpful if someone inadvertantly starts up a new cmds, the
compat set updates, and then they can't start old cmds instances.

Of course, that will only work if the new cmds didn't write any new format
metadata!

src/include/CompatSet.h
src/mon/MDSMonitor.cc

index 050853cdb4f182f7d6231f6c22c61d52b5718d88..a7cb8f6f2dbf33fc24489585ed4a4a1ef00a5b83 100644 (file)
@@ -39,6 +39,16 @@ struct CompatSet {
       names[f.id] = f.name;
     }
 
+    bool contains(uint64_t f) const {
+      return names.count(f);
+    }
+    void remove(uint64_t f) {
+      if (names.count(f)) {
+       names.erase(f);
+       mask &= ~f;
+      }
+    }      
+
     void encode(bufferlist& bl) const {
       ::encode(mask, bl);
       ::encode(names, bl);
index 549a5a523743172ba09f57546e326f1c4c8cd9da..1abfc0d739259a9924cf41b952de709f926a8555 100644 (file)
@@ -517,6 +517,20 @@ bool MDSMonitor::preprocess_command(MMonCommand *m)
        } else ss << "specify mds number or *";
       }
     }
+    else if (m->cmd[1] == "compat") {
+      if (m->cmd.size() >= 3) {
+       if (m->cmd[2] == "show") {
+         ss << mdsmap.compat;
+         r = 0;
+       } else if (m->cmd[2] == "help") {
+         ss << "mds compat <rm_compat|rm_ro_compat|rm_incompat> <id>";
+         r = 0;
+       }
+      } else {
+       ss << "mds compat <rm_compat|rm_ro_compat|rm_incompat> <id>";
+       r = 0;
+      }
+    }
   }
 
   if (r != -1) {
@@ -583,6 +597,28 @@ bool MDSMonitor::prepare_command(MMonCommand *m)
        return true;
       }
     }
+    else if (m->cmd[1] == "compat" && m->cmd.size() == 4) {
+      uint64_t f = atoll(m->cmd[3].c_str());
+      if (m->cmd[2] == "rm_compat") {
+       if (pending_mdsmap.compat.compat.contains(f)) {
+         ss << "removing compat feature " << f;
+         pending_mdsmap.compat.compat.remove(f);
+         r = 0;
+       } else {
+         ss << "compat feature " << f << " not present in " << pending_mdsmap.compat;
+         r = -ENOENT;
+       }
+      } else if (m->cmd[2] == "rm_incompat") {
+       if (pending_mdsmap.compat.incompat.contains(f)) {
+         ss << "removing incompat feature " << f;
+         pending_mdsmap.compat.incompat.remove(f);
+         r = 0;
+       } else {
+         ss << "incompat feature " << f << " not present in " << pending_mdsmap.compat;
+         r = -ENOENT;
+       }
+      }
+    }
   }
   if (r == -EINVAL) 
     ss << "unrecognized command";