1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/libfsserver/include/fsserver/copied_page_mapper.h Sat May 28 00:59:04 2022 +0200
1.3 @@ -0,0 +1,78 @@
1.4 +/*
1.5 + * A page mapper providing copied memory pages or deferring to another page
1.6 + * mapper to satisfy file accesses.
1.7 + *
1.8 + * Copyright (C) 2021, 2022 Paul Boddie <paul@boddie.org.uk>
1.9 + *
1.10 + * This program is free software; you can redistribute it and/or
1.11 + * modify it under the terms of the GNU General Public License as
1.12 + * published by the Free Software Foundation; either version 2 of
1.13 + * the License, or (at your option) any later version.
1.14 + *
1.15 + * This program is distributed in the hope that it will be useful,
1.16 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.17 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.18 + * GNU General Public License for more details.
1.19 + *
1.20 + * You should have received a copy of the GNU General Public License
1.21 + * along with this program; if not, write to the Free Software
1.22 + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
1.23 + * Boston, MA 02110-1301, USA
1.24 + */
1.25 +
1.26 +#pragma once
1.27 +
1.28 +#include <fsserver/access_map.h>
1.29 +#include <fsserver/generic_page_mapper.h>
1.30 +#include <mem/memory_incremental.h>
1.31 +
1.32 +
1.33 +
1.34 +/* A special flexpage class for copied flexpages. */
1.35 +
1.36 +class CopiedFlexpage : public Flexpage
1.37 +{
1.38 +public:
1.39 + explicit CopiedFlexpage(Region *region = NULL);
1.40 +};
1.41 +
1.42 +
1.43 +
1.44 +/* A file mapper, associating flexpages with file regions. */
1.45 +
1.46 +class CopiedPageMapper : public GenericPageMapper
1.47 +{
1.48 +protected:
1.49 + GenericPageMapper *_mapper;
1.50 + offset_t _size;
1.51 +
1.52 + /* Copied page support. */
1.53 +
1.54 + AccessMap _map;
1.55 + MemoryIncremental _memory;
1.56 +
1.57 + /* Internal flexpage retrieval methods. */
1.58 +
1.59 + Flexpage *find(offset_t offset);
1.60 +
1.61 + Flexpage *replicate_flexpage(offset_t offset, Flexpage *flexpage);
1.62 +
1.63 +public:
1.64 + explicit CopiedPageMapper(GenericPageMapper *mapper);
1.65 +
1.66 + virtual ~CopiedPageMapper();
1.67 +
1.68 + /* Interface for the pager, implementing GenericPageMapper. */
1.69 +
1.70 + Flexpage *get(offset_t offset, map_flags_t flags);
1.71 +
1.72 + void queue(Flexpage *flexpage);
1.73 +
1.74 + void flush_all(offset_t start, offset_t size);
1.75 +
1.76 + offset_t get_data_size();
1.77 +
1.78 + void set_data_size(offset_t size);
1.79 +};
1.80 +
1.81 +// vim: tabstop=4 expandtab shiftwidth=4