]>
Commit | Line | Data |
---|---|---|
8822ebee AR |
1 | /* |
2 | * $Id$ | |
3 | * | |
4 | * DEBUG: section 79 Squid-side DISKD I/O functions. | |
5 | * | |
6 | */ | |
7 | ||
8 | #include "config.h" | |
9 | #include "base/TextException.h" | |
10 | #include "Store.h" | |
11 | #include "ipc/Messages.h" | |
12 | #include "ipc/TypedMsgHdr.h" | |
13 | #include "mgr/ActionWriter.h" | |
14 | #include "DiskIO/DiskDaemon/DiskdAction.h" | |
15 | #include "DiskIO/DiskDaemon/DiskdIOStrategy.h" | |
16 | ||
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 | ||
57 | DiskdAction::Pointer | |
58 | DiskdAction::Create(const Mgr::CommandPointer &aCmd) | |
59 | { | |
60 | return new DiskdAction(aCmd); | |
61 | } | |
62 | ||
63 | DiskdAction::DiskdAction(const Mgr::CommandPointer &aCmd): | |
d9fc6862 | 64 | Action(aCmd), data() |
8822ebee AR |
65 | { |
66 | debugs(79, 5, HERE); | |
67 | } | |
68 | ||
69 | void | |
70 | DiskdAction::add(const Action& action) | |
71 | { | |
72 | debugs(79, 5, HERE); | |
73 | data += dynamic_cast<const DiskdAction&>(action).data; | |
74 | } | |
75 | ||
76 | void | |
77 | DiskdAction::collect() | |
78 | { | |
79 | data.sent_count = diskd_stats.sent_count; | |
80 | data.recv_count = diskd_stats.recv_count; | |
81 | data.max_away = diskd_stats.max_away; | |
82 | data.max_shmuse = diskd_stats.max_shmuse; | |
83 | data.open_fail_queue_len = diskd_stats.open_fail_queue_len; | |
84 | data.block_queue_len = diskd_stats.block_queue_len; | |
85 | diskd_stats.max_away = diskd_stats.max_shmuse = 0; | |
86 | ||
87 | data.open_ops = diskd_stats.open.ops; | |
88 | data.open_success = diskd_stats.open.success; | |
89 | data.open_fail = diskd_stats.open.fail; | |
90 | ||
91 | data.create_ops = diskd_stats.create.ops; | |
92 | data.create_success = diskd_stats.create.success; | |
93 | data.create_fail = diskd_stats.create.fail; | |
94 | ||
95 | data.close_ops = diskd_stats.close.ops; | |
96 | data.close_success = diskd_stats.close.success; | |
97 | data.close_fail = diskd_stats.close.fail; | |
98 | ||
99 | data.unlink_ops = diskd_stats.unlink.ops; | |
100 | data.unlink_success = diskd_stats.unlink.success; | |
101 | data.unlink_fail = diskd_stats.unlink.fail; | |
102 | ||
103 | data.read_ops = diskd_stats.read.ops; | |
104 | data.read_success = diskd_stats.read.success; | |
105 | data.read_fail = diskd_stats.read.fail; | |
106 | ||
107 | data.write_ops = diskd_stats.write.ops; | |
108 | data.write_success = diskd_stats.write.success; | |
109 | data.write_fail = diskd_stats.write.fail; | |
110 | } | |
111 | ||
112 | void | |
113 | DiskdAction::dump(StoreEntry* entry) | |
114 | { | |
115 | debugs(79, 5, HERE); | |
116 | Must(entry != NULL); | |
117 | storeAppendPrintf(entry, "sent_count: %.0f\n", data.sent_count); | |
118 | storeAppendPrintf(entry, "recv_count: %.0f\n", data.recv_count); | |
119 | storeAppendPrintf(entry, "max_away: %.0f\n", data.max_away); | |
120 | storeAppendPrintf(entry, "max_shmuse: %.0f\n", data.max_shmuse); | |
121 | storeAppendPrintf(entry, "open_fail_queue_len: %.0f\n", data.open_fail_queue_len); | |
122 | storeAppendPrintf(entry, "block_queue_len: %.0f\n", data.block_queue_len); | |
123 | storeAppendPrintf(entry, "\n OPS SUCCESS FAIL\n"); | |
124 | storeAppendPrintf(entry, "%7s %9.0f %9.0f %7.0f\n", | |
125 | "open", data.open_ops, data.open_success, data.open_fail); | |
126 | storeAppendPrintf(entry, "%7s %9.0f %9.0f %7.0f\n", | |
127 | "create", data.create_ops, data.create_success, data.create_fail); | |
128 | storeAppendPrintf(entry, "%7s %9.0f %9.0f %7.0f\n", | |
129 | "close", data.close_ops, data.close_success, data.close_fail); | |
130 | storeAppendPrintf(entry, "%7s %9.0f %9.0f %7.0f\n", | |
131 | "unlink", data.unlink_ops, data.unlink_success, data.unlink_fail); | |
132 | storeAppendPrintf(entry, "%7s %9.0f %9.0f %7.0f\n", | |
133 | "read", data.read_ops, data.read_success, data.read_fail); | |
134 | storeAppendPrintf(entry, "%7s %9.0f %9.0f %7.0f\n", | |
135 | "write", data.write_ops, data.write_success, data.write_fail); | |
136 | } | |
137 | ||
138 | void | |
139 | DiskdAction::pack(Ipc::TypedMsgHdr& hdrMsg) const | |
140 | { | |
141 | hdrMsg.setType(Ipc::mtCacheMgrResponse); | |
142 | hdrMsg.putPod(data); | |
143 | } | |
144 | ||
145 | void | |
146 | DiskdAction::unpack(const Ipc::TypedMsgHdr& hdrMsg) | |
147 | { | |
148 | hdrMsg.checkType(Ipc::mtCacheMgrResponse); | |
149 | hdrMsg.getPod(data); | |
150 | } |