]> git.proxmox.com Git - ceph.git/blob - ceph/src/mon/FSCommands.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / mon / FSCommands.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) 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"
20 #include "CommandHandler.h"
21
22 #include "osd/OSDMap.h"
23 #include "mds/FSMap.h"
24
25 #include <string>
26 #include <ostream>
27
28 class FileSystemCommandHandler : protected CommandHandler
29 {
30 protected:
31 std::string prefix;
32
33 enum {
34 POOL_METADATA,
35 POOL_DATA_DEFAULT,
36 POOL_DATA_EXTRA,
37 };
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
41 * the passed ostream with an explanation.
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,
48 int type,
49 bool force,
50 std::ostream *ss,
51 bool allow_overlay = false) const;
52
53 virtual std::string const &get_prefix() const {return prefix;}
54
55 public:
56 FileSystemCommandHandler(const std::string &prefix_)
57 : prefix(prefix_)
58 {}
59
60 virtual ~FileSystemCommandHandler()
61 {}
62
63 int is_op_allowed(const MonOpRequestRef& op, const FSMap& fsmap,
64 const cmdmap_t& cmdmap, std::ostream &ss) const;
65
66 int can_handle(std::string const &prefix_, MonOpRequestRef& op, FSMap& fsmap,
67 const cmdmap_t& cmdmap, std::ostream &ss) const
68 {
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);
78 }
79
80 static std::list<std::shared_ptr<FileSystemCommandHandler> > load(Paxos *paxos);
81
82 virtual bool batched_propose() {
83 return false;
84 }
85
86 virtual int handle(
87 Monitor *mon,
88 FSMap &fsmap,
89 MonOpRequestRef op,
90 const cmdmap_t& cmdmap,
91 std::ostream &ss) = 0;
92 };
93
94 #endif