]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/store/Disk.h
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
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.
9 #ifndef SQUID_STORE_DISK_H
10 #define SQUID_STORE_DISK_H
12 #include "store/Controlled.h"
13 #include "StoreIOState.h"
21 /// manages a single cache_dir
22 class Disk
: public Controlled
26 typedef RefCount
<Disk
> Pointer
;
28 explicit Disk(char const *aType
);
30 virtual void reconfigure() = 0;
31 char const *type() const;
33 virtual bool needsDiskStrand() const; ///< needs a dedicated kid process
34 virtual bool active() const; ///< may be used in this strand
35 /// whether stat should be reported by this SwapDir
36 virtual bool doReportStat() const { return active(); }
37 /// whether SwapDir may benefit from unlinkd
38 virtual bool unlinkdUseful() const = 0;
41 * Notify this disk that it is full.
42 \todo XXX move into a protected api call between store files and their stores, rather than a top level api call
44 virtual void diskFull();
47 virtual void create() override
;
48 virtual StoreEntry
*get(const cache_key
*) override
;
49 virtual uint64_t maxSize() const override
{ return max_size
; }
50 virtual uint64_t minSize() const override
;
51 virtual int64_t maxObjectSize() const override
;
52 virtual void getStats(StoreInfoStats
&stats
) const override
;
53 virtual void stat(StoreEntry
&) const override
;
54 virtual void reference(StoreEntry
&e
) override
;
55 virtual bool dereference(StoreEntry
&e
) override
;
56 virtual void maintain() override
;
58 /// configure the maximum object size for this storage area.
59 /// May be any size up to the total storage area.
60 void maxObjectSize(int64_t newMax
);
62 /// whether we can store an object of the given size
63 /// negative objSize means the object size is currently unknown
64 bool objectSizeIsAcceptable(int64_t objSize
) const;
66 /// called when the entry is about to forget its association with cache_dir
67 virtual void disconnect(StoreEntry
&) {}
69 /// called when entry swap out is complete
70 virtual void swappedOut(const StoreEntry
&e
) = 0;
73 void parseOptions(int reconfiguring
);
74 void dumpOptions(StoreEntry
* e
) const;
75 virtual ConfigOption
*getOptionTree() const;
76 virtual bool allowOptionReconfigure(const char *const) const { return true; }
78 int64_t sizeInBlocks(const int64_t size
) const { return (size
+ fs
.blksize
- 1) / fs
.blksize
; }
81 bool optionReadOnlyParse(char const *option
, const char *value
, int reconfiguring
);
82 void optionReadOnlyDump(StoreEntry
* e
) const;
83 bool optionObjectSizeParse(char const *option
, const char *value
, int reconfiguring
);
84 void optionObjectSizeDump(StoreEntry
* e
) const;
88 uint64_t max_size
; ///< maximum allocatable size of the storage area
89 int64_t min_objsize
; ///< minimum size of any object stored here (-1 for no limit)
90 int64_t max_objsize
; ///< maximum size of any object stored here (-1 for no limit)
94 int index
; /* This entry's index into the swapDirs array */
95 int disker
; ///< disker kid id dedicated to this SwapDir or -1
101 Flags() : selected(false), read_only(false) {}
106 virtual void dump(StoreEntry
&)const; /* Dump fs config snippet */
107 virtual bool doubleCheck(StoreEntry
&); /* Double check the obj integrity */
108 virtual void statfs(StoreEntry
&) const; /* Dump fs statistics */
110 /// check whether we can store the entry; if we can, report current load
111 virtual bool canStore(const StoreEntry
&e
, int64_t diskSpaceNeeded
, int &load
) const = 0;
113 virtual StoreIOState::Pointer
createStoreIO(StoreEntry
&, StoreIOState::STFNCB
*, StoreIOState::STIOCB
*, void *) = 0;
114 virtual StoreIOState::Pointer
openStoreIO(StoreEntry
&, StoreIOState::STFNCB
*, StoreIOState::STIOCB
*, void *) = 0;
116 bool canLog(StoreEntry
const &e
)const;
117 virtual void openLog();
118 virtual void closeLog();
119 virtual void logEntry(const StoreEntry
& e
, int op
) const;
125 virtual ~CleanLog() {}
127 virtual const StoreEntry
*nextEntry() = 0;
128 virtual void write(StoreEntry
const &) = 0;
132 virtual int writeCleanStart();
133 virtual void writeCleanDone();
134 virtual void parse(int index
, char *path
) = 0;
143 #endif /* SQUID_STORE_DISK_H */