4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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
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
27 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2012, 2013, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lustre/osp/lproc_osp.c
38 * Lustre OST Proxy Device, procfs functions
40 * Author: Alex Zhuravlev <alexey.zhuravlev@intel.com>
43 #define DEBUG_SUBSYSTEM S_CLASS
45 #include "osp_internal.h"
48 static int osp_active_seq_show(struct seq_file *m, void *data)
50 struct obd_device *dev = m->private;
53 LPROCFS_CLIMP_CHECK(dev);
54 rc = seq_printf(m, "%d\n", !dev->u.cli.cl_import->imp_deactive);
55 LPROCFS_CLIMP_EXIT(dev);
60 osp_active_seq_write(struct file *file, const char *buffer,
61 size_t count, loff_t *off)
63 struct seq_file *m = file->private_data;
64 struct obd_device *dev = m->private;
67 rc = lprocfs_write_helper(buffer, count, &val);
70 if (val < 0 || val > 1)
73 LPROCFS_CLIMP_CHECK(dev);
75 if (dev->u.cli.cl_import->imp_deactive == val)
76 rc = ptlrpc_set_import_active(dev->u.cli.cl_import, val);
78 CDEBUG(D_CONFIG, "activate %d: ignoring repeat request\n",
81 LPROCFS_CLIMP_EXIT(dev);
84 LPROC_SEQ_FOPS(osp_active);
86 static int osp_syn_in_flight_seq_show(struct seq_file *m, void *data)
88 struct obd_device *dev = m->private;
89 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
94 return seq_printf(m, "%u\n", osp->opd_syn_rpc_in_flight);
96 LPROC_SEQ_FOPS_RO(osp_syn_in_flight);
98 static int osp_syn_in_prog_seq_show(struct seq_file *m, void *data)
100 struct obd_device *dev = m->private;
101 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
106 return seq_printf(m, "%u\n", osp->opd_syn_rpc_in_progress);
108 LPROC_SEQ_FOPS_RO(osp_syn_in_prog);
110 static int osp_syn_changes_seq_show(struct seq_file *m, void *data)
112 struct obd_device *dev = m->private;
113 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
118 return seq_printf(m, "%lu\n", osp->opd_syn_changes);
120 LPROC_SEQ_FOPS_RO(osp_syn_changes);
122 static int osp_max_rpcs_in_flight_seq_show(struct seq_file *m, void *data)
124 struct obd_device *dev = m->private;
125 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
130 return seq_printf(m, "%u\n", osp->opd_syn_max_rpc_in_flight);
134 osp_max_rpcs_in_flight_seq_write(struct file *file, const char *buffer,
135 size_t count, loff_t *off)
137 struct seq_file *m = file->private_data;
138 struct obd_device *dev = m->private;
139 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
145 rc = lprocfs_write_helper(buffer, count, &val);
152 osp->opd_syn_max_rpc_in_flight = val;
155 LPROC_SEQ_FOPS(osp_max_rpcs_in_flight);
157 static int osp_max_rpcs_in_prog_seq_show(struct seq_file *m, void *data)
159 struct obd_device *dev = m->private;
160 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
165 return seq_printf(m, "%u\n", osp->opd_syn_max_rpc_in_progress);
169 osp_max_rpcs_in_prog_seq_write(struct file *file, const char *buffer,
170 size_t count, loff_t *off)
172 struct seq_file *m = file->private_data;
173 struct obd_device *dev = m->private;
174 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
180 rc = lprocfs_write_helper(buffer, count, &val);
187 osp->opd_syn_max_rpc_in_progress = val;
191 LPROC_SEQ_FOPS(osp_max_rpcs_in_prog);
193 static int osp_create_count_seq_show(struct seq_file *m, void *data)
195 struct obd_device *obd = m->private;
196 struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
198 if (osp == NULL || osp->opd_pre == NULL)
201 return seq_printf(m, "%d\n", osp->opd_pre_grow_count);
205 osp_create_count_seq_write(struct file *file, const char *buffer,
206 size_t count, loff_t *off)
208 struct seq_file *m = file->private_data;
209 struct obd_device *obd = m->private;
210 struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
213 if (osp == NULL || osp->opd_pre == NULL)
216 rc = lprocfs_write_helper(buffer, count, &val);
220 /* The MDT ALWAYS needs to limit the precreate count to
221 * OST_MAX_PRECREATE, and the constant cannot be changed
222 * because it is a value shared between the OSP and OST
223 * that is the maximum possible number of objects that will
224 * ever be handled by MDT->OST recovery processing.
226 * If the OST ever gets a request to delete more orphans,
227 * this implies that something has gone badly on the MDT
228 * and the OST will refuse to delete so much data from the
229 * filesystem as a safety measure. */
230 if (val < OST_MIN_PRECREATE || val > OST_MAX_PRECREATE)
232 if (val > osp->opd_pre_max_grow_count)
235 for (i = 1; (i << 1) <= val; i <<= 1)
237 osp->opd_pre_grow_count = i;
241 LPROC_SEQ_FOPS(osp_create_count);
243 static int osp_max_create_count_seq_show(struct seq_file *m, void *data)
245 struct obd_device *obd = m->private;
246 struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
248 if (osp == NULL || osp->opd_pre == NULL)
251 return seq_printf(m, "%d\n", osp->opd_pre_max_grow_count);
255 osp_max_create_count_seq_write(struct file *file, const char *buffer,
256 size_t count, loff_t *off)
258 struct seq_file *m = file->private_data;
259 struct obd_device *obd = m->private;
260 struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
263 if (osp == NULL || osp->opd_pre == NULL)
266 rc = lprocfs_write_helper(buffer, count, &val);
272 if (val > OST_MAX_PRECREATE)
275 if (osp->opd_pre_grow_count > val)
276 osp->opd_pre_grow_count = val;
278 osp->opd_pre_max_grow_count = val;
282 LPROC_SEQ_FOPS(osp_max_create_count);
284 static int osp_prealloc_next_id_seq_show(struct seq_file *m, void *data)
286 struct obd_device *obd = m->private;
287 struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
289 if (osp == NULL || osp->opd_pre == NULL)
292 return seq_printf(m, "%u\n", fid_oid(&osp->opd_pre_used_fid) + 1);
294 LPROC_SEQ_FOPS_RO(osp_prealloc_next_id);
296 static int osp_prealloc_last_id_seq_show(struct seq_file *m, void *data)
298 struct obd_device *obd = m->private;
299 struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
301 if (osp == NULL || osp->opd_pre == NULL)
304 return seq_printf(m, "%u\n", fid_oid(&osp->opd_pre_last_created_fid));
306 LPROC_SEQ_FOPS_RO(osp_prealloc_last_id);
308 static int osp_prealloc_next_seq_seq_show(struct seq_file *m, void *data)
310 struct obd_device *obd = m->private;
311 struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
313 if (osp == NULL || osp->opd_pre == NULL)
316 return seq_printf(m, LPX64"\n", fid_seq(&osp->opd_pre_used_fid));
318 LPROC_SEQ_FOPS_RO(osp_prealloc_next_seq);
320 static int osp_prealloc_last_seq_seq_show(struct seq_file *m, void *data)
322 struct obd_device *obd = m->private;
323 struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
325 if (osp == NULL || osp->opd_pre == NULL)
328 return seq_printf(m, LPX64"\n",
329 fid_seq(&osp->opd_pre_last_created_fid));
331 LPROC_SEQ_FOPS_RO(osp_prealloc_last_seq);
333 static int osp_prealloc_reserved_seq_show(struct seq_file *m, void *data)
335 struct obd_device *obd = m->private;
336 struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
338 if (osp == NULL || osp->opd_pre == NULL)
341 return seq_printf(m, LPU64"\n", osp->opd_pre_reserved);
343 LPROC_SEQ_FOPS_RO(osp_prealloc_reserved);
345 static int osp_maxage_seq_show(struct seq_file *m, void *data)
347 struct obd_device *dev = m->private;
348 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
353 return seq_printf(m, "%u\n", osp->opd_statfs_maxage);
357 osp_maxage_seq_write(struct file *file, const char *buffer,
358 size_t count, loff_t *off)
360 struct seq_file *m = file->private_data;
361 struct obd_device *dev = m->private;
362 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
368 rc = lprocfs_write_helper(buffer, count, &val);
375 osp->opd_statfs_maxage = val;
379 LPROC_SEQ_FOPS(osp_maxage);
381 static int osp_pre_status_seq_show(struct seq_file *m, void *data)
383 struct obd_device *dev = m->private;
384 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
386 if (osp == NULL || osp->opd_pre == NULL)
389 return seq_printf(m, "%d\n", osp->opd_pre_status);
391 LPROC_SEQ_FOPS_RO(osp_pre_status);
393 static int osp_destroys_in_flight_seq_show(struct seq_file *m, void *data)
395 struct obd_device *dev = m->private;
396 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
402 * This counter used to determine if OST has space returned.
403 * Now we need to wait for the following:
404 * - sync changes are zero - no llog records
405 * - sync in progress are zero - no RPCs in flight
407 return seq_printf(m, "%lu\n",
408 osp->opd_syn_rpc_in_progress + osp->opd_syn_changes);
410 LPROC_SEQ_FOPS_RO(osp_destroys_in_flight);
412 static int osp_old_sync_processed_seq_show(struct seq_file *m, void *data)
414 struct obd_device *dev = m->private;
415 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
420 return seq_printf(m, "%d\n", osp->opd_syn_prev_done);
422 LPROC_SEQ_FOPS_RO(osp_old_sync_processed);
425 osp_lfsck_max_rpcs_in_flight_seq_show(struct seq_file *m, void *data)
427 struct obd_device *dev = m->private;
430 max = obd_get_max_rpcs_in_flight(&dev->u.cli);
431 return seq_printf(m, "%u\n", max);
435 osp_lfsck_max_rpcs_in_flight_seq_write(struct file *file,
436 const char __user *buffer,
437 size_t count, loff_t *off)
439 struct seq_file *m = file->private_data;
440 struct obd_device *dev = m->private;
444 rc = lprocfs_write_helper(buffer, count, &val);
446 rc = obd_set_max_rpcs_in_flight(&dev->u.cli, val);
453 LPROC_SEQ_FOPS(osp_lfsck_max_rpcs_in_flight);
455 LPROC_SEQ_FOPS_WO_TYPE(osp, ping);
456 LPROC_SEQ_FOPS_RO_TYPE(osp, uuid);
457 LPROC_SEQ_FOPS_RO_TYPE(osp, connect_flags);
458 LPROC_SEQ_FOPS_RO_TYPE(osp, server_uuid);
459 LPROC_SEQ_FOPS_RO_TYPE(osp, conn_uuid);
461 static int osp_max_pages_per_rpc_seq_show(struct seq_file *m, void *v)
463 return lprocfs_obd_max_pages_per_rpc_seq_show(m, m->private);
465 LPROC_SEQ_FOPS_RO(osp_max_pages_per_rpc);
466 LPROC_SEQ_FOPS_RO_TYPE(osp, timeouts);
468 LPROC_SEQ_FOPS_RW_TYPE(osp, import);
469 LPROC_SEQ_FOPS_RO_TYPE(osp, state);
471 static struct lprocfs_seq_vars lprocfs_osp_obd_vars[] = {
473 .fops = &osp_uuid_fops },
475 .fops = &osp_ping_fops,
477 { .name = "connect_flags",
478 .fops = &osp_connect_flags_fops },
479 { .name = "ost_server_uuid",
480 .fops = &osp_server_uuid_fops },
481 { .name = "ost_conn_uuid",
482 .fops = &osp_conn_uuid_fops },
484 .fops = &osp_active_fops },
485 { .name = "max_rpcs_in_flight",
486 .fops = &osp_max_rpcs_in_flight_fops },
487 { .name = "max_rpcs_in_progress",
488 .fops = &osp_max_rpcs_in_prog_fops },
489 { .name = "create_count",
490 .fops = &osp_create_count_fops },
491 { .name = "max_create_count",
492 .fops = &osp_max_create_count_fops },
493 { .name = "prealloc_next_id",
494 .fops = &osp_prealloc_next_id_fops },
495 { .name = "prealloc_next_seq",
496 .fops = &osp_prealloc_next_seq_fops },
497 { .name = "prealloc_last_id",
498 .fops = &osp_prealloc_last_id_fops },
499 { .name = "prealloc_last_seq",
500 .fops = &osp_prealloc_last_seq_fops },
501 { .name = "prealloc_reserved",
502 .fops = &osp_prealloc_reserved_fops },
503 { .name = "timeouts",
504 .fops = &osp_timeouts_fops },
506 .fops = &osp_import_fops },
508 .fops = &osp_state_fops },
510 .fops = &osp_maxage_fops },
511 { .name = "prealloc_status",
512 .fops = &osp_pre_status_fops },
513 { .name = "sync_changes",
514 .fops = &osp_syn_changes_fops },
515 { .name = "sync_in_flight",
516 .fops = &osp_syn_in_flight_fops },
517 { .name = "sync_in_progress",
518 .fops = &osp_syn_in_prog_fops },
519 { .name = "old_sync_processed",
520 .fops = &osp_old_sync_processed_fops },
522 /* for compatibility reasons */
523 { .name = "destroys_in_flight",
524 .fops = &osp_destroys_in_flight_fops },
525 { .name = "lfsck_max_rpcs_in_flight",
526 .fops = &osp_lfsck_max_rpcs_in_flight_fops },
530 LPROC_SEQ_FOPS_RO_TYPE(osp, dt_blksize);
531 LPROC_SEQ_FOPS_RO_TYPE(osp, dt_kbytestotal);
532 LPROC_SEQ_FOPS_RO_TYPE(osp, dt_kbytesfree);
533 LPROC_SEQ_FOPS_RO_TYPE(osp, dt_kbytesavail);
534 LPROC_SEQ_FOPS_RO_TYPE(osp, dt_filestotal);
535 LPROC_SEQ_FOPS_RO_TYPE(osp, dt_filesfree);
537 static struct lprocfs_seq_vars lprocfs_osp_osd_vars[] = {
538 { .name = "blocksize",
539 .fops = &osp_dt_blksize_fops },
540 { .name = "kbytestotal",
541 .fops = &osp_dt_kbytestotal_fops },
542 { .name = "kbytesfree",
543 .fops = &osp_dt_kbytesfree_fops },
544 { .name = "kbytesavail",
545 .fops = &osp_dt_kbytesavail_fops },
546 { .name = "filestotal",
547 .fops = &osp_dt_filestotal_fops },
548 { .name = "filesfree",
549 .fops = &osp_dt_filesfree_fops },
553 void osp_lprocfs_init(struct osp_device *osp)
555 struct obd_device *obd = osp->opd_obd;
556 struct proc_dir_entry *osc_proc_dir = NULL;
557 struct obd_type *type;
560 obd->obd_vars = lprocfs_osp_obd_vars;
561 if (lprocfs_seq_obd_setup(obd) != 0)
564 rc = lprocfs_seq_add_vars(obd->obd_proc_entry, lprocfs_osp_osd_vars,
567 CERROR("%s: can't register in lprocfs, rc %d\n",
572 ptlrpc_lprocfs_register_obd(obd);
574 if (osp->opd_connect_mdt || !strstr(obd->obd_name, "osc"))
577 /* If the real OSC is present which is the case for setups
578 * with both server and clients on the same node then use
579 * the OSC's proc root */
580 type = class_search_type(LUSTRE_OSC_NAME);
581 if (type != NULL && type->typ_procroot != NULL)
582 osc_proc_dir = type->typ_procroot;
584 osc_proc_dir = obd->obd_type->typ_procsym;
586 if (osc_proc_dir == NULL)
589 /* for compatibility we link old procfs's OSC entries to osp ones */
590 osp->opd_symlink = lprocfs_add_symlink(obd->obd_name, osc_proc_dir,
591 "../osp/%s", obd->obd_name);
592 if (osp->opd_symlink == NULL)
593 CERROR("could not register OSC symlink for "
594 "/proc/fs/lustre/osp/%s.", obd->obd_name);