Commit | Line | Data |
---|---|---|
d7e09d03 PT |
1 | /* |
2 | * GPL HEADER START | |
3 | * | |
4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License version 2 only, | |
8 | * as published by the Free Software Foundation. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, but | |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * General Public License version 2 for more details (a copy is included | |
14 | * in the LICENSE file that accompanied this code). | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * version 2 along with this program; If not, see | |
18 | * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf | |
19 | * | |
20 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
21 | * CA 95054 USA or visit www.sun.com if you need additional information or | |
22 | * have any questions. | |
23 | * | |
24 | * GPL HEADER END | |
25 | */ | |
26 | /* | |
27 | * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. | |
28 | * Use is subject to license terms. | |
29 | * | |
30 | * Copyright (c) 2011, 2012, Intel Corporation. | |
31 | */ | |
32 | /* | |
33 | * This file is part of Lustre, http://www.lustre.org/ | |
34 | * Lustre is a trademark of Sun Microsystems, Inc. | |
35 | */ | |
36 | #define DEBUG_SUBSYSTEM S_CLASS | |
37 | ||
d7e09d03 | 38 | #include <asm/statfs.h> |
3ee30015 GKH |
39 | #include "../include/obd_cksum.h" |
40 | #include "../include/obd_class.h" | |
41 | #include "../include/lprocfs_status.h" | |
d7e09d03 PT |
42 | #include <linux/seq_file.h> |
43 | #include "osc_internal.h" | |
44 | ||
73bb1da6 | 45 | static int osc_active_seq_show(struct seq_file *m, void *v) |
d7e09d03 | 46 | { |
73bb1da6 | 47 | struct obd_device *dev = m->private; |
d7e09d03 PT |
48 | int rc; |
49 | ||
50 | LPROCFS_CLIMP_CHECK(dev); | |
73bb1da6 | 51 | rc = seq_printf(m, "%d\n", !dev->u.cli.cl_import->imp_deactive); |
d7e09d03 PT |
52 | LPROCFS_CLIMP_EXIT(dev); |
53 | return rc; | |
54 | } | |
55 | ||
e84962e3 TL |
56 | static ssize_t osc_active_seq_write(struct file *file, |
57 | const char __user *buffer, | |
58 | size_t count, loff_t *off) | |
d7e09d03 | 59 | { |
73bb1da6 | 60 | struct obd_device *dev = ((struct seq_file *)file->private_data)->private; |
d7e09d03 PT |
61 | int val, rc; |
62 | ||
63 | rc = lprocfs_write_helper(buffer, count, &val); | |
64 | if (rc) | |
65 | return rc; | |
66 | if (val < 0 || val > 1) | |
67 | return -ERANGE; | |
68 | ||
69 | /* opposite senses */ | |
70 | if (dev->u.cli.cl_import->imp_deactive == val) | |
71 | rc = ptlrpc_set_import_active(dev->u.cli.cl_import, val); | |
72 | else | |
73 | CDEBUG(D_CONFIG, "activate %d: ignoring repeat request\n", val); | |
74 | ||
75 | return count; | |
76 | } | |
73bb1da6 | 77 | LPROC_SEQ_FOPS(osc_active); |
d7e09d03 | 78 | |
73bb1da6 | 79 | static int osc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v) |
d7e09d03 | 80 | { |
73bb1da6 | 81 | struct obd_device *dev = m->private; |
d7e09d03 PT |
82 | struct client_obd *cli = &dev->u.cli; |
83 | int rc; | |
84 | ||
85 | client_obd_list_lock(&cli->cl_loi_list_lock); | |
73bb1da6 | 86 | rc = seq_printf(m, "%u\n", cli->cl_max_rpcs_in_flight); |
d7e09d03 PT |
87 | client_obd_list_unlock(&cli->cl_loi_list_lock); |
88 | return rc; | |
89 | } | |
90 | ||
73bb1da6 | 91 | static ssize_t osc_max_rpcs_in_flight_seq_write(struct file *file, |
e84962e3 TL |
92 | const char __user *buffer, |
93 | size_t count, loff_t *off) | |
d7e09d03 | 94 | { |
73bb1da6 | 95 | struct obd_device *dev = ((struct seq_file *)file->private_data)->private; |
d7e09d03 PT |
96 | struct client_obd *cli = &dev->u.cli; |
97 | struct ptlrpc_request_pool *pool = cli->cl_import->imp_rq_pool; | |
98 | int val, rc; | |
99 | ||
100 | rc = lprocfs_write_helper(buffer, count, &val); | |
101 | if (rc) | |
102 | return rc; | |
103 | ||
104 | if (val < 1 || val > OSC_MAX_RIF_MAX) | |
105 | return -ERANGE; | |
106 | ||
107 | LPROCFS_CLIMP_CHECK(dev); | |
108 | if (pool && val > cli->cl_max_rpcs_in_flight) | |
109 | pool->prp_populate(pool, val-cli->cl_max_rpcs_in_flight); | |
110 | ||
111 | client_obd_list_lock(&cli->cl_loi_list_lock); | |
112 | cli->cl_max_rpcs_in_flight = val; | |
113 | client_obd_list_unlock(&cli->cl_loi_list_lock); | |
114 | ||
115 | LPROCFS_CLIMP_EXIT(dev); | |
116 | return count; | |
117 | } | |
73bb1da6 | 118 | LPROC_SEQ_FOPS(osc_max_rpcs_in_flight); |
d7e09d03 | 119 | |
73bb1da6 | 120 | static int osc_max_dirty_mb_seq_show(struct seq_file *m, void *v) |
d7e09d03 | 121 | { |
73bb1da6 | 122 | struct obd_device *dev = m->private; |
d7e09d03 PT |
123 | struct client_obd *cli = &dev->u.cli; |
124 | long val; | |
125 | int mult; | |
126 | ||
127 | client_obd_list_lock(&cli->cl_loi_list_lock); | |
128 | val = cli->cl_dirty_max; | |
129 | client_obd_list_unlock(&cli->cl_loi_list_lock); | |
130 | ||
131 | mult = 1 << 20; | |
73bb1da6 | 132 | return lprocfs_seq_read_frac_helper(m, val, mult); |
d7e09d03 PT |
133 | } |
134 | ||
e84962e3 TL |
135 | static ssize_t osc_max_dirty_mb_seq_write(struct file *file, |
136 | const char __user *buffer, | |
137 | size_t count, loff_t *off) | |
d7e09d03 | 138 | { |
73bb1da6 | 139 | struct obd_device *dev = ((struct seq_file *)file->private_data)->private; |
d7e09d03 PT |
140 | struct client_obd *cli = &dev->u.cli; |
141 | int pages_number, mult, rc; | |
142 | ||
143 | mult = 1 << (20 - PAGE_CACHE_SHIFT); | |
144 | rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult); | |
145 | if (rc) | |
146 | return rc; | |
147 | ||
148 | if (pages_number <= 0 || | |
149 | pages_number > OSC_MAX_DIRTY_MB_MAX << (20 - PAGE_CACHE_SHIFT) || | |
4f6cc9ab | 150 | pages_number > totalram_pages / 4) /* 1/4 of RAM */ |
d7e09d03 PT |
151 | return -ERANGE; |
152 | ||
153 | client_obd_list_lock(&cli->cl_loi_list_lock); | |
21aef7d9 | 154 | cli->cl_dirty_max = (u32)(pages_number << PAGE_CACHE_SHIFT); |
d7e09d03 PT |
155 | osc_wake_cache_waiters(cli); |
156 | client_obd_list_unlock(&cli->cl_loi_list_lock); | |
157 | ||
158 | return count; | |
159 | } | |
73bb1da6 | 160 | LPROC_SEQ_FOPS(osc_max_dirty_mb); |
d7e09d03 | 161 | |
73bb1da6 | 162 | static int osc_cached_mb_seq_show(struct seq_file *m, void *v) |
d7e09d03 | 163 | { |
73bb1da6 | 164 | struct obd_device *dev = m->private; |
d7e09d03 PT |
165 | struct client_obd *cli = &dev->u.cli; |
166 | int shift = 20 - PAGE_CACHE_SHIFT; | |
d7e09d03 | 167 | |
e6eae365 | 168 | return seq_printf(m, |
d7e09d03 PT |
169 | "used_mb: %d\n" |
170 | "busy_cnt: %d\n", | |
171 | (atomic_read(&cli->cl_lru_in_list) + | |
172 | atomic_read(&cli->cl_lru_busy)) >> shift, | |
173 | atomic_read(&cli->cl_lru_busy)); | |
d7e09d03 PT |
174 | } |
175 | ||
176 | /* shrink the number of caching pages to a specific number */ | |
a1e7e2d4 OD |
177 | static ssize_t osc_cached_mb_seq_write(struct file *file, |
178 | const char __user *buffer, | |
179 | size_t count, loff_t *off) | |
d7e09d03 | 180 | { |
73bb1da6 | 181 | struct obd_device *dev = ((struct seq_file *)file->private_data)->private; |
d7e09d03 PT |
182 | struct client_obd *cli = &dev->u.cli; |
183 | int pages_number, mult, rc; | |
a1e7e2d4 OD |
184 | char kernbuf[128]; |
185 | ||
186 | if (count >= sizeof(kernbuf)) | |
187 | return -EINVAL; | |
188 | ||
189 | if (copy_from_user(kernbuf, buffer, count)) | |
190 | return -EFAULT; | |
191 | kernbuf[count] = 0; | |
d7e09d03 PT |
192 | |
193 | mult = 1 << (20 - PAGE_CACHE_SHIFT); | |
a1e7e2d4 OD |
194 | buffer += lprocfs_find_named_value(kernbuf, "used_mb:", &count) - |
195 | kernbuf; | |
d7e09d03 PT |
196 | rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult); |
197 | if (rc) | |
198 | return rc; | |
199 | ||
200 | if (pages_number < 0) | |
201 | return -ERANGE; | |
202 | ||
203 | rc = atomic_read(&cli->cl_lru_in_list) - pages_number; | |
204 | if (rc > 0) | |
205 | (void)osc_lru_shrink(cli, rc); | |
206 | ||
207 | return count; | |
208 | } | |
73bb1da6 | 209 | LPROC_SEQ_FOPS(osc_cached_mb); |
d7e09d03 | 210 | |
73bb1da6 | 211 | static int osc_cur_dirty_bytes_seq_show(struct seq_file *m, void *v) |
d7e09d03 | 212 | { |
73bb1da6 | 213 | struct obd_device *dev = m->private; |
d7e09d03 PT |
214 | struct client_obd *cli = &dev->u.cli; |
215 | int rc; | |
216 | ||
217 | client_obd_list_lock(&cli->cl_loi_list_lock); | |
73bb1da6 | 218 | rc = seq_printf(m, "%lu\n", cli->cl_dirty); |
d7e09d03 PT |
219 | client_obd_list_unlock(&cli->cl_loi_list_lock); |
220 | return rc; | |
221 | } | |
73bb1da6 | 222 | LPROC_SEQ_FOPS_RO(osc_cur_dirty_bytes); |
d7e09d03 | 223 | |
73bb1da6 | 224 | static int osc_cur_grant_bytes_seq_show(struct seq_file *m, void *v) |
d7e09d03 | 225 | { |
73bb1da6 | 226 | struct obd_device *dev = m->private; |
d7e09d03 PT |
227 | struct client_obd *cli = &dev->u.cli; |
228 | int rc; | |
229 | ||
230 | client_obd_list_lock(&cli->cl_loi_list_lock); | |
73bb1da6 | 231 | rc = seq_printf(m, "%lu\n", cli->cl_avail_grant); |
d7e09d03 PT |
232 | client_obd_list_unlock(&cli->cl_loi_list_lock); |
233 | return rc; | |
234 | } | |
235 | ||
e84962e3 TL |
236 | static ssize_t osc_cur_grant_bytes_seq_write(struct file *file, |
237 | const char __user *buffer, | |
238 | size_t count, loff_t *off) | |
d7e09d03 | 239 | { |
73bb1da6 | 240 | struct obd_device *obd = ((struct seq_file *)file->private_data)->private; |
d7e09d03 PT |
241 | struct client_obd *cli = &obd->u.cli; |
242 | int rc; | |
243 | __u64 val; | |
244 | ||
245 | if (obd == NULL) | |
246 | return 0; | |
247 | ||
248 | rc = lprocfs_write_u64_helper(buffer, count, &val); | |
249 | if (rc) | |
250 | return rc; | |
251 | ||
252 | /* this is only for shrinking grant */ | |
253 | client_obd_list_lock(&cli->cl_loi_list_lock); | |
254 | if (val >= cli->cl_avail_grant) { | |
255 | client_obd_list_unlock(&cli->cl_loi_list_lock); | |
256 | return 0; | |
257 | } | |
258 | client_obd_list_unlock(&cli->cl_loi_list_lock); | |
259 | ||
260 | LPROCFS_CLIMP_CHECK(obd); | |
261 | if (cli->cl_import->imp_state == LUSTRE_IMP_FULL) | |
262 | rc = osc_shrink_grant_to_target(cli, val); | |
263 | LPROCFS_CLIMP_EXIT(obd); | |
264 | if (rc) | |
265 | return rc; | |
266 | return count; | |
267 | } | |
73bb1da6 | 268 | LPROC_SEQ_FOPS(osc_cur_grant_bytes); |
d7e09d03 | 269 | |
73bb1da6 | 270 | static int osc_cur_lost_grant_bytes_seq_show(struct seq_file *m, void *v) |
d7e09d03 | 271 | { |
73bb1da6 | 272 | struct obd_device *dev = m->private; |
d7e09d03 PT |
273 | struct client_obd *cli = &dev->u.cli; |
274 | int rc; | |
275 | ||
276 | client_obd_list_lock(&cli->cl_loi_list_lock); | |
73bb1da6 | 277 | rc = seq_printf(m, "%lu\n", cli->cl_lost_grant); |
d7e09d03 PT |
278 | client_obd_list_unlock(&cli->cl_loi_list_lock); |
279 | return rc; | |
280 | } | |
73bb1da6 | 281 | LPROC_SEQ_FOPS_RO(osc_cur_lost_grant_bytes); |
d7e09d03 | 282 | |
73bb1da6 | 283 | static int osc_grant_shrink_interval_seq_show(struct seq_file *m, void *v) |
d7e09d03 | 284 | { |
73bb1da6 | 285 | struct obd_device *obd = m->private; |
d7e09d03 PT |
286 | |
287 | if (obd == NULL) | |
288 | return 0; | |
73bb1da6 | 289 | return seq_printf(m, "%d\n", |
d7e09d03 PT |
290 | obd->u.cli.cl_grant_shrink_interval); |
291 | } | |
292 | ||
73bb1da6 | 293 | static ssize_t osc_grant_shrink_interval_seq_write(struct file *file, |
e84962e3 TL |
294 | const char __user *buffer, |
295 | size_t count, loff_t *off) | |
d7e09d03 | 296 | { |
73bb1da6 | 297 | struct obd_device *obd = ((struct seq_file *)file->private_data)->private; |
d7e09d03 PT |
298 | int val, rc; |
299 | ||
300 | if (obd == NULL) | |
301 | return 0; | |
302 | ||
303 | rc = lprocfs_write_helper(buffer, count, &val); | |
304 | if (rc) | |
305 | return rc; | |
306 | ||
307 | if (val <= 0) | |
308 | return -ERANGE; | |
309 | ||
310 | obd->u.cli.cl_grant_shrink_interval = val; | |
311 | ||
312 | return count; | |
313 | } | |
73bb1da6 | 314 | LPROC_SEQ_FOPS(osc_grant_shrink_interval); |
d7e09d03 | 315 | |
73bb1da6 | 316 | static int osc_checksum_seq_show(struct seq_file *m, void *v) |
d7e09d03 | 317 | { |
73bb1da6 | 318 | struct obd_device *obd = m->private; |
d7e09d03 PT |
319 | |
320 | if (obd == NULL) | |
321 | return 0; | |
322 | ||
73bb1da6 | 323 | return seq_printf(m, "%d\n", |
d7e09d03 PT |
324 | obd->u.cli.cl_checksum ? 1 : 0); |
325 | } | |
326 | ||
e84962e3 TL |
327 | static ssize_t osc_checksum_seq_write(struct file *file, |
328 | const char __user *buffer, | |
329 | size_t count, loff_t *off) | |
d7e09d03 | 330 | { |
73bb1da6 | 331 | struct obd_device *obd = ((struct seq_file *)file->private_data)->private; |
d7e09d03 PT |
332 | int val, rc; |
333 | ||
334 | if (obd == NULL) | |
335 | return 0; | |
336 | ||
337 | rc = lprocfs_write_helper(buffer, count, &val); | |
338 | if (rc) | |
339 | return rc; | |
340 | ||
341 | obd->u.cli.cl_checksum = (val ? 1 : 0); | |
342 | ||
343 | return count; | |
344 | } | |
73bb1da6 | 345 | LPROC_SEQ_FOPS(osc_checksum); |
d7e09d03 | 346 | |
73bb1da6 | 347 | static int osc_checksum_type_seq_show(struct seq_file *m, void *v) |
d7e09d03 | 348 | { |
73bb1da6 PT |
349 | struct obd_device *obd = m->private; |
350 | int i; | |
d7e09d03 PT |
351 | DECLARE_CKSUM_NAME; |
352 | ||
353 | if (obd == NULL) | |
354 | return 0; | |
355 | ||
73bb1da6 | 356 | for (i = 0; i < ARRAY_SIZE(cksum_name); i++) { |
d7e09d03 PT |
357 | if (((1 << i) & obd->u.cli.cl_supp_cksum_types) == 0) |
358 | continue; | |
359 | if (obd->u.cli.cl_cksum_type == (1 << i)) | |
73bb1da6 | 360 | seq_printf(m, "[%s] ", cksum_name[i]); |
d7e09d03 | 361 | else |
73bb1da6 | 362 | seq_printf(m, "%s ", cksum_name[i]); |
d7e09d03 | 363 | } |
e6aa864f | 364 | seq_putc(m, '\n'); |
73bb1da6 | 365 | return 0; |
d7e09d03 PT |
366 | } |
367 | ||
e84962e3 TL |
368 | static ssize_t osc_checksum_type_seq_write(struct file *file, |
369 | const char __user *buffer, | |
73bb1da6 | 370 | size_t count, loff_t *off) |
d7e09d03 | 371 | { |
73bb1da6 | 372 | struct obd_device *obd = ((struct seq_file *)file->private_data)->private; |
d7e09d03 PT |
373 | int i; |
374 | DECLARE_CKSUM_NAME; | |
375 | char kernbuf[10]; | |
376 | ||
377 | if (obd == NULL) | |
378 | return 0; | |
379 | ||
380 | if (count > sizeof(kernbuf) - 1) | |
381 | return -EINVAL; | |
382 | if (copy_from_user(kernbuf, buffer, count)) | |
383 | return -EFAULT; | |
384 | if (count > 0 && kernbuf[count - 1] == '\n') | |
385 | kernbuf[count - 1] = '\0'; | |
386 | else | |
387 | kernbuf[count] = '\0'; | |
388 | ||
389 | for (i = 0; i < ARRAY_SIZE(cksum_name); i++) { | |
390 | if (((1 << i) & obd->u.cli.cl_supp_cksum_types) == 0) | |
391 | continue; | |
392 | if (!strcmp(kernbuf, cksum_name[i])) { | |
393 | obd->u.cli.cl_cksum_type = 1 << i; | |
394 | return count; | |
395 | } | |
396 | } | |
397 | return -EINVAL; | |
398 | } | |
73bb1da6 | 399 | LPROC_SEQ_FOPS(osc_checksum_type); |
d7e09d03 | 400 | |
73bb1da6 | 401 | static int osc_resend_count_seq_show(struct seq_file *m, void *v) |
d7e09d03 | 402 | { |
73bb1da6 | 403 | struct obd_device *obd = m->private; |
d7e09d03 | 404 | |
73bb1da6 | 405 | return seq_printf(m, "%u\n", atomic_read(&obd->u.cli.cl_resends)); |
d7e09d03 PT |
406 | } |
407 | ||
e84962e3 TL |
408 | static ssize_t osc_resend_count_seq_write(struct file *file, |
409 | const char __user *buffer, | |
410 | size_t count, loff_t *off) | |
d7e09d03 | 411 | { |
73bb1da6 | 412 | struct obd_device *obd = ((struct seq_file *)file->private_data)->private; |
d7e09d03 PT |
413 | int val, rc; |
414 | ||
415 | rc = lprocfs_write_helper(buffer, count, &val); | |
416 | if (rc) | |
417 | return rc; | |
418 | ||
419 | if (val < 0) | |
420 | return -EINVAL; | |
421 | ||
422 | atomic_set(&obd->u.cli.cl_resends, val); | |
423 | ||
424 | return count; | |
425 | } | |
73bb1da6 | 426 | LPROC_SEQ_FOPS(osc_resend_count); |
d7e09d03 | 427 | |
73bb1da6 | 428 | static int osc_contention_seconds_seq_show(struct seq_file *m, void *v) |
d7e09d03 | 429 | { |
73bb1da6 | 430 | struct obd_device *obd = m->private; |
d7e09d03 PT |
431 | struct osc_device *od = obd2osc_dev(obd); |
432 | ||
73bb1da6 | 433 | return seq_printf(m, "%u\n", od->od_contention_time); |
d7e09d03 PT |
434 | } |
435 | ||
e84962e3 TL |
436 | static ssize_t osc_contention_seconds_seq_write(struct file *file, |
437 | const char __user *buffer, | |
438 | size_t count, loff_t *off) | |
d7e09d03 | 439 | { |
73bb1da6 | 440 | struct obd_device *obd = ((struct seq_file *)file->private_data)->private; |
d7e09d03 PT |
441 | struct osc_device *od = obd2osc_dev(obd); |
442 | ||
443 | return lprocfs_write_helper(buffer, count, &od->od_contention_time) ?: | |
444 | count; | |
445 | } | |
73bb1da6 | 446 | LPROC_SEQ_FOPS(osc_contention_seconds); |
d7e09d03 | 447 | |
73bb1da6 | 448 | static int osc_lockless_truncate_seq_show(struct seq_file *m, void *v) |
d7e09d03 | 449 | { |
73bb1da6 | 450 | struct obd_device *obd = m->private; |
d7e09d03 PT |
451 | struct osc_device *od = obd2osc_dev(obd); |
452 | ||
73bb1da6 | 453 | return seq_printf(m, "%u\n", od->od_lockless_truncate); |
d7e09d03 PT |
454 | } |
455 | ||
e84962e3 TL |
456 | static ssize_t osc_lockless_truncate_seq_write(struct file *file, |
457 | const char __user *buffer, | |
458 | size_t count, loff_t *off) | |
d7e09d03 | 459 | { |
73bb1da6 | 460 | struct obd_device *obd = ((struct seq_file *)file->private_data)->private; |
d7e09d03 PT |
461 | struct osc_device *od = obd2osc_dev(obd); |
462 | ||
463 | return lprocfs_write_helper(buffer, count, &od->od_lockless_truncate) ?: | |
464 | count; | |
465 | } | |
73bb1da6 | 466 | LPROC_SEQ_FOPS(osc_lockless_truncate); |
d7e09d03 | 467 | |
73bb1da6 | 468 | static int osc_destroys_in_flight_seq_show(struct seq_file *m, void *v) |
d7e09d03 | 469 | { |
73bb1da6 PT |
470 | struct obd_device *obd = m->private; |
471 | return seq_printf(m, "%u\n", | |
d7e09d03 PT |
472 | atomic_read(&obd->u.cli.cl_destroy_in_flight)); |
473 | } | |
73bb1da6 PT |
474 | LPROC_SEQ_FOPS_RO(osc_destroys_in_flight); |
475 | ||
476 | static int osc_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *v) | |
477 | { | |
478 | return lprocfs_obd_rd_max_pages_per_rpc(m, m->private); | |
479 | } | |
d7e09d03 | 480 | |
73bb1da6 | 481 | static ssize_t osc_obd_max_pages_per_rpc_seq_write(struct file *file, |
e84962e3 TL |
482 | const char __user *buffer, |
483 | size_t count, loff_t *off) | |
d7e09d03 | 484 | { |
73bb1da6 | 485 | struct obd_device *dev = ((struct seq_file *)file->private_data)->private; |
d7e09d03 PT |
486 | struct client_obd *cli = &dev->u.cli; |
487 | struct obd_connect_data *ocd = &cli->cl_import->imp_connect_data; | |
488 | int chunk_mask, rc; | |
489 | __u64 val; | |
490 | ||
491 | rc = lprocfs_write_u64_helper(buffer, count, &val); | |
492 | if (rc) | |
493 | return rc; | |
494 | ||
495 | /* if the max_pages is specified in bytes, convert to pages */ | |
496 | if (val >= ONE_MB_BRW_SIZE) | |
497 | val >>= PAGE_CACHE_SHIFT; | |
498 | ||
499 | LPROCFS_CLIMP_CHECK(dev); | |
500 | ||
501 | chunk_mask = ~((1 << (cli->cl_chunkbits - PAGE_CACHE_SHIFT)) - 1); | |
502 | /* max_pages_per_rpc must be chunk aligned */ | |
503 | val = (val + ~chunk_mask) & chunk_mask; | |
504 | if (val == 0 || val > ocd->ocd_brw_size >> PAGE_CACHE_SHIFT) { | |
505 | LPROCFS_CLIMP_EXIT(dev); | |
506 | return -ERANGE; | |
507 | } | |
508 | client_obd_list_lock(&cli->cl_loi_list_lock); | |
509 | cli->cl_max_pages_per_rpc = val; | |
510 | client_obd_list_unlock(&cli->cl_loi_list_lock); | |
511 | ||
512 | LPROCFS_CLIMP_EXIT(dev); | |
513 | return count; | |
514 | } | |
73bb1da6 PT |
515 | LPROC_SEQ_FOPS(osc_obd_max_pages_per_rpc); |
516 | ||
517 | LPROC_SEQ_FOPS_RO_TYPE(osc, uuid); | |
518 | LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags); | |
519 | LPROC_SEQ_FOPS_RO_TYPE(osc, blksize); | |
520 | LPROC_SEQ_FOPS_RO_TYPE(osc, kbytestotal); | |
521 | LPROC_SEQ_FOPS_RO_TYPE(osc, kbytesfree); | |
522 | LPROC_SEQ_FOPS_RO_TYPE(osc, kbytesavail); | |
523 | LPROC_SEQ_FOPS_RO_TYPE(osc, filestotal); | |
524 | LPROC_SEQ_FOPS_RO_TYPE(osc, filesfree); | |
525 | LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid); | |
526 | LPROC_SEQ_FOPS_RO_TYPE(osc, conn_uuid); | |
527 | LPROC_SEQ_FOPS_RO_TYPE(osc, timeouts); | |
528 | LPROC_SEQ_FOPS_RO_TYPE(osc, state); | |
529 | ||
530 | LPROC_SEQ_FOPS_WR_ONLY(osc, ping); | |
531 | ||
532 | LPROC_SEQ_FOPS_RW_TYPE(osc, import); | |
533 | LPROC_SEQ_FOPS_RW_TYPE(osc, pinger_recov); | |
d7e09d03 PT |
534 | |
535 | static struct lprocfs_vars lprocfs_osc_obd_vars[] = { | |
114a16b1 BKV |
536 | { "uuid", &osc_uuid_fops, NULL, 0 }, |
537 | { "ping", &osc_ping_fops, NULL, 0222 }, | |
538 | { "connect_flags", &osc_connect_flags_fops, NULL, 0 }, | |
539 | { "blocksize", &osc_blksize_fops, NULL, 0 }, | |
540 | { "kbytestotal", &osc_kbytestotal_fops, NULL, 0 }, | |
541 | { "kbytesfree", &osc_kbytesfree_fops, NULL, 0 }, | |
542 | { "kbytesavail", &osc_kbytesavail_fops, NULL, 0 }, | |
543 | { "filestotal", &osc_filestotal_fops, NULL, 0 }, | |
544 | { "filesfree", &osc_filesfree_fops, NULL, 0 }, | |
545 | /*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/ | |
546 | { "ost_server_uuid", &osc_server_uuid_fops, NULL, 0 }, | |
547 | { "ost_conn_uuid", &osc_conn_uuid_fops, NULL, 0 }, | |
548 | { "active", &osc_active_fops, NULL }, | |
549 | { "max_pages_per_rpc", &osc_obd_max_pages_per_rpc_fops, NULL }, | |
550 | { "max_rpcs_in_flight", &osc_max_rpcs_in_flight_fops, NULL }, | |
551 | { "destroys_in_flight", &osc_destroys_in_flight_fops, NULL, 0 }, | |
552 | { "max_dirty_mb", &osc_max_dirty_mb_fops, NULL }, | |
553 | { "osc_cached_mb", &osc_cached_mb_fops, NULL }, | |
554 | { "cur_dirty_bytes", &osc_cur_dirty_bytes_fops, NULL, 0 }, | |
555 | { "cur_grant_bytes", &osc_cur_grant_bytes_fops, NULL }, | |
556 | { "cur_lost_grant_bytes", &osc_cur_lost_grant_bytes_fops, NULL, 0}, | |
557 | { "grant_shrink_interval", &osc_grant_shrink_interval_fops, NULL }, | |
558 | { "checksums", &osc_checksum_fops, NULL }, | |
559 | { "checksum_type", &osc_checksum_type_fops, NULL }, | |
560 | { "resend_count", &osc_resend_count_fops, NULL}, | |
561 | { "timeouts", &osc_timeouts_fops, NULL, 0 }, | |
562 | { "contention_seconds", &osc_contention_seconds_fops, NULL }, | |
563 | { "lockless_truncate", &osc_lockless_truncate_fops, NULL }, | |
564 | { "import", &osc_import_fops, NULL }, | |
565 | { "state", &osc_state_fops, NULL, 0 }, | |
566 | { "pinger_recov", &osc_pinger_recov_fops, NULL }, | |
567 | { NULL } | |
d7e09d03 PT |
568 | }; |
569 | ||
73bb1da6 | 570 | LPROC_SEQ_FOPS_RO_TYPE(osc, numrefs); |
d7e09d03 | 571 | static struct lprocfs_vars lprocfs_osc_module_vars[] = { |
114a16b1 BKV |
572 | { "num_refs", &osc_numrefs_fops, NULL, 0 }, |
573 | { NULL } | |
d7e09d03 PT |
574 | }; |
575 | ||
1d8cb70c | 576 | #define pct(a, b) (b ? a * 100 / b : 0) |
d7e09d03 PT |
577 | |
578 | static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v) | |
579 | { | |
580 | struct timeval now; | |
581 | struct obd_device *dev = seq->private; | |
582 | struct client_obd *cli = &dev->u.cli; | |
583 | unsigned long read_tot = 0, write_tot = 0, read_cum, write_cum; | |
584 | int i; | |
585 | ||
586 | do_gettimeofday(&now); | |
587 | ||
588 | client_obd_list_lock(&cli->cl_loi_list_lock); | |
589 | ||
590 | seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n", | |
996adff8 | 591 | now.tv_sec, (unsigned long)now.tv_usec); |
d7e09d03 PT |
592 | seq_printf(seq, "read RPCs in flight: %d\n", |
593 | cli->cl_r_in_flight); | |
594 | seq_printf(seq, "write RPCs in flight: %d\n", | |
595 | cli->cl_w_in_flight); | |
596 | seq_printf(seq, "pending write pages: %d\n", | |
597 | atomic_read(&cli->cl_pending_w_pages)); | |
598 | seq_printf(seq, "pending read pages: %d\n", | |
599 | atomic_read(&cli->cl_pending_r_pages)); | |
600 | ||
e6aa864f HA |
601 | seq_puts(seq, "\n\t\t\tread\t\t\twrite\n"); |
602 | seq_puts(seq, "pages per rpc rpcs % cum % |"); | |
603 | seq_puts(seq, " rpcs % cum %\n"); | |
d7e09d03 PT |
604 | |
605 | read_tot = lprocfs_oh_sum(&cli->cl_read_page_hist); | |
606 | write_tot = lprocfs_oh_sum(&cli->cl_write_page_hist); | |
607 | ||
608 | read_cum = 0; | |
609 | write_cum = 0; | |
610 | for (i = 0; i < OBD_HIST_MAX; i++) { | |
611 | unsigned long r = cli->cl_read_page_hist.oh_buckets[i]; | |
612 | unsigned long w = cli->cl_write_page_hist.oh_buckets[i]; | |
613 | read_cum += r; | |
614 | write_cum += w; | |
615 | seq_printf(seq, "%d:\t\t%10lu %3lu %3lu | %10lu %3lu %3lu\n", | |
616 | 1 << i, r, pct(r, read_tot), | |
617 | pct(read_cum, read_tot), w, | |
618 | pct(w, write_tot), | |
619 | pct(write_cum, write_tot)); | |
620 | if (read_cum == read_tot && write_cum == write_tot) | |
621 | break; | |
622 | } | |
623 | ||
e6aa864f HA |
624 | seq_puts(seq, "\n\t\t\tread\t\t\twrite\n"); |
625 | seq_puts(seq, "rpcs in flight rpcs % cum % |"); | |
626 | seq_puts(seq, " rpcs % cum %\n"); | |
d7e09d03 PT |
627 | |
628 | read_tot = lprocfs_oh_sum(&cli->cl_read_rpc_hist); | |
629 | write_tot = lprocfs_oh_sum(&cli->cl_write_rpc_hist); | |
630 | ||
631 | read_cum = 0; | |
632 | write_cum = 0; | |
633 | for (i = 0; i < OBD_HIST_MAX; i++) { | |
634 | unsigned long r = cli->cl_read_rpc_hist.oh_buckets[i]; | |
635 | unsigned long w = cli->cl_write_rpc_hist.oh_buckets[i]; | |
636 | read_cum += r; | |
637 | write_cum += w; | |
638 | seq_printf(seq, "%d:\t\t%10lu %3lu %3lu | %10lu %3lu %3lu\n", | |
639 | i, r, pct(r, read_tot), | |
640 | pct(read_cum, read_tot), w, | |
641 | pct(w, write_tot), | |
642 | pct(write_cum, write_tot)); | |
643 | if (read_cum == read_tot && write_cum == write_tot) | |
644 | break; | |
645 | } | |
646 | ||
e6aa864f HA |
647 | seq_puts(seq, "\n\t\t\tread\t\t\twrite\n"); |
648 | seq_puts(seq, "offset rpcs % cum % |"); | |
649 | seq_puts(seq, " rpcs % cum %\n"); | |
d7e09d03 PT |
650 | |
651 | read_tot = lprocfs_oh_sum(&cli->cl_read_offset_hist); | |
652 | write_tot = lprocfs_oh_sum(&cli->cl_write_offset_hist); | |
653 | ||
654 | read_cum = 0; | |
655 | write_cum = 0; | |
656 | for (i = 0; i < OBD_HIST_MAX; i++) { | |
657 | unsigned long r = cli->cl_read_offset_hist.oh_buckets[i]; | |
658 | unsigned long w = cli->cl_write_offset_hist.oh_buckets[i]; | |
659 | read_cum += r; | |
660 | write_cum += w; | |
661 | seq_printf(seq, "%d:\t\t%10lu %3lu %3lu | %10lu %3lu %3lu\n", | |
662 | (i == 0) ? 0 : 1 << (i - 1), | |
663 | r, pct(r, read_tot), pct(read_cum, read_tot), | |
664 | w, pct(w, write_tot), pct(write_cum, write_tot)); | |
665 | if (read_cum == read_tot && write_cum == write_tot) | |
666 | break; | |
667 | } | |
668 | ||
669 | client_obd_list_unlock(&cli->cl_loi_list_lock); | |
670 | ||
671 | return 0; | |
672 | } | |
673 | #undef pct | |
674 | ||
e84962e3 TL |
675 | static ssize_t osc_rpc_stats_seq_write(struct file *file, |
676 | const char __user *buf, | |
677 | size_t len, loff_t *off) | |
d7e09d03 PT |
678 | { |
679 | struct seq_file *seq = file->private_data; | |
680 | struct obd_device *dev = seq->private; | |
681 | struct client_obd *cli = &dev->u.cli; | |
682 | ||
683 | lprocfs_oh_clear(&cli->cl_read_rpc_hist); | |
684 | lprocfs_oh_clear(&cli->cl_write_rpc_hist); | |
685 | lprocfs_oh_clear(&cli->cl_read_page_hist); | |
686 | lprocfs_oh_clear(&cli->cl_write_page_hist); | |
687 | lprocfs_oh_clear(&cli->cl_read_offset_hist); | |
688 | lprocfs_oh_clear(&cli->cl_write_offset_hist); | |
689 | ||
690 | return len; | |
691 | } | |
692 | ||
693 | LPROC_SEQ_FOPS(osc_rpc_stats); | |
694 | ||
695 | static int osc_stats_seq_show(struct seq_file *seq, void *v) | |
696 | { | |
697 | struct timeval now; | |
698 | struct obd_device *dev = seq->private; | |
699 | struct osc_stats *stats = &obd2osc_dev(dev)->od_stats; | |
700 | ||
701 | do_gettimeofday(&now); | |
702 | ||
703 | seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n", | |
996adff8 | 704 | now.tv_sec, (unsigned long)now.tv_usec); |
b0f5aad5 | 705 | seq_printf(seq, "lockless_write_bytes\t\t%llu\n", |
d7e09d03 | 706 | stats->os_lockless_writes); |
b0f5aad5 | 707 | seq_printf(seq, "lockless_read_bytes\t\t%llu\n", |
d7e09d03 | 708 | stats->os_lockless_reads); |
b0f5aad5 | 709 | seq_printf(seq, "lockless_truncate\t\t%llu\n", |
d7e09d03 PT |
710 | stats->os_lockless_truncates); |
711 | return 0; | |
712 | } | |
713 | ||
e84962e3 TL |
714 | static ssize_t osc_stats_seq_write(struct file *file, |
715 | const char __user *buf, | |
716 | size_t len, loff_t *off) | |
d7e09d03 PT |
717 | { |
718 | struct seq_file *seq = file->private_data; | |
719 | struct obd_device *dev = seq->private; | |
720 | struct osc_stats *stats = &obd2osc_dev(dev)->od_stats; | |
721 | ||
722 | memset(stats, 0, sizeof(*stats)); | |
723 | return len; | |
724 | } | |
725 | ||
726 | LPROC_SEQ_FOPS(osc_stats); | |
727 | ||
728 | int lproc_osc_attach_seqstat(struct obd_device *dev) | |
729 | { | |
730 | int rc; | |
731 | ||
732 | rc = lprocfs_seq_create(dev->obd_proc_entry, "osc_stats", 0644, | |
733 | &osc_stats_fops, dev); | |
734 | if (rc == 0) | |
735 | rc = lprocfs_obd_seq_create(dev, "rpc_stats", 0644, | |
736 | &osc_rpc_stats_fops, dev); | |
737 | ||
738 | return rc; | |
739 | } | |
740 | ||
741 | void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars) | |
742 | { | |
743 | lvars->module_vars = lprocfs_osc_module_vars; | |
744 | lvars->obd_vars = lprocfs_osc_obd_vars; | |
745 | } |