]>
git.proxmox.com Git - ceph.git/blob - ceph/src/mds/MDSTableClient.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_MDSTABLECLIENT_H
16 #define CEPH_MDSTABLECLIENT_H
18 #include "include/types.h"
19 #include "MDSContext.h"
20 #include "mds_table_types.h"
22 #include "messages/MMDSTableRequest.h"
27 class MDSTableClient
{
29 MDSTableClient(MDSRank
*m
, int tab
) :
31 virtual ~MDSTableClient() {}
33 void handle_request(const cref_t
<MMDSTableRequest
> &m
);
35 void _prepare(bufferlist
& mutation
, version_t
*ptid
, bufferlist
*pbl
, MDSContext
*onfinish
);
36 void commit(version_t tid
, LogSegment
*ls
);
38 void resend_commits();
39 void resend_prepares();
41 // for recovery (by me)
42 void got_journaled_agree(version_t tid
, LogSegment
*ls
);
43 void got_journaled_ack(version_t tid
);
45 bool has_committed(version_t tid
) const {
46 return pending_commit
.count(tid
) == 0;
48 void wait_for_ack(version_t tid
, MDSContext
*c
) {
49 ack_waiters
[tid
].push_back(c
);
52 std::set
<version_t
> get_journaled_tids() const {
53 std::set
<version_t
> tids
;
54 for (auto p
: pending_commit
)
59 void handle_mds_failure(mds_rank_t mds
);
61 // child must implement
62 virtual void resend_queries() = 0;
63 virtual void handle_query_result(const cref_t
<MMDSTableRequest
> &m
) = 0;
64 virtual void handle_notify_prep(const cref_t
<MMDSTableRequest
> &m
) = 0;
65 virtual void notify_commit(version_t tid
) = 0;
68 struct _pending_prepare
{
70 _pending_prepare(MDSContext
*c
, version_t
*pt
, bufferlist
*pb
, bufferlist
& m
) :
71 onfinish(c
), ptid(pt
), pbl(pb
), mutation(m
) {}
73 MDSContext
*onfinish
= nullptr;
74 version_t
*ptid
= nullptr;
75 bufferlist
*pbl
= nullptr;
79 friend class C_LoggedAck
;
81 void handle_reply(class MMDSTableQuery
*m
);
82 void _logged_ack(version_t tid
);
87 uint64_t last_reqid
= ~0ULL;
89 bool server_ready
= false;
91 std::map
<uint64_t, _pending_prepare
> pending_prepare
;
92 std::map
<version_t
, uint64_t> prepared_update
;
93 std::list
<_pending_prepare
> waiting_for_reqid
;
96 std::map
<version_t
, LogSegment
*> pending_commit
;
97 std::map
<version_t
, MDSContext::vec
> ack_waiters
;