]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/SwapDir.cc
4 * DEBUG: section 20 Swap Dir base object
5 * AUTHOR: Robert Collins
7 * SQUID Web Proxy Cache http://www.squid-cache.org/
8 * ----------------------------------------------------------
10 * Squid is the result of efforts by numerous individuals from
11 * the Internet community; see the CONTRIBUTORS file for full
12 * details. Many organizations have provided support for Squid's
13 * development; see the SPONSORS file for full details. Squid is
14 * Copyrighted (C) 2001 by the Regents of the University of
15 * California; see the COPYRIGHT file for full details. Squid
16 * incorporates software developed and/or copyrighted by other
17 * sources; see the CREDITS file for full details.
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
36 #include "compat/strtoll.h"
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 ((maxSize() * Config
.Swap
.lowWaterMark
) / 100);
91 SwapDir::reference(StoreEntry
&) {}
94 SwapDir::dereference(StoreEntry
&) {}
105 /* Move to StoreEntry ? */
107 SwapDir::canLog(StoreEntry
const &e
)const
109 if (e
.swap_filen
< 0)
112 if (e
.swap_status
!= SWAPOUT_DONE
)
115 if (e
.swap_file_sz
<= 0)
118 if (EBIT_TEST(e
.flags
, RELEASE_REQUEST
))
121 if (EBIT_TEST(e
.flags
, KEY_PRIVATE
))
124 if (EBIT_TEST(e
.flags
, ENTRY_SPECIAL
))
131 SwapDir::openLog() {}
134 SwapDir::closeLog() {}
137 SwapDir::writeCleanStart()
143 SwapDir::writeCleanDone() {}
146 SwapDir::logEntry(const StoreEntry
& e
, int op
) const {}
149 SwapDir::type() const
154 /* NOT performance critical. Really. Don't bother optimising for speed
158 SwapDir::getOptionTree() const
160 ConfigOptionVector
*result
= new ConfigOptionVector
;
161 result
->options
.push_back(new ConfigOptionAdapter
<SwapDir
>(*const_cast<SwapDir
*>(this), &SwapDir::optionReadOnlyParse
, &SwapDir::optionReadOnlyDump
));
162 result
->options
.push_back(new ConfigOptionAdapter
<SwapDir
>(*const_cast<SwapDir
*>(this), &SwapDir::optionObjectSizeParse
, &SwapDir::optionObjectSizeDump
));
167 SwapDir::parseOptions(int isaReconfig
)
169 unsigned int old_read_only
= flags
.read_only
;
172 ConfigOption
*newOption
= getOptionTree();
174 while ((name
= strtok(NULL
, w_space
)) != NULL
) {
175 value
= strchr(name
, '=');
178 *value
++ = '\0'; /* cut on = */
180 debugs(3,2, "SwapDir::parseOptions: parsing store option '" << name
<< "'='" << (value
? value
: "") << "'");
183 if (!newOption
->parse(name
, value
, isaReconfig
))
190 * Handle notifications about reconfigured single-options with no value
191 * where the removal of the option cannot be easily detected in the
196 if (old_read_only
!= flags
.read_only
) {
197 debugs(3, 1, "Cache dir '" << path
<< "' now " << (flags
.read_only
? "No-Store" : "Read-Write"));
203 SwapDir::dumpOptions(StoreEntry
* entry
) const
205 ConfigOption
*newOption
= getOptionTree();
208 newOption
->dump(entry
);
214 SwapDir::optionReadOnlyParse(char const *option
, const char *value
, int isaReconfig
)
216 if (strcmp(option
, "no-store") != 0 && strcmp(option
, "read-only") != 0)
222 read_only
= xatoi(value
);
226 flags
.read_only
= read_only
;
232 SwapDir::optionReadOnlyDump(StoreEntry
* e
) const
235 storeAppendPrintf(e
, " no-store");
239 SwapDir::optionObjectSizeParse(char const *option
, const char *value
, int isaReconfig
)
242 if (strcmp(option
, "max-size") == 0) {
244 } else if (strcmp(option
, "min-size") == 0) {
252 int64_t size
= strtoll(value
, NULL
, 10);
254 if (isaReconfig
&& *val
!= size
)
255 debugs(3, 1, "Cache dir '" << path
<< "' object " << option
<< " now " << size
);
263 SwapDir::optionObjectSizeDump(StoreEntry
* e
) const
265 if (min_objsize
!= 0)
266 storeAppendPrintf(e
, " min-size=%"PRId64
, min_objsize
);
268 if (max_objsize
!= -1)
269 storeAppendPrintf(e
, " max-size=%"PRId64
, max_objsize
);
272 /* Swapdirs do not have an index of their own - thus they ask their parent..
273 * but the parent child relationship isn't implemented yet
278 (const cache_key
*key
)
280 return Store::Root().get(key
);
286 (String
const key
, STOREGETCLIENT aCallback
, void *aCallbackData
)
288 fatal("not implemented");