~ubuntu-branches/ubuntu/quantal/ceph/quantal

« back to all changes in this revision

Viewing changes to src/mds/MDCache.h

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum, Clint Byrum, Micah Gersten
  • Date: 2011-02-12 22:50:26 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110212225026-yyyw4tk0msgql3ul
Tags: 0.24.2-0ubuntu1
[ Clint Byrum <clint@ubuntu.com> ]
* New upstream release. (LP: #658670, LP: #684011)
* debian/patches/fix-mkcephfs.patch: dropped (applied upstream)
* Removed .la files from libceph1-dev, libcrush1-dev and 
  librados1-dev (per Debian policy v3.9.1 10.2).
* debian/control: adding pkg-config as a build dependency
* debian/control: depend on libcrypto++-dev instead of libssl-dev
* debian/watch: added watch file

[ Micah Gersten <micahg@ubuntu.com> ]
* debian/control: add Homepage

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
class MDS;
35
35
class Session;
36
36
class Migrator;
37
 
class Renamer;
38
37
 
39
38
class Message;
40
39
class Session;
100
99
  list<ScatterLock*> updated_locks;
101
100
 
102
101
  list<CInode*> dirty_cow_inodes;
103
 
  list<CDentry*> dirty_cow_dentries;
 
102
  list<pair<CDentry*,version_t> > dirty_cow_dentries;
104
103
 
105
104
  Mutation() : 
106
105
    ls(0),
206
205
  }
207
206
  void add_cow_dentry(CDentry *dn) {
208
207
    pin(dn);
209
 
    dirty_cow_dentries.push_back(dn);
 
208
    dirty_cow_dentries.push_back(pair<CDentry*,version_t>(dn, dn->get_projected_version()));
210
209
  }
211
210
 
212
211
  void apply() {
217
216
         p != dirty_cow_inodes.end();
218
217
         p++) 
219
218
      (*p)->_mark_dirty(ls);
220
 
    for (list<CDentry*>::iterator p = dirty_cow_dentries.begin();
 
219
    for (list<pair<CDentry*,version_t> >::iterator p = dirty_cow_dentries.begin();
221
220
         p != dirty_cow_dentries.end();
222
 
         p++) 
223
 
      (*p)->_mark_dirty(ls);
 
221
         p++)
 
222
      p->first->mark_dirty(p->second, ls);
224
223
 
225
224
    for (list<ScatterLock*>::iterator p = updated_locks.begin();
226
225
         p != updated_locks.end();
245
244
}
246
245
 
247
246
 
248
 
enum {
249
 
  MDS_INTERNAL_OP_FRAGMENT,
250
 
};
251
 
 
252
247
/** active_request_t
253
248
 * state we track for requests we are currently processing.
254
249
 * mostly information about locks held, so that we can drop them all
264
259
 
265
260
  // store up to two sets of dn vectors, inode pointers, for request path1 and path2.
266
261
  vector<CDentry*> dn[2];
 
262
  CDentry *straydn;
267
263
  CInode *in[2];
268
264
  snapid_t snapid;
269
265
 
316
312
    Context *slave_commit;
317
313
    bufferlist rollback_bl;
318
314
 
319
 
    // internal ops
320
 
    CInode *fragment_in;
321
 
    frag_t fragment_base;
322
 
    list<CDir*> fragment_start;
323
 
    list<CDir*> fragment_result;
324
 
    int fragment_bits;
325
 
 
326
315
    More() : 
327
316
      src_reanchor_atid(0), dst_reanchor_atid(0), inode_import_v(0),
328
317
      destdn_was_remote_inode(0), was_link_merge(false),
329
318
      stid(0),
330
 
      slave_commit(0),
331
 
      fragment_in(0), fragment_bits(0) { }
 
319
      slave_commit(0) { }
332
320
  } *_more;
333
321
 
334
322
 
336
324
  MDRequest() : 
337
325
    ref(1),
338
326
    session(0), item_session_request(this),
339
 
    client_request(0), snapid(CEPH_NOSNAP), tracei(0), tracedn(0),
 
327
    client_request(0), straydn(NULL), snapid(CEPH_NOSNAP), tracei(0), tracedn(0),
340
328
    alloc_ino(0), used_prealloc_ino(0), snap_caps(0), did_early_reply(false),
341
329
    slave_request(0),
342
330
    internal_op(-1),
347
335
    Mutation(ri),
348
336
    ref(1),
349
337
    session(0), item_session_request(this),
350
 
    client_request(req), snapid(CEPH_NOSNAP), tracei(0), tracedn(0),
 
338
    client_request(req), straydn(NULL), snapid(CEPH_NOSNAP), tracei(0), tracedn(0),
351
339
    alloc_ino(0), used_prealloc_ino(0), snap_caps(0), did_early_reply(false),
352
340
    slave_request(0),
353
341
    internal_op(-1),
358
346
    Mutation(ri, by),
359
347
    ref(1),
360
348
    session(0), item_session_request(this),
361
 
    client_request(0), snapid(CEPH_NOSNAP), tracei(0), tracedn(0),
 
349
    client_request(0), straydn(NULL), snapid(CEPH_NOSNAP), tracei(0), tracedn(0),
362
350
    alloc_ino(0), used_prealloc_ino(0), snap_caps(0), did_early_reply(false),
363
351
    slave_request(0),
364
352
    internal_op(-1),
403
391
    if (is_slave()) out << " slave_to mds" << slave_to_mds;
404
392
    if (client_request) out << " cr=" << client_request;
405
393
    if (slave_request) out << " sr=" << slave_request;
406
 
    if (internal_op == MDS_INTERNAL_OP_FRAGMENT) out << " fragment";
407
394
    out << ")";
408
395
  }
409
396
};
446
433
  hash_map<vinodeno_t,CInode*> inode_map;  // map of inodes by ino
447
434
  CInode *root;                            // root inode
448
435
  CInode *myin;                            // .ceph/mds%d dir
449
 
  CInode *stray;                           // my stray dir
 
436
 
 
437
  CInode *strays[NUM_STRAY];         // my stray dir
 
438
  int stray_index;
 
439
 
 
440
  CInode *get_stray() {
 
441
    return strays[stray_index];
 
442
  }
 
443
 
450
444
  set<CInode*> base_inodes;
451
445
 
452
446
public:
 
447
  void advance_stray() {
 
448
    stray_index = (stray_index+1)%NUM_STRAY;
 
449
  }
 
450
 
453
451
  DecayRate decayrate;
454
452
 
455
453
  int num_inodes_with_caps;
456
454
  int num_caps;
457
455
 
458
456
  ceph_file_layout default_file_layout;
459
 
  ceph_file_layout default_dir_layout;
 
457
  ceph_file_layout default_log_layout;
460
458
 
461
459
  // -- client leases --
462
460
public:
473
471
  // -- client caps --
474
472
  uint64_t              last_cap_id;
475
473
  
476
 
  void remove_client_cap(CInode *in, client_t client);
477
474
 
478
475
 
479
476
  // -- discover --
 
477
  struct discover_info_t {
 
478
    tid_t tid;
 
479
    int mds;
 
480
    inodeno_t ino;
 
481
    frag_t frag;
 
482
    snapid_t snap;
 
483
    filepath want_path;
 
484
    inodeno_t want_ino;
 
485
    bool want_base_dir;
 
486
    bool want_xlocked;
 
487
 
 
488
    discover_info_t() : tid(0), mds(-1), snap(CEPH_NOSNAP), want_base_dir(false), want_xlocked(false) {}
 
489
  };
 
490
 
 
491
  map<tid_t, discover_info_t> discovers;
 
492
  tid_t discover_last_tid;
 
493
 
 
494
  void _send_discover(discover_info_t& dis);
 
495
  discover_info_t& _create_discover(int mds) {
 
496
    discover_info_t& d = discovers[++discover_last_tid];
 
497
    d.mds = mds;
 
498
    return d;
 
499
  }
 
500
 
480
501
  // waiters
481
502
  map<int, map<inodeno_t, list<Context*> > > waiting_for_base_ino;
482
503
 
483
 
  // in process discovers, by mds.
484
 
  //  this is just enough info to kick any waiters in the event of a failure.
485
 
  //  FIXME: use pointers here instead of identifiers?
486
 
  map<int, map<inodeno_t,int> > discover_dir;
487
 
  map<int, map<dirfrag_t,int> > discover_dir_sub;
488
 
 
489
504
  void discover_base_ino(inodeno_t want_ino, Context *onfinish, int from=-1);
490
505
  void discover_dir_frag(CInode *base, frag_t approx_fg, Context *onfinish,
491
506
                         int from=-1);
591
606
                          CInode **pcow_inode=0);
592
607
  inode_t *journal_dirty_inode(Mutation *mut, EMetaBlob *metablob, CInode *in, snapid_t follows=CEPH_NOSNAP);
593
608
 
594
 
  void project_rstat_inode_to_frag(inode_t& inode, snapid_t ofirst, snapid_t last,
595
 
                                   CDir *parent, int linkunlink=0);
 
609
  void project_rstat_inode_to_frag(CInode *cur, CDir *parent, snapid_t first, int linkunlink);
 
610
  void _project_rstat_inode_to_frag(inode_t& inode, snapid_t ofirst, snapid_t last,
 
611
                                    CDir *parent, int linkunlink=0);
596
612
  void project_rstat_frag_to_inode(nest_info_t& rstat, nest_info_t& accounted_rstat,
597
613
                                   snapid_t ofirst, snapid_t last, 
598
614
                                   CInode *pin, bool cow_head);
657
673
  void disambiguate_imports();
658
674
  void recalc_auth_bits();
659
675
  void trim_unlinked_inodes();
 
676
public:
660
677
  void remove_inode_recursive(CInode *in);
661
 
public:
 
678
 
662
679
  void add_rollback(metareqid_t reqid) {
663
680
    need_resolve_rollback.insert(reqid);
664
681
  }
677
694
  void cancel_ambiguous_import(dirfrag_t dirino);
678
695
  void finish_ambiguous_import(dirfrag_t dirino);
679
696
  void resolve_start();
680
 
  void send_resolve(int who);
 
697
  void send_resolves();
681
698
  void send_resolve_now(int who);
682
699
  void send_resolve_later(int who);
683
700
  void maybe_send_pending_resolves();
702
719
  
703
720
  set<CInode*> rejoin_undef_inodes;
704
721
  set<CInode*> rejoin_potential_updated_scatterlocks;
 
722
  set<CDir*>   rejoin_undef_dirfrags;
705
723
 
706
724
  vector<CInode*> rejoin_recover_q, rejoin_check_q;
707
725
  list<Context*> rejoin_waiters;
710
728
  void handle_cache_rejoin(MMDSCacheRejoin *m);
711
729
  void handle_cache_rejoin_weak(MMDSCacheRejoin *m);
712
730
  CInode* rejoin_invent_inode(inodeno_t ino, snapid_t last);
 
731
  CDir* rejoin_invent_dirfrag(dirfrag_t df);
713
732
  void handle_cache_rejoin_strong(MMDSCacheRejoin *m);
714
 
  void rejoin_scour_survivor_replicas(int from, MMDSCacheRejoin *ack);
 
733
  void rejoin_scour_survivor_replicas(int from, MMDSCacheRejoin *ack, set<vinodeno_t>& acked_inodes);
715
734
  void handle_cache_rejoin_ack(MMDSCacheRejoin *m);
716
735
  void handle_cache_rejoin_purge(MMDSCacheRejoin *m);
717
736
  void handle_cache_rejoin_missing(MMDSCacheRejoin *m);
755
774
    reconnected_snaprealms[ino][client] = seq;
756
775
  }
757
776
  void process_imported_caps();
758
 
  void process_reconnected_caps();
 
777
  void choose_lock_states_and_reconnect_caps();
759
778
  void prepare_realm_split(SnapRealm *realm, client_t client, inodeno_t ino,
760
779
                           map<client_t,MClientSnap*>& splits);
761
780
  void do_realm_invalidate_and_update_notify(CInode *in, int snapop, bool nosend=false);
774
793
  void check_realm_past_parents(SnapRealm *realm);
775
794
  void open_snap_parents();
776
795
 
 
796
  void open_undef_dirfrags();
 
797
  void opened_undef_dirfrag(CDir *dir) {
 
798
    rejoin_undef_dirfrags.erase(dir);
 
799
  }
 
800
 
777
801
  void reissue_all_caps();
778
802
  
779
803
 
780
804
  friend class Locker;
781
805
  friend class Migrator;
782
 
  friend class Renamer;
783
806
  friend class MDBalancer;
784
807
 
785
808
 
805
828
 
806
829
  // subsystems
807
830
  Migrator *migrator;
808
 
  Renamer *renamer;
809
831
 
810
832
 public:
811
833
  MDCache(MDS *m);
831
853
                  map<int,class MCacheExpire*>& expiremap);
832
854
  void send_expire_messages(map<int, MCacheExpire*>& expiremap);
833
855
  void trim_non_auth();      // trim out trimmable non-auth items
 
856
  bool trim_non_auth_subtree(CDir *directory);
834
857
 
835
858
  void trim_client_leases();
836
859
  void check_memory_usage();
846
869
  bool did_shutdown_log_cap;
847
870
 
848
871
  // inode_map
 
872
  bool have_inode(vinodeno_t vino) {
 
873
    return inode_map.count(vino) ? true:false;
 
874
  }
849
875
  bool have_inode(inodeno_t ino, snapid_t snap=CEPH_NOSNAP) {
850
876
    return have_inode(vinodeno_t(ino, snap));
851
877
  }
852
 
  bool have_inode(vinodeno_t vino) { return inode_map.count(vino) ? true:false; }
853
 
 
854
878
  CInode* get_inode(vinodeno_t vino) {
855
 
    return get_inode(vino.ino, vino.snapid);
856
 
  }
857
 
  CInode* get_inode(inodeno_t ino, snapid_t s=CEPH_NOSNAP) {
858
 
    vinodeno_t vino(ino, s);
859
879
    if (have_inode(vino))
860
880
      return inode_map[vino];
861
881
    return NULL;
862
882
  }
 
883
  CInode* get_inode(inodeno_t ino, snapid_t s=CEPH_NOSNAP) {
 
884
    return get_inode(vinodeno_t(ino, s));
 
885
  }
863
886
 
864
887
  CDir* get_dirfrag(dirfrag_t df) {
865
888
    if (!have_inode(df.ino)) return NULL;
879
902
    if (in->get_parent_dn())
880
903
      touch_dentry(in->get_projected_parent_dn());
881
904
  }
 
905
public:
882
906
  void touch_dentry(CDentry *dn) {
883
907
    // touch ancestors
884
908
    if (dn->get_dir()->get_inode()->get_projected_parent_dn())
890
914
    else
891
915
      lru.lru_midtouch(dn);
892
916
  }
893
 
public:
894
917
  void touch_dentry_bottom(CDentry *dn) {
895
918
    lru.lru_bottouch(dn);
896
919
  }
1016
1039
  friend class C_MDC_PurgeStrayLoggedTruncate;
1017
1040
  friend class C_MDC_PurgeStrayPurged;
1018
1041
  void reintegrate_stray(CDentry *dn, CDentry *rlink);
1019
 
  void migrate_stray(CDentry *dn, int src, int dest);
 
1042
  void migrate_stray(CDentry *dn, int dest);
1020
1043
 
1021
1044
 
1022
1045
  // == messages ==
1050
1073
  CDir* forge_replica_dir(CInode *diri, frag_t fg, int from);
1051
1074
  CDentry *add_replica_dentry(bufferlist::iterator& p, CDir *dir, list<Context*>& finished);
1052
1075
  CInode *add_replica_inode(bufferlist::iterator& p, CDentry *dn, list<Context*>& finished);
 
1076
 
 
1077
  void replicate_stray(CDentry *straydn, int who, bufferlist& bl);
1053
1078
  CDentry *add_replica_stray(bufferlist &bl, int from);
1054
1079
 
1055
1080
  // -- namespace --
1065
1090
private:
1066
1091
  void adjust_dir_fragments(CInode *diri, frag_t basefrag, int bits,
1067
1092
                            list<CDir*>& frags, list<Context*>& waiters, bool replay);
 
1093
  void adjust_dir_fragments(CInode *diri,
 
1094
                            list<CDir*>& srcfrags,
 
1095
                            frag_t basefrag, int bits,
 
1096
                            list<CDir*>& resultfrags, 
 
1097
                            list<Context*>& waiters,
 
1098
                            bool replay);
 
1099
 
1068
1100
  friend class EFragment;
1069
1101
 
 
1102
  bool can_fragment_lock(CInode *diri);
 
1103
  bool can_fragment(CInode *diri, list<CDir*>& dirs);
 
1104
 
1070
1105
public:
1071
1106
  void split_dir(CDir *dir, int byn);
 
1107
  void merge_dir(CInode *diri, frag_t fg);
1072
1108
 
1073
1109
private:
1074
 
  void dispatch_fragment(MDRequest *mdr);
1075
 
  void fragment_mark_and_complete(MDRequest *mdr);
1076
 
  void fragment_go(MDRequest *mdr);
1077
 
  void fragment_stored(MDRequest *mdr);
1078
 
  void fragment_logged(MDRequest *mdr);
1079
 
  friend class C_MDC_FragmentGo;
 
1110
  void fragment_freeze_dirs(list<CDir*>& dirs, C_Gather *gather);
 
1111
  void fragment_mark_and_complete(list<CDir*>& dirs);
 
1112
  void fragment_frozen(list<CDir*>& dirs, frag_t basefrag, int bits);
 
1113
  void fragment_unmark_unfreeze_dirs(list<CDir*>& dirs);
 
1114
  void fragment_stored(list<CDir*>& resultfrags, frag_t basefrag, int bits);
 
1115
  void fragment_logged(Mutation *mut, list<CDir*>& resultfrags, frag_t basefrag, int bits);
 
1116
  friend class C_MDC_FragmentFrozen;
1080
1117
  friend class C_MDC_FragmentMarking;
1081
1118
  friend class C_MDC_FragmentStored;
1082
1119
  friend class C_MDC_FragmentLogged;