1
#ifndef __COSSSWAPDIR_H__
2
#define __COSSSWAPDIR_H__
5
#include "StoreSearch.h"
8
#define COSS_MEMBUF_SZ 1048576
11
/* Note that swap_filen in sio/e are actually disk offsets too! */
13
/* What we're doing in storeCossAllocate() */
14
#define COSS_ALLOC_ALLOCATE 1
15
#define COSS_ALLOC_REALLOC 2
26
class ConfigOptionVector;
27
#include "DiskIO/DiskFile.h"
28
#include "DiskIO/IORequestor.h"
30
class CossSwapDir : public SwapDir, public IORequestor
36
virtual void create();
37
virtual void dump(StoreEntry &)const;
39
virtual StoreSearch *search(String const url, HttpRequest *);
40
virtual void unlink (StoreEntry &);
41
virtual void statfs (StoreEntry &)const;
42
virtual int canStore(StoreEntry const &)const;
43
virtual int callback();
45
virtual StoreIOState::Pointer createStoreIO(StoreEntry &, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *);
46
virtual StoreIOState::Pointer openStoreIO(StoreEntry &, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *);
47
virtual void openLog();
48
virtual void closeLog();
49
virtual int writeCleanStart();
50
virtual void writeCleanDone();
51
virtual void logEntry(const StoreEntry & e, int op) const;
52
virtual void parse (int index, char *path);
53
virtual void reconfigure (int, char *);
55
virtual off_t storeCossFilenoToDiskOffset(sfileno);
56
virtual sfileno storeCossDiskOffsetToFileno(off_t);
57
virtual CossMemBuf *storeCossFilenoToMembuf(sfileno f);
58
/* IORequestor routines */
59
virtual void ioCompletedNotification();
60
virtual void closeCompleted();
61
virtual void readCompleted(const char *buf, int len, int errflag, RefCount<ReadRequest>);
62
virtual void writeCompleted(int errflag, size_t len, RefCount<WriteRequest>);
68
CossMemBuf *current_membuf;
69
size_t current_offset; /* in Blocks */
72
unsigned int blksz_bits;
73
unsigned int blksz_mask; /* just 1<<blksz_bits - 1*/
75
RefCount<DiskFile> theFile;
76
char *storeCossMemPointerFromDiskOffset(size_t offset, CossMemBuf ** mb);
77
void storeCossMemBufUnlock(StoreIOState::Pointer);
78
CossMemBuf *createMemBuf(size_t start, sfileno curfn, int *collision);
79
sfileno allocate(const StoreEntry * e, int which);
83
void changeIO(DiskIOModule *module);
84
bool optionIOParse(char const *option, const char *value, int reconfiguring);
85
void optionIODump(StoreEntry * e) const;
86
void optionBlockSizeDump(StoreEntry *) const;
87
bool optionBlockSizeParse(const char *, const char *, int);
88
char const *stripePath() const;
89
ConfigOption * getOptionTree() const;
91
mutable ConfigOptionVector *currentIOOptions;
92
const char *stripe_path;
95
extern void storeCossAdd(CossSwapDir *, StoreEntry *);
96
extern void storeCossRemove(CossSwapDir *, StoreEntry *);
97
extern void storeCossStartMembuf(CossSwapDir * SD);
99
class StoreSearchCoss : public StoreSearch
103
StoreSearchCoss(RefCount<CossSwapDir> sd);
104
StoreSearchCoss(StoreSearchCoss const &);
106
/* Iterator API - garh, wrong place */
107
/* callback the client when a new StoreEntry is available
110
virtual void next(void (callback)(void *cbdata), void *cbdata);
111
/* return true if a new StoreEntry is immediately available */
113
virtual bool error() const;
114
virtual bool isDone() const;
115
virtual StoreEntry *currentItem();
118
CBDATA_CLASS2(StoreSearchCoss);
119
RefCount<CossSwapDir> sd;
120
void (*callback)(void *cbdata);
123
dlink_node * current;