Disk.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #ifndef SQUID_STORE_DISK_H
10 #define SQUID_STORE_DISK_H
11 
12 #include "store/Controlled.h"
13 #include "StoreIOState.h"
14 
15 class ConfigOption;
16 class RemovalPolicy;
17 
18 namespace Store {
19 
21 class Disk: public Controlled
22 {
23 
24 public:
26 
27  explicit Disk(char const *aType);
28  virtual ~Disk();
29  virtual void reconfigure() = 0;
30  char const *type() const;
31 
32  virtual bool needsDiskStrand() const;
33  virtual bool active() const;
34  virtual bool doReportStat() const { return active(); }
37  virtual bool unlinkdUseful() const = 0;
38 
43  virtual void diskFull();
44 
45  /* Controlled API */
46  virtual void create() override;
47  virtual StoreEntry *get(const cache_key *) override;
48  virtual uint64_t maxSize() const override { return max_size; }
49  virtual uint64_t minSize() const override;
50  virtual int64_t maxObjectSize() const override;
51  virtual void getStats(StoreInfoStats &stats) const override;
52  virtual void stat(StoreEntry &) const override;
53  virtual void reference(StoreEntry &e) override;
54  virtual bool dereference(StoreEntry &e) override;
55  virtual void maintain() override;
56  virtual bool smpAware() const override { return false; }
57 
59  int64_t minObjectSize() const;
60 
63  void maxObjectSize(int64_t newMax);
64 
67  bool objectSizeIsAcceptable(int64_t objSize) const;
68 
70  virtual void disconnect(StoreEntry &) {}
71 
73  virtual void finalizeSwapoutSuccess(const StoreEntry &) = 0;
75  virtual void finalizeSwapoutFailure(StoreEntry &) = 0;
76 
78  virtual bool hasReadableEntry(const StoreEntry &e) const = 0;
79 
80 protected:
81  void parseOptions(int reconfiguring);
82  void dumpOptions(StoreEntry * e) const;
83  virtual ConfigOption *getOptionTree() const;
84  virtual bool allowOptionReconfigure(const char *const) const { return true; }
85 
86  int64_t sizeInBlocks(const int64_t size) const { return (size + fs.blksize - 1) / fs.blksize; }
87 
88 private:
89  bool optionReadOnlyParse(char const *option, const char *value, int reconfiguring);
90  void optionReadOnlyDump(StoreEntry * e) const;
91  bool optionObjectSizeParse(char const *option, const char *value, int reconfiguring);
92  void optionObjectSizeDump(StoreEntry * e) const;
93  char const *theType;
94 
95 protected:
96  uint64_t max_size;
97  int64_t min_objsize;
98  int64_t max_objsize;
99 
100 public:
101  char *path;
102  int index; /* This entry's index into the swapDirs array */
103  int disker;
105  int removals;
106  int scanned;
107 
108  struct Flags {
110  bool selected;
111  bool read_only;
112  } flags;
113 
114  virtual void dump(StoreEntry &)const; /* Dump fs config snippet */
115  virtual bool doubleCheck(StoreEntry &); /* Double check the obj integrity */
116  virtual void statfs(StoreEntry &) const; /* Dump fs statistics */
117 
119  virtual bool canStore(const StoreEntry &e, int64_t diskSpaceNeeded, int &load) const = 0;
120 
123 
124  bool canLog(StoreEntry const &e)const;
125  virtual void openLog();
126  virtual void closeLog();
127  virtual void logEntry(const StoreEntry & e, int op) const;
128 
129  class CleanLog
130  {
131 
132  public:
133  virtual ~CleanLog() {}
134 
135  virtual const StoreEntry *nextEntry() = 0;
136  virtual void write(StoreEntry const &) = 0;
137  };
138 
140  virtual int writeCleanStart();
141  virtual void writeCleanDone();
142  virtual void parse(int index, char *path) = 0;
143 
144  struct {
145  int blksize;
146  } fs;
147 };
148 
149 } // namespace Store
150 
151 #endif /* SQUID_STORE_DISK_H */
152 
CleanLog * cleanLog
Definition: Disk.h:139
virtual void getStats(StoreInfoStats &stats) const override
collect statistics
Definition: Disk.cc:52
int64_t max_objsize
maximum size of any object stored here (-1 for no limit)
Definition: Disk.h:98
virtual int64_t maxObjectSize() const override
the maximum size of a storable object; -1 if unlimited
Definition: Disk.cc:103
virtual bool active() const
Definition: Disk.cc:236
virtual void closeLog()
Definition: Disk.cc:215
virtual bool hasReadableEntry(const StoreEntry &e) const =0
whether this cache dir has an entry with e.key
RefCount< Disk > Pointer
Definition: Disk.h:25
unsigned char cache_key
Store key.
Definition: forward.h:29
virtual void openLog()
Definition: Disk.cc:212
virtual void disconnect(StoreEntry &)
called when the entry is about to forget its association with cache_dir
Definition: Disk.h:70
int scanned
Definition: Disk.h:106
class Ping::pingStats_ stats
struct Store::Disk::Flags flags
bool canLog(StoreEntry const &e) const
Definition: Disk.cc:188
virtual void stat(StoreEntry &) const override
Definition: Disk.cc:63
High-level store statistics used by mgr:info action. Used inside PODs!
Definition: StoreStats.h:13
virtual bool dereference(StoreEntry &e) override
Definition: Disk.cc:139
virtual void reference(StoreEntry &e) override
somebody needs this entry (many cache replacement policies need to know)
Definition: Disk.cc:136
int64_t minObjectSize() const
the size of the smallest entry this cache_dir can store
Definition: Disk.cc:96
int removals
Definition: Disk.h:105
char * path
Definition: Disk.h:101
virtual ~CleanLog()
Definition: Disk.h:133
virtual StoreIOState::Pointer createStoreIO(StoreEntry &, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *)=0
virtual void statfs(StoreEntry &) const
Definition: Disk.cc:83
void parseOptions(int reconfiguring)
Definition: Disk.cc:267
struct Store::Disk::@141 fs
int64_t sizeInBlocks(const int64_t size) const
Definition: Disk.h:86
void dumpOptions(StoreEntry *e) const
Definition: Disk.cc:307
int disker
disker kid id dedicated to this SwapDir or -1
Definition: Disk.h:103
virtual void dump(StoreEntry &) const
Definition: Disk.cc:43
void STFNCB(void *their_data, int errflag, StoreIOState::Pointer self)
Definition: StoreIOState.h:41
virtual bool needsDiskStrand() const
needs a dedicated kid process
Definition: Disk.cc:249
virtual void write(StoreEntry const &)=0
RemovalPolicy * repl
Definition: Disk.h:104
virtual ~Disk()
Definition: Disk.cc:33
virtual bool unlinkdUseful() const =0
whether SwapDir may benefit from unlinkd
virtual bool doReportStat() const
whether stat should be reported by this SwapDir
Definition: Disk.h:35
virtual uint64_t maxSize() const override
Definition: Disk.h:48
char const * theType
Definition: Disk.h:93
virtual uint64_t minSize() const override
the minimum size the store will shrink to via normal housekeeping
Definition: Disk.cc:89
int64_t min_objsize
minimum size of any object stored here (-1 for no limit)
Definition: Disk.h:97
virtual bool smpAware() const override
Definition: Disk.h:56
int index
Definition: Disk.h:102
virtual void diskFull()
Definition: Disk.cc:145
void STIOCB(void *their_data, int errflag, StoreIOState::Pointer self)
Definition: StoreIOState.h:51
virtual bool allowOptionReconfigure(const char *const) const
Definition: Disk.h:84
bool objectSizeIsAcceptable(int64_t objSize) const
Definition: Disk.cc:156
Disk(char const *aType)
Definition: Disk.cc:24
bool read_only
Definition: Disk.h:111
uint64_t max_size
maximum allocatable size of the storage area
Definition: Disk.h:96
virtual void create() override
create system resources needed for this store to operate in the future
Definition: Disk.cc:40
bool optionReadOnlyParse(char const *option, const char *value, int reconfiguring)
Definition: Disk.cc:318
int blksize
Definition: Disk.h:145
void optionObjectSizeDump(StoreEntry *e) const
Definition: Disk.cc:382
virtual ConfigOption * getOptionTree() const
Definition: Disk.cc:258
virtual int writeCleanStart()
Definition: Disk.cc:218
virtual void maintain() override
perform regular periodic maintenance; TODO: move to UFSSwapDir::Maintain
Definition: Disk.cc:86
char const * type() const
Definition: Disk.cc:230
virtual void reconfigure()=0
virtual void finalizeSwapoutSuccess(const StoreEntry &)=0
finalize the successful swapout that has been already noticed by Store
virtual void writeCleanDone()
Definition: Disk.cc:224
virtual void parse(int index, char *path)=0
virtual void logEntry(const StoreEntry &e, int op) const
Definition: Disk.cc:227
virtual bool doubleCheck(StoreEntry &)
Definition: Disk.cc:46
bool optionObjectSizeParse(char const *option, const char *value, int reconfiguring)
Definition: Disk.cc:347
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
Definition: Disk.cc:164
virtual StoreIOState::Pointer openStoreIO(StoreEntry &, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *)=0
void optionReadOnlyDump(StoreEntry *e) const
Definition: Disk.cc:340
virtual void finalizeSwapoutFailure(StoreEntry &)=0
abort the failed swapout that has been already noticed by Store
virtual const StoreEntry * nextEntry()=0
int reconfiguring
int size
Definition: ModDevPoll.cc:77
#define false
Definition: GnuRegex.c:233
manages a single cache_dir
Definition: Disk.h:21

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors