]>
Commit | Line | Data |
---|---|---|
59b2d47f | 1 | /* |
262a0e14 | 2 | * $Id$ |
59b2d47f | 3 | * |
4 | * SQUID Web Proxy Cache http://www.squid-cache.org/ | |
5 | * ---------------------------------------------------------- | |
6 | * | |
7 | * Squid is the result of efforts by numerous individuals from | |
8 | * the Internet community; see the CONTRIBUTORS file for full | |
9 | * details. Many organizations have provided support for Squid's | |
10 | * development; see the SPONSORS file for full details. Squid is | |
11 | * Copyrighted (C) 2001 by the Regents of the University of | |
12 | * California; see the COPYRIGHT file for full details. Squid | |
13 | * incorporates software developed and/or copyrighted by other | |
14 | * sources; see the CREDITS file for full details. | |
15 | * | |
16 | * This program is free software; you can redistribute it and/or modify | |
17 | * it under the terms of the GNU General Public License as published by | |
18 | * the Free Software Foundation; either version 2 of the License, or | |
19 | * (at your option) any later version. | |
26ac0430 | 20 | * |
59b2d47f | 21 | * This program is distributed in the hope that it will be useful, |
22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
24 | * GNU General Public License for more details. | |
26ac0430 | 25 | * |
59b2d47f | 26 | * You should have received a copy of the GNU General Public License |
27 | * along with this program; if not, write to the Free Software | |
28 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. | |
29 | * | |
30 | * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org> | |
31 | */ | |
32 | ||
33 | #ifndef SQUID_STOREFILESYSTEM_H | |
34 | #define SQUID_STOREFILESYSTEM_H | |
35 | ||
f7f3304a | 36 | #include "squid-old.h" |
59b2d47f | 37 | #include "Array.h" |
38 | ||
946c686b AJ |
39 | /* ****** DOCUMENTATION ***** */ |
40 | ||
4d95a996 AJ |
41 | /** |
42 | \defgroup FileSystems Storage Filesystems | |
26ac0430 | 43 | * |
4d95a996 AJ |
44 | \section Introduction Introduction |
45 | \par | |
46 | * Traditionally, Squid has always used the Unix filesystem (\link UFS UFS\endlink) | |
47 | * to store cache objects on disk. Over the years, the | |
48 | * poor performance of \link UFS UFS\endlink has become very obvious. In most | |
49 | * cases, \link UFS UFS\endlink limits Squid to about 30-50 requests per second. | |
50 | * Our work indicates that the poor performance is mostly | |
51 | * due to the synchronous nature of open() and unlink() | |
52 | * system calls, and perhaps thrashing of inode/buffer caches. | |
26ac0430 | 53 | * |
4d95a996 AJ |
54 | \par |
55 | * We want to try out our own, customized filesystems with Squid. | |
56 | * In order to do that, we need a well-defined interface | |
57 | * for the bits of Squid that access the permanent storage | |
58 | * devices. We also require tighter control of the replacement | |
59 | * policy by each storage module, rather than a single global | |
60 | * replacement policy. | |
26ac0430 | 61 | * |
4d95a996 AJ |
62 | \section BuildStructure Build structure |
63 | \par | |
64 | * The storage types live in \em src/fs/. Each subdirectory corresponds | |
65 | * to the name of the storage type. When a new storage type is implemented | |
a6093a2d | 66 | * configure.ac must be updated to autogenerate a Makefile in |
4d95a996 AJ |
67 | * \em src/fs/foo/ from a Makefile.in file. |
68 | * | |
a6093a2d | 69 | \todo DOCS: add template addition to configure.ac for storage module addition. |
4d95a996 | 70 | \todo DOCS: add template Makefile.am for storage module addition. |
26ac0430 | 71 | * |
4d95a996 AJ |
72 | \par |
73 | * configure will take a list of storage types through the | |
74 | * --enable-store-io parameter. This parameter takes a list of | |
75 | * space seperated storage types. For example, | |
76 | * --enable-store-io="ufs coss" . | |
26ac0430 | 77 | * |
4d95a996 AJ |
78 | \par |
79 | * Each storage type must create an archive file | |
80 | * in \em src/fs/foo/.a . This file is automatically linked into | |
81 | * squid at compile time. | |
26ac0430 | 82 | * |
4d95a996 AJ |
83 | \par |
84 | * Each storage filesystem must inherit from StoreFileSystem and provide | |
85 | * all virtual function hooks for squid to operate with. | |
26ac0430 | 86 | * |
4d95a996 AJ |
87 | \section OperationOfStorageModules Operation of a Storage Module |
88 | \par | |
89 | * Squid understands the concept of multiple diverse storage directories. | |
90 | * Each storage directory provides a caching object store, with object | |
91 | * storage, retrieval, indexing and replacement. | |
26ac0430 | 92 | * |
4d95a996 AJ |
93 | \par |
94 | * Each open object has associated with it a storeIOState object. The | |
95 | * storeIOState object is used to record the state of the current | |
96 | * object. Each storeIOState can have a storage module specific data | |
97 | * structure containing information private to the storage module. | |
26ac0430 | 98 | * |
4d95a996 AJ |
99 | \par |
100 | * Each SwapDir has the concept of a maximum object size. This is used | |
101 | * as a basic hint to the storage layer in first choosing a suitable | |
102 | * SwapDir. The checkobj function is then called for suitable | |
103 | * candidate SwapDirs to find out whether it wants to store a | |
104 | * given StoreEntry. A maxobjsize of -1 means 'any size'. | |
105 | */ | |
62ee09ca | 106 | |
e1f7507e AJ |
107 | class SwapDir; |
108 | ||
4d95a996 AJ |
109 | /** |
110 | \ingroup FileSystems | |
111 | * | |
112 | * The core API for storage modules this class provides all the hooks | |
113 | * squid uses to interact with a filesystem IO module. | |
114 | */ | |
59b2d47f | 115 | class StoreFileSystem |
116 | { | |
117 | ||
118 | public: | |
119 | static void SetupAllFs(); | |
120 | static void FsAdd(StoreFileSystem &); | |
121 | static void FreeAllFs(); | |
122 | static Vector<StoreFileSystem*> const &FileSystems(); | |
123 | typedef Vector<StoreFileSystem*>::iterator iterator; | |
124 | typedef Vector<StoreFileSystem*>::const_iterator const_iterator; | |
e1f7507e | 125 | StoreFileSystem() : initialised(false) {} |
59b2d47f | 126 | |
26ac0430 | 127 | virtual ~StoreFileSystem() {} |
59b2d47f | 128 | |
129 | virtual char const *type () const = 0; | |
130 | virtual SwapDir *createSwapDir() = 0; | |
131 | virtual void done() = 0; | |
132 | virtual void setup() = 0; | |
133 | // Not implemented | |
134 | StoreFileSystem(StoreFileSystem const &); | |
135 | StoreFileSystem &operator=(StoreFileSystem const&); | |
136 | ||
137 | protected: | |
138 | bool initialised; | |
6b7d87bb | 139 | virtual void registerWithCacheManager(void); |
59b2d47f | 140 | |
141 | private: | |
142 | static Vector<StoreFileSystem*> &GetFileSystems(); | |
143 | static Vector<StoreFileSystem*> *_FileSystems; | |
6b7d87bb | 144 | static void RegisterAllFsWithCacheManager(void); |
59b2d47f | 145 | }; |
146 | ||
4d95a996 | 147 | // TODO: Kill this typedef! |
59b2d47f | 148 | typedef StoreFileSystem storefs_entry_t; |
149 | ||
150 | ||
151 | #endif /* SQUID_STOREFILESYSTEM_H */ |