From 7be9be14947543d6d46d79056e3ef8b0b912eb97 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Tue, 4 Jun 2019 10:38:58 +0100 Subject: [PATCH] [space-maps/noop] Add the noops space map Used when we know we're npt modifying the metadata. --- persistent-data/space-maps/noop.h | 103 ++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 persistent-data/space-maps/noop.h diff --git a/persistent-data/space-maps/noop.h b/persistent-data/space-maps/noop.h new file mode 100644 index 0000000..500dae8 --- /dev/null +++ b/persistent-data/space-maps/noop.h @@ -0,0 +1,103 @@ +// Copyright (C) 2019 Red Hat, Inc. All rights reserved. +// +// This file is part of the thin-provisioning-tools source. +// +// thin-provisioning-tools 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 3 of +// the License, or (at your option) any later version. +// +// thin-provisioning-tools 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 thin-provisioning-tools. If not, see +// . + +#ifndef NOOP_MAP_H +#define NOOP_MAP_H + +#include "persistent-data/space_map.h" + +//---------------------------------------------------------------- + +namespace persistent_data { + class noop_map : public checked_space_map { + public: + typedef boost::shared_ptr ptr; + + block_address get_nr_blocks() const { + fail(); + return 0; + } + + block_address get_nr_free() const { + fail(); + return 0; + } + + ref_t get_count(block_address b) const { + fail(); + return 0; + } + + void set_count(block_address b, ref_t c) { + fail(); + } + + void commit() { + fail(); + } + + void inc(block_address b) { + fail(); + } + + void dec(block_address b) { + fail(); + } + + maybe_block find_free(span_iterator &it) { + fail(); + return 0; + } + + bool count_possibly_greater_than_one(block_address b) const { + fail(); + return false; + } + + void extend(block_address extra_blocks) { + fail(); + } + + void count_metadata(block_counter &bc) const { + fail(); + } + + size_t root_size() const { + fail(); + return 0; + } + + virtual void copy_root(void *dest, size_t len) const { + fail(); + } + + checked_space_map::ptr clone() const { + return ptr(new noop_map()); + } + + private: + void fail() const { + throw std::runtime_error("noop space map used"); + } + }; +} + +//---------------------------------------------------------------- + +#endif +