]>
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 bool unlinkdUseful() const;
39 virtual void unlink (StoreEntry
&);
40 virtual void statfs (StoreEntry
&)const;
41 virtual bool canStore(const StoreEntry
&e
, int64_t diskSpaceNeeded
, int &load
) const;
42 virtual int callback();
44 virtual StoreIOState::Pointer
createStoreIO(StoreEntry
&, StoreIOState::STFNCB
*, StoreIOState::STIOCB
*, void *);
45 virtual StoreIOState::Pointer
openStoreIO(StoreEntry
&, StoreIOState::STFNCB
*, StoreIOState::STIOCB
*, void *);
46 virtual void openLog();
47 virtual void closeLog();
48 virtual int writeCleanStart();
49 virtual void writeCleanDone();
50 virtual void logEntry(const StoreEntry
& e
, int op
) const;
51 virtual void parse (int index
, char *path
);
52 virtual void reconfigure();
53 virtual void swappedOut(const StoreEntry
&e
);
54 virtual uint64_t currentSize() const { return cur_size
; }
55 virtual uint64_t currentCount() const { return n_disk_objects
; }
57 virtual off_t
storeCossFilenoToDiskOffset(sfileno
);
58 virtual sfileno
storeCossDiskOffsetToFileno(off_t
);
59 virtual CossMemBuf
*storeCossFilenoToMembuf(sfileno f
);
60 /* IORequestor routines */
61 virtual void ioCompletedNotification();
62 virtual void closeCompleted();
63 virtual void readCompleted(const char *buf
, int len
, int errflag
, RefCount
<ReadRequest
>);
64 virtual void writeCompleted(int errflag
, size_t len
, RefCount
<WriteRequest
>);
70 CossMemBuf
*current_membuf
;
71 off_t current_offset
; /* in Blocks */
74 unsigned int blksz_bits
;
75 unsigned int blksz_mask
; /* just 1<<blksz_bits - 1*/
77 RefCount
<DiskFile
> theFile
;
78 char *storeCossMemPointerFromDiskOffset(off_t offset
, CossMemBuf
** mb
);
79 void storeCossMemBufUnlock(StoreIOState::Pointer
);
80 CossMemBuf
*createMemBuf(off_t start
, sfileno curfn
, int *collision
);
81 sfileno
allocate(const StoreEntry
* e
, int which
);
83 StoreEntry
*addDiskRestore(const cache_key
*const key
,
85 uint64_t swap_file_sz
,
95 void changeIO(DiskIOModule
*module
);
96 bool optionIOParse(char const *option
, const char *value
, int reconfiguring
);
97 void optionIODump(StoreEntry
* e
) const;
98 void optionBlockSizeDump(StoreEntry
*) const;
99 bool optionBlockSizeParse(const char *, const char *, int);
100 char const *stripePath() const;
101 ConfigOption
* getOptionTree() const;
102 const char *ioModule
;
103 mutable ConfigOptionVector
*currentIOOptions
;
104 const char *stripe_path
;
105 uint64_t cur_size
; ///< currently used space in the storage area
106 uint64_t n_disk_objects
; ///< total number of objects stored
110 extern void storeCossAdd(CossSwapDir
*, StoreEntry
*);
112 extern void storeCossRemove(CossSwapDir
*, StoreEntry
*);
114 extern void storeCossStartMembuf(CossSwapDir
* SD
);
117 #include "StoreSearch.h"
120 class StoreSearchCoss
: public StoreSearch
124 StoreSearchCoss(RefCount
<CossSwapDir
> sd
);
125 StoreSearchCoss(StoreSearchCoss
const &);
127 /* Iterator API - garh, wrong place */
128 /* callback the client when a new StoreEntry is available
131 virtual void next(void (callback
)(void *cbdata
), void *cbdata
);
132 /* return true if a new StoreEntry is immediately available */
134 virtual bool error() const;
135 virtual bool isDone() const;
136 virtual StoreEntry
*currentItem();
139 RefCount
<CossSwapDir
> sd
;
140 void (*callback
)(void *cbdata
);
143 dlink_node
* current
;
146 CBDATA_CLASS2(StoreSearchCoss
);