From c997c2f88702df3306889b9d3e831e6f42526bf8 Mon Sep 17 00:00:00 2001 From: sageweil Date: Thu, 27 Sep 2007 22:22:06 +0000 Subject: [PATCH] goof from merge git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1850 29311d96-e01e-0410-9327-a35deaab8ce9 --- branches/sage/mds/dupstore.cc | 102 ++++++++++++++++++++++++++++ branches/sage/mds/extractosdmaps.cc | 64 +++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100644 branches/sage/mds/dupstore.cc create mode 100644 branches/sage/mds/extractosdmaps.cc diff --git a/branches/sage/mds/dupstore.cc b/branches/sage/mds/dupstore.cc new file mode 100644 index 0000000000000..d43f935cb50cc --- /dev/null +++ b/branches/sage/mds/dupstore.cc @@ -0,0 +1,102 @@ +// -*- 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. + * + */ + +#include +#include "ebofs/Ebofs.h" +#include "osd/FakeStore.h" + + +int dupstore(ObjectStore* src, ObjectStore* dst) +{ + if (src->mount() < 0) return 1; + if (dst->mkfs() < 0) return 1; + if (dst->mount() < 0) return 1; + + // objects + list objects; + src->list_objects(objects); + int num = objects.size(); + cout << num << " objects" << std::endl; + int i = 1; + for (list::iterator p = objects.begin(); p != objects.end(); ++p) { + bufferlist bl; + src->read(*p, 0, 0, bl); + cout << "object " << i++ << "/" << num << " " << *p << " = " << bl.length() << " bytes" << std::endl; + dst->write(*p, 0, bl.length(), bl, 0); + map attrs; + src->getattrs(*p, attrs); + dst->setattrs(*p, attrs); + } + + // collections + list collections; + src->list_collections(collections); + num = collections.size(); + cout << num << " collections" << std::endl; + i = 1; + for (list::iterator p = collections.begin(); + p != collections.end(); + ++p) { + dst->create_collection(*p, 0); + map attrs; + src->collection_getattrs(*p, attrs); + dst->collection_setattrs(*p, attrs); + list o; + src->collection_list(*p, o); + int numo = 0; + for (list::iterator q = o.begin(); q != o.end(); q++) { + dst->collection_add(*p, *q, 0); + numo++; + } + cout << "collection " << i++ << "/" << num << " " << hex << *p << dec << " = " << numo << " objects" << std::endl; + } + + + src->umount(); + dst->umount(); + return 0; +} + +void usage() +{ + cerr << "usage: dup.ebofs (ebofs|fakestore) src (ebofs|fakestore) dst" << std::endl; + exit(0); +} + +int main(int argc, char **argv) +{ + vector args; + argv_to_vec(argc, argv, args); + parse_config_options(args); + + // args + if (args.size() != 4) + usage(); + + ObjectStore *src, *dst; + + if (strcmp(args[0], "ebofs") == 0) + src = new Ebofs(args[1]); + else if (strcmp(args[0], "fakestore") == 0) + src = new FakeStore(args[1]); + else usage(); + + if (strcmp(args[2], "ebofs") == 0) + dst = new Ebofs(args[3]); + else if (strcmp(args[2], "fakestore") == 0) + dst = new FakeStore(args[3]); + else usage(); + + return dupstore(src, dst); +} diff --git a/branches/sage/mds/extractosdmaps.cc b/branches/sage/mds/extractosdmaps.cc new file mode 100644 index 0000000000000..bc8ec91984d1e --- /dev/null +++ b/branches/sage/mds/extractosdmaps.cc @@ -0,0 +1,64 @@ +// -*- 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. + * + */ + +#include +#include +#include + +#include +#include +#include +using namespace std; + +#include "config.h" + +#include "mon/MonMap.h" + +#include "ebofs/Ebofs.h" + +#include "osd/OSD.h" +#include "mon/MonitorStore.h" + +int main(int argc, char **argv) +{ + vector args; + argv_to_vec(argc, argv, args); + + Ebofs eb("dev/osd0"); + eb.mount(); + MonitorStore ms("mondata/mon0"); + ms.mount(); + + epoch_t e = 1; + while (1) { + bufferlist bl; + object_t oid = OSD::get_osdmap_object_name(e); + eb.read(oid, 0, 0, bl); + if (bl.length() == 0) break; + cout << "saving epoch " << e << std::endl; + + bufferlist ibl; + oid = OSD::get_inc_osdmap_object_name(e); + eb.read(oid, 0, 0, ibl); + + ms.put_bl_sn(ibl, "osdmap", e); + ms.put_bl_sn(bl, "osdmap_full", e); + e++; + } + + eb.umount(); + //ms.umount(); + + return 0; +} -- 2.39.5