]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/fs/coss/CossSwapDir.h
1 #ifndef __COSSSWAPDIR_H__
2 #define __COSSSWAPDIR_H__
9 class ConfigOptionVector
;
13 #include "DiskIO/IORequestor.h"
16 #ifndef COSS_MEMBUF_SZ
17 #define COSS_MEMBUF_SZ 1048576
20 /* Note that swap_filen in sio/e are actually disk offsets too! */
22 /* What we're doing in storeCossAllocate() */
23 #define COSS_ALLOC_ALLOCATE 1
24 #define COSS_ALLOC_REALLOC 2
28 class CossSwapDir
: public SwapDir
, public IORequestor
34 virtual void create();
35 virtual void dump(StoreEntry
&)const;
37 virtual StoreSearch
*search(String
const url
, HttpRequest
*);
38 virtual void unlink (StoreEntry
&);
39 virtual void statfs (StoreEntry
&)const;
40 virtual bool canStore(const StoreEntry
&e
, int64_t diskSpaceNeeded
, int &load
) const;
41 virtual int callback();
43 virtual StoreIOState::Pointer
createStoreIO(StoreEntry
&, StoreIOState::STFNCB
*, StoreIOState::STIOCB
*, void *);
44 virtual StoreIOState::Pointer
openStoreIO(StoreEntry
&, StoreIOState::STFNCB
*, StoreIOState::STIOCB
*, void *);
45 virtual void openLog();
46 virtual void closeLog();
47 virtual int writeCleanStart();
48 virtual void writeCleanDone();
49 virtual void logEntry(const StoreEntry
& e
, int op
) const;
50 virtual void parse (int index
, char *path
);
51 virtual void reconfigure (int, char *);
52 virtual void swappedOut(const StoreEntry
&e
);
53 virtual uint64_t currentSize() const { return cur_size
; }
54 virtual uint64_t currentCount() const { return n_disk_objects
; }
56 virtual off_t
storeCossFilenoToDiskOffset(sfileno
);
57 virtual sfileno
storeCossDiskOffsetToFileno(off_t
);
58 virtual CossMemBuf
*storeCossFilenoToMembuf(sfileno f
);
59 /* IORequestor routines */
60 virtual void ioCompletedNotification();
61 virtual void closeCompleted();
62 virtual void readCompleted(const char *buf
, int len
, int errflag
, RefCount
<ReadRequest
>);
63 virtual void writeCompleted(int errflag
, size_t len
, RefCount
<WriteRequest
>);
69 CossMemBuf
*current_membuf
;
70 off_t current_offset
; /* in Blocks */
73 unsigned int blksz_bits
;
74 unsigned int blksz_mask
; /* just 1<<blksz_bits - 1*/
76 RefCount
<DiskFile
> theFile
;
77 char *storeCossMemPointerFromDiskOffset(off_t offset
, CossMemBuf
** mb
);
78 void storeCossMemBufUnlock(StoreIOState::Pointer
);
79 CossMemBuf
*createMemBuf(off_t start
, sfileno curfn
, int *collision
);
80 sfileno
allocate(const StoreEntry
* e
, int which
);
82 StoreEntry
*addDiskRestore(const cache_key
*const key
,
84 uint64_t swap_file_sz
,
94 void changeIO(DiskIOModule
*module
);
95 bool optionIOParse(char const *option
, const char *value
, int reconfiguring
);
96 void optionIODump(StoreEntry
* e
) const;
97 void optionBlockSizeDump(StoreEntry
*) const;
98 bool optionBlockSizeParse(const char *, const char *, int);
99 char const *stripePath() const;
100 ConfigOption
* getOptionTree() const;
101 const char *ioModule
;
102 mutable ConfigOptionVector
*currentIOOptions
;
103 const char *stripe_path
;
104 uint64_t cur_size
; ///< currently used space in the storage area
105 uint64_t n_disk_objects
; ///< total number of objects stored
109 extern void storeCossAdd(CossSwapDir
*, StoreEntry
*);
111 extern void storeCossRemove(CossSwapDir
*, StoreEntry
*);
113 extern void storeCossStartMembuf(CossSwapDir
* SD
);
116 #include "StoreSearch.h"
119 class StoreSearchCoss
: public StoreSearch
123 StoreSearchCoss(RefCount
<CossSwapDir
> sd
);
124 StoreSearchCoss(StoreSearchCoss
const &);
126 /* Iterator API - garh, wrong place */
127 /* callback the client when a new StoreEntry is available
130 virtual void next(void (callback
)(void *cbdata
), void *cbdata
);
131 /* return true if a new StoreEntry is immediately available */
133 virtual bool error() const;
134 virtual bool isDone() const;
135 virtual StoreEntry
*currentItem();
138 CBDATA_CLASS2(StoreSearchCoss
);
139 RefCount
<CossSwapDir
> sd
;
140 void (*callback
)(void *cbdata
);
143 dlink_node
* current
;