]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: record osd metadata key/value info
authorSage Weil <sage@inktank.com>
Sat, 9 Nov 2013 14:05:59 +0000 (06:05 -0800)
committerSage Weil <sage@inktank.com>
Sat, 9 Nov 2013 14:10:14 +0000 (06:10 -0800)
Shove what the OSD gives us on boot into the store.

Signed-off-by: Sage Weil <sage@inktank.com>
src/mon/OSDMonitor.cc
src/mon/OSDMonitor.h

index 2c17cca85b7eb012848621e7b8ee31d71fd32444..1967660bd1fe1f8abfe2f99023012a63d728f35d 100644 (file)
@@ -591,6 +591,18 @@ void OSDMonitor::encode_pending(MonitorDBStore::Transaction *t)
   /* put everything in the transaction */
   put_version(t, pending_inc.epoch, bl);
   put_last_committed(t, pending_inc.epoch);
+
+  // metadata, too!
+  for (map<int,bufferlist>::iterator p = pending_metadata.begin();
+       p != pending_metadata.end();
+       ++p)
+    t->put(OSD_METADATA_PREFIX, stringify(p->first), p->second);
+  for (set<int>::iterator p = pending_metadata_rm.begin();
+       p != pending_metadata_rm.end();
+       ++p)
+    t->erase(OSD_METADATA_PREFIX, stringify(*p));
+  pending_metadata.clear();
+  pending_metadata_rm.clear();
 }
 
 void OSDMonitor::share_map_with_random_osd()
@@ -1266,6 +1278,11 @@ bool OSDMonitor::prepare_boot(MOSDBoot *m)
       }
     }
 
+    // metadata
+    bufferlist osd_metadata;
+    ::encode(m->metadata, osd_metadata);
+    pending_metadata[from] = osd_metadata;
+
     // adjust last clean unmount epoch?
     const osd_info_t& info = osdmap.get_info(from);
     dout(10) << " old osd_info: " << info << dendl;
@@ -3500,6 +3517,7 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
        } else {
          pending_inc.new_state[osd] = osdmap.get_state(osd);
           pending_inc.new_uuid[osd] = uuid_d();
+         pending_metadata_rm.insert(osd);
          if (any) {
            ss << ", osd." << osd;
           } else {
index 25a2061a8eb8fc4502961028249145289bb8ad9e..7ea9dc3f804cf08bc191ffc44753b008011a7e70 100644 (file)
@@ -37,6 +37,8 @@ class Monitor;
 #include "messages/MOSDFailure.h"
 #include "messages/MPoolOp.h"
 
+#define OSD_METADATA_PREFIX "osd_metadata"
+
 /// information about a particular peer's failure reports for one osd
 struct failure_reporter_t {
   int num_reports;          ///< reports from this reporter
@@ -120,6 +122,8 @@ public:
 private:
   // [leader]
   OSDMap::Incremental pending_inc;
+  map<int, bufferlist> pending_metadata;
+  set<int>             pending_metadata_rm;
   map<int, failure_info_t> failure_info;
   map<int,utime_t>    down_pending_out;  // osd down -> out