X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Fmds%2FSnapServer.h;fp=src%2Fceph%2Fsrc%2Fmds%2FSnapServer.h;h=3eceaaef7a7fb18d1e6d67c40b888effbbf769b8;hb=812ff6ca9fcd3e629e49d4328905f33eee8ca3f5;hp=0000000000000000000000000000000000000000;hpb=15280273faafb77777eab341909a3f495cf248d9;p=stor4nfv.git diff --git a/src/ceph/src/mds/SnapServer.h b/src/ceph/src/mds/SnapServer.h new file mode 100644 index 0000000..3eceaae --- /dev/null +++ b/src/ceph/src/mds/SnapServer.h @@ -0,0 +1,94 @@ +// -*- 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 + * + * 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 MDSRank; +class MonClient; + +class SnapServer : public MDSTableServer { +protected: + MonClient *mon_client; + snapid_t last_snap; + map snaps; + map > need_to_purge; + + map pending_update; + map > pending_destroy; // (removed_snap, seq) + set pending_noop; + + version_t last_checked_osdmap; + +public: + SnapServer(MDSRank *m, MonClient *monc) + : MDSTableServer(m, TABLE_SNAP), mon_client(monc), last_checked_osdmap(0) + {} + + void reset_state() override; + void encode_server_state(bufferlist& bl) const override { + ENCODE_START(3, 3, bl); + ::encode(last_snap, bl); + ::encode(snaps, bl); + ::encode(need_to_purge, bl); + ::encode(pending_update, bl); + ::encode(pending_destroy, bl); + ::encode(pending_noop, bl); + ENCODE_FINISH(bl); + } + void decode_server_state(bufferlist::iterator& bl) override { + DECODE_START_LEGACY_COMPAT_LEN(3, 3, 3, bl); + ::decode(last_snap, bl); + ::decode(snaps, bl); + ::decode(need_to_purge, bl); + ::decode(pending_update, bl); + if (struct_v >= 2) + ::decode(pending_destroy, bl); + else { + map t; + ::decode(t, bl); + for (map::iterator p = t.begin(); p != t.end(); ++p) + pending_destroy[p->first].first = p->second; + } + ::decode(pending_noop, bl); + DECODE_FINISH(bl); + } + + // To permit enc/decoding in isolation in dencoder + SnapServer() : MDSTableServer(NULL, TABLE_SNAP), last_checked_osdmap(0) {} + void encode(bufferlist& bl) const { + encode_server_state(bl); + } + void decode(bufferlist::iterator& bl) { + decode_server_state(bl); + } + void dump(Formatter *f) const; + static void generate_test_instances(list& ls); + + // server bits + void _prepare(bufferlist &bl, uint64_t reqid, mds_rank_t bymds) override; + bool _is_prepared(version_t tid) const; + bool _commit(version_t tid, MMDSTableRequest *req=NULL) override; + void _rollback(version_t tid) override; + void _server_update(bufferlist& bl) override; + void handle_query(MMDSTableRequest *m) override; + + void check_osd_map(bool force); +}; +WRITE_CLASS_ENCODER(SnapServer) + +#endif