]>
Commit | Line | Data |
---|---|---|
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 | * Ceph - scalable distributed file system | |
5 | * | |
6 | * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net> | |
7 | * | |
8 | * This is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU Lesser General Public | |
10 | * License version 2.1, as published by the Free Software | |
11 | * Foundation. See file COPYING. | |
12 | * | |
13 | */ | |
14 | ||
15 | ||
16 | #ifndef CEPH_MCLIENTLEASE_H | |
17 | #define CEPH_MCLIENTLEASE_H | |
18 | ||
11fdf7f2 | 19 | #include <string_view> |
94b18763 | 20 | |
7c673cae FG |
21 | #include "msg/Message.h" |
22 | ||
f67539c2 | 23 | class MClientLease final : public SafeMessage { |
11fdf7f2 | 24 | public: |
7c673cae | 25 | struct ceph_mds_lease h; |
94b18763 | 26 | std::string dname; |
7c673cae FG |
27 | |
28 | int get_action() const { return h.action; } | |
29 | ceph_seq_t get_seq() const { return h.seq; } | |
30 | int get_mask() const { return h.mask; } | |
31 | inodeno_t get_ino() const { return inodeno_t(h.ino); } | |
32 | snapid_t get_first() const { return snapid_t(h.first); } | |
33 | snapid_t get_last() const { return snapid_t(h.last); } | |
34 | ||
11fdf7f2 | 35 | protected: |
9f95a23c | 36 | MClientLease() : SafeMessage(CEPH_MSG_CLIENT_LEASE) {} |
11fdf7f2 | 37 | MClientLease(const MClientLease& m) : |
9f95a23c | 38 | SafeMessage(CEPH_MSG_CLIENT_LEASE), |
11fdf7f2 TL |
39 | h(m.h), |
40 | dname(m.dname) {} | |
7c673cae | 41 | MClientLease(int ac, ceph_seq_t seq, int m, uint64_t i, uint64_t sf, uint64_t sl) : |
9f95a23c | 42 | SafeMessage(CEPH_MSG_CLIENT_LEASE) { |
7c673cae FG |
43 | h.action = ac; |
44 | h.seq = seq; | |
45 | h.mask = m; | |
46 | h.ino = i; | |
47 | h.first = sf; | |
48 | h.last = sl; | |
49 | h.duration_ms = 0; | |
50 | } | |
11fdf7f2 | 51 | MClientLease(int ac, ceph_seq_t seq, int m, uint64_t i, uint64_t sf, uint64_t sl, std::string_view d) : |
9f95a23c | 52 | SafeMessage(CEPH_MSG_CLIENT_LEASE), |
7c673cae FG |
53 | dname(d) { |
54 | h.action = ac; | |
55 | h.seq = seq; | |
56 | h.mask = m; | |
57 | h.ino = i; | |
58 | h.first = sf; | |
59 | h.last = sl; | |
60 | h.duration_ms = 0; | |
61 | } | |
f67539c2 | 62 | ~MClientLease() final {} |
7c673cae FG |
63 | |
64 | public: | |
11fdf7f2 | 65 | std::string_view get_type_name() const override { return "client_lease"; } |
f67539c2 | 66 | void print(std::ostream& out) const override { |
7c673cae FG |
67 | out << "client_lease(a=" << ceph_lease_op_name(get_action()) |
68 | << " seq " << get_seq() | |
69 | << " mask " << get_mask(); | |
70 | out << " " << get_ino(); | |
71 | if (h.last != CEPH_NOSNAP) | |
72 | out << " [" << snapid_t(h.first) << "," << snapid_t(h.last) << "]"; | |
73 | if (dname.length()) | |
74 | out << "/" << dname; | |
75 | out << ")"; | |
76 | } | |
f67539c2 | 77 | |
7c673cae | 78 | void decode_payload() override { |
f67539c2 | 79 | using ceph::decode; |
11fdf7f2 TL |
80 | auto p = payload.cbegin(); |
81 | decode(h, p); | |
82 | decode(dname, p); | |
7c673cae FG |
83 | } |
84 | void encode_payload(uint64_t features) override { | |
11fdf7f2 TL |
85 | using ceph::encode; |
86 | encode(h, payload); | |
87 | encode(dname, payload); | |
7c673cae FG |
88 | } |
89 | ||
9f95a23c TL |
90 | private: |
91 | template<class T, typename... Args> | |
92 | friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args); | |
20effc67 TL |
93 | template<class T, typename... Args> |
94 | friend MURef<T> crimson::make_message(Args&&... args); | |
7c673cae FG |
95 | }; |
96 | ||
97 | #endif |