manages a single cache_dir More...

#include <Disk.h>

Inheritance diagram for Store::Disk:
Collaboration diagram for Store::Disk:

Classes

class  CleanLog
 
struct  Flags
 

Public Types

typedef RefCount< DiskPointer
 

Public Member Functions

 Disk (char const *aType)
 
 ~Disk () override
 
virtual void reconfigure ()=0
 
char const * type () const
 
virtual bool needsDiskStrand () const
 needs a dedicated kid process More...
 
virtual bool active () const
 
virtual bool doReportStat () const
 whether stat should be reported by this SwapDir More...
 
virtual bool unlinkdUseful () const =0
 whether SwapDir may benefit from unlinkd More...
 
virtual void diskFull ()
 
void create () override
 create system resources needed for this store to operate in the future More...
 
StoreEntryget (const cache_key *) override
 
uint64_t maxSize () const override
 
uint64_t minSize () const override
 the minimum size the store will shrink to via normal housekeeping More...
 
int64_t maxObjectSize () const override
 the maximum size of a storable object; -1 if unlimited More...
 
void getStats (StoreInfoStats &stats) const override
 collect statistics More...
 
void stat (StoreEntry &) const override
 
void reference (StoreEntry &e) override
 somebody needs this entry (many cache replacement policies need to know) More...
 
bool dereference (StoreEntry &e) override
 
void maintain () override
 perform regular periodic maintenance; TODO: move to UFSSwapDir::Maintain More...
 
virtual bool smpAware () const =0
 whether this disk storage is capable of serving multiple workers More...
 
int64_t minObjectSize () const
 the size of the smallest entry this cache_dir can store More...
 
void maxObjectSize (int64_t newMax)
 
bool objectSizeIsAcceptable (int64_t objSize) const
 
virtual void disconnect (StoreEntry &)
 called when the entry is about to forget its association with cache_dir More...
 
virtual void finalizeSwapoutSuccess (const StoreEntry &)=0
 finalize the successful swapout that has been already noticed by Store More...
 
virtual void finalizeSwapoutFailure (StoreEntry &)=0
 abort the failed swapout that has been already noticed by Store More...
 
virtual bool hasReadableEntry (const StoreEntry &e) const =0
 whether this cache dir has an entry with e.key More...
 
virtual void dump (StoreEntry &) const
 
virtual bool doubleCheck (StoreEntry &)
 
virtual void statfs (StoreEntry &) const
 
virtual bool canStore (const StoreEntry &e, int64_t diskSpaceNeeded, int &load) const =0
 check whether we can store the entry; if we can, report current load More...
 
virtual StoreIOState::Pointer createStoreIO (StoreEntry &, StoreIOState::STIOCB *, void *)=0
 
virtual StoreIOState::Pointer openStoreIO (StoreEntry &, StoreIOState::STIOCB *, void *)=0
 
bool canLog (StoreEntry const &e) const
 
virtual void openLog ()
 
virtual void closeLog ()
 
virtual void logEntry (const StoreEntry &e, int op) const
 
virtual int writeCleanStart ()
 
virtual void writeCleanDone ()
 
virtual void parse (int index, char *path)=0
 
virtual void updateHeaders (StoreEntry *)
 make stored metadata and HTTP headers the same as in the given entry More...
 
virtual bool anchorToCache (StoreEntry &)
 
virtual bool updateAnchored (StoreEntry &)
 
virtual void init ()=0
 
virtual uint64_t currentSize () const =0
 current size More...
 
virtual uint64_t currentCount () const =0
 the total number of objects stored right now More...
 
virtual void evictCached (StoreEntry &e)=0
 
virtual void evictIfFound (const cache_key *)=0
 
virtual int callback ()
 called once every main loop iteration; TODO: Move to UFS code. More...
 
virtual void sync ()
 prepare for shutdown More...
 

Public Attributes

char * path
 
int index
 
int disker
 disker kid id dedicated to this SwapDir or -1 More...
 
RemovalPolicyrepl
 
int removals
 
int scanned
 
struct Store::Disk::Flags flags
 
CleanLogcleanLog
 
struct {
   int   blksize
 
fs
 

Protected Member Functions

void parseOptions (int reconfiguring)
 
void dumpOptions (StoreEntry *e) const
 
virtual ConfigOptiongetOptionTree () const
 
virtual bool allowOptionReconfigure (const char *const) const
 
int64_t sizeInBlocks (const int64_t size) const
 

Protected Attributes

uint64_t max_size
 maximum allocatable size of the storage area More...
 
int64_t min_objsize
 minimum size of any object stored here (-1 for no limit) More...
 
int64_t max_objsize
 maximum size of any object stored here (-1 for no limit) More...
 

Private Member Functions

bool optionReadOnlyParse (char const *option, const char *value, int reconfiguring)
 
void optionReadOnlyDump (StoreEntry *e) const
 
bool optionObjectSizeParse (char const *option, const char *value, int reconfiguring)
 
void optionObjectSizeDump (StoreEntry *e) const
 

Private Attributes

char const * theType
 

Detailed Description

Definition at line 21 of file Disk.h.

Member Typedef Documentation

◆ Pointer

Definition at line 25 of file Disk.h.

Constructor & Destructor Documentation

◆ Disk()

Store::Disk::Disk ( char const *  aType)
explicit

Definition at line 24 of file Disk.cc.

References fs.

◆ ~Disk()

Store::Disk::~Disk ( )
override

Definition at line 33 of file Disk.cc.

References xfree.

Member Function Documentation

◆ active()

bool Store::Disk::active ( ) const
virtual

may be used in this strand

Definition at line 236 of file Disk.cc.

References IamWorkerProcess(), and KidIdentifier.

Referenced by Store::Disks::anchorToCache(), and doReportStat().

◆ allowOptionReconfigure()

virtual bool Store::Disk::allowOptionReconfigure ( const char * const  ) const
inlineprotectedvirtual

Reimplemented in Rock::SwapDir.

Definition at line 85 of file Disk.h.

Referenced by Rock::SwapDir::allowOptionReconfigure().

◆ anchorToCache()

virtual bool Store::Controlled::anchorToCache ( StoreEntry )
inlinevirtualinherited

tie StoreEntry to this storage if this storage has a matching entry

Return values
trueif this storage has a matching entry

Reimplemented in Rock::SwapDir, MemStore, and Store::Disks.

Definition at line 39 of file Controlled.h.

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

◆ callback()

virtual int Store::Storage::callback ( )
inlinevirtualinherited

Reimplemented in Fs::Ufs::UFSSwapDir, Store::Controller, Store::Disks, and StoreControllerStub.

Definition at line 72 of file Storage.h.

◆ canLog()

bool Store::Disk::canLog ( StoreEntry const &  e) const

◆ canStore()

bool Store::Disk::canStore ( const StoreEntry e,
int64_t  diskSpaceNeeded,
int load 
) const
pure virtual

◆ closeLog()

void Store::Disk::closeLog ( )
virtual

Reimplemented in Fs::Ufs::UFSSwapDir.

Definition at line 215 of file Disk.cc.

Referenced by storeDirCloseSwapLogs().

◆ create()

void Store::Disk::create ( )
overridevirtual

Implements Store::Storage.

Definition at line 40 of file Disk.cc.

◆ createStoreIO()

virtual StoreIOState::Pointer Store::Disk::createStoreIO ( StoreEntry ,
StoreIOState::STIOCB ,
void *   
)
pure virtual

◆ currentCount()

virtual uint64_t Store::Storage::currentCount ( ) const
pure virtualinherited

◆ currentSize()

virtual uint64_t Store::Storage::currentSize ( ) const
pure virtualinherited

◆ dereference()

bool Store::Disk::dereference ( StoreEntry e)
overridevirtual

somebody no longer needs this entry (usually after calling reference()) return false iff the idle entry should be destroyed

Implements Store::Controlled.

Definition at line 139 of file Disk.cc.

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

◆ disconnect()

virtual void Store::Disk::disconnect ( StoreEntry )
inlinevirtual

Reimplemented in Rock::SwapDir.

Definition at line 71 of file Disk.h.

Referenced by destroyStoreEntry().

◆ diskFull()

void Store::Disk::diskFull ( )
virtual

Notify this disk that it is full. XXX move into a protected api call between store files and their stores, rather than a top level api call

Reimplemented in Rock::SwapDir.

Definition at line 145 of file Disk.cc.

References DBG_IMPORTANT, and debugs.

Referenced by storeSwapOutFileClosed().

◆ doReportStat()

virtual bool Store::Disk::doReportStat ( ) const
inlinevirtual

Reimplemented in Rock::SwapDir.

Definition at line 35 of file Disk.h.

References active().

◆ doubleCheck()

bool Store::Disk::doubleCheck ( StoreEntry )
virtual

Reimplemented in Fs::Ufs::UFSSwapDir.

Definition at line 46 of file Disk.cc.

Referenced by storeCleanup().

◆ dump()

void Store::Disk::dump ( StoreEntry ) const
virtual

Reimplemented in Fs::Ufs::UFSSwapDir.

Definition at line 43 of file Disk.cc.

◆ dumpOptions()

void Store::Disk::dumpOptions ( StoreEntry e) const
protected

Definition at line 307 of file Disk.cc.

References ConfigOption::dump().

◆ evictCached()

virtual void Store::Storage::evictCached ( StoreEntry e)
pure virtualinherited

Prevent new get() calls from returning the matching entry. If the matching entry is unused, it may be removed from the store now. The store entry is matched using either e attachment info or e.key.

Implemented in Rock::SwapDir, Fs::Ufs::UFSSwapDir, MemStore, Store::Controller, Store::Disks, TestSwapDir, and Transients.

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

◆ evictIfFound()

virtual void Store::Storage::evictIfFound ( const cache_key )
pure virtualinherited

An evictCached() equivalent for callers that did not get() a StoreEntry. Callers with StoreEntry objects must use evictCached() instead.

Implemented in Rock::SwapDir, Fs::Ufs::UFSSwapDir, MemStore, Store::Controller, Store::Disks, TestSwapDir, and Transients.

◆ finalizeSwapoutFailure()

virtual void Store::Disk::finalizeSwapoutFailure ( StoreEntry )
pure virtual

◆ finalizeSwapoutSuccess()

virtual void Store::Disk::finalizeSwapoutSuccess ( const StoreEntry )
pure virtual

◆ get()

StoreEntry * Store::Disk::get ( const cache_key )
overridevirtual
Returns
a possibly unlocked/unregistered stored entry with key (or nil) The returned entry might not match the caller's Store ID or method. The caller must abandon()/release() the entry or register it with Root(). This method must not trigger slow I/O operations (e.g., disk swap in).

Implements Store::Controlled.

Definition at line 393 of file Disk.cc.

◆ getOptionTree()

ConfigOption * Store::Disk::getOptionTree ( ) const
protectedvirtual

◆ getStats()

void Store::Disk::getStats ( StoreInfoStats stats) const
overridevirtual

Implements Store::Storage.

Definition at line 52 of file Disk.cc.

References Ping::stats.

◆ hasReadableEntry()

virtual bool Store::Disk::hasReadableEntry ( const StoreEntry e) const
pure virtual

◆ init()

virtual void Store::Storage::init ( )
pure virtualinherited

Start preparing the store for use. To check readiness, callers should use readable() and writable() methods.

Implemented in Rock::SwapDir, Fs::Ufs::UFSSwapDir, MemStore, Store::Controller, Store::Disks, StoreControllerStub, TestSwapDir, and Transients.

◆ logEntry()

void Store::Disk::logEntry ( const StoreEntry e,
int  op 
) const
virtual

Reimplemented in Fs::Ufs::UFSSwapDir.

Definition at line 227 of file Disk.cc.

Referenced by storeDirSwapLog().

◆ maintain()

void Store::Disk::maintain ( )
overridevirtual

Implements Store::Storage.

Definition at line 86 of file Disk.cc.

◆ maxObjectSize() [1/2]

int64_t Store::Disk::maxObjectSize ( ) const
overridevirtual

Implements Store::Storage.

Definition at line 103 of file Disk.cc.

References Config, SquidConfig::maxObjectSize, min(), and SquidConfig::Store.

Referenced by Fs::Ufs::UFSStoreState::write().

◆ maxObjectSize() [2/2]

void Store::Disk::maxObjectSize ( int64_t  newMax)

configure the maximum object size for this storage area. May be any size up to the total storage area.

Definition at line 115 of file Disk.cc.

References DBG_PARSE_NOTE, and debugs.

◆ maxSize()

uint64_t Store::Disk::maxSize ( ) const
inlineoverridevirtual

The maximum size the store will support in normal use. Inaccuracy is permitted, but may throw estimates for memory etc out of whack.

Implements Store::Storage.

Reimplemented in TestSwapDir.

Definition at line 48 of file Disk.h.

References max_size.

◆ minObjectSize()

int64_t Store::Disk::minObjectSize ( ) const

Definition at line 96 of file Disk.cc.

References Config, SquidConfig::minObjectSize, and SquidConfig::Store.

◆ minSize()

uint64_t Store::Disk::minSize ( ) const
overridevirtual

Implements Store::Storage.

Definition at line 89 of file Disk.cc.

References Config, SquidConfig::lowWaterMark, and SquidConfig::Swap.

◆ needsDiskStrand()

bool Store::Disk::needsDiskStrand ( ) const
virtual

Reimplemented in Rock::SwapDir.

Definition at line 249 of file Disk.cc.

◆ objectSizeIsAcceptable()

bool Store::Disk::objectSizeIsAcceptable ( int64_t  objSize) const

whether we can store an object of the given size negative objSize means the object size is currently unknown

Definition at line 156 of file Disk.cc.

References assert.

◆ openLog()

void Store::Disk::openLog ( )
virtual

Reimplemented in Fs::Ufs::UFSSwapDir.

Definition at line 212 of file Disk.cc.

Referenced by storeDirOpenSwapLogs().

◆ openStoreIO()

virtual StoreIOState::Pointer Store::Disk::openStoreIO ( StoreEntry ,
StoreIOState::STIOCB ,
void *   
)
pure virtual

Implemented in Rock::SwapDir, Fs::Ufs::UFSSwapDir, and TestSwapDir.

Referenced by storeOpen().

◆ optionObjectSizeDump()

void Store::Disk::optionObjectSizeDump ( StoreEntry e) const
private

Definition at line 382 of file Disk.cc.

References PRId64, and storeAppendPrintf().

Referenced by getOptionTree().

◆ optionObjectSizeParse()

bool Store::Disk::optionObjectSizeParse ( char const *  option,
const char *  value,
int  reconfiguring 
)
private

Definition at line 347 of file Disk.cc.

References DBG_IMPORTANT, debugs, self_destruct(), size, and strtoll().

Referenced by getOptionTree().

◆ optionReadOnlyDump()

void Store::Disk::optionReadOnlyDump ( StoreEntry e) const
private

Definition at line 340 of file Disk.cc.

References storeAppendPrintf().

Referenced by getOptionTree().

◆ optionReadOnlyParse()

bool Store::Disk::optionReadOnlyParse ( char const *  option,
const char *  value,
int  reconfiguring 
)
private

Definition at line 318 of file Disk.cc.

References DBG_PARSE_NOTE, debugs, and xatoi().

Referenced by getOptionTree().

◆ parse()

virtual void Store::Disk::parse ( int  index,
char *  path 
)
pure virtual

◆ parseOptions()

void Store::Disk::parseOptions ( int  reconfiguring)
protected

◆ reconfigure()

virtual void Store::Disk::reconfigure ( )
pure virtual

◆ reference()

void Store::Disk::reference ( StoreEntry e)
overridevirtual

Implements Store::Controlled.

Definition at line 136 of file Disk.cc.

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

◆ sizeInBlocks()

int64_t Store::Disk::sizeInBlocks ( const int64_t  size) const
inlineprotected

Definition at line 87 of file Disk.h.

References fs, and size.

◆ smpAware()

virtual bool Store::Disk::smpAware ( ) const
pure virtual

◆ stat()

void Store::Disk::stat ( StoreEntry e) const
overridevirtual

Output stats to the provided store entry. TODO: make these calls asynchronous

Implements Store::Storage.

Reimplemented in TestSwapDir.

Definition at line 63 of file Disk.cc.

References storeAppendPrintf().

◆ statfs()

void Store::Disk::statfs ( StoreEntry ) const
virtual

Reimplemented in Fs::Ufs::UFSSwapDir, and Rock::SwapDir.

Definition at line 83 of file Disk.cc.

◆ sync()

virtual void Store::Storage::sync ( void  )
inlinevirtualinherited

Reimplemented in Fs::Ufs::UFSSwapDir, Store::Controller, and Store::Disks.

Definition at line 78 of file Storage.h.

◆ type()

char const * Store::Disk::type ( ) const

Definition at line 230 of file Disk.cc.

◆ unlinkdUseful()

virtual bool Store::Disk::unlinkdUseful ( ) const
pure virtual

◆ updateAnchored()

virtual bool Store::Controlled::updateAnchored ( StoreEntry )
inlinevirtualinherited

Update a local Transients entry with fresh info from this cache (if any). Return true iff the cache supports Transients entries and the given local Transients entry is now in sync with this storage.

Reimplemented in Rock::SwapDir, MemStore, and Store::Disks.

Definition at line 44 of file Controlled.h.

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

◆ updateHeaders()

virtual void Store::Controlled::updateHeaders ( StoreEntry )
inlinevirtualinherited

Reimplemented in Store::Disks, Rock::SwapDir, and MemStore.

Definition at line 35 of file Controlled.h.

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

◆ writeCleanDone()

void Store::Disk::writeCleanDone ( )
virtual

Reimplemented in Fs::Ufs::UFSSwapDir.

Definition at line 224 of file Disk.cc.

Referenced by storeDirWriteCleanLogs().

◆ writeCleanStart()

int Store::Disk::writeCleanStart ( )
virtual

Reimplemented in Fs::Ufs::UFSSwapDir.

Definition at line 218 of file Disk.cc.

Member Data Documentation

◆ blksize

int Store::Disk::blksize

Definition at line 146 of file Disk.h.

◆ cleanLog

CleanLog* Store::Disk::cleanLog

Definition at line 140 of file Disk.h.

Referenced by UFSCleanLog::write().

◆ disker

int Store::Disk::disker

Definition at line 104 of file Disk.h.

◆ flags

struct Store::Disk::Flags Store::Disk::flags

◆ 

struct { ... } Store::Disk::fs

Referenced by Disk(), and sizeInBlocks().

◆ index

int Store::Disk::index

Definition at line 103 of file Disk.h.

Referenced by Fs::Ufs::UFSStoreState::UFSStoreState(), and Rock::Rebuild::Start().

◆ max_objsize

int64_t Store::Disk::max_objsize
protected

Definition at line 99 of file Disk.h.

◆ max_size

uint64_t Store::Disk::max_size
protected

Definition at line 97 of file Disk.h.

Referenced by maxSize().

◆ min_objsize

int64_t Store::Disk::min_objsize
protected

Definition at line 98 of file Disk.h.

◆ path

char* Store::Disk::path

◆ removals

int Store::Disk::removals

Definition at line 106 of file Disk.h.

◆ repl

RemovalPolicy* Store::Disk::repl

Definition at line 105 of file Disk.h.

◆ scanned

int Store::Disk::scanned

Definition at line 107 of file Disk.h.

◆ theType

char const* Store::Disk::theType
private

Definition at line 94 of file Disk.h.


The documentation for this class was generated from the following files:

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors