Disks.cc File Reference
#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"
Include dependency graph for Disks.cc:

Go to the source code of this file.

Typedefs

typedef SwapDirSTDIRSELECT(const StoreEntry *e)
 

Functions

static int64_t objectSizeForDirSelection (const StoreEntry &entry)
 
static SwapDirSwapDirByIndex (const int i)
 TODO: Remove when cache_dir-iterating functions are converted to Disks methods. More...
 
static SwapDirstoreDirSelectSwapDirRoundRobin (const StoreEntry *e)
 
static SwapDirstoreDirSelectSwapDirLeastLoad (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 STDIRSELECTstoreDirSelectSwapDir = storeDirSelectSwapDirLeastLoad
 

Typedef Documentation

◆ STDIRSELECT

typedef SwapDir * STDIRSELECT(const StoreEntry *e)

Definition at line 27 of file Disks.cc.

Function Documentation

◆ allocate_new_swapdir()

void allocate_new_swapdir ( Store::DiskConfig swap)

◆ free_cachedir()

◆ objectSizeForDirSelection()

static int64_t objectSizeForDirSelection ( const StoreEntry entry)
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  )

◆ storeDirOpenSwapLogs()

void storeDirOpenSwapLogs ( void  )

◆ storeDirSelectSwapDirLeastLoad()

static SwapDir * storeDirSelectSwapDirLeastLoad ( const StoreEntry e)
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 SwapDir * storeDirSelectSwapDirRoundRobin ( const StoreEntry e)
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.

  1. 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.
  2. 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()

int storeDirWriteCleanLogs ( int  reopen)

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()

Variable Documentation

◆ storeDirSelectSwapDir

STDIRSELECT* storeDirSelectSwapDir = storeDirSelectSwapDirLeastLoad
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

STDIRSELECT storeDirSelectSwapDirLeastLoad
static

Definition at line 30 of file Disks.cc.

Referenced by Store::Disks::init().

◆ storeDirSelectSwapDirRoundRobin

STDIRSELECT storeDirSelectSwapDirRoundRobin
static

Definition at line 29 of file Disks.cc.

Referenced by Store::Disks::init().

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors