]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/SwapDir.cc
5 * DEBUG: section 20 Swap Dir base object
6 * AUTHOR: Robert Collins
8 * SQUID Web Proxy Cache http://www.squid-cache.org/
9 * ----------------------------------------------------------
11 * Squid is the result of efforts by numerous individuals from
12 * the Internet community; see the CONTRIBUTORS file for full
13 * details. Many organizations have provided support for Squid's
14 * development; see the SPONSORS file for full details. Squid is
15 * Copyrighted (C) 2001 by the Regents of the University of
16 * California; see the COPYRIGHT file for full details. Squid
17 * incorporates software developed and/or copyrighted by other
18 * sources; see the CREDITS file for full details.
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
38 #include "StoreFileSystem.h"
39 #include "ConfigOption.h"
50 SwapDir::dump(StoreEntry
&)const {}
53 SwapDir::doubleCheck(StoreEntry
&)
59 SwapDir::unlink(StoreEntry
&) {}
62 SwapDir::stat(StoreEntry
&output
) const
64 storeAppendPrintf(&output
, "Store Directory #%d (%s): %s\n", index
, type(),
66 storeAppendPrintf(&output
, "FS Block Size %d Bytes\n",
71 storeAppendPrintf(&output
, "Removal policy: %s\n", repl
->_type
);
74 repl
->Stats(repl
, &output
);
79 SwapDir::statfs(StoreEntry
&)const {}
82 SwapDir::maintain() {}
85 SwapDir::minSize() const
87 return (size_t) (((float) maxSize() *
88 (float) Config
.Swap
.lowWaterMark
) / 100.0);
92 SwapDir::reference(StoreEntry
&) {}
95 SwapDir::dereference(StoreEntry
&) {}
106 /* Move to StoreEntry ? */
108 SwapDir::canLog(StoreEntry
const &e
)const
110 if (e
.swap_filen
< 0)
113 if (e
.swap_status
!= SWAPOUT_DONE
)
116 if (e
.swap_file_sz
<= 0)
119 if (EBIT_TEST(e
.flags
, RELEASE_REQUEST
))
122 if (EBIT_TEST(e
.flags
, KEY_PRIVATE
))
125 if (EBIT_TEST(e
.flags
, ENTRY_SPECIAL
))
132 SwapDir::openLog() {}
135 SwapDir::closeLog() {}
138 SwapDir::writeCleanStart()
144 SwapDir::writeCleanDone() {}
147 SwapDir::logEntry(const StoreEntry
& e
, int op
) const {}
150 SwapDir::type() const
155 /* NOT performance critical. Really. Don't bother optimising for speed
159 SwapDir::getOptionTree() const
161 ConfigOptionVector
*result
= new ConfigOptionVector
;
162 result
->options
.push_back(new ConfigOptionAdapter
<SwapDir
>(*const_cast<SwapDir
*>(this), &SwapDir::optionReadOnlyParse
, &SwapDir::optionReadOnlyDump
));
163 result
->options
.push_back(new ConfigOptionAdapter
<SwapDir
>(*const_cast<SwapDir
*>(this), &SwapDir::optionMaxSizeParse
, &SwapDir::optionMaxSizeDump
));
168 SwapDir::parseOptions(int reconfiguring
)
170 unsigned int old_read_only
= flags
.read_only
;
173 ConfigOption
*newOption
= getOptionTree();
175 while ((name
= strtok(NULL
, w_space
)) != NULL
) {
176 value
= strchr(name
, '=');
179 *value
++ = '\0'; /* cut on = */
181 debugs(3,2, "SwapDir::parseOptions: parsing store option '" << name
<< "'='" << (value
? value
: "") << "'");
184 if (!newOption
->parse(name
, value
, reconfiguring
))
191 * Handle notifications about reconfigured single-options with no value
192 * where the removal of the option cannot be easily detected in the
197 if (old_read_only
!= flags
.read_only
) {
198 debugs(3, 1, "Cache dir '" << path
<< "' now " << (flags
.read_only
? "No-Store" : "Read-Write"));
204 SwapDir::dumpOptions(StoreEntry
* entry
) const
206 ConfigOption
*newOption
= getOptionTree();
209 newOption
->dump(entry
);
215 SwapDir::optionReadOnlyParse(char const *option
, const char *value
, int reconfiguring
)
217 if (strcmp(option
, "no-store") != 0 && strcmp(option
, "read-only") != 0)
223 read_only
= xatoi(value
);
227 flags
.read_only
= read_only
;
233 SwapDir::optionReadOnlyDump(StoreEntry
* e
) const
236 storeAppendPrintf(e
, " no-store");
240 SwapDir::optionMaxSizeParse(char const *option
, const char *value
, int reconfiguring
)
242 if (strcmp(option
, "max-size") != 0)
248 int64_t size
= strtoll(value
, NULL
, 10);
250 if (reconfiguring
&& max_objsize
!= size
)
251 debugs(3, 1, "Cache dir '" << path
<< "' max object size now " << size
);
259 SwapDir::optionMaxSizeDump(StoreEntry
* e
) const
261 if (max_objsize
!= -1)
262 storeAppendPrintf(e
, " max-size=%"PRId64
, max_objsize
);
265 /* Swapdirs do not have an index of their own - thus they ask their parent..
266 * but the parent child relationship isn't implemented yet
271 (const cache_key
*key
)
273 return Store::Root().get(key
);
279 (String
const key
, STOREGETCLIENT callback
, void *cbdata
)
281 fatal("not implemented");