]> git.ipfire.org Git - thirdparty/squid.git/blame - src/StoreFileSystem.h
Bug 5428: Warn if pkg-config is not found (#1902)
[thirdparty/squid.git] / src / StoreFileSystem.h
CommitLineData
59b2d47f 1/*
b8ae064d 2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
59b2d47f 3 *
bbc27441
AJ
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
59b2d47f 7 */
8
ff9d9458
FC
9#ifndef SQUID_SRC_STOREFILESYSTEM_H
10#define SQUID_SRC_STOREFILESYSTEM_H
59b2d47f 11
23b79630 12#include "base/TypeTraits.h"
2745fea5 13#include "store/forward.h"
b181c1df 14#include <vector>
59b2d47f 15
946c686b
AJ
16/* ****** DOCUMENTATION ***** */
17
4d95a996 18/**
f53969cc 19 \defgroup FileSystems Storage Filesystems
26ac0430 20 *
f439fbd2 21 \section FileSystemsIntroduction Introduction
4d95a996
AJ
22 \par
23 * Traditionally, Squid has always used the Unix filesystem (\link UFS UFS\endlink)
24 * to store cache objects on disk. Over the years, the
25 * poor performance of \link UFS UFS\endlink has become very obvious. In most
26 * cases, \link UFS UFS\endlink limits Squid to about 30-50 requests per second.
27 * Our work indicates that the poor performance is mostly
28 * due to the synchronous nature of open() and unlink()
29 * system calls, and perhaps thrashing of inode/buffer caches.
26ac0430 30 *
4d95a996
AJ
31 \par
32 * We want to try out our own, customized filesystems with Squid.
33 * In order to do that, we need a well-defined interface
34 * for the bits of Squid that access the permanent storage
35 * devices. We also require tighter control of the replacement
36 * policy by each storage module, rather than a single global
37 * replacement policy.
26ac0430 38 *
4d95a996
AJ
39 \section BuildStructure Build structure
40 \par
41 * The storage types live in \em src/fs/. Each subdirectory corresponds
42 * to the name of the storage type. When a new storage type is implemented
a6093a2d 43 * configure.ac must be updated to autogenerate a Makefile in
4d95a996
AJ
44 * \em src/fs/foo/ from a Makefile.in file.
45 *
9837567d
AJ
46 * TODO: DOCS: add template addition to configure.ac for storage module addition.
47 * TODO: DOCS: add template Makefile.am for storage module addition.
26ac0430 48 *
4d95a996
AJ
49 \par
50 * configure will take a list of storage types through the
51 * --enable-store-io parameter. This parameter takes a list of
2b61af8e 52 * space separated storage types. For example,
73656056 53 * --enable-store-io="ufs aufs" .
26ac0430 54 *
4d95a996
AJ
55 \par
56 * Each storage type must create an archive file
57 * in \em src/fs/foo/.a . This file is automatically linked into
58 * squid at compile time.
26ac0430 59 *
4d95a996
AJ
60 \par
61 * Each storage filesystem must inherit from StoreFileSystem and provide
62 * all virtual function hooks for squid to operate with.
26ac0430 63 *
4d95a996
AJ
64 \section OperationOfStorageModules Operation of a Storage Module
65 \par
66 * Squid understands the concept of multiple diverse storage directories.
67 * Each storage directory provides a caching object store, with object
68 * storage, retrieval, indexing and replacement.
26ac0430 69 *
4d95a996
AJ
70 \par
71 * Each open object has associated with it a storeIOState object. The
72 * storeIOState object is used to record the state of the current
73 * object. Each storeIOState can have a storage module specific data
74 * structure containing information private to the storage module.
26ac0430 75 *
4d95a996
AJ
76 \par
77 * Each SwapDir has the concept of a maximum object size. This is used
78 * as a basic hint to the storage layer in first choosing a suitable
79 * SwapDir. The checkobj function is then called for suitable
80 * candidate SwapDirs to find out whether it wants to store a
81 * given StoreEntry. A maxobjsize of -1 means 'any size'.
82 */
62ee09ca 83
4d95a996
AJ
84/**
85 \ingroup FileSystems
86 *
87 * The core API for storage modules this class provides all the hooks
88 * squid uses to interact with a filesystem IO module.
89 */
23b79630 90class StoreFileSystem: public Interface
59b2d47f 91{
92
93public:
59b2d47f 94 static void FsAdd(StoreFileSystem &);
5d84beb5 95 static StoreFileSystem *FindByType(const char *type);
81481ec0
FC
96 static std::vector<StoreFileSystem*> const &FileSystems();
97 typedef std::vector<StoreFileSystem*>::iterator iterator;
98 typedef std::vector<StoreFileSystem*>::const_iterator const_iterator;
59b2d47f 99
23b79630
AR
100 StoreFileSystem() = default;
101 StoreFileSystem(StoreFileSystem &&) = delete; // no copying/moving of any kind
59b2d47f 102
103 virtual char const *type () const = 0;
104 virtual SwapDir *createSwapDir() = 0;
59b2d47f 105
106private:
81481ec0
FC
107 static std::vector<StoreFileSystem*> &GetFileSystems();
108 static std::vector<StoreFileSystem*> *_FileSystems;
59b2d47f 109};
110
4d95a996 111// TODO: Kill this typedef!
59b2d47f 112typedef StoreFileSystem storefs_entry_t;
113
ff9d9458 114#endif /* SQUID_SRC_STOREFILESYSTEM_H */
f53969cc 115