]> git.proxmox.com Git - ceph.git/blob - ceph/src/mds/MDSTable.h
bump version to 12.2.12-pve1
[ceph.git] / ceph / src / mds / MDSTable.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
15 #ifndef CEPH_MDSTABLE_H
16 #define CEPH_MDSTABLE_H
17
18 #include "mdstypes.h"
19 #include "mds_table_types.h"
20 #include "include/buffer_fwd.h"
21
22 class MDSRank;
23 class Context;
24 class MDSInternalContextBase;
25
26 class MDSTable {
27 public:
28 MDSRank *mds;
29 protected:
30 const char *table_name;
31 bool per_mds;
32 mds_rank_t rank;
33
34 object_t get_object_name() const;
35
36 static const int STATE_UNDEF = 0;
37 static const int STATE_OPENING = 1;
38 static const int STATE_ACTIVE = 2;
39 //static const int STATE_COMMITTING = 3;
40 int state;
41
42 version_t version, committing_version, committed_version, projected_version;
43
44 map<version_t, list<MDSInternalContextBase*> > waitfor_save;
45
46 public:
47 MDSTable(MDSRank *m, const char *n, bool is_per_mds) :
48 mds(m), table_name(n), per_mds(is_per_mds), rank(MDS_RANK_NONE),
49 state(STATE_UNDEF),
50 version(0), committing_version(0), committed_version(0), projected_version(0) {}
51 virtual ~MDSTable() {}
52
53 void set_rank(mds_rank_t r)
54 {
55 rank = r;
56 }
57
58 version_t get_version() const { return version; }
59 version_t get_committed_version() const { return committed_version; }
60 version_t get_committing_version() const { return committing_version; }
61 version_t get_projected_version() const { return projected_version; }
62
63 void force_replay_version(version_t v) {
64 version = projected_version = v;
65 }
66
67 //version_t project_version() { return ++projected_version; }
68 //version_t inc_version() { return ++version; }
69
70 // load/save from disk (hack)
71 bool is_undef() const { return state == STATE_UNDEF; }
72 bool is_active() const { return state == STATE_ACTIVE; }
73 bool is_opening() const { return state == STATE_OPENING; }
74
75 void reset();
76 void save(MDSInternalContextBase *onfinish=0, version_t need=0);
77 void save_2(int r, version_t v);
78
79 void shutdown() {
80 if (is_active()) save(0);
81 }
82
83 void load(MDSInternalContextBase *onfinish);
84 void load_2(int, bufferlist&, Context *onfinish);
85
86 // child must overload these
87 virtual void reset_state() = 0;
88 virtual void decode_state(bufferlist::iterator& p) = 0;
89 virtual void encode_state(bufferlist& bl) const = 0;
90
91 friend class C_IO_MT_Load;
92 friend class C_IO_MT_Save;
93 };
94
95 #endif