#include "squid.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"
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 786 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 805 of file Disks.cc.
References Store::DiskConfig::n_allocated, Store::DiskConfig::n_configured, reconfiguring, and Store::DiskConfig::swapDirs.
Referenced by TestRock::tearDown(), TestStoreController::testMaxSize(), TestStoreHashIndex::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 40 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 | ( | void | ) |
Definition at line 683 of file Disks.cc.
References SquidConfig::cacheSwap, Store::Disk::closeLog(), Config, Store::DiskConfig::n_configured, and SwapDirByIndex().
Referenced by mainReconfigureStart().
◆ storeDirOpenSwapLogs()
void storeDirOpenSwapLogs | ( | void | ) |
Definition at line 676 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 114 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 72 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 838 of file Disks.cc.
References assert, debugs, StoreEntry::disk(), EBIT_TEST, ENTRY_SPECIAL, StoreEntry::flags, StoreEntry::getMD5Text(), StoreEntry::hasDisk(), KEY_PRIVATE, Store::Disk::logEntry(), StoreEntry::swap_dirn, StoreEntry::swap_filen, SWAP_LOG_MAX, SWAP_LOG_NOP, and swap_log_op_str.
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 699 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 57 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 35 of file Disks.cc.
Referenced by Store::Disks::init(), and Store::Disks::SelectSwapDir().
◆ storeDirSelectSwapDirLeastLoad
|
static |
Definition at line 30 of file Disks.cc.
Referenced by Store::Disks::init().
◆ storeDirSelectSwapDirRoundRobin
|
static |
Definition at line 29 of file Disks.cc.
Referenced by Store::Disks::init().