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