-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDentry.h
53 lines (43 loc) · 1.06 KB
/
Dentry.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef CEPH_CLIENT_DENTRY_H
#define CEPH_CLIENT_DENTRY_H
#include "include/lru.h"
class Dir;
class Inode;
class Dentry : public LRUObject {
public:
string name; // sort of lame
//const char *name;
Dir *dir;
Inode *inode;
int ref; // 1 if there's a dir beneath me.
uint64_t offset;
int lease_mds;
utime_t lease_ttl;
uint64_t lease_gen;
ceph_seq_t lease_seq;
int cap_shared_gen;
/*
* ref==1 -> cached, unused
* ref >1 -> pinned in lru
*/
void get() {
assert(ref > 0);
if (++ref == 2)
lru_pin();
//cout << "dentry.get on " << this << " " << name << " now " << ref << std::endl;
}
void put() {
assert(ref > 0);
if (--ref == 1)
lru_unpin();
//cout << "dentry.put on " << this << " " << name << " now " << ref << std::endl;
if (ref == 0)
delete this;
}
Dentry() : dir(0), inode(0), ref(1), offset(0), lease_mds(-1), lease_gen(0), lease_seq(0), cap_shared_gen(0) { }
private:
~Dentry() {
assert(ref == 0);
}
};
#endif