]> git.proxmox.com Git - ceph.git/blob - ceph/src/mds/FSMapUser.h
update ceph source to reef 18.2.1
[ceph.git] / ceph / src / mds / FSMapUser.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 #ifndef CEPH_FSMAPCOMPACT_H
15 #define CEPH_FSMAPCOMPACT_H
16
17 #include <map>
18 #include <string>
19 #include <string_view>
20
21 #include "mds/mdstypes.h"
22
23 class FSMapUser {
24 public:
25 struct fs_info_t {
26 fs_info_t() {}
27 void encode(ceph::buffer::list& bl, uint64_t features) const;
28 void decode(ceph::buffer::list::const_iterator &bl);
29 std::string name;
30 fs_cluster_id_t cid = FS_CLUSTER_ID_NONE;
31 };
32
33 FSMapUser() {}
34
35 epoch_t get_epoch() const { return epoch; }
36
37 fs_cluster_id_t get_fs_cid(std::string_view name) const {
38 for (auto &p : filesystems) {
39 if (p.second.name == name)
40 return p.first;
41 }
42 return FS_CLUSTER_ID_NONE;
43 }
44
45 void encode(ceph::buffer::list& bl, uint64_t features) const;
46 void decode(ceph::buffer::list::const_iterator& bl);
47
48 void print(std::ostream& out) const;
49 void print_summary(ceph::Formatter *f, std::ostream *out) const;
50
51 static void generate_test_instances(std::list<FSMapUser*>& ls);
52
53 std::map<fs_cluster_id_t, fs_info_t> filesystems;
54 fs_cluster_id_t legacy_client_fscid = FS_CLUSTER_ID_NONE;
55 epoch_t epoch = 0;
56 };
57 WRITE_CLASS_ENCODER_FEATURES(FSMapUser::fs_info_t)
58 WRITE_CLASS_ENCODER_FEATURES(FSMapUser)
59
60 inline std::ostream& operator<<(std::ostream& out, const FSMapUser& m) {
61 m.print_summary(NULL, &out);
62 return out;
63 }
64 #endif