mds/LogEvent.cc \
mds/MDSTable.cc \
mds/IdAllocator.cc \
+ mds/SnapTable.cc \
mds/SessionMap.cc \
mds/MDLog.cc
#include "MDCache.h"
#include "MDLog.h"
#include "MDBalancer.h"
-#include "IdAllocator.h"
#include "Migrator.h"
#include "AnchorTable.h"
#include "AnchorClient.h"
+#include "IdAllocator.h"
+#include "SnapTable.h"
+
#include "common/Logger.h"
#include "common/LogType.h"
idalloc = new IdAllocator(this);
anchortable = new AnchorTable(this);
+ snaptable = new SnapTable(this);
server = new Server(this);
locker = new Locker(this, mdcache);
if (balancer) { delete balancer; balancer = NULL; }
if (idalloc) { delete idalloc; idalloc = NULL; }
if (anchortable) { delete anchortable; anchortable = NULL; }
+ if (snaptable) { delete snaptable; snaptable = NULL; }
if (anchorclient) { delete anchorclient; anchorclient = NULL; }
if (osdmap) { delete osdmap; osdmap = 0; }
if (mdsmap) { delete mdsmap; mdsmap = 0; }
anchortable->create_fresh();
anchortable->save(fin->new_sub());
}
+
+ if (whoami == 0) {
+ dout(10) << "boot_create creating fresh snaptable" << dendl;
+ snaptable->reset();
+ snaptable->save(fin->new_sub());
+ }
}
void MDS::creating_done()
dout(2) << "boot_start " << step << ": opening anchor table" << dendl;
anchortable->load(gather->new_sub());
}
+ if (whoami == 0) {
+ dout(2) << "boot_start " << step << ": opening snap table" << dendl;
+ snaptable->load(gather->new_sub());
+ }
dout(2) << "boot_start " << step << ": opening mds log" << dendl;
mdlog->open(gather->new_sub());
class MDLog;
class MDBalancer;
class IdAllocator;
+class SnapTable;
class CInode;
class CDir;
AnchorTable *anchortable;
AnchorClient *anchorclient;
+ SnapTable *snaptable;
+
Logger *logger, *logger2;
--- /dev/null
+// -*- 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 <sage@newdream.net>
+ *
+ * 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.
+ *
+ */
+
+#include "SnapTable.h"
+#include "MDS.h"
+
+#include "include/types.h"
+
+#include "config.h"
+
+#define dout(x) if (x <= g_conf.debug_mds) *_dout << dbeginl << g_clock.now() << " mds" << mds->get_nodeid() << ".snap: "
+
+void SnapTable::init_inode()
+{
+ ino = MDS_INO_SNAPTABLE;
+ layout = g_default_file_layout;
+}
+
+void SnapTable::reset_state()
+{
+ last_snap = 0;
+ snaps.clear();
+ pending_removal.clear();
+}
+
+snapid_t SnapTable::create(inodeno_t base, const string& name, utime_t stamp)
+{
+ assert(is_active());
+
+ snapid_t sn = ++last_snap;
+ snaps[sn].base = base;
+ snaps[sn].name = name;
+ snaps[sn].stamp = stamp;
+ version++;
+
+ dout(10) << "create(" << base << "," << name << ") = " << sn << dendl;
+
+ return sn;
+}
+
+void SnapTable::remove(snapid_t sn)
+{
+ assert(is_active());
+
+ snaps.erase(sn);
+ pending_removal.insert(sn);
+ version++;
+}
+
--- /dev/null
+// -*- 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 <sage@newdream.net>
+ *
+ * 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 __SNAPTABLE_H
+#define __SNAPTABLE_H
+
+#include "MDSTable.h"
+#include "include/interval_set.h"
+
+class MDS;
+
+class SnapTable : public MDSTable {
+public:
+ struct snapinfo {
+ inodeno_t base;
+ utime_t stamp;
+ string name;
+
+ void encode(bufferlist& bl) const {
+ ::encode(base, bl);
+ ::encode(stamp, bl);
+ ::encode(name, bl);
+ }
+ void decode(bufferlist::iterator& bl) {
+ ::decode(base, bl);
+ ::decode(stamp, bl);
+ ::decode(name, bl);
+ }
+ };
+ WRITE_CLASS_ENCODER(snapinfo)
+
+protected:
+ snapid_t last_snap;
+ map<snapid_t, snapinfo> snaps;
+ set<snapid_t> pending_removal;
+
+public:
+ SnapTable(MDS *m) : MDSTable(m, "snap") { }
+
+ // alloc or reclaim ids
+ snapid_t create(inodeno_t base, const string& name, utime_t stamp);
+ void remove(snapid_t sn);
+
+ void init_inode();
+ void reset_state();
+ void encode_state(bufferlist& bl) {
+ ::encode(last_snap, bl);
+ ::encode(snaps, bl);
+ ::encode(pending_removal, bl);
+ }
+ void decode_state(bufferlist::iterator& bl) {
+ ::decode(last_snap, bl);
+ ::decode(snaps, bl);
+ ::decode(pending_removal, bl);
+ }
+};
+WRITE_CLASS_ENCODER(SnapTable::snapinfo)
+
+#endif
#define MDS_INO_ROOT 1
#define MDS_INO_PGTABLE 2
#define MDS_INO_ANCHORTABLE 3
+#define MDS_INO_SNAPTABLE 4
#define MDS_INO_LOG_OFFSET (1*MAX_MDS)
#define MDS_INO_IDS_OFFSET (2*MAX_MDS)