-/* LBS: An LFS-inspired filesystem backup system
- * Copyright (C) 2007 Michael Vrable
+/* Cumulus: Smart Filesystem Backup to Dumb Servers
*
- * Handling of metadata written to backup snapshots. This manages the writing
+ * Copyright (C) 2007-2008 The Regents of the University of California
+ * Written by Michael Vrable <mvrable@cs.ucsd.edu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+/* Handling of metadata written to backup snapshots. This manages the writing
* of file metadata into new backup snapshots, including breaking the metadata
* log apart across separate objects. Eventually this should include unified
* handling of the statcache, and re-use of metadata between snapshots.
*/
+#include <stdlib.h>
+#include <string.h>
#include <string>
#include <iostream>
#include <map>
#include "metadata.h"
+#include "localdb.h"
#include "ref.h"
#include "store.h"
#include "util.h"
bool flag_full_metadata = false;
/* TODO: Move to header file */
+extern LocalDb *db;
void add_segment(const string& segment);
/* Like strcmp, but sorts in the order that files will be visited in the
{
statcache_path = path;
statcache_path += "/statcache2";
- if (snapshot_scheme != NULL)
+ if (snapshot_scheme != NULL && strlen(snapshot_scheme) > 0)
statcache_path = statcache_path + "-" + snapshot_scheme;
statcache_tmp_path = statcache_path + "." + snapshot_name;
i != items.end(); ++i) {
// If indirectly referencing any other metadata logs, be sure those
// segments are properly referenced.
- if (i->reused)
+ if (i->reused) {
add_segment(i->ref.get_segment());
+ db->UseSegment(i->ref.get_segment(), 1.0);
+ }
// Write out an indirect reference to any previous objects which could
// be reused
ObjectReference ref = meta->get_ref();
metadata_root << "@" << ref.to_string() << "\n";
add_segment(ref.get_segment());
+ db->UseSegment(ref.get_segment(), 1.0);
delete meta;
root->write(store);
root->checksum();
add_segment(root->get_ref().get_segment());
+ db->UseSegment(root->get_ref().get_segment(), 1.0);
ObjectReference ref = root->get_ref();
delete root;