]> git.ipfire.org Git - thirdparty/squid.git/blame - src/DiskIO/DiskDaemon/DiskdIOStrategy.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / DiskIO / DiskDaemon / DiskdIOStrategy.h
CommitLineData
b9ae18aa 1/*
bbc27441 2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
b9ae18aa 3 *
bbc27441
AJ
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.
b9ae18aa 7 */
8
bbc27441
AJ
9/* DEBUG: section 79 Squid-side DISKD I/O functions. */
10
b9ae18aa 11#ifndef __STORE_DISKDIOSTRATEGY_H__
12#define __STORE_DISKDIOSTRATEGY_H__
13
b9ae18aa 14struct diomsg;
15
63be0a78 16/// \ingroup diskd
b9ae18aa 17class SharedMemory
18{
19
20public:
ee139403 21 void put(ssize_t);
b9ae18aa 22
ee139403 23 void *get(ssize_t *);
b9ae18aa 24
ee139403 25 void init(int ikey, int magic2);
b9ae18aa 26
27 int nbufs;
28
29 char *buf;
30
31 char *inuse_map;
32
33 int id;
34};
35
36#include "DiskIO/DiskIOStrategy.h"
e877aaac 37#include "StoreIOState.h"
b9ae18aa 38
39class DiskFile;
40
41class DiskdFile;
8bf217bd 42class Lock;
b9ae18aa 43class ReadRequest;
44
63be0a78 45/// \ingroup diskd
b9ae18aa 46class DiskdIOStrategy : public DiskIOStrategy
47{
48
49public:
50 DiskdIOStrategy();
51 virtual bool shedLoad();
52 virtual int load();
53 virtual RefCount<DiskFile> newFile(char const *path);
c521ad17 54 virtual bool unlinkdUseful() const;
b9ae18aa 55 virtual void unlinkFile (char const *);
56 virtual ConfigOption *getOptionTree() const;
57 virtual void init();
58 virtual void sync();
59 virtual int callback();
8bf217bd
AJ
60 virtual void statfs(StoreEntry & sentry) const;
61 int send(int mtype, int id, DiskdFile *theFile, size_t size, off_t offset, ssize_t shm_offset, Lock *requestor);
63be0a78 62
63 /** public for accessing return address's */
b9ae18aa 64 SharedMemory shm;
65
66private:
67 static size_t newInstance();
68 static size_t nextInstanceID;
69 void openFailed();
70 bool optionQ1Parse(char const *option, const char *value, int reconfiguring);
71 void optionQ1Dump(StoreEntry * e) const;
72 bool optionQ2Parse(char const *option, const char *value, int reconfiguring);
73 void optionQ2Dump(StoreEntry * e) const;
ee139403 74 int send(int mtype, int id, RefCount<StoreIOState> sio, size_t size, off_t offset, ssize_t shm_offset);
75 int SEND(diomsg * M, int mtype, int id, size_t size, off_t offset, ssize_t shm_offset);
b9ae18aa 76 void handle(diomsg * M);
77 void unlinkDone(diomsg * M);
63be0a78 78
79 /**
80 * magic1 is the number of messages away which we
81 * stop allowing open/create for.
82 */
b9ae18aa 83 int magic1;
63be0a78 84
85 /**
86 * magic2 is the point at which we start blocking on msgsnd/msgrcv.
87 * If a queue has magic2 (or more) messages away, then we read the
88 * queue until the level falls below magic2. Recommended value
89 * is 75% of SHMBUFS.
90 */
b9ae18aa 91 int magic2;
63be0a78 92
b9ae18aa 93 int away;
94 int smsgid;
95 int rmsgid;
96 int wfd;
97 size_t instanceID;
98};
99
63be0a78 100/// \ingroup diskd
b9ae18aa 101#define SHMBUF_BLKSZ SM_PAGE_SIZE
102
63be0a78 103/// \ingroup diskd
26ac0430 104struct diskd_stats_t {
b9ae18aa 105 int open_fail_queue_len;
106 int block_queue_len;
107 int max_away;
108 int max_shmuse;
109 int shmbuf_count;
110 int sent_count;
111 int recv_count;
112 int sio_id;
113
26ac0430 114 struct {
b9ae18aa 115 int ops;
116 int success;
117 int fail;
118 }
119
120 open, create, close, unlink, read, write;
121};
122
63be0a78 123/// \ingroup diskd
b9ae18aa 124extern diskd_stats_t diskd_stats;
125
126#endif
f53969cc 127