out[i] = rawout[i];
}
+
+ void adjust_osd_weights(map<int,double> &weights) {
+ float max = 0;
+ for (map<int,double>::iterator p = weights.begin(); p != weights.end(); p++)
+ if (p->second > max)
+ max = p->second;
+
+ for (map<int,double>::iterator p = weights.begin(); p != weights.end(); p++) {
+ unsigned w = 0x10000 - (p->second / max * 0x10000);
+ set_offload(p->first, w);
+ }
+ }
+
+
+
int read_from_file(const char *fn) {
bufferlist bl;
int r = bl.read_file(fn);
bool OSDMonitor::should_propose(double& delay)
{
dout(10) << "should_propose" << dendl;
- if (osdmap.epoch == 1) {
- if (pending_inc.new_up.size() == (unsigned)osdmap.get_max_osd()) {
- delay = 0.0;
- if (g_conf.osd_auto_weight) {
- CrushWrapper crush;
- OSDMap::build_simple_crush_map(crush, osdmap.get_max_osd(), osd_weight);
- crush.encode(pending_inc.crush);
- }
- return true;
- } else
- return false;
+
+ // adjust osd weights?
+ if (osd_weight.size() == (unsigned)osdmap.get_max_osd()) {
+ dout(0) << " adjusting crush osd weights based on " << osd_weight << dendl;
+ bufferlist bl;
+ osdmap.crush.encode(bl);
+ CrushWrapper crush;
+ bufferlist::iterator p = bl.begin();
+ crush.decode(p);
+ crush.adjust_osd_weights(osd_weight);
+ crush.encode(pending_inc.crush);
+ delay = 0.0;
+ osd_weight.clear();
+ return true;
}
+
return PaxosService::should_propose(delay);
}
// mark in?
pending_inc.new_offload[from] = CEPH_OSD_IN;
-
- osd_weight[from] = m->sb.weight;
+
+ if (m->sb.weight)
+ osd_weight[from] = m->sb.weight;
// wait
paxos->wait_for_commit(new C_Booted(this, m));
int OSD::mkfs(const char *dev, ceph_fsid fsid, int whoami)
{
ObjectStore *store = create_object_store(dev);
+ if (!store)
+ return -ENOENT;
int err = store->mkfs();
if (err < 0) return err;
err = store->mount();
bufferptr bp(1048576);
bp.zero();
bl.push_back(bp);
+ cout << "testing disk bandwidth..." << std::endl;
utime_t start = g_clock.now();
for (int i=0; i<1000; i++)
store->write(0, pobject_t(0, 0, object_t(999,i)), 0, bl.length(), bl, 0);
pg_num = pgp_num = num_osd << pg_bits;
// crush map
- map<int,double> weights;
- build_simple_crush_map(crush, num_osd, weights);
+ build_simple_crush_map(crush, num_osd);
for (int i=0; i<num_osd; i++) {
set_state(i, CEPH_OSD_EXISTS|CEPH_OSD_CLEAN);
}
}
-void OSDMap::build_simple_crush_map(CrushWrapper& crush, int num_osd, map<int,double>& weights)
+void OSDMap::build_simple_crush_map(CrushWrapper& crush, int num_osd)
{
// new
crush.create();
dout(20) << "crush max_devices " << crush.crush->max_devices << dendl;
}
+
if (inc.fullmap.length())
return;
- if (inc.crush.length()) {
- bufferlist::iterator blp = inc.crush.begin();
- crush.decode(blp);
- }
-
// nope, incremental.
if (inc.new_flags >= 0)
flags = inc.new_flags;
i != inc.old_pg_swap_primary.end();
i++)
pg_swap_primary.erase(*i);
+
+ // do new crush map last (after up/down stuff)
+ if (inc.crush.length()) {
+ bufferlist::iterator blp = inc.crush.begin();
+ crush.decode(blp);
+ }
}
// serialize, unserialize
*/
void build_simple(epoch_t e, ceph_fsid &fsid,
int num_osd, int pg_bits, int mds_local_osd);
- static void build_simple_crush_map(CrushWrapper& crush, int num_osd, map<int,double>& weights);
+ static void build_simple_crush_map(CrushWrapper& crush, int num_osd);
};