]> git.proxmox.com Git - ceph.git/blob - ceph/src/client/Fh.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / client / Fh.h
1 #ifndef CEPH_CLIENT_FH_H
2 #define CEPH_CLIENT_FH_H
3
4 #include "common/Readahead.h"
5 #include "include/types.h"
6 #include "InodeRef.h"
7 #include "UserPerm.h"
8 #include "mds/flock.h"
9
10 class Inode;
11
12 // file handle for any open file state
13
14 struct Fh {
15 InodeRef inode;
16 int _ref;
17 loff_t pos;
18 int mds; // have to talk to mds we opened with (for now)
19 int mode; // the mode i opened the file with
20
21 int flags;
22 bool pos_locked; // pos is currently in use
23 std::list<ceph::condition_variable*> pos_waiters; // waiters for pos
24
25 UserPerm actor_perms; // perms I opened the file with
26
27 Readahead readahead;
28
29 // file lock
30 std::unique_ptr<ceph_lock_state_t> fcntl_locks;
31 std::unique_ptr<ceph_lock_state_t> flock_locks;
32
33 // IO error encountered by any writeback on this Inode while
34 // this Fh existed (i.e. an fsync on another Fh will still show
35 // up as an async_err here because it could have been the same
36 // bytes we wrote via this Fh).
37 int async_err = {0};
38
39 int take_async_err()
40 {
41 int e = async_err;
42 async_err = 0;
43 return e;
44 }
45
46 Fh() = delete;
47 Fh(InodeRef in, int flags, int cmode, const UserPerm &perms);
48 ~Fh();
49
50 void get() { ++_ref; }
51 int put() { return --_ref; }
52 };
53
54
55 #endif