]>
Commit | Line | Data |
---|---|---|
28e407b8 AA |
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 | #ifndef CEPH_PAXOS_FSMAP_H | |
16 | #define CEPH_PAXOS_FSMAP_H | |
17 | ||
18 | #include "mds/FSMap.h" | |
19 | #include "mds/MDSMap.h" | |
20 | ||
21 | #include "include/assert.h" | |
22 | ||
23 | class PaxosFSMap { | |
24 | public: | |
25 | virtual ~PaxosFSMap() {} | |
26 | ||
27 | const FSMap &get_pending_fsmap() const { assert(is_leader()); return pending_fsmap; } | |
28 | const FSMap &get_fsmap() const { return fsmap; } | |
29 | ||
30 | virtual bool is_leader() const = 0; | |
31 | ||
32 | protected: | |
33 | FSMap &get_pending_fsmap_writeable() { assert(is_leader()); return pending_fsmap; } | |
34 | ||
35 | /* get_working_fsmap returns the "relevant" version of the fsmap (see MDSMonitor.cc history) | |
36 | * used depending in helper methods of MDSMonitor.cc. | |
37 | * | |
38 | * This is technically evil and will be removed in the future. | |
39 | * | |
40 | * See discussion: https://github.com/ceph/ceph/pull/21458#discussion_r182081366 | |
41 | */ | |
42 | const FSMap &get_working_fsmap() const { return is_leader() ? pending_fsmap : fsmap; } | |
43 | ||
44 | FSMap &create_pending() { | |
45 | assert(is_leader()); | |
46 | pending_fsmap = fsmap; | |
47 | pending_fsmap.epoch++; | |
48 | return pending_fsmap; | |
49 | } | |
50 | ||
51 | void decode(bufferlist &bl) { | |
52 | fsmap.decode(bl); | |
53 | pending_fsmap = FSMap(); /* nuke it to catch invalid access */ | |
54 | } | |
55 | ||
56 | private: | |
57 | /* Keep these PRIVATE to prevent unprotected manipulation. */ | |
58 | FSMap fsmap; /* the current epoch */ | |
59 | FSMap pending_fsmap; /* the next epoch */ | |
60 | }; | |
61 | ||
62 | ||
63 | #endif |