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"
24 class MMDSTableRequest;
26 class MDSTableClient {
36 struct _pending_prepare {
37 MDSInternalContextBase *onfinish;
42 _pending_prepare() : onfinish(0), ptid(0), pbl(0) {}
43 _pending_prepare(MDSInternalContextBase *c, version_t *pt, bufferlist *pb, bufferlist& m) :
44 onfinish(c), ptid(pt), pbl(pb), mutation(m) {}
47 map<uint64_t, _pending_prepare> pending_prepare;
48 map<version_t, uint64_t> prepared_update;
49 list<_pending_prepare> waiting_for_reqid;
52 map<version_t, LogSegment*> pending_commit;
53 map<version_t, list<MDSInternalContextBase*> > ack_waiters;
55 void handle_reply(class MMDSTableQuery *m);
56 void _logged_ack(version_t tid);
57 friend class C_LoggedAck;
60 MDSTableClient(MDSRank *m, int tab) :
61 mds(m), table(tab), last_reqid(~0ULL), server_ready(false) {}
62 virtual ~MDSTableClient() {}
64 void handle_request(MMDSTableRequest *m);
66 void _prepare(bufferlist& mutation, version_t *ptid, bufferlist *pbl, MDSInternalContextBase *onfinish);
67 void commit(version_t tid, LogSegment *ls);
69 void resend_commits();
70 void resend_prepares();
72 // for recovery (by me)
73 void got_journaled_agree(version_t tid, LogSegment *ls);
74 void got_journaled_ack(version_t tid);
76 bool has_committed(version_t tid) const {
77 return pending_commit.count(tid) == 0;
79 void wait_for_ack(version_t tid, MDSInternalContextBase *c) {
80 ack_waiters[tid].push_back(c);
83 void handle_mds_failure(mds_rank_t mds);
85 // child must implement
86 virtual void resend_queries() = 0;
87 virtual void handle_query_result(MMDSTableRequest *m) = 0;
89 // and friendly front-end for _prepare.