#include "squid.h"
#include "base/IoManip.h"
#include "cache_cf.h"
#include "ConfigParser.h"
#include "debug/Messages.h"
#include "debug/Stream.h"
#include "globals.h"
#include "sbuf/Stream.h"
#include "SquidConfig.h"
#include "Store.h"
#include "store/Disk.h"
#include "store/Disks.h"
#include "store_rebuild.h"
#include "StoreFileSystem.h"
#include "swap_log_op.h"
#include "tools.h"
![](Disks_8cc__incl.png)
Go to the source code of this file.
Typedefs | |
typedef SwapDir * | STDIRSELECT(const StoreEntry *e) |
Functions | |
static int64_t | objectSizeForDirSelection (const StoreEntry &entry) |
static SwapDir & | SwapDirByIndex (const int i) |
TODO: Remove when cache_dir-iterating functions are converted to Disks methods. More... | |
static SwapDir * | storeDirSelectSwapDirRoundRobin (const StoreEntry *e) |
static SwapDir * | storeDirSelectSwapDirLeastLoad (const StoreEntry *e) |
void | storeDirOpenSwapLogs () |
void | storeDirCloseSwapLogs () |
int | storeDirWriteCleanLogs (int reopen) |
void | allocate_new_swapdir (Store::DiskConfig &swap) |
void | free_cachedir (Store::DiskConfig *swap) |
void | storeDirSwapLog (const StoreEntry *e, int op) |
Variables | |
static STDIRSELECT | storeDirSelectSwapDirRoundRobin |
static STDIRSELECT | storeDirSelectSwapDirLeastLoad |
static STDIRSELECT * | storeDirSelectSwapDir = storeDirSelectSwapDirLeastLoad |
Typedef Documentation
◆ STDIRSELECT
typedef SwapDir* STDIRSELECT(const StoreEntry *e) |
Function Documentation
◆ allocate_new_swapdir()
void allocate_new_swapdir | ( | Store::DiskConfig & | swap | ) |
Definition at line 787 of file Disks.cc.
References Store::DiskConfig::n_allocated, Store::DiskConfig::n_configured, and Store::DiskConfig::swapDirs.
Referenced by addSwapDir(), and Store::Disks::Parse().
◆ free_cachedir()
void free_cachedir | ( | Store::DiskConfig * | swap | ) |
Definition at line 806 of file Disks.cc.
References Store::DiskConfig::n_allocated, Store::DiskConfig::n_configured, reconfiguring, and Store::DiskConfig::swapDirs.
Referenced by TestRock::tearDown(), TestStoreHashIndex::testMaxSize(), TestStoreController::testMaxSize(), TestStoreController::testStats(), TestStoreHashIndex::testStats(), TestUfs::testUfsDefaultEngine(), and TestUfs::testUfsSearch().
◆ objectSizeForDirSelection()
|
static |
The entry size to use for Disk::canStore() size limit checks. This is an optimization to avoid similar calculations in every cache_dir.
Definition at line 41 of file Disks.cc.
References assert, MemObject::endOffset(), MemObject::expectedReplySize(), StoreEntry::mem_obj, and MemObject::swap_hdr_sz.
Referenced by storeDirSelectSwapDirLeastLoad(), and storeDirSelectSwapDirRoundRobin().
◆ storeDirCloseSwapLogs()
void storeDirCloseSwapLogs | ( | ) |
Definition at line 684 of file Disks.cc.
References SquidConfig::cacheSwap, Store::Disk::closeLog(), Config, Store::DiskConfig::n_configured, and SwapDirByIndex().
Referenced by mainReconfigureStart().
◆ storeDirOpenSwapLogs()
void storeDirOpenSwapLogs | ( | ) |
Definition at line 677 of file Disks.cc.
References SquidConfig::cacheSwap, Config, Store::DiskConfig::n_configured, Store::Disk::openLog(), and SwapDirByIndex().
Referenced by mainReconfigureFinish(), and storeDirWriteCleanLogs().
◆ storeDirSelectSwapDirLeastLoad()
|
static |
Spread load across all of the store directories
Note: We should modify this later on to prefer sticking objects in the tightest fit swapdir to conserve space, along with the actual swapdir usage. But for now, this hack will do while testing, so you should order your swapdirs in the config file from smallest max-size= to largest max-size=.
We also have to choose nleast == nconf since we need to consider ALL swapdirs, regardless of state. Again, this is a hack while we sort out the real usefulness of this algorithm.
Definition at line 115 of file Disks.cc.
References SquidConfig::cacheSwap, Config, Store::Disk::flags, INT_MAX, Store::DiskConfig::n_configured, objectSizeForDirSelection(), Store::Disk::Flags::selected, and SwapDirByIndex().
◆ storeDirSelectSwapDirRoundRobin()
|
static |
This new selection scheme simply does round-robin on all SwapDirs. A SwapDir is skipped if it is over the max_size (100%) limit, or overloaded.
Definition at line 73 of file Disks.cc.
References SquidConfig::cacheSwap, Config, Store::DiskConfig::n_configured, objectSizeForDirSelection(), and SwapDirByIndex().
◆ storeDirSwapLog()
void storeDirSwapLog | ( | const StoreEntry * | e, |
int | op | ||
) |
An entry written to the swap log MUST have the following properties.
- It MUST be a public key. It does no good to log a public ADD, change the key, then log a private DEL. So we need to log a DEL before we change a key from public to private.
- It MUST have a valid (> -1) swap_filen.
Definition at line 839 of file Disks.cc.
Referenced by Fs::Ufs::RebuildState::addIfFresh(), Store::Disks::evictCached(), StoreEntry::forcePublicKey(), and storeSwapOutFileClosed().
◆ storeDirWriteCleanLogs()
storeDirWriteCleanLogs
Writes a "clean" swap log file from in-memory metadata. This is a rewrite of the original function to troll each StoreDir and write the logs, and flush at the end of the run. Thanks goes to Eric Stern, since this solution came out of his COSS code.
Definition at line 700 of file Disks.cc.
References SquidConfig::cacheSwap, Config, current_time, DBG_IMPORTANT, debugs, getCurrentTime(), Important, Store::DiskConfig::n_configured, Store::Controller::store_dirs_rebuilding, storeDirOpenSwapLogs(), SwapDirByIndex(), tvSubDsec(), StoreEntry::write(), and Store::Disk::writeCleanDone().
Referenced by death(), fatal(), fatal_dump(), mainRotate(), SquidShutdown(), and TestUfs::testUfsSearch().
◆ SwapDirByIndex()
Definition at line 58 of file Disks.cc.
References assert, SquidConfig::cacheSwap, Config, INDEXSD, and Store::DiskConfig::n_allocated.
Referenced by Store::Disks::Dir(), Store::Disks::store(), storeDirCloseSwapLogs(), storeDirOpenSwapLogs(), storeDirSelectSwapDirLeastLoad(), storeDirSelectSwapDirRoundRobin(), and storeDirWriteCleanLogs().
Variable Documentation
◆ storeDirSelectSwapDir
|
static |
This function pointer is set according to 'store_dir_select_algorithm' in squid.conf.
Definition at line 36 of file Disks.cc.
Referenced by Store::Disks::init(), and Store::Disks::SelectSwapDir().
◆ storeDirSelectSwapDirLeastLoad
|
static |
Definition at line 31 of file Disks.cc.
Referenced by Store::Disks::init().
◆ storeDirSelectSwapDirRoundRobin
|
static |
Definition at line 30 of file Disks.cc.
Referenced by Store::Disks::init().
Introduction
- About Squid
- Why Squid?
- Squid Developers
- How to Donate
- How to Help Out
- Getting Squid
- Squid Source Packages
- Squid Deployment Case-Studies
- Squid Software Foundation
Documentation
- Quick Setup
- Configuration:
- FAQ and Wiki
- Guide Books:
- Non-English
- More...
Support
- Security Advisories
- Bugzilla Database
- Mailing lists
- Contacting us
- Commercial services
- Project Sponsors
- Squid-based products