263
267
void _add_heartbeat_source(int p, map<int, epoch_t>& old_from, map<int, utime_t>& old_from_stamp,
264
268
map<int,Connection*>& old_con);
265
void update_heartbeat_peers();
269
void maybe_update_heartbeat_peers();
266
270
void reset_heartbeat_peers();
267
271
void heartbeat();
268
272
void heartbeat_check();
269
273
void heartbeat_entry();
274
void need_heartbeat_peer_update();
271
276
struct T_Heartbeat : public Thread {
304
309
void update_osd_stat();
307
list<class Message*> finished;
312
list<OpRequest*> finished;
308
313
Mutex finished_lock;
310
void take_waiters(list<class Message*>& ls) {
315
void take_waiters(list<class OpRequest*>& ls) {
311
316
finished_lock.Lock();
312
317
finished.splice(finished.end(), ls);
313
318
finished_lock.Unlock();
315
void take_waiter(Message *o) {
320
void take_waiter(OpRequest *op) {
316
321
finished_lock.Lock();
317
finished.push_back(o);
322
finished.push_back(op);
318
323
finished_lock.Unlock();
320
void push_waiters(list<class Message*>& ls) {
325
void push_waiters(list<OpRequest*>& ls) {
321
326
assert(osd_lock.is_locked()); // currently, at least. be careful if we change this (see #743)
322
327
finished_lock.Lock();
323
328
finished.splice(finished.begin(), ls);
326
331
void do_waiters();
334
xlist<OpRequest*> ops_in_flight;
335
/** This is an inner lock that is taken by the following three
336
* functions without regard for what locks the callers hold. It
337
* protects the xlist, but not the OpRequests. */
338
Mutex ops_in_flight_lock;
339
void register_inflight_op(xlist<OpRequest*>::item *i);
340
void check_ops_in_flight();
341
void unregister_inflight_op(xlist<OpRequest*>::item *i);
342
void dump_ops_in_flight(ostream& ss);
343
friend struct OpRequest;
344
friend class OpsFlightSocketHook;
345
OpsFlightSocketHook *admin_ops_hook;
328
347
// -- op queue --
329
348
deque<PG*> op_queue;
330
349
int op_queue_len;
353
void enqueue_op(PG *pg, Message *op);
354
void requeue_ops(PG *pg, list<Message*>& ls);
372
void enqueue_op(PG *pg, OpRequest *op);
373
void requeue_ops(PG *pg, list<OpRequest*>& ls);
355
374
void dequeue_op(PG *pg);
356
375
static void static_dequeueop(OSD *o, PG *pg) {
357
376
o->dequeue_op(pg);
381
400
Session *session = 0);
382
401
void _share_map_outgoing(const entity_inst_t& inst);
384
void wait_for_new_map(Message *m);
403
void wait_for_new_map(OpRequest *op);
385
404
void handle_osd_map(class MOSDMap *m);
386
405
void note_down_osd(int osd);
387
406
void note_up_osd(int osd);
389
void advance_map(ObjectStore::Transaction& t);
408
void advance_map(ObjectStore::Transaction& t, C_Contexts *tfin);
390
409
void activate_map(ObjectStore::Transaction& t, list<Context*>& tfin);
392
411
// osd map cache (past osd maps)
420
439
// -- placement groups --
421
440
map<int, PGPool*> pool_map;
422
441
hash_map<pg_t, PG*> pg_map;
423
map<pg_t, list<Message*> > waiting_for_pg;
442
map<pg_t, list<OpRequest*> > waiting_for_pg;
424
443
PGRecoveryStats pg_recovery_stats;
426
445
PGPool *_get_pool(int id);
429
448
bool _have_pg(pg_t pgid);
430
449
PG *_lookup_lock_pg(pg_t pgid);
431
PG *_open_lock_pg(pg_t pg, bool no_lockdep_check=false); // create new PG (in memory)
432
PG *_create_lock_pg(pg_t pg, ObjectStore::Transaction& t); // create new PG
433
PG *_create_lock_new_pg(pg_t pgid, vector<int>& acting, ObjectStore::Transaction& t,
434
PG::Info::History history);
435
//void _remove_unlock_pg(PG *pg); // remove from store and memory
450
PG *_lookup_lock_pg_with_map_lock_held(pg_t pgid);
451
PG *_open_lock_pg(pg_t pg, bool no_lockdep_check=false, bool hold_map_lock=false);
452
PG *_create_lock_pg(pg_t pgid, bool newly_created, bool hold_map_lock,
453
int role, vector<int>& up, vector<int>& acting, pg_history_t history,
454
ObjectStore::Transaction& t);
437
456
PG *lookup_lock_raw_pg(pg_t pgid);
439
PG *get_or_create_pg(const PG::Info& info, epoch_t epoch, int from, int& pcreated, bool primary,
458
PG *get_or_create_pg(const pg_info_t& info, epoch_t epoch, int from, int& pcreated, bool primary,
440
459
ObjectStore::Transaction **pt,
441
460
C_Contexts **pfin);
444
463
void calc_priors_during(pg_t pgid, epoch_t start, epoch_t end, set<int>& pset);
445
void project_pg_history(pg_t pgid, PG::Info::History& h, epoch_t from,
464
void project_pg_history(pg_t pgid, pg_history_t& h, epoch_t from,
446
465
vector<int>& lastup, vector<int>& lastacting);
448
467
void wake_pg_waiters(pg_t pgid) {
463
482
// -- pg creation --
464
483
struct create_pg_info {
465
PG::Info::History history;
484
pg_history_t history;
466
485
vector<int> acting;
471
490
hash_map<pg_t, create_pg_info> creating_pgs;
472
map<pg_t, set<pg_t> > pg_split_ready; // children ready to be split to, by parent
474
492
bool can_create_pg(pg_t pgid);
475
void handle_pg_create(class MOSDPGCreate *m);
493
void handle_pg_create(OpRequest *op);
477
void kick_pg_split_queue();
495
void do_split(PG *parent, set<pg_t>& children, ObjectStore::Transaction &t, C_Contexts *tfin);
478
496
void split_pg(PG *parent, map<pg_t,PG*>& children, ObjectStore::Transaction &t);
581
599
// -- generic pg peering --
582
void do_notifies(map< int, vector<PG::Info> >& notify_list,
600
void do_notifies(map< int, vector<pg_info_t> >& notify_list,
583
601
epoch_t query_epoch);
584
void do_queries(map< int, map<pg_t,PG::Query> >& query_map);
602
void do_queries(map< int, map<pg_t,pg_query_t> >& query_map);
585
603
void do_infos(map<int, MOSDPGInfo*>& info_map);
586
void repeer(PG *pg, map< int, map<pg_t,PG::Query> >& query_map);
604
void repeer(PG *pg, map< int, map<pg_t,pg_query_t> >& query_map);
588
606
bool require_mon_peer(Message *m);
589
bool require_osd_peer(Message *m);
591
bool require_current_map(Message *m, epoch_t v);
592
bool require_same_or_newer_map(Message *m, epoch_t e);
594
void handle_pg_query(class MOSDPGQuery *m);
595
void handle_pg_missing(class MOSDPGMissing *m);
596
void handle_pg_notify(class MOSDPGNotify *m);
597
void handle_pg_log(class MOSDPGLog *m);
598
void handle_pg_info(class MOSDPGInfo *m);
599
void handle_pg_trim(class MOSDPGTrim *m);
601
void handle_pg_scan(class MOSDPGScan *m);
602
bool scan_is_queueable(PG *pg, MOSDPGScan *m);
604
void handle_pg_backfill(class MOSDPGBackfill *m);
605
bool backfill_is_queueable(PG *pg, MOSDPGBackfill *m);
607
void handle_pg_remove(class MOSDPGRemove *m);
607
bool require_osd_peer(OpRequest *op);
609
bool require_same_or_newer_map(OpRequest *op, epoch_t e);
611
void handle_pg_query(OpRequest *op);
612
void handle_pg_missing(OpRequest *op);
613
void handle_pg_notify(OpRequest *op);
614
void handle_pg_log(OpRequest *op);
615
void handle_pg_info(OpRequest *op);
616
void handle_pg_trim(OpRequest *op);
618
void handle_pg_scan(OpRequest *op);
619
bool scan_is_queueable(PG *pg, OpRequest *op);
621
void handle_pg_backfill(OpRequest *op);
622
bool backfill_is_queueable(PG *pg, OpRequest *op);
624
void handle_pg_remove(OpRequest *op);
608
625
void queue_pg_for_deletion(PG *pg);
609
626
void _remove_pg(PG *pg);
733
750
Mutex remove_list_lock;
734
751
map<epoch_t, map<int, vector<pg_t> > > remove_list;
736
void queue_for_removal(int osd, pg_t pgid) {
753
void queue_for_removal(epoch_t epoch, int osd, pg_t pgid) {
737
754
remove_list_lock.Lock();
738
remove_list[osdmap->get_epoch()][osd].push_back(pgid);
755
remove_list[epoch][osd].push_back(pgid);
739
756
remove_list_lock.Unlock();
1039
1055
// startup/shutdown
1040
1056
int pre_init();
1059
void suicide(int exitcode);
1042
1060
int shutdown();
1044
void reply_op_error(MOSDOp *op, int r);
1045
void reply_op_error(MOSDOp *op, int r, eversion_t v);
1046
void handle_misdirected_op(PG *pg, MOSDOp *op);
1062
void handle_signal(int signum);
1064
void reply_op_error(OpRequest *op, int r);
1065
void reply_op_error(OpRequest *op, int r, eversion_t v);
1066
void handle_misdirected_op(PG *pg, OpRequest *op);
1048
1068
void handle_rep_scrub(MOSDRepScrub *m);
1049
1069
void handle_scrub(class MOSDScrub *m);
1050
1070
void handle_osd_ping(class MOSDPing *m);
1051
void handle_op(class MOSDOp *m);
1052
void handle_sub_op(class MOSDSubOp *m);
1053
void handle_sub_op_reply(class MOSDSubOpReply *m);
1071
void handle_op(OpRequest *op);
1072
void handle_sub_op(OpRequest *op);
1073
void handle_sub_op_reply(OpRequest *op);
1056
1076
/// check if we can throw out op from a disconnected client
1058
1078
/// check if op has sufficient caps
1059
1079
bool op_has_sufficient_caps(PG *pg, class MOSDOp *m);
1060
1080
/// check if op should be (re)queued for processing
1061
bool op_is_queueable(PG *pg, class MOSDOp *m);
1081
bool op_is_queueable(PG *pg, OpRequest *op);
1062
1082
/// check if subop should be (re)queued for processing
1063
bool subop_is_queueable(PG *pg, class MOSDSubOp *m);
1083
bool subop_is_queueable(PG *pg, OpRequest *op);
1066
1086
void force_remount();