X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=metadata.cc;h=e1ea1aa18b87a04bd3db29ac251a4c58c9e5db85;hb=974240b635af9cf2b94e2f1f3c02beab662a189d;hp=cb3dabb89ab22df541330c89c94cadc56f10695e;hpb=8cbb089d5463234be70eb7029e5e0bf050c4f7c5;p=cumulus.git diff --git a/metadata.cc b/metadata.cc index cb3dabb..e1ea1aa 100644 --- a/metadata.cc +++ b/metadata.cc @@ -1,17 +1,37 @@ -/* 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 + * + * 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 +#include #include #include #include #include "metadata.h" +#include "localdb.h" #include "ref.h" #include "store.h" #include "util.h" @@ -29,6 +49,7 @@ static const size_t LBS_METADATA_BLOCK_SIZE = 65536; 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 @@ -97,7 +118,7 @@ MetadataWriter::MetadataWriter(TarSegmentStore *store, { 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; @@ -107,7 +128,7 @@ MetadataWriter::MetadataWriter(TarSegmentStore *store, if (statcache_out == NULL) { fprintf(stderr, "Error opening statcache %s: %m\n", statcache_tmp_path.c_str()); - throw IOException("Error opening statcache"); + fatal("Error opening statcache"); } old_metadata_eof = false; @@ -275,8 +296,10 @@ void MetadataWriter::metadata_flush() 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 @@ -324,6 +347,7 @@ void MetadataWriter::metadata_flush() 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; @@ -378,6 +402,7 @@ ObjectReference MetadataWriter::close() 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;