Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / client / Dentry.h
1 #ifndef CEPH_CLIENT_DENTRY_H
2 #define CEPH_CLIENT_DENTRY_H
3
4 #include "include/lru.h"
5 #include "include/xlist.h"
6
7 #include "mds/mdstypes.h"
8 #include "InodeRef.h"
9
10 class Dir;
11 struct Inode;
12
13 class Dentry : public LRUObject {
14  public:
15   string   name;                      // sort of lame
16   //const char *name;
17   Dir      *dir;
18   InodeRef inode;
19   int      ref;                       // 1 if there's a dir beneath me.
20   int64_t offset;
21   mds_rank_t lease_mds;
22   utime_t lease_ttl;
23   uint64_t lease_gen;
24   ceph_seq_t lease_seq;
25   int cap_shared_gen;
26
27   /*
28    * ref==1 -> cached, unused
29    * ref >1 -> pinned in lru
30    */
31   void get() {
32     assert(ref > 0);
33     if (++ref == 2)
34       lru_pin();
35     //cout << "dentry.get on " << this << " " << name << " now " << ref << std::endl;
36   }
37   void put() {
38     assert(ref > 0);
39     if (--ref == 1)
40       lru_unpin();
41     //cout << "dentry.put on " << this << " " << name << " now " << ref << std::endl;
42     if (ref == 0)
43       delete this;
44   }
45
46   void dump(Formatter *f) const;
47
48   Dentry() :
49     dir(0), ref(1), offset(0),
50     lease_mds(-1), lease_gen(0), lease_seq(0), cap_shared_gen(0)
51   { }
52 private:
53   ~Dentry() {
54     assert(ref == 0);
55   }
56 };
57
58
59
60
61
62 #endif