]>
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) 2017 Red Hat Ltd | |
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 FS_COMMANDS_H_ | |
17 | #define FS_COMMANDS_H_ | |
18 | ||
19 | #include "Monitor.h" | |
11fdf7f2 | 20 | #include "CommandHandler.h" |
7c673cae FG |
21 | |
22 | #include "osd/OSDMap.h" | |
23 | #include "mds/FSMap.h" | |
24 | ||
25 | #include <string> | |
522d829b | 26 | #include <ostream> |
7c673cae | 27 | |
11fdf7f2 | 28 | class FileSystemCommandHandler : protected CommandHandler |
7c673cae FG |
29 | { |
30 | protected: | |
31 | std::string prefix; | |
32 | ||
92f5a8d4 TL |
33 | enum { |
34 | POOL_METADATA, | |
35 | POOL_DATA_DEFAULT, | |
36 | POOL_DATA_EXTRA, | |
37 | }; | |
7c673cae FG |
38 | /** |
39 | * Return 0 if the pool is suitable for use with CephFS, or | |
40 | * in case of errors return a negative error code, and populate | |
522d829b | 41 | * the passed ostream with an explanation. |
7c673cae FG |
42 | * |
43 | * @param metadata whether the pool will be for metadata (stricter checks) | |
44 | */ | |
45 | int _check_pool( | |
46 | OSDMap &osd_map, | |
47 | const int64_t pool_id, | |
92f5a8d4 | 48 | int type, |
c07f9fc5 | 49 | bool force, |
1e59de90 TL |
50 | std::ostream *ss, |
51 | bool allow_overlay = false) const; | |
7c673cae | 52 | |
f67539c2 | 53 | virtual std::string const &get_prefix() const {return prefix;} |
7c673cae FG |
54 | |
55 | public: | |
56 | FileSystemCommandHandler(const std::string &prefix_) | |
57 | : prefix(prefix_) | |
58 | {} | |
59 | ||
60 | virtual ~FileSystemCommandHandler() | |
61 | {} | |
62 | ||
f67539c2 | 63 | int is_op_allowed(const MonOpRequestRef& op, const FSMap& fsmap, |
522d829b | 64 | const cmdmap_t& cmdmap, std::ostream &ss) const; |
f67539c2 TL |
65 | |
66 | int can_handle(std::string const &prefix_, MonOpRequestRef& op, FSMap& fsmap, | |
522d829b | 67 | const cmdmap_t& cmdmap, std::ostream &ss) const |
7c673cae | 68 | { |
f67539c2 TL |
69 | if (get_prefix() != prefix_) { |
70 | return 0; | |
71 | } | |
72 | ||
73 | if (get_prefix() == "fs new" || get_prefix() == "fs flag set") { | |
74 | return 1; | |
75 | } | |
76 | ||
77 | return is_op_allowed(op, fsmap, cmdmap, ss); | |
7c673cae FG |
78 | } |
79 | ||
c07f9fc5 FG |
80 | static std::list<std::shared_ptr<FileSystemCommandHandler> > load(Paxos *paxos); |
81 | ||
82 | virtual bool batched_propose() { | |
83 | return false; | |
84 | } | |
7c673cae FG |
85 | |
86 | virtual int handle( | |
87 | Monitor *mon, | |
88 | FSMap &fsmap, | |
89 | MonOpRequestRef op, | |
11fdf7f2 | 90 | const cmdmap_t& cmdmap, |
522d829b | 91 | std::ostream &ss) = 0; |
7c673cae FG |
92 | }; |
93 | ||
94 | #endif |