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