~ubuntu-branches/ubuntu/raring/ceph/raring

« back to all changes in this revision

Viewing changes to src/osd/OSD.h

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-06-08 15:54:37 UTC
  • mfrom: (1.1.8) (0.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20120608155437-gy3j9k6wzv7w4gn9
Tags: 0.44.1-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - d/control: Switch from libcryptopp to libnss as libcryptopp
    is not seeded.
  - d/control,d/rules: Move from python-support to dh_python2.
  - d/patches/manpage_updates*.patch: cherry picked upstream manpage
    updates warning about lack of encryption, per MIR review.
  - d/rules,d/control: Drop radosgw since libfcgi is not in main and
    the code may not be suitable for LTS.
  - d/rules,d/control: Drop tcmalloc since google perftools is not
    in main yet.
  - d/rules,d/control: Drop ceph-fuse entirely per MIR review
    recommendation.
* d/patches/fix-radosgw-tests.patch: Cherry picked patch from upstream
  VCS to fixup tests to conditionally use radosgw if enabled.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
using namespace __gnu_cxx;
47
47
 
48
48
 
49
 
#define CEPH_OSD_PROTOCOL     9 /* cluster internal */
 
49
#define CEPH_OSD_PROTOCOL    10 /* cluster internal */
50
50
 
51
51
 
52
52
enum {
120
120
 
121
121
class AuthAuthorizeHandlerRegistry;
122
122
 
 
123
class OpRequest;
 
124
class OpsFlightSocketHook;
 
125
 
123
126
extern const coll_t meta_coll;
124
127
 
125
128
class OSD : public Dispatcher {
160
163
  void create_logger();
161
164
  void tick();
162
165
  void _dispatch(Message *m);
 
166
  void dispatch_op(OpRequest *op);
163
167
 
164
168
public:
165
169
  ClassHandler  *class_handler;
252
256
  // -- heartbeat --
253
257
  Mutex heartbeat_lock;
254
258
  Cond heartbeat_cond;
255
 
  bool heartbeat_stop;
 
259
  bool heartbeat_stop, heartbeat_need_update;
256
260
  epoch_t heartbeat_epoch;
257
261
  map<int, epoch_t> heartbeat_to, heartbeat_from;
258
262
  map<int, utime_t> heartbeat_from_stamp;
262
266
  
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();
270
275
 
271
276
  struct T_Heartbeat : public Thread {
272
277
    OSD *osd;
304
309
  void update_osd_stat();
305
310
  
306
311
  // -- waiters --
307
 
  list<class Message*> finished;
 
312
  list<OpRequest*> finished;
308
313
  Mutex finished_lock;
309
314
  
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();
314
319
  }
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();
319
324
  }
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);
325
330
  }
326
331
  void do_waiters();
327
332
  
 
333
  // -- op tracking --
 
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;
 
346
 
328
347
  // -- op queue --
329
348
  deque<PG*> op_queue;
330
349
  int op_queue_len;
350
369
    }
351
370
  } op_wq;
352
371
 
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);
368
387
  OSDMapRef       osdmap;
369
388
  utime_t         had_map_since;
370
389
  RWLock          map_lock;
371
 
  list<Message*>  waiting_for_osdmap;
 
390
  list<OpRequest*>  waiting_for_osdmap;
372
391
 
373
392
  Mutex peer_map_epoch_lock;
374
393
  map<int, epoch_t> peer_map_epoch;
381
400
                           Session *session = 0);
382
401
  void _share_map_outgoing(const entity_inst_t& inst);
383
402
 
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);
388
407
  
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);
391
410
 
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;
425
444
 
426
445
  PGPool *_get_pool(int id);
428
447
 
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);
436
455
 
437
456
  PG *lookup_lock_raw_pg(pg_t pgid);
438
457
 
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);
442
461
  
443
462
  void load_pgs();
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);
447
466
 
448
467
  void wake_pg_waiters(pg_t pgid) {
452
471
    }
453
472
  }
454
473
  void wake_all_pg_waiters() {
455
 
    for (map<pg_t, list<Message*> >::iterator p = waiting_for_pg.begin();
 
474
    for (map<pg_t, list<OpRequest*> >::iterator p = waiting_for_pg.begin();
456
475
         p != waiting_for_pg.end();
457
476
         p++)
458
477
      take_waiters(p->second);
462
481
 
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;
467
486
    set<int> prior;
468
487
    pg_t parent;
469
488
    int split_bits;
470
489
  };
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
473
491
 
474
492
  bool can_create_pg(pg_t pgid);
475
 
  void handle_pg_create(class MOSDPGCreate *m);
 
493
  void handle_pg_create(OpRequest *op);
476
494
 
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);
479
497
 
480
498
 
579
597
 
580
598
 
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);
587
605
 
588
606
  bool require_mon_peer(Message *m);
589
 
  bool require_osd_peer(Message *m);
590
 
 
591
 
  bool require_current_map(Message *m, epoch_t v);
592
 
  bool require_same_or_newer_map(Message *m, epoch_t e);
593
 
 
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);
600
 
 
601
 
  void handle_pg_scan(class MOSDPGScan *m);
602
 
  bool scan_is_queueable(PG *pg, MOSDPGScan *m);
603
 
 
604
 
  void handle_pg_backfill(class MOSDPGBackfill *m);
605
 
  bool backfill_is_queueable(PG *pg, MOSDPGBackfill *m);
606
 
 
607
 
  void handle_pg_remove(class MOSDPGRemove *m);
 
607
  bool require_osd_peer(OpRequest *op);
 
608
 
 
609
  bool require_same_or_newer_map(OpRequest *op, epoch_t e);
 
610
 
 
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);
 
617
 
 
618
  void handle_pg_scan(OpRequest *op);
 
619
  bool scan_is_queueable(PG *pg, OpRequest *op);
 
620
 
 
621
  void handle_pg_backfill(OpRequest *op);
 
622
  bool backfill_is_queueable(PG *pg, OpRequest *op);
 
623
 
 
624
  void handle_pg_remove(OpRequest *op);
608
625
  void queue_pg_for_deletion(PG *pg);
609
626
  void _remove_pg(PG *pg);
610
627
 
733
750
  Mutex remove_list_lock;
734
751
  map<epoch_t, map<int, vector<pg_t> > > remove_list;
735
752
 
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();
740
757
  }
741
758
 
744
761
  list< pair<pg_t, utime_t > > replay_queue;
745
762
  
746
763
  void check_replay_queue();
747
 
  void activate_pg(pg_t pgid, utime_t activate_at);
748
764
 
749
765
 
750
766
  // -- snap trimming --
1039
1055
  // startup/shutdown
1040
1056
  int pre_init();
1041
1057
  int init();
 
1058
 
 
1059
  void suicide(int exitcode);
1042
1060
  int shutdown();
1043
1061
 
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);
 
1063
 
 
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);
1047
1067
 
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);
1054
1074
 
1055
1075
private:
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);
1064
1084
 
1065
1085
public:
1066
1086
  void force_remount();
1087
1107
extern const CompatSet::Feature ceph_osd_feature_ro_compat[];
1088
1108
extern const CompatSet::Feature ceph_osd_feature_incompat[];
1089
1109
 
1090
 
 
1091
1110
#endif