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)
 
virtual ~Disk ()
 
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 ()
 
virtual void create () override
 create system resources needed for this store to operate in the future More...
 
virtual StoreEntryget (const cache_key *) override
 
virtual uint64_t maxSize () const override
 
virtual uint64_t minSize () const override
 the minimum size the store will shrink to via normal housekeeping More...
 
virtual int64_t maxObjectSize () const override
 the maximum size of a storable object; -1 if unlimited More...
 
virtual void getStats (StoreInfoStats &stats) const override
 collect statistics More...
 
virtual void stat (StoreEntry &) const override
 
virtual void reference (StoreEntry &e) override
 somebody needs this entry (many cache replacement policies need to know) More...
 
virtual bool dereference (StoreEntry &e) override
 
virtual 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::STFNCB *, StoreIOState::STIOCB *, void *)=0
 
virtual StoreIOState::Pointer openStoreIO (StoreEntry &, StoreIOState::STFNCB *, 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 &, bool &)
 
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 ( )
virtual

Definition at line 33 of file Disk.cc.

References path, and 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 disker, IamWorkerProcess(), and KidIdentifier.

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

◆ 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(), and optionObjectSizeParse().

◆ anchorToCache()

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

If Transients entry cannot be attached to this storage, return false. If the entry is not found, return false. Otherwise, return true after tying the entry to this cache and setting inSync to updateAnchored().

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

Definition at line 40 of file Controlled.h.

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

◆ callback()

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

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

Definition at line 72 of file Storage.h.

References Store::Storage::maintain().

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

◆ 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.

◆ create()

void Store::Disk::create ( )
overridevirtual

Implements Store::Storage.

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

Definition at line 40 of file Disk.cc.

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

◆ createStoreIO()

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

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

Referenced by storeCreate().

◆ 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.

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

Definition at line 139 of file Disk.cc.

Referenced by Store::Disks::dereference(), and maxSize().

◆ disconnect()

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

◆ diskFull()

void Store::Disk::diskFull ( )
virtual

Notify this disk that it is full.

Todo:
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 Store::Storage::currentSize(), DBG_IMPORTANT, debugs, index, max_size, and maxSize().

Referenced by storeSwapOutFileClosed().

◆ doReportStat()

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

Reimplemented in Rock::SwapDir.

Definition at line 35 of file Disk.h.

Referenced by getStats(), and stat().

◆ doubleCheck()

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

Reimplemented in Fs::Ufs::UFSSwapDir.

Definition at line 46 of file Disk.cc.

Referenced by storeCleanupDoubleCheck().

◆ dump()

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

Reimplemented in Fs::Ufs::UFSSwapDir.

Definition at line 43 of file Disk.cc.

Referenced by dump_cachedir().

◆ dumpOptions()

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

Definition at line 307 of file Disk.cc.

References ConfigOption::dump(), and getOptionTree().

Referenced by disconnect(), and Fs::Ufs::UFSSwapDir::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 Transients, MemStore, Fs::Ufs::UFSSwapDir, Rock::SwapDir, Store::Disks, Store::Controller, and TestSwapDir.

Referenced by Store::Disks::evictCached(), and Store::Storage::~Storage().

◆ 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 Transients, MemStore, Fs::Ufs::UFSSwapDir, Rock::SwapDir, Store::Disks, Store::Controller, and TestSwapDir.

Referenced by Store::Disks::evictIfFound(), and Store::Storage::~Storage().

◆ 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.

Reimplemented in Rock::SwapDir.

Definition at line 393 of file Disk.cc.

References NULL.

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

◆ getOptionTree()

◆ getStats()

◆ hasReadableEntry()

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

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

Referenced by disconnect().

◆ 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, Transients, TestStore, MemStore, Fs::Ufs::UFSSwapDir, Store::Controller, TestSwapDir, and Store::Disks.

Referenced by Store::Disks::init(), and Store::Storage::~Storage().

◆ 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.

◆ maintain()

void Store::Disk::maintain ( )
overridevirtual

Implements Store::Storage.

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

Definition at line 86 of file Disk.cc.

Referenced by Store::Disks::maintain(), and maxSize().

◆ maxObjectSize() [1/2]

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

◆ 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, debugs, max_objsize, maxSize(), and path.

◆ maxSize()

◆ minObjectSize()

int64_t Store::Disk::minObjectSize ( ) const

Definition at line 96 of file Disk.cc.

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

Referenced by maxSize(), and objectSizeIsAcceptable().

◆ minSize()

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

◆ needsDiskStrand()

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

Reimplemented in Rock::SwapDir.

Definition at line 249 of file Disk.cc.

Referenced by configDoConfigure().

◆ 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, maxObjectSize(), and minObjectSize().

Referenced by canStore(), and maxSize().

◆ openLog()

void Store::Disk::openLog ( )
virtual

Reimplemented in Fs::Ufs::UFSSwapDir.

Definition at line 212 of file Disk.cc.

◆ openStoreIO()

virtual StoreIOState::Pointer Store::Disk::openStoreIO ( StoreEntry ,
StoreIOState::STFNCB ,
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 max_objsize, min_objsize, PRId64, and storeAppendPrintf().

Referenced by getOptionTree(), and sizeInBlocks().

◆ optionObjectSizeParse()

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

◆ optionReadOnlyDump()

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

Definition at line 340 of file Disk.cc.

References flags, Store::Disk::Flags::read_only, and storeAppendPrintf().

Referenced by getOptionTree(), and sizeInBlocks().

◆ 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, flags, Store::Disk::Flags::read_only, and xatoi().

Referenced by getOptionTree(), and sizeInBlocks().

◆ parse()

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

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

Referenced by parse_cachedir().

◆ parseOptions()

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

◆ reconfigure()

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

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

Referenced by parse_cachedir().

◆ reference()

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

Implements Store::Controlled.

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

Definition at line 136 of file Disk.cc.

Referenced by maxSize(), and Store::Disks::reference().

◆ sizeInBlocks()

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

◆ smpAware()

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

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

Referenced by maxSize().

◆ stat()

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

◆ statfs()

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

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

Definition at line 83 of file Disk.cc.

Referenced by stat().

◆ 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.

Referenced by Store::Disks::sync(), and Store::Controller::sync().

◆ type()

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

Definition at line 230 of file Disk.cc.

References theType.

Referenced by dump_cachedir(), parse_cachedir(), and stat().

◆ unlinkdUseful()

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

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

Referenced by unlinkdNeeded().

◆ 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 45 of file Controlled.h.

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

◆ updateHeaders()

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

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

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.

◆ writeCleanStart()

int Store::Disk::writeCleanStart ( )
virtual

Reimplemented in Fs::Ufs::UFSSwapDir.

Definition at line 218 of file Disk.cc.

Referenced by storeDirWriteCleanLogs().

Member Data Documentation

◆ blksize

int Store::Disk::blksize

Definition at line 146 of file Disk.h.

◆ cleanLog

◆ disker

int Store::Disk::disker

Definition at line 104 of file Disk.h.

Referenced by active(), and configDoConfigure().

◆ flags

◆ fs

◆ index

◆ max_objsize

int64_t Store::Disk::max_objsize
protected

Definition at line 99 of file Disk.h.

Referenced by canStore(), maxObjectSize(), optionObjectSizeDump(), and optionObjectSizeParse().

◆ max_size

uint64_t Store::Disk::max_size
protected

Definition at line 97 of file Disk.h.

Referenced by diskFull(), maxSize(), and Rock::SwapDir::parseSize().

◆ min_objsize

int64_t Store::Disk::min_objsize
protected

Definition at line 98 of file Disk.h.

Referenced by minObjectSize(), optionObjectSizeDump(), and optionObjectSizeParse().

◆ path

◆ removals

int Store::Disk::removals

Definition at line 106 of file Disk.h.

◆ repl

◆ 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.

Referenced by type().


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors