]> git.proxmox.com Git - ceph.git/blame - ceph/src/client/Fh.h
import 15.2.5
[ceph.git] / ceph / src / client / Fh.h
CommitLineData
7c673cae
FG
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"
11fdf7f2 8#include "mds/flock.h"
7c673cae 9
7c673cae
FG
10class Inode;
11
12// file handle for any open file state
13
14struct 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
f6b5b4d7 20 uint64_t gen;
7c673cae
FG
21
22 int flags;
23 bool pos_locked; // pos is currently in use
9f95a23c 24 std::list<ceph::condition_variable*> pos_waiters; // waiters for pos
7c673cae
FG
25
26 UserPerm actor_perms; // perms I opened the file with
27
28 Readahead readahead;
29
30 // file lock
11fdf7f2
TL
31 std::unique_ptr<ceph_lock_state_t> fcntl_locks;
32 std::unique_ptr<ceph_lock_state_t> flock_locks;
7c673cae 33
f6b5b4d7
TL
34 bool has_any_filelocks() {
35 return
36 (fcntl_locks && !fcntl_locks->empty()) ||
37 (flock_locks && !flock_locks->empty());
38 }
39
7c673cae
FG
40 // IO error encountered by any writeback on this Inode while
41 // this Fh existed (i.e. an fsync on another Fh will still show
42 // up as an async_err here because it could have been the same
43 // bytes we wrote via this Fh).
44 int async_err = {0};
45
46 int take_async_err()
47 {
48 int e = async_err;
49 async_err = 0;
50 return e;
51 }
11fdf7f2
TL
52
53 Fh() = delete;
f6b5b4d7 54 Fh(InodeRef in, int flags, int cmode, uint64_t gen, const UserPerm &perms);
7c673cae 55 ~Fh();
11fdf7f2 56
7c673cae
FG
57 void get() { ++_ref; }
58 int put() { return --_ref; }
59};
60
61
62#endif