5 * SQUID Web Proxy Cache http://www.squid-cache.org/
6 * ----------------------------------------------------------
8 * Squid is the result of efforts by numerous individuals from
9 * the Internet community; see the CONTRIBUTORS file for full
10 * details. Many organizations have provided support for Squid's
11 * development; see the SPONSORS file for full details. Squid is
12 * Copyrighted (C) 2001 by the Regents of the University of
13 * California; see the COPYRIGHT file for full details. Squid
14 * incorporates software developed and/or copyrighted by other
15 * sources; see the CREDITS file for full details.
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
32 #ifndef SQUID_SWAPDIR_H
33 #define SQUID_SWAPDIR_H
36 #include "StoreIOState.h"
41 /* Store dir configuration routines */
42 /* SwapDir *sd, char *path ( + char *opt later when the strtok mess is gone) */
46 /* New class that replaces the static SwapDir methods as part of the Store overhaul */
48 class StoreController
: public Store
53 virtual ~StoreController();
54 virtual int callback();
55 virtual void create();
57 virtual StoreEntry
* get(const cache_key
*);
59 virtual void get(String
const, STOREGETCLIENT
, void * cbdata
);
63 virtual void maintain(); /* perform regular maintenance should be private and self registered ... */
65 virtual uint64_t maxSize() const;
67 virtual uint64_t minSize() const;
69 virtual void stat(StoreEntry
&) const;
71 virtual void sync(); /* Sync the store prior to shutdown */
73 virtual StoreSearch
*search(String
const url
, HttpRequest
*);
75 virtual void reference(StoreEntry
&); /* Reference this object */
77 virtual void dereference(StoreEntry
&); /* Unreference this object */
79 virtual void updateSize(int64_t size
, int sign
);
81 /* the number of store dirs being rebuilt. */
82 static int store_dirs_rebuilding
;
85 void createOneStore(Store
&aStore
);
90 /* migrating from the Config based list of swapdirs */
91 extern void allocate_new_swapdir(SquidConfig::_cacheSwap
*);
92 extern void free_cachedir(SquidConfig::_cacheSwap
* swap
);
93 SQUIDCEXTERN OBJH storeDirStats
;
94 SQUIDCEXTERN
char *storeDirSwapLogFile(int, const char *);
95 SQUIDCEXTERN
char *storeSwapFullPath(int, char *);
96 SQUIDCEXTERN
char *storeSwapSubSubDir(int, char *);
97 SQUIDCEXTERN
const char *storeSwapPath(int);
98 SQUIDCEXTERN
int storeDirWriteCleanLogs(int reopen
);
99 SQUIDCEXTERN STDIRSELECT
*storeDirSelectSwapDir
;
100 SQUIDCEXTERN
int storeVerifySwapDirs(void);
101 SQUIDCEXTERN
void storeDirCloseSwapLogs(void);
102 SQUIDCEXTERN
void storeDirCloseTmpSwapLog(int dirn
);
103 SQUIDCEXTERN
void storeDirDiskFull(sdirno
);
104 SQUIDCEXTERN
void storeDirOpenSwapLogs(void);
105 SQUIDCEXTERN
void storeDirSwapLog(const StoreEntry
*, int op
);
106 SQUIDCEXTERN
void storeDirLRUDelete(StoreEntry
*);
107 SQUIDCEXTERN
void storeDirLRUAdd(StoreEntry
*);
108 SQUIDCEXTERN
int storeDirGetBlkSize(const char *path
, int *blksize
);
109 SQUIDCEXTERN
int storeDirGetUFSStats(const char *, int *, int *, int *, int *);
112 class SwapDir
: public Store
116 SwapDir(char const *aType
) : theType (aType
), cur_size(0), max_size(0), min_objsize(0), max_objsize(-1), cleanLog(NULL
) {
122 virtual void reconfigure(int, char *) = 0;
123 char const *type() const;
125 /* official Store interface functions */
126 virtual void diskFull();
128 virtual StoreEntry
* get(const cache_key
*);
130 virtual void get(String
const, STOREGETCLIENT
, void * cbdata
);
132 virtual uint64_t maxSize() const { return max_size
;}
134 virtual uint64_t minSize() const;
135 virtual void stat (StoreEntry
&anEntry
) const;
136 virtual StoreSearch
*search(String
const url
, HttpRequest
*) = 0;
138 virtual void updateSize(int64_t size
, int sign
);
140 /* migrated from store_dir.cc */
141 bool objectSizeIsAcceptable(int64_t objsize
) const;
144 void parseOptions(int reconfiguring
);
145 void dumpOptions(StoreEntry
* e
) const;
146 virtual ConfigOption
*getOptionTree() const;
149 bool optionReadOnlyParse(char const *option
, const char *value
, int reconfiguring
);
150 void optionReadOnlyDump(StoreEntry
* e
) const;
151 bool optionObjectSizeParse(char const *option
, const char *value
, int reconfiguring
);
152 void optionObjectSizeDump(StoreEntry
* e
) const;
156 uint64_t cur_size
; ///< currently used space in the storage area
157 uint64_t max_size
; ///< maximum allocatable size of the storage area
159 int index
; /* This entry's index into the swapDirs array */
167 Flags() : selected(0), read_only(0) {}
168 unsigned int selected
:1;
169 unsigned int read_only
:1;
171 virtual void init() = 0; /* Initialise the fs */
172 virtual void create(); /* Create a new fs */
173 virtual void dump(StoreEntry
&)const; /* Dump fs config snippet */
174 virtual bool doubleCheck(StoreEntry
&); /* Double check the obj integrity */
175 virtual void statfs(StoreEntry
&) const; /* Dump fs statistics */
176 virtual void maintain(); /* Replacement maintainence */
177 /* <0 == error. > 1000 == error */
178 virtual int canStore(StoreEntry
const &)const = 0; /* Check if the fs will store an object */
179 /* These two are notifications */
180 virtual void reference(StoreEntry
&); /* Reference this object */
181 virtual void dereference(StoreEntry
&); /* Unreference this object */
182 virtual int callback(); /* Handle pending callbacks */
183 virtual void sync(); /* Sync the store prior to shutdown */
184 virtual StoreIOState::Pointer
createStoreIO(StoreEntry
&, StoreIOState::STFNCB
*, StoreIOState::STIOCB
*, void *) = 0;
185 virtual StoreIOState::Pointer
openStoreIO(StoreEntry
&, StoreIOState::STFNCB
*, StoreIOState::STIOCB
*, void *) = 0;
186 virtual void unlink (StoreEntry
&);
187 bool canLog(StoreEntry
const &e
)const;
188 virtual void openLog();
189 virtual void closeLog();
190 virtual void logEntry(const StoreEntry
& e
, int op
) const;
196 virtual ~CleanLog() {}
198 virtual const StoreEntry
*nextEntry() = 0;
199 virtual void write(StoreEntry
const &) = 0;
203 virtual int writeCleanStart();
204 virtual void writeCleanDone();
205 virtual void parse(int index
, char *path
) = 0;
212 #endif /* SQUID_SWAPDIR_H */