Skip to content

Commit 5c6f9d8

Browse files
MaxKellermannvshankar
authored andcommitted
include/cephfs/types.h: move dump() methods to dump.h
This eliminates the header dependency on Formatter.h from most includers. Signed-off-by: Max Kellermann <[email protected]>
1 parent 4d7941f commit 5c6f9d8

File tree

3 files changed

+145
-112
lines changed

3 files changed

+145
-112
lines changed

src/include/cephfs/dump.h

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
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) 2020 Red Hat, Inc.
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+
#pragma once
15+
16+
#include "types.h"
17+
18+
#include "common/Formatter.h"
19+
20+
template<template<typename> class Allocator>
21+
void inode_t<Allocator>::dump(ceph::Formatter *f) const
22+
{
23+
f->dump_unsigned("ino", ino);
24+
f->dump_unsigned("rdev", rdev);
25+
f->dump_stream("ctime") << ctime;
26+
f->dump_stream("btime") << btime;
27+
f->dump_unsigned("mode", mode);
28+
f->dump_unsigned("uid", uid);
29+
f->dump_unsigned("gid", gid);
30+
f->dump_unsigned("nlink", nlink);
31+
32+
f->open_object_section("dir_layout");
33+
::dump(dir_layout, f);
34+
f->close_section();
35+
36+
f->dump_object("layout", layout);
37+
38+
f->open_array_section("old_pools");
39+
for (const auto &p : old_pools) {
40+
f->dump_int("pool", p);
41+
}
42+
f->close_section();
43+
44+
f->dump_unsigned("size", size);
45+
f->dump_unsigned("truncate_seq", truncate_seq);
46+
f->dump_unsigned("truncate_size", truncate_size);
47+
f->dump_unsigned("truncate_from", truncate_from);
48+
f->dump_unsigned("truncate_pending", truncate_pending);
49+
f->dump_stream("mtime") << mtime;
50+
f->dump_stream("atime") << atime;
51+
f->dump_unsigned("time_warp_seq", time_warp_seq);
52+
f->dump_unsigned("change_attr", change_attr);
53+
f->dump_int("export_pin", export_pin);
54+
f->dump_float("export_ephemeral_random_pin", export_ephemeral_random_pin);
55+
f->dump_bool("export_ephemeral_distributed_pin", get_ephemeral_distributed_pin());
56+
f->dump_bool("quiesce_block", get_quiesce_block());
57+
58+
f->open_array_section("client_ranges");
59+
for (const auto &p : client_ranges) {
60+
f->open_object_section("client");
61+
f->dump_unsigned("client", p.first.v);
62+
p.second.dump(f);
63+
f->close_section();
64+
}
65+
f->close_section();
66+
67+
f->open_object_section("dirstat");
68+
dirstat.dump(f);
69+
f->close_section();
70+
71+
f->open_object_section("rstat");
72+
rstat.dump(f);
73+
f->close_section();
74+
75+
f->open_object_section("accounted_rstat");
76+
accounted_rstat.dump(f);
77+
f->close_section();
78+
79+
f->dump_unsigned("version", version);
80+
f->dump_unsigned("file_data_version", file_data_version);
81+
f->dump_unsigned("xattr_version", xattr_version);
82+
f->dump_unsigned("backtrace_version", backtrace_version);
83+
f->dump_unsigned("inline_data_version", inline_data.version);
84+
f->dump_unsigned("inline_data_length", inline_data.length());
85+
86+
f->dump_string("stray_prior_path", stray_prior_path);
87+
f->dump_unsigned("max_size_ever", max_size_ever);
88+
89+
f->open_object_section("quota");
90+
quota.dump(f);
91+
f->close_section();
92+
93+
f->dump_object("optmetadata", optmetadata);
94+
95+
f->dump_stream("last_scrub_stamp") << last_scrub_stamp;
96+
f->dump_unsigned("last_scrub_version", last_scrub_version);
97+
f->dump_unsigned("remote_ino", remote_ino);
98+
f->open_array_section("referent_inodes");
99+
for (const auto &ri : referent_inodes) {
100+
f->dump_unsigned("referent_inode", ri);
101+
}
102+
f->close_section();
103+
}
104+
105+
inline void vinodeno_t::dump(ceph::Formatter *f) const {
106+
f->dump_unsigned("ino", ino);
107+
f->dump_unsigned("snapid", snapid);
108+
}
109+
110+
template<template<typename> class Allocator>
111+
void charmap_md_t<Allocator>::dump(ceph::Formatter* f) const {
112+
f->dump_bool("casesensitive", casesensitive);
113+
f->dump_string("normalization", normalization);
114+
f->dump_string("encoding", encoding);
115+
}
116+
117+
template<template<typename> class Allocator>
118+
void unknown_md_t<Allocator>::dump(ceph::Formatter* f) const {
119+
f->dump_bool("length", payload.size());
120+
}
121+
122+
template<typename M, template<typename> class Allocator>
123+
void optmetadata_singleton<M, Allocator>::dump(ceph::Formatter* f) const {
124+
f->dump_int("kind", u64kind);
125+
f->open_object_section("metadata");
126+
std::visit([f](auto& o) { o.dump(f); }, optmetadata);
127+
f->close_section();
128+
}
129+
130+
template<typename Singleton, template<typename> class Allocator>
131+
void optmetadata_multiton<Singleton, Allocator>::dump(ceph::Formatter* f) const {
132+
f->dump_bool("length", opts.size());
133+
f->open_array_section("opts");
134+
for (auto& opt : opts) {
135+
f->dump_object("opt", opt);
136+
}
137+
f->close_section();
138+
}

src/include/cephfs/types.h

Lines changed: 6 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <string_view>
2323
#include <vector>
2424

25-
#include "common/Formatter.h"
2625
#include "include/compact_set.h"
2726
#include "include/encoding.h"
2827
#include "include/fs_types.h"
@@ -36,6 +35,7 @@
3635
#define CEPH_FS_ONDISK_MAGIC "ceph fs volume v011"
3736
#define MAX_MDS 0x100
3837

38+
namespace ceph { class Formatter; }
3939
class JSONObj;
4040

4141
BOOST_STRONG_TYPEDEF(uint64_t, mds_gid_t)
@@ -211,10 +211,7 @@ struct vinodeno_t {
211211
decode(ino, p);
212212
decode(snapid, p);
213213
}
214-
void dump(ceph::Formatter *f) const {
215-
f->dump_unsigned("ino", ino);
216-
f->dump_unsigned("snapid", snapid);
217-
}
214+
void dump(ceph::Formatter *f) const;
218215
static void generate_test_instances(std::list<vinodeno_t*>& ls) {
219216
ls.push_back(new vinodeno_t);
220217
ls.push_back(new vinodeno_t(1, 2));
@@ -298,11 +295,7 @@ class charmap_md_t {
298295
return casesensitive;
299296
}
300297

301-
void dump(ceph::Formatter* f) const {
302-
f->dump_bool("casesensitive", casesensitive);
303-
f->dump_string("normalization", normalization);
304-
f->dump_string("encoding", encoding);
305-
}
298+
void dump(ceph::Formatter* f) const;
306299

307300
constexpr std::string_view get_default_normalization() const {
308301
return DEFAULT_NORMALIZATION;
@@ -480,9 +473,7 @@ class unknown_md_t {
480473
void print(std::ostream& os) const {
481474
os << "unknown_md_t(len=" << payload.size() << ")";
482475
}
483-
void dump(ceph::Formatter* f) const {
484-
f->dump_bool("length", payload.size());
485-
}
476+
void dump(ceph::Formatter* f) const;
486477

487478
private:
488479
std::vector<uint8_t,Allocator<uint8_t>> payload;
@@ -557,12 +548,7 @@ struct optmetadata_singleton {
557548
std::visit([&os](auto& o) { o.print(os); }, optmetadata);
558549
os << ")";
559550
}
560-
void dump(ceph::Formatter* f) const {
561-
f->dump_int("kind", u64kind);
562-
f->open_object_section("metadata");
563-
std::visit([f](auto& o) { o.dump(f); }, optmetadata);
564-
f->close_section();
565-
}
551+
void dump(ceph::Formatter* f) const;
566552

567553
void encode(ceph::buffer::list& bl, uint64_t features) const {
568554
// no versioning, use optmetadata
@@ -608,14 +594,7 @@ struct optmetadata_multiton {
608594
void print(std::ostream& os) const {
609595
os << "optm(len=" << opts.size() << " " << opts << ")";
610596
}
611-
void dump(ceph::Formatter* f) const {
612-
f->dump_bool("length", opts.size());
613-
f->open_array_section("opts");
614-
for (auto& opt : opts) {
615-
f->dump_object("opt", opt);
616-
}
617-
f->close_section();
618-
}
597+
void dump(ceph::Formatter* f) const;
619598

620599
bool has_opt(optkind_t kind) const {
621600
auto f = [kind](auto& o) {
@@ -1149,91 +1128,6 @@ void inode_t<Allocator>::decode(ceph::buffer::list::const_iterator &p)
11491128
DECODE_FINISH(p);
11501129
}
11511130

1152-
template<template<typename> class Allocator>
1153-
void inode_t<Allocator>::dump(ceph::Formatter *f) const
1154-
{
1155-
f->dump_unsigned("ino", ino);
1156-
f->dump_unsigned("rdev", rdev);
1157-
f->dump_stream("ctime") << ctime;
1158-
f->dump_stream("btime") << btime;
1159-
f->dump_unsigned("mode", mode);
1160-
f->dump_unsigned("uid", uid);
1161-
f->dump_unsigned("gid", gid);
1162-
f->dump_unsigned("nlink", nlink);
1163-
1164-
f->open_object_section("dir_layout");
1165-
::dump(dir_layout, f);
1166-
f->close_section();
1167-
1168-
f->dump_object("layout", layout);
1169-
1170-
f->open_array_section("old_pools");
1171-
for (const auto &p : old_pools) {
1172-
f->dump_int("pool", p);
1173-
}
1174-
f->close_section();
1175-
1176-
f->dump_unsigned("size", size);
1177-
f->dump_unsigned("truncate_seq", truncate_seq);
1178-
f->dump_unsigned("truncate_size", truncate_size);
1179-
f->dump_unsigned("truncate_from", truncate_from);
1180-
f->dump_unsigned("truncate_pending", truncate_pending);
1181-
f->dump_stream("mtime") << mtime;
1182-
f->dump_stream("atime") << atime;
1183-
f->dump_unsigned("time_warp_seq", time_warp_seq);
1184-
f->dump_unsigned("change_attr", change_attr);
1185-
f->dump_int("export_pin", export_pin);
1186-
f->dump_float("export_ephemeral_random_pin", export_ephemeral_random_pin);
1187-
f->dump_bool("export_ephemeral_distributed_pin", get_ephemeral_distributed_pin());
1188-
f->dump_bool("quiesce_block", get_quiesce_block());
1189-
1190-
f->open_array_section("client_ranges");
1191-
for (const auto &p : client_ranges) {
1192-
f->open_object_section("client");
1193-
f->dump_unsigned("client", p.first.v);
1194-
p.second.dump(f);
1195-
f->close_section();
1196-
}
1197-
f->close_section();
1198-
1199-
f->open_object_section("dirstat");
1200-
dirstat.dump(f);
1201-
f->close_section();
1202-
1203-
f->open_object_section("rstat");
1204-
rstat.dump(f);
1205-
f->close_section();
1206-
1207-
f->open_object_section("accounted_rstat");
1208-
accounted_rstat.dump(f);
1209-
f->close_section();
1210-
1211-
f->dump_unsigned("version", version);
1212-
f->dump_unsigned("file_data_version", file_data_version);
1213-
f->dump_unsigned("xattr_version", xattr_version);
1214-
f->dump_unsigned("backtrace_version", backtrace_version);
1215-
f->dump_unsigned("inline_data_version", inline_data.version);
1216-
f->dump_unsigned("inline_data_length", inline_data.length());
1217-
1218-
f->dump_string("stray_prior_path", stray_prior_path);
1219-
f->dump_unsigned("max_size_ever", max_size_ever);
1220-
1221-
f->open_object_section("quota");
1222-
quota.dump(f);
1223-
f->close_section();
1224-
1225-
f->dump_object("optmetadata", optmetadata);
1226-
1227-
f->dump_stream("last_scrub_stamp") << last_scrub_stamp;
1228-
f->dump_unsigned("last_scrub_version", last_scrub_version);
1229-
f->dump_unsigned("remote_ino", remote_ino);
1230-
f->open_array_section("referent_inodes");
1231-
for (const auto &ri : referent_inodes) {
1232-
f->dump_unsigned("referent_inode", ri);
1233-
}
1234-
f->close_section();
1235-
}
1236-
12371131
template<template<typename> class Allocator>
12381132
void inode_t<Allocator>::generate_test_instances(std::list<inode_t*>& ls)
12391133
{

src/mds/mdstypes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "include/fs_types.h"
2020

2121
#include "include/ceph_assert.h"
22+
#include "include/cephfs/dump.h"
2223
#include "include/cephfs/types.h"
2324

2425
#define MDS_PORT_CACHE 0x200

0 commit comments

Comments
 (0)