]> git.ipfire.org Git - thirdparty/squid.git/blame - src/DiskIO/DiskDaemon/DiskdIOStrategy.h
Updates for running on squid-cache.org
[thirdparty/squid.git] / src / DiskIO / DiskDaemon / DiskdIOStrategy.h
CommitLineData
b9ae18aa 1/*
63be0a78 2 * $Id: DiskdIOStrategy.h,v 1.5 2008/02/26 21:49:40 amosjeffries Exp $
b9ae18aa 3 *
4 * DEBUG: section 79 Squid-side DISKD I/O functions.
5 * AUTHOR: Duane Wessels
6 *
7 * SQUID Web Proxy Cache http://www.squid-cache.org/
8 * ----------------------------------------------------------
9 *
10 * Squid is the result of efforts by numerous individuals from
11 * the Internet community; see the CONTRIBUTORS file for full
12 * details. Many organizations have provided support for Squid's
13 * development; see the SPONSORS file for full details. Squid is
14 * Copyrighted (C) 2001 by the Regents of the University of
15 * California; see the COPYRIGHT file for full details. Squid
16 * incorporates software developed and/or copyrighted by other
17 * sources; see the CREDITS file for full details.
18 *
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
28 *
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
32 *
33 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
34 */
35
36#ifndef __STORE_DISKDIOSTRATEGY_H__
37#define __STORE_DISKDIOSTRATEGY_H__
38
b9ae18aa 39struct diomsg;
40
63be0a78 41/// \ingroup diskd
b9ae18aa 42class SharedMemory
43{
44
45public:
ee139403 46 void put(ssize_t);
b9ae18aa 47
ee139403 48 void *get(ssize_t *);
b9ae18aa 49
ee139403 50 void init(int ikey, int magic2);
b9ae18aa 51
52 int nbufs;
53
54 char *buf;
55
56 char *inuse_map;
57
58 int id;
59};
60
61#include "DiskIO/DiskIOStrategy.h"
e877aaac 62#include "StoreIOState.h"
b9ae18aa 63
64class DiskFile;
65
66class DiskdFile;
67
68class ReadRequest;
69
63be0a78 70/// \ingroup diskd
b9ae18aa 71class DiskdIOStrategy : public DiskIOStrategy
72{
73
74public:
75 DiskdIOStrategy();
76 virtual bool shedLoad();
77 virtual int load();
78 virtual RefCount<DiskFile> newFile(char const *path);
79 virtual void unlinkFile (char const *);
80 virtual ConfigOption *getOptionTree() const;
81 virtual void init();
82 virtual void sync();
83 virtual int callback();
84 virtual void statfs(StoreEntry & sentry)const;
63be0a78 85 int send(int mtype, int id, DiskdFile *theFile, size_t size, off_t offset, ssize_t shm_offset, RefCountable_ *requestor);
86
87 /** public for accessing return address's */
b9ae18aa 88 SharedMemory shm;
89
90private:
91 static size_t newInstance();
92 static size_t nextInstanceID;
93 void openFailed();
94 bool optionQ1Parse(char const *option, const char *value, int reconfiguring);
95 void optionQ1Dump(StoreEntry * e) const;
96 bool optionQ2Parse(char const *option, const char *value, int reconfiguring);
97 void optionQ2Dump(StoreEntry * e) const;
ee139403 98 int send(int mtype, int id, RefCount<StoreIOState> sio, size_t size, off_t offset, ssize_t shm_offset);
99 int SEND(diomsg * M, int mtype, int id, size_t size, off_t offset, ssize_t shm_offset);
b9ae18aa 100 void handle(diomsg * M);
101 void unlinkDone(diomsg * M);
63be0a78 102
103 /**
104 * magic1 is the number of messages away which we
105 * stop allowing open/create for.
106 */
b9ae18aa 107 int magic1;
63be0a78 108
109 /**
110 * magic2 is the point at which we start blocking on msgsnd/msgrcv.
111 * If a queue has magic2 (or more) messages away, then we read the
112 * queue until the level falls below magic2. Recommended value
113 * is 75% of SHMBUFS.
114 */
b9ae18aa 115 int magic2;
63be0a78 116
b9ae18aa 117 int away;
118 int smsgid;
119 int rmsgid;
120 int wfd;
121 size_t instanceID;
122};
123
63be0a78 124/// \ingroup diskd
b9ae18aa 125#define SHMBUF_BLKSZ SM_PAGE_SIZE
126
63be0a78 127/// \ingroup diskd
b9ae18aa 128struct diskd_stats_t
129{
130 int open_fail_queue_len;
131 int block_queue_len;
132 int max_away;
133 int max_shmuse;
134 int shmbuf_count;
135 int sent_count;
136 int recv_count;
137 int sio_id;
138
139 struct
140 {
141 int ops;
142 int success;
143 int fail;
144 }
145
146 open, create, close, unlink, read, write;
147};
148
63be0a78 149/// \ingroup diskd
b9ae18aa 150extern diskd_stats_t diskd_stats;
151
152#endif