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