Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / mds / LogSegment.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
2 // vim: ts=8 sw=2 smarttab
3 /*
4  * Ceph - scalable distributed file system
5  *
6  * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
7  *
8  * This is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License version 2.1, as published by the Free Software 
11  * Foundation.  See file COPYING.
12  * 
13  */
14
15 #ifndef CEPH_LOGSEGMENT_H
16 #define CEPH_LOGSEGMENT_H
17
18 #include "include/elist.h"
19 #include "include/interval_set.h"
20 #include "include/Context.h"
21 #include "mdstypes.h"
22 #include "CInode.h"
23 #include "CDentry.h"
24 #include "CDir.h"
25 #include "MDSContext.h"
26
27 #include "include/unordered_set.h"
28 using ceph::unordered_set;
29
30 class CDir;
31 class CInode;
32 class CDentry;
33 class MDSRank;
34 struct MDSlaveUpdate;
35
36 typedef uint64_t log_segment_seq_t;
37
38 class LogSegment {
39  public:
40   const log_segment_seq_t seq;
41   uint64_t offset, end;
42   int num_events;
43
44   // dirty items
45   elist<CDir*>    dirty_dirfrags, new_dirfrags;
46   elist<CInode*>  dirty_inodes;
47   elist<CDentry*> dirty_dentries;
48
49   elist<CInode*>  open_files;
50   elist<CInode*>  dirty_parent_inodes;
51   elist<CInode*>  dirty_dirfrag_dir;
52   elist<CInode*>  dirty_dirfrag_nest;
53   elist<CInode*>  dirty_dirfrag_dirfragtree;
54
55   elist<MDSlaveUpdate*> slave_updates;
56   
57   set<CInode*> truncating_inodes;
58
59   map<int, ceph::unordered_set<version_t> > pending_commit_tids;  // mdstable
60   set<metareqid_t> uncommitted_masters;
61   set<dirfrag_t> uncommitted_fragments;
62
63   // client request ids
64   map<int, ceph_tid_t> last_client_tids;
65
66   // potentially dirty sessions
67   std::set<entity_name_t> touched_sessions;
68
69   // table version
70   version_t inotablev;
71   version_t sessionmapv;
72   map<int,version_t> tablev;
73
74   // try to expire
75   void try_to_expire(MDSRank *mds, MDSGatherBuilder &gather_bld, int op_prio);
76
77   std::list<MDSInternalContextBase*> expiry_waiters;
78
79   void wait_for_expiry(MDSInternalContextBase *c)
80   {
81     assert(c != NULL);
82     expiry_waiters.push_back(c);
83   }
84
85   // cons
86   LogSegment(uint64_t _seq, loff_t off=-1) :
87     seq(_seq), offset(off), end(off), num_events(0),
88     dirty_dirfrags(member_offset(CDir, item_dirty)),
89     new_dirfrags(member_offset(CDir, item_new)),
90     dirty_inodes(member_offset(CInode, item_dirty)),
91     dirty_dentries(member_offset(CDentry, item_dirty)),
92     open_files(member_offset(CInode, item_open_file)),
93     dirty_parent_inodes(member_offset(CInode, item_dirty_parent)),
94     dirty_dirfrag_dir(member_offset(CInode, item_dirty_dirfrag_dir)),
95     dirty_dirfrag_nest(member_offset(CInode, item_dirty_dirfrag_nest)),
96     dirty_dirfrag_dirfragtree(member_offset(CInode, item_dirty_dirfrag_dirfragtree)),
97     slave_updates(0), // passed to begin() manually
98     inotablev(0), sessionmapv(0)
99   { }
100 };
101
102 #endif