Squid Web Cache master
Loading...
Searching...
No Matches
UFSSwapDir.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2025 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_SRC_FS_UFS_UFSSWAPDIR_H
10#define SQUID_SRC_FS_UFS_UFSSWAPDIR_H
11
12#include "SquidString.h"
13#include "Store.h"
14#include "store/Disk.h"
15#include "StoreIOState.h"
16#include "StoreSearch.h"
17#include "swap_log_op.h"
18#include "UFSStrategy.h"
19
20class HttpRequest;
22class FileMap;
23class DiskIOModule;
24
25namespace Fs
26{
27namespace Ufs
28{
30class UFSSwapDir : public SwapDir
31{
32public:
33 static bool IsUFSDir(SwapDir* sd);
34 static int DirClean(int swap_index);
41 static bool FilenoBelongsHere(int fn, int cachedir, int level1dir, int level2dir);
42
43 UFSSwapDir(char const *aType, const char *aModuleType);
44 ~UFSSwapDir() override;
45
46 /* Store::Disk API */
47 void create() override;
48 void init() override;
49 void dump(StoreEntry &) const override;
50 bool doubleCheck(StoreEntry &) override;
51 bool unlinkdUseful() const override;
52 void statfs(StoreEntry &) const override;
53 void maintain() override;
54 void evictCached(StoreEntry &) override;
55 void evictIfFound(const cache_key *) override;
56 bool canStore(const StoreEntry &e, int64_t diskSpaceNeeded, int &load) const override;
57 void reference(StoreEntry &) override;
58 bool dereference(StoreEntry &) override;
61 void openLog() override;
62 void closeLog() override;
63 int writeCleanStart() override;
64 void writeCleanDone() override;
65 void logEntry(const StoreEntry & e, int op) const override;
66 void parse(int index, char *path) override;
67 void reconfigure() override;
68 int callback() override;
69 void sync() override;
70 void finalizeSwapoutSuccess(const StoreEntry &) override;
71 void finalizeSwapoutFailure(StoreEntry &) override;
72 uint64_t currentSize() const override { return cur_size; }
73 uint64_t currentCount() const override { return n_disk_objects; }
74 ConfigOption *getOptionTree() const override;
75 bool smpAware() const override { return false; }
78 bool hasReadableEntry(const StoreEntry &) const override { return false; }
79
80 void unlinkFile(sfileno f);
81 // move down when unlink is a virtual method
82 //protected:
84 char *fullPath(sfileno, char *) const;
85 /* temp */
86 void closeTmpSwapLog();
87 FILE *openTmpSwapLog(int *clean_flag, int *zero_flag);
88 char *swapSubDir(int subdirn) const;
89 int mapBitTest(sfileno filn);
90 void mapBitReset(sfileno filn);
91 void mapBitSet(sfileno filn);
97 sfileno file_number,
98 uint64_t swap_file_sz,
99 time_t expires,
100 time_t timestamp,
101 time_t lastref,
102 time_t lastmod,
103 uint32_t refcount,
104 uint16_t flags,
105 int clean);
106 int validFileno(sfileno filn, int flag) const;
107 int mapBitAllocate();
108
109 void *fsdata;
110
111 bool validL2(int) const;
112 bool validL1(int) const;
113
115 void replacementAdd(StoreEntry *e);
117
118protected:
121 int l1;
122 int l2;
123
124private:
125 void parseSizeL1L2();
126 static size_t NumberOfUFSDirs;
128 bool pathIsDirectory(const char *path)const;
131 static int HandleCleanEvent();
138 bool verifyCacheDirs();
139 void rebuild();
140 int createDirectory(const char *path, int);
141 void createSwapSubDirs();
142 void dumpEntry(StoreEntry &) const;
143 SBuf logFile(char const *ext = nullptr) const;
144 void changeIO(DiskIOModule *);
145 bool optionIOParse(char const *option, const char *value, int reconfiguring);
146 void optionIODump(StoreEntry * e) const;
148 char const *ioType;
149 uint64_t cur_size;
150 uint64_t n_disk_objects;
152};
153
154} //namespace Ufs
155} //namespace Fs
156#endif /* SQUID_SRC_FS_UFS_UFSSWAPDIR_H */
157
void openLog() override
bool pathIsDirectory(const char *path) const
void sync() override
prepare for shutdown
ConfigOptionVector * currentIOOptions
Definition UFSSwapDir.h:147
static EVH CleanEvent
Definition UFSSwapDir.h:130
void finalizeSwapoutFailure(StoreEntry &) override
abort the failed swapout that has been already noticed by Store
uint64_t currentCount() const override
the total number of objects stored right now
Definition UFSSwapDir.h:73
bool unlinkdUseful() const override
whether SwapDir may benefit from unlinkd
int callback() override
called once every main loop iteration; TODO: Move to UFS code.
void replacementAdd(StoreEntry *e)
void evictIfFound(const cache_key *) override
uint64_t currentSize() const override
current size
Definition UFSSwapDir.h:72
StoreEntry * addDiskRestore(const cache_key *key, sfileno file_number, uint64_t swap_file_sz, time_t expires, time_t timestamp, time_t lastref, time_t lastmod, uint32_t refcount, uint16_t flags, int clean)
void mapBitReset(sfileno filn)
void optionIODump(StoreEntry *e) const
int createDirectory(const char *path, int)
void changeIO(DiskIOModule *)
~UFSSwapDir() override
void reconfigure() override
void finalizeSwapoutSuccess(const StoreEntry &) override
finalize the successful swapout that has been already noticed by Store
void parse(int index, char *path) override
void statfs(StoreEntry &) const override
static int DirClean(int swap_index)
SBuf logFile(char const *ext=nullptr) const
FILE * openTmpSwapLog(int *clean_flag, int *zero_flag)
void create() override
create system resources needed for this store to operate in the future
bool hasReadableEntry(const StoreEntry &) const override
Definition UFSSwapDir.h:78
void mapBitSet(sfileno filn)
void evictCached(StoreEntry &) override
char const * ioType
Definition UFSSwapDir.h:148
void reference(StoreEntry &) override
somebody needs this entry (many cache replacement policies need to know)
char * swapSubDir(int subdirn) const
uint64_t n_disk_objects
total number of objects stored
Definition UFSSwapDir.h:150
static int * UFSDirToGlobalDirMapping
Definition UFSSwapDir.h:127
static size_t NumberOfUFSDirs
Definition UFSSwapDir.h:126
void init() override
int validFileno(sfileno filn, int flag) const
void replacementRemove(StoreEntry *e)
int mapBitTest(sfileno filn)
Fs::Ufs::UFSStrategy * IO
Definition UFSSwapDir.h:83
void dumpEntry(StoreEntry &) const
bool dereference(StoreEntry &) override
bool rebuilding_
whether RebuildState is writing the new swap.state
Definition UFSSwapDir.h:151
bool doubleCheck(StoreEntry &) override
void maintain() override
perform regular periodic maintenance; TODO: move to UFSSwapDir::Maintain
static bool IsUFSDir(SwapDir *sd)
ConfigOption * getOptionTree() const override
StoreIOState::Pointer createStoreIO(StoreEntry &, StoreIOState::STIOCB *, void *) override
StoreIOState::Pointer openStoreIO(StoreEntry &, StoreIOState::STIOCB *, void *) override
void logEntry(const StoreEntry &e, int op) const override
void dump(StoreEntry &) const override
static bool FilenoBelongsHere(int fn, int cachedir, int level1dir, int level2dir)
char * fullPath(sfileno, char *) const
int writeCleanStart() override
void closeLog() override
static int HandleCleanEvent()
safely cleans a few unused files if possible
void unlinkFile(sfileno f)
bool validL1(int) const
uint64_t cur_size
currently used space in the storage area
Definition UFSSwapDir.h:149
bool smpAware() const override
whether this disk storage is capable of serving multiple workers
Definition UFSSwapDir.h:75
bool optionIOParse(char const *option, const char *value, int reconfiguring)
bool canStore(const StoreEntry &e, int64_t diskSpaceNeeded, int &load) const override
check whether we can store the entry; if we can, report current load
bool validL2(int) const
void writeCleanDone() override
Definition SBuf.h:94
void STIOCB(void *their_data, int errflag, StoreIOState::Pointer self)
manages a single cache_dir
Definition Disk.h:22
char * path
Definition Disk.h:102
int index
Definition Disk.h:103
struct Store::Disk::Flags flags
void EVH(void *)
Definition event.h:18
int reconfiguring
Definition Module.h:13
unsigned char cache_key
Store key.
Definition forward.h:29
signed_int32_t sfileno
Definition forward.h:22