]> git.ipfire.org Git - thirdparty/squid.git/blob - src/DiskIO/DiskDaemon/DiskdAction.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / DiskIO / DiskDaemon / DiskdAction.cc
1 /*
2 * Copyright (C) 1996-2015 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 #include "squid.h"
12 #include "base/TextException.h"
13 #include "DiskIO/DiskDaemon/DiskdAction.h"
14 #include "DiskIO/DiskDaemon/DiskdIOStrategy.h"
15 #include "ipc/Messages.h"
16 #include "ipc/TypedMsgHdr.h"
17 #include "mgr/ActionWriter.h"
18 #include "Store.h"
19 #include "tools.h"
20
21 DiskdActionData::DiskdActionData()
22 {
23 memset(this, 0, sizeof(*this));
24 }
25
26 DiskdActionData&
27 DiskdActionData::operator += (const DiskdActionData& stats)
28 {
29 sent_count += stats.sent_count;
30 recv_count += stats.recv_count;
31 if (stats.max_away > max_away)
32 max_away = stats.max_away;
33 if (stats.max_shmuse > max_shmuse)
34 max_shmuse += stats.max_shmuse;
35 open_fail_queue_len += stats.open_fail_queue_len;
36 block_queue_len += stats.block_queue_len;
37 open_ops += stats.open_ops;
38 open_success += stats.open_success;
39 open_fail += stats.open_fail;
40 create_ops += stats.create_ops;
41 create_success += stats.create_success;
42 create_fail += stats.create_fail;
43 close_ops += stats.close_ops;
44 close_success += stats.close_success;
45 close_fail += stats.close_fail;
46 unlink_ops += stats.unlink_ops;
47 unlink_success += stats.unlink_success;
48 unlink_fail += stats.unlink_fail;
49 read_ops += stats.read_ops;
50 read_success += stats.read_success;
51 read_fail += stats.read_fail;
52 write_ops += stats.write_ops;
53 write_success += stats.write_success;
54 write_fail += stats.write_fail;
55
56 return *this;
57 }
58
59 DiskdAction::Pointer
60 DiskdAction::Create(const Mgr::CommandPointer &aCmd)
61 {
62 return new DiskdAction(aCmd);
63 }
64
65 DiskdAction::DiskdAction(const Mgr::CommandPointer &aCmd):
66 Action(aCmd), data()
67 {
68 debugs(79, 5, HERE);
69 }
70
71 void
72 DiskdAction::add(const Action& action)
73 {
74 debugs(79, 5, HERE);
75 data += dynamic_cast<const DiskdAction&>(action).data;
76 }
77
78 void
79 DiskdAction::collect()
80 {
81 data.sent_count = diskd_stats.sent_count;
82 data.recv_count = diskd_stats.recv_count;
83 data.max_away = diskd_stats.max_away;
84 data.max_shmuse = diskd_stats.max_shmuse;
85 data.open_fail_queue_len = diskd_stats.open_fail_queue_len;
86 data.block_queue_len = diskd_stats.block_queue_len;
87 diskd_stats.max_away = diskd_stats.max_shmuse = 0;
88
89 data.open_ops = diskd_stats.open.ops;
90 data.open_success = diskd_stats.open.success;
91 data.open_fail = diskd_stats.open.fail;
92
93 data.create_ops = diskd_stats.create.ops;
94 data.create_success = diskd_stats.create.success;
95 data.create_fail = diskd_stats.create.fail;
96
97 data.close_ops = diskd_stats.close.ops;
98 data.close_success = diskd_stats.close.success;
99 data.close_fail = diskd_stats.close.fail;
100
101 data.unlink_ops = diskd_stats.unlink.ops;
102 data.unlink_success = diskd_stats.unlink.success;
103 data.unlink_fail = diskd_stats.unlink.fail;
104
105 data.read_ops = diskd_stats.read.ops;
106 data.read_success = diskd_stats.read.success;
107 data.read_fail = diskd_stats.read.fail;
108
109 data.write_ops = diskd_stats.write.ops;
110 data.write_success = diskd_stats.write.success;
111 data.write_fail = diskd_stats.write.fail;
112 }
113
114 void
115 DiskdAction::dump(StoreEntry* entry)
116 {
117 debugs(79, 5, HERE);
118 Must(entry != NULL);
119 storeAppendPrintf(entry, "sent_count: %.0f\n", data.sent_count);
120 storeAppendPrintf(entry, "recv_count: %.0f\n", data.recv_count);
121 storeAppendPrintf(entry, "max_away: %.0f\n", data.max_away);
122 storeAppendPrintf(entry, "max_shmuse: %.0f\n", data.max_shmuse);
123 storeAppendPrintf(entry, "open_fail_queue_len: %.0f\n", data.open_fail_queue_len);
124 storeAppendPrintf(entry, "block_queue_len: %.0f\n", data.block_queue_len);
125 storeAppendPrintf(entry, "\n OPS SUCCESS FAIL\n");
126 storeAppendPrintf(entry, "%7s %9.0f %9.0f %7.0f\n",
127 "open", data.open_ops, data.open_success, data.open_fail);
128 storeAppendPrintf(entry, "%7s %9.0f %9.0f %7.0f\n",
129 "create", data.create_ops, data.create_success, data.create_fail);
130 storeAppendPrintf(entry, "%7s %9.0f %9.0f %7.0f\n",
131 "close", data.close_ops, data.close_success, data.close_fail);
132 storeAppendPrintf(entry, "%7s %9.0f %9.0f %7.0f\n",
133 "unlink", data.unlink_ops, data.unlink_success, data.unlink_fail);
134 storeAppendPrintf(entry, "%7s %9.0f %9.0f %7.0f\n",
135 "read", data.read_ops, data.read_success, data.read_fail);
136 storeAppendPrintf(entry, "%7s %9.0f %9.0f %7.0f\n",
137 "write", data.write_ops, data.write_success, data.write_fail);
138 }
139
140 void
141 DiskdAction::pack(Ipc::TypedMsgHdr& hdrMsg) const
142 {
143 hdrMsg.setType(Ipc::mtCacheMgrResponse);
144 hdrMsg.putPod(data);
145 }
146
147 void
148 DiskdAction::unpack(const Ipc::TypedMsgHdr& hdrMsg)
149 {
150 hdrMsg.checkType(Ipc::mtCacheMgrResponse);
151 hdrMsg.getPod(data);
152 }
153