]>
git.proxmox.com Git - ceph.git/blob - 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
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
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.
15 #ifndef CEPH_MDSTABLE_H
16 #define CEPH_MDSTABLE_H
19 #include "mds_table_types.h"
20 #include "include/buffer_fwd.h"
24 class MDSInternalContextBase
;
30 const char *table_name
;
34 object_t
get_object_name() const;
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;
42 version_t version
, committing_version
, committed_version
, projected_version
;
44 map
<version_t
, list
<MDSInternalContextBase
*> > waitfor_save
;
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
),
50 version(0), committing_version(0), committed_version(0), projected_version(0) {}
51 virtual ~MDSTable() {}
53 void set_rank(mds_rank_t r
)
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
; }
63 void force_replay_version(version_t v
) {
64 version
= projected_version
= v
;
67 //version_t project_version() { return ++projected_version; }
68 //version_t inc_version() { return ++version; }
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
; }
76 void save(MDSInternalContextBase
*onfinish
=0, version_t need
=0);
77 void save_2(int r
, version_t v
);
80 if (is_active()) save(0);
83 void load(MDSInternalContextBase
*onfinish
);
84 void load_2(int, bufferlist
&, Context
*onfinish
);
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;