-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSnapServer.h
81 lines (69 loc) · 2.15 KB
/
SnapServer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_SNAPSERVER_H
#define CEPH_SNAPSERVER_H
#include "MDSTableServer.h"
#include "snap.h"
class MDS;
class SnapServer : public MDSTableServer {
public:
protected:
snapid_t last_snap;
map<snapid_t, SnapInfo> snaps;
map<int, set<snapid_t> > need_to_purge;
map<version_t, SnapInfo> pending_create;
map<version_t, pair<snapid_t,snapid_t> > pending_destroy; // (removed_snap, seq)
set<version_t> pending_noop;
version_t last_checked_osdmap;
public:
SnapServer(MDS *m) : MDSTableServer(m, TABLE_SNAP),
last_checked_osdmap(0) { }
void reset_state();
void encode_server_state(bufferlist& bl) {
ENCODE_START(3, 3, bl);
::encode(last_snap, bl);
::encode(snaps, bl);
::encode(need_to_purge, bl);
::encode(pending_create, bl);
::encode(pending_destroy, bl);
::encode(pending_noop, bl);
ENCODE_FINISH(bl);
}
void decode_server_state(bufferlist::iterator& bl) {
DECODE_START_LEGACY_COMPAT_LEN(3, 3, 3, bl);
::decode(last_snap, bl);
::decode(snaps, bl);
::decode(need_to_purge, bl);
::decode(pending_create, bl);
if (struct_v >= 2)
::decode(pending_destroy, bl);
else {
map<version_t, snapid_t> t;
::decode(t, bl);
for (map<version_t, snapid_t>::iterator p = t.begin(); p != t.end(); ++p)
pending_destroy[p->first].first = p->second;
}
::decode(pending_noop, bl);
DECODE_FINISH(bl);
}
// server bits
void _prepare(bufferlist &bl, uint64_t reqid, int bymds);
bool _is_prepared(version_t tid);
bool _commit(version_t tid, MMDSTableRequest *req=NULL);
void _rollback(version_t tid);
void _server_update(bufferlist& bl);
void handle_query(MMDSTableRequest *m);
void check_osd_map(bool force);
};
#endif