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