]>
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_MSTATFS_H | |
17 | #define CEPH_MSTATFS_H | |
18 | ||
19 | #include <sys/statvfs.h> /* or <sys/statfs.h> */ | |
20 | #include "messages/PaxosServiceMessage.h" | |
21 | ||
9f95a23c | 22 | class MStatfs : public PaxosServiceMessage { |
11fdf7f2 TL |
23 | private: |
24 | static constexpr int HEAD_VERSION = 2; | |
25 | static constexpr int COMPAT_VERSION = 1; | |
d2e6a577 | 26 | |
7c673cae FG |
27 | public: |
28 | uuid_d fsid; | |
d2e6a577 | 29 | boost::optional<int64_t> data_pool; |
7c673cae | 30 | |
9f95a23c | 31 | MStatfs() : PaxosServiceMessage{CEPH_MSG_STATFS, 0, HEAD_VERSION, COMPAT_VERSION} {} |
d2e6a577 | 32 | MStatfs(const uuid_d& f, ceph_tid_t t, boost::optional<int64_t> _data_pool, |
9f95a23c TL |
33 | version_t v) |
34 | : PaxosServiceMessage{CEPH_MSG_STATFS, v, HEAD_VERSION, COMPAT_VERSION}, | |
35 | fsid(f), data_pool(_data_pool) { | |
7c673cae FG |
36 | set_tid(t); |
37 | } | |
38 | ||
39 | private: | |
40 | ~MStatfs() override {} | |
41 | ||
42 | public: | |
11fdf7f2 | 43 | std::string_view get_type_name() const override { return "statfs"; } |
9f95a23c | 44 | void print(std::ostream& out) const override { |
d2e6a577 FG |
45 | out << "statfs(" << get_tid() << " pool " |
46 | << (data_pool ? *data_pool : -1) << " v" << version << ")"; | |
7c673cae FG |
47 | } |
48 | ||
49 | void encode_payload(uint64_t features) override { | |
11fdf7f2 | 50 | using ceph::encode; |
7c673cae | 51 | paxos_encode(); |
11fdf7f2 TL |
52 | encode(fsid, payload); |
53 | encode(data_pool, payload); | |
7c673cae FG |
54 | } |
55 | void decode_payload() override { | |
9f95a23c | 56 | using ceph::decode; |
11fdf7f2 | 57 | auto p = payload.cbegin(); |
7c673cae | 58 | paxos_decode(p); |
11fdf7f2 | 59 | decode(fsid, p); |
d2e6a577 | 60 | if (header.version >= 2) { |
11fdf7f2 | 61 | decode(data_pool, p); |
d2e6a577 FG |
62 | } else { |
63 | data_pool = boost::optional<int64_t> (); | |
64 | } | |
7c673cae | 65 | } |
9f95a23c TL |
66 | private: |
67 | template<class T, typename... Args> | |
68 | friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args); | |
7c673cae FG |
69 | }; |
70 | ||
71 | #endif |