]> git.proxmox.com Git - ceph.git/blame - ceph/src/client/MetaSession.h
update ceph source to reef 18.2.1
[ceph.git] / ceph / src / client / MetaSession.h
CommitLineData
7c673cae
FG
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3
4#ifndef CEPH_CLIENT_METASESSION_H
5#define CEPH_CLIENT_METASESSION_H
6
7#include "include/types.h"
8#include "include/utime.h"
7c673cae 9#include "include/xlist.h"
11fdf7f2 10#include "mds/MDSMap.h"
7c673cae 11#include "mds/mdstypes.h"
11fdf7f2 12#include "messages/MClientCapRelease.h"
7c673cae
FG
13
14struct Cap;
15struct Inode;
16struct CapSnap;
17struct MetaRequest;
7c673cae
FG
18
19struct MetaSession {
20 mds_rank_t mds_num;
21 ConnectionRef con;
f67539c2
TL
22 version_t seq = 0;
23 uint64_t cap_gen = 0;
7c673cae 24 utime_t cap_ttl, last_cap_renew_request;
f67539c2 25 uint64_t cap_renew_seq = 0;
11fdf7f2
TL
26 entity_addrvec_t addrs;
27 feature_bitset_t mds_features;
33c7a0ef 28 feature_bitset_t mds_metric_flags;
7c673cae
FG
29
30 enum {
11fdf7f2 31 STATE_NEW, // Unused
7c673cae
FG
32 STATE_OPENING,
33 STATE_OPEN,
34 STATE_CLOSING,
35 STATE_CLOSED,
36 STATE_STALE,
f6b5b4d7 37 STATE_REJECTED,
f67539c2 38 } state = STATE_OPENING;
7c673cae 39
11fdf7f2
TL
40 enum {
41 RECLAIM_NULL,
42 RECLAIMING,
43 RECLAIM_OK,
44 RECLAIM_FAIL,
f67539c2 45 } reclaim_state = RECLAIM_NULL;
11fdf7f2 46
f67539c2
TL
47 int mds_state = MDSMap::STATE_NULL;
48 bool readonly = false;
7c673cae 49
20effc67 50 std::list<Context*> waiting_for_open;
7c673cae
FG
51
52 xlist<Cap*> caps;
20effc67
TL
53 // dirty_list keeps all the dirty inodes before flushing in current session.
54 xlist<Inode*> dirty_list;
7c673cae
FG
55 xlist<Inode*> flushing_caps;
56 xlist<MetaRequest*> requests;
57 xlist<MetaRequest*> unsafe_requests;
58 std::set<ceph_tid_t> flushing_caps_tids;
7c673cae 59
9f95a23c 60 ceph::ref_t<MClientCapRelease> release;
11fdf7f2 61
f67539c2
TL
62 MetaSession(mds_rank_t mds_num, ConnectionRef con, const entity_addrvec_t& addrs)
63 : mds_num(mds_num), con(con), addrs(addrs) {
64 }
aee94f69
TL
65 ~MetaSession() {
66 ceph_assert(caps.empty());
67 ceph_assert(dirty_list.empty());
68 ceph_assert(flushing_caps.empty());
69 ceph_assert(requests.empty());
70 ceph_assert(unsafe_requests.empty());
71 }
7c673cae 72
20effc67
TL
73 xlist<Inode*> &get_dirty_list() { return dirty_list; }
74
7c673cae
FG
75 const char *get_state_name() const;
76
adb31ebb 77 void dump(Formatter *f, bool cap_dump=false) const;
7c673cae
FG
78
79 void enqueue_cap_release(inodeno_t ino, uint64_t cap_id, ceph_seq_t iseq,
80 ceph_seq_t mseq, epoch_t osd_barrier);
81};
82
20effc67 83using MetaSessionRef = std::shared_ptr<MetaSession>;
7c673cae 84#endif