]>
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 | ||
19 | #include "msg/Message.h" | |
20 | ||
21 | struct MClientLease : public Message { | |
22 | struct ceph_mds_lease h; | |
23 | string dname; | |
24 | ||
25 | int get_action() const { return h.action; } | |
26 | ceph_seq_t get_seq() const { return h.seq; } | |
27 | int get_mask() const { return h.mask; } | |
28 | inodeno_t get_ino() const { return inodeno_t(h.ino); } | |
29 | snapid_t get_first() const { return snapid_t(h.first); } | |
30 | snapid_t get_last() const { return snapid_t(h.last); } | |
31 | ||
32 | MClientLease() : Message(CEPH_MSG_CLIENT_LEASE) {} | |
33 | MClientLease(int ac, ceph_seq_t seq, int m, uint64_t i, uint64_t sf, uint64_t sl) : | |
34 | Message(CEPH_MSG_CLIENT_LEASE) { | |
35 | h.action = ac; | |
36 | h.seq = seq; | |
37 | h.mask = m; | |
38 | h.ino = i; | |
39 | h.first = sf; | |
40 | h.last = sl; | |
41 | h.duration_ms = 0; | |
42 | } | |
43 | MClientLease(int ac, ceph_seq_t seq, int m, uint64_t i, uint64_t sf, uint64_t sl, const string& d) : | |
44 | Message(CEPH_MSG_CLIENT_LEASE), | |
45 | dname(d) { | |
46 | h.action = ac; | |
47 | h.seq = seq; | |
48 | h.mask = m; | |
49 | h.ino = i; | |
50 | h.first = sf; | |
51 | h.last = sl; | |
52 | h.duration_ms = 0; | |
53 | } | |
54 | private: | |
55 | ~MClientLease() override {} | |
56 | ||
57 | public: | |
58 | const char *get_type_name() const override { return "client_lease"; } | |
59 | void print(ostream& out) const override { | |
60 | out << "client_lease(a=" << ceph_lease_op_name(get_action()) | |
61 | << " seq " << get_seq() | |
62 | << " mask " << get_mask(); | |
63 | out << " " << get_ino(); | |
64 | if (h.last != CEPH_NOSNAP) | |
65 | out << " [" << snapid_t(h.first) << "," << snapid_t(h.last) << "]"; | |
66 | if (dname.length()) | |
67 | out << "/" << dname; | |
68 | out << ")"; | |
69 | } | |
70 | ||
71 | void decode_payload() override { | |
72 | bufferlist::iterator p = payload.begin(); | |
73 | ::decode(h, p); | |
74 | ::decode(dname, p); | |
75 | } | |
76 | void encode_payload(uint64_t features) override { | |
77 | ::encode(h, payload); | |
78 | ::encode(dname, payload); | |
79 | } | |
80 | ||
81 | }; | |
82 | ||
83 | #endif |