]> git.ipfire.org Git - thirdparty/squid.git/blame - src/StoreFileSystem.h
Boilerplate: update copyright blurbs on src/
[thirdparty/squid.git] / src / StoreFileSystem.h
CommitLineData
59b2d47f 1/*
bbc27441 2 * Copyright (C) 1996-2014 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
9#ifndef SQUID_STOREFILESYSTEM_H
10#define SQUID_STOREFILESYSTEM_H
11
b181c1df 12#include <vector>
59b2d47f 13
946c686b
AJ
14/* ****** DOCUMENTATION ***** */
15
4d95a996
AJ
16/**
17 \defgroup FileSystems Storage Filesystems
26ac0430 18 *
4d95a996
AJ
19 \section Introduction Introduction
20 \par
21 * Traditionally, Squid has always used the Unix filesystem (\link UFS UFS\endlink)
22 * to store cache objects on disk. Over the years, the
23 * poor performance of \link UFS UFS\endlink has become very obvious. In most
24 * cases, \link UFS UFS\endlink limits Squid to about 30-50 requests per second.
25 * Our work indicates that the poor performance is mostly
26 * due to the synchronous nature of open() and unlink()
27 * system calls, and perhaps thrashing of inode/buffer caches.
26ac0430 28 *
4d95a996
AJ
29 \par
30 * We want to try out our own, customized filesystems with Squid.
31 * In order to do that, we need a well-defined interface
32 * for the bits of Squid that access the permanent storage
33 * devices. We also require tighter control of the replacement
34 * policy by each storage module, rather than a single global
35 * replacement policy.
26ac0430 36 *
4d95a996
AJ
37 \section BuildStructure Build structure
38 \par
39 * The storage types live in \em src/fs/. Each subdirectory corresponds
40 * to the name of the storage type. When a new storage type is implemented
a6093a2d 41 * configure.ac must be updated to autogenerate a Makefile in
4d95a996
AJ
42 * \em src/fs/foo/ from a Makefile.in file.
43 *
a6093a2d 44 \todo DOCS: add template addition to configure.ac for storage module addition.
4d95a996 45 \todo DOCS: add template Makefile.am for storage module addition.
26ac0430 46 *
4d95a996
AJ
47 \par
48 * configure will take a list of storage types through the
49 * --enable-store-io parameter. This parameter takes a list of
50 * space seperated storage types. For example,
73656056 51 * --enable-store-io="ufs aufs" .
26ac0430 52 *
4d95a996
AJ
53 \par
54 * Each storage type must create an archive file
55 * in \em src/fs/foo/.a . This file is automatically linked into
56 * squid at compile time.
26ac0430 57 *
4d95a996
AJ
58 \par
59 * Each storage filesystem must inherit from StoreFileSystem and provide
60 * all virtual function hooks for squid to operate with.
26ac0430 61 *
4d95a996
AJ
62 \section OperationOfStorageModules Operation of a Storage Module
63 \par
64 * Squid understands the concept of multiple diverse storage directories.
65 * Each storage directory provides a caching object store, with object
66 * storage, retrieval, indexing and replacement.
26ac0430 67 *
4d95a996
AJ
68 \par
69 * Each open object has associated with it a storeIOState object. The
70 * storeIOState object is used to record the state of the current
71 * object. Each storeIOState can have a storage module specific data
72 * structure containing information private to the storage module.
26ac0430 73 *
4d95a996
AJ
74 \par
75 * Each SwapDir has the concept of a maximum object size. This is used
76 * as a basic hint to the storage layer in first choosing a suitable
77 * SwapDir. The checkobj function is then called for suitable
78 * candidate SwapDirs to find out whether it wants to store a
79 * given StoreEntry. A maxobjsize of -1 means 'any size'.
80 */
62ee09ca 81
e1f7507e
AJ
82class SwapDir;
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 */
59b2d47f 90class StoreFileSystem
91{
92
93public:
94 static void SetupAllFs();
95 static void FsAdd(StoreFileSystem &);
96 static void FreeAllFs();
81481ec0
FC
97 static std::vector<StoreFileSystem*> const &FileSystems();
98 typedef std::vector<StoreFileSystem*>::iterator iterator;
99 typedef std::vector<StoreFileSystem*>::const_iterator const_iterator;
e1f7507e 100 StoreFileSystem() : initialised(false) {}
59b2d47f 101
26ac0430 102 virtual ~StoreFileSystem() {}
59b2d47f 103
104 virtual char const *type () const = 0;
105 virtual SwapDir *createSwapDir() = 0;
106 virtual void done() = 0;
107 virtual void setup() = 0;
108 // Not implemented
109 StoreFileSystem(StoreFileSystem const &);
110 StoreFileSystem &operator=(StoreFileSystem const&);
111
112protected:
113 bool initialised;
6b7d87bb 114 virtual void registerWithCacheManager(void);
59b2d47f 115
116private:
81481ec0
FC
117 static std::vector<StoreFileSystem*> &GetFileSystems();
118 static std::vector<StoreFileSystem*> *_FileSystems;
6b7d87bb 119 static void RegisterAllFsWithCacheManager(void);
59b2d47f 120};
121
4d95a996 122// TODO: Kill this typedef!
59b2d47f 123typedef StoreFileSystem storefs_entry_t;
124
59b2d47f 125#endif /* SQUID_STOREFILESYSTEM_H */