~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to src/fs/coss/CossSwapDir.h

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2006-11-11 10:32:06 UTC
  • Revision ID: james.westby@ubuntu.com-20061111103206-f3p0r9g0vq44rp3r
Tags: upstream-3.0.PRE5
ImportĀ upstreamĀ versionĀ 3.0.PRE5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef __COSSSWAPDIR_H__
 
2
#define __COSSSWAPDIR_H__
 
3
 
 
4
#include "SwapDir.h"
 
5
#include "StoreSearch.h"
 
6
 
 
7
#ifndef COSS_MEMBUF_SZ
 
8
#define COSS_MEMBUF_SZ  1048576
 
9
#endif
 
10
 
 
11
/* Note that swap_filen in sio/e are actually disk offsets too! */
 
12
 
 
13
/* What we're doing in storeCossAllocate() */
 
14
#define COSS_ALLOC_ALLOCATE             1
 
15
#define COSS_ALLOC_REALLOC              2
 
16
 
 
17
class CossSwapDir;
 
18
 
 
19
 
 
20
class CossMemBuf;
 
21
 
 
22
class DiskIOStrategy;
 
23
 
 
24
class DiskIOModule;
 
25
 
 
26
class ConfigOptionVector;
 
27
#include "DiskIO/DiskFile.h"
 
28
#include "DiskIO/IORequestor.h"
 
29
 
 
30
class CossSwapDir : public SwapDir, public IORequestor
 
31
{
 
32
 
 
33
public:
 
34
    CossSwapDir();
 
35
    virtual void init();
 
36
    virtual void create();
 
37
    virtual void dump(StoreEntry &)const;
 
38
    ~CossSwapDir();
 
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();
 
44
    virtual void sync();
 
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 *);
 
54
    /* internals */
 
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>);
 
63
    //private:
 
64
    int swaplog_fd;
 
65
    int count;
 
66
    dlink_list membufs;
 
67
 
 
68
    CossMemBuf *current_membuf;
 
69
    size_t current_offset;      /* in Blocks */
 
70
    int numcollisions;
 
71
    dlink_list cossindex;
 
72
    unsigned int blksz_bits;
 
73
    unsigned int blksz_mask;  /* just 1<<blksz_bits - 1*/
 
74
    DiskIOStrategy *io;
 
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);
 
80
    void startMembuf();
 
81
 
 
82
private:
 
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;
 
90
    const char *ioModule;
 
91
    mutable ConfigOptionVector *currentIOOptions;
 
92
    const char *stripe_path;
 
93
};
 
94
 
 
95
extern void storeCossAdd(CossSwapDir *, StoreEntry *);
 
96
extern void storeCossRemove(CossSwapDir *, StoreEntry *);
 
97
extern void storeCossStartMembuf(CossSwapDir * SD);
 
98
 
 
99
class StoreSearchCoss : public StoreSearch
 
100
{
 
101
 
 
102
public:
 
103
    StoreSearchCoss(RefCount<CossSwapDir> sd);
 
104
    StoreSearchCoss(StoreSearchCoss const &);
 
105
    ~StoreSearchCoss();
 
106
    /* Iterator API - garh, wrong place */
 
107
    /* callback the client when a new StoreEntry is available
 
108
     * or an error occurs 
 
109
     */
 
110
    virtual void next(void (callback)(void *cbdata), void *cbdata);
 
111
    /* return true if a new StoreEntry is immediately available */
 
112
    virtual bool next();
 
113
    virtual bool error() const;
 
114
    virtual bool isDone() const;
 
115
    virtual StoreEntry *currentItem();
 
116
 
 
117
private:
 
118
    CBDATA_CLASS2(StoreSearchCoss);
 
119
    RefCount<CossSwapDir> sd;
 
120
    void (*callback)(void *cbdata);
 
121
    void *cbdata;
 
122
    bool _done;
 
123
    dlink_node * current;
 
124
    dlink_node * next_;
 
125
};
 
126
 
 
127
#endif