]> git.ipfire.org Git - thirdparty/squid.git/blob - src/DiskIO/DiskDaemon/DiskdIOStrategy.h
Merged from trunk
[thirdparty/squid.git] / src / DiskIO / DiskDaemon / DiskdIOStrategy.h
1 /*
2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
3 *
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.
7 */
8
9 /* DEBUG: section 79 Squid-side DISKD I/O functions. */
10
11 #ifndef __STORE_DISKDIOSTRATEGY_H__
12 #define __STORE_DISKDIOSTRATEGY_H__
13
14 struct diomsg;
15
16 /// \ingroup diskd
17 class SharedMemory
18 {
19
20 public:
21 void put(ssize_t);
22
23 void *get(ssize_t *);
24
25 void init(int ikey, int magic2);
26
27 int nbufs;
28
29 char *buf;
30
31 char *inuse_map;
32
33 int id;
34 };
35
36 #include "DiskIO/DiskIOStrategy.h"
37 #include "StoreIOState.h"
38
39 class DiskFile;
40
41 class DiskdFile;
42 class Lock;
43 class ReadRequest;
44
45 /// \ingroup diskd
46 class DiskdIOStrategy : public DiskIOStrategy
47 {
48
49 public:
50 DiskdIOStrategy();
51 virtual bool shedLoad();
52 virtual int load();
53 virtual RefCount<DiskFile> newFile(char const *path);
54 virtual bool unlinkdUseful() const;
55 virtual void unlinkFile (char const *);
56 virtual ConfigOption *getOptionTree() const;
57 virtual void init();
58 virtual void sync();
59 virtual int callback();
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);
62
63 /** public for accessing return address's */
64 SharedMemory shm;
65
66 private:
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;
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);
76 void handle(diomsg * M);
77 void unlinkDone(diomsg * M);
78
79 /**
80 * magic1 is the number of messages away which we
81 * stop allowing open/create for.
82 */
83 int magic1;
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 */
91 int magic2;
92
93 int away;
94 int smsgid;
95 int rmsgid;
96 int wfd;
97 size_t instanceID;
98 };
99
100 /// \ingroup diskd
101 #define SHMBUF_BLKSZ SM_PAGE_SIZE
102
103 /// \ingroup diskd
104 struct diskd_stats_t {
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
114 struct {
115 int ops;
116 int success;
117 int fail;
118 }
119
120 open, create, close, unlink, read, write;
121 };
122
123 /// \ingroup diskd
124 extern diskd_stats_t diskd_stats;
125
126 #endif
127