summaryrefslogtreecommitdiffstats
path: root/src/client/Fh.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
commite6918187568dbd01842d8d1d2c808ce16a894239 (patch)
tree64f88b554b444a49f656b6c656111a145cbbaa28 /src/client/Fh.h
parentInitial commit. (diff)
downloadceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz
ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/client/Fh.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/client/Fh.h b/src/client/Fh.h
new file mode 100644
index 000000000..434716fee
--- /dev/null
+++ b/src/client/Fh.h
@@ -0,0 +1,65 @@
+#ifndef CEPH_CLIENT_FH_H
+#define CEPH_CLIENT_FH_H
+
+#include "common/Readahead.h"
+#include "include/types.h"
+#include "InodeRef.h"
+#include "UserPerm.h"
+#include "mds/flock.h"
+
+class Inode;
+
+// file handle for any open file state
+
+struct Fh {
+ InodeRef inode;
+ int flags;
+ uint64_t gen;
+ UserPerm actor_perms; // perms I opened the file with
+
+ // the members above once ininitalized in the constructor
+ // they won't change, and putting them under the client_lock
+ // makes no sense.
+
+ int _ref = 1;
+ loff_t pos = 0;
+ int mode; // the mode i opened the file with
+
+ bool pos_locked = false; // pos is currently in use
+ std::list<ceph::condition_variable*> pos_waiters; // waiters for pos
+
+ Readahead readahead;
+
+ // file lock
+ std::unique_ptr<ceph_lock_state_t> fcntl_locks;
+ std::unique_ptr<ceph_lock_state_t> flock_locks;
+
+ bool has_any_filelocks() {
+ return
+ (fcntl_locks && !fcntl_locks->empty()) ||
+ (flock_locks && !flock_locks->empty());
+ }
+
+ // IO error encountered by any writeback on this Inode while
+ // this Fh existed (i.e. an fsync on another Fh will still show
+ // up as an async_err here because it could have been the same
+ // bytes we wrote via this Fh).
+ int async_err = {0};
+
+ int take_async_err()
+ {
+ int e = async_err;
+ async_err = 0;
+ return e;
+ }
+
+ Fh() = delete;
+ Fh(InodeRef in, int flags, int cmode, uint64_t gen, const UserPerm &perms);
+ ~Fh();
+
+ void get() { ++_ref; }
+ int put() { return --_ref; }
+};
+
+
+#endif