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.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2012, 2017, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
32 * lustre/osp/lproc_osp.c
34 * Lustre OST Proxy Device (OSP), procfs functions
36 * Author: Alex Zhuravlev <alexey.zhuravlev@intel.com>
39 #define DEBUG_SUBSYSTEM S_CLASS
41 #include "osp_internal.h"
44 * Show OSP active status
46 * \param[in] m seq_file handle
47 * \param[in] data unused for single entry
48 * \retval 0 on success
49 * \retval negative number on error
51 static ssize_t active_show(struct kobject *kobj, struct attribute *attr,
54 struct dt_device *dt = container_of(kobj, struct dt_device,
56 struct lu_device *lu = dt2lu_dev(dt);
57 struct obd_device *obd = lu->ld_obd;
60 LPROCFS_CLIMP_CHECK(obd);
61 rc = sprintf(buf, "%d\n", !obd->u.cli.cl_import->imp_deactive);
62 LPROCFS_CLIMP_EXIT(obd);
67 * Activate/Deactivate OSP
69 * \param[in] file proc file
70 * \param[in] buffer string, which is "1" or "0" to activate/deactivate OSP
71 * \param[in] count \a buffer length
72 * \param[in] off unused for single entry
73 * \retval \a count on success
74 * \retval negative number on error
76 static ssize_t active_store(struct kobject *kobj, struct attribute *attr,
77 const char *buffer, size_t count)
79 struct dt_device *dt = container_of(kobj, struct dt_device,
81 struct lu_device *lu = dt2lu_dev(dt);
82 struct obd_device *obd = lu->ld_obd;
86 rc = kstrtobool(buffer, &val);
90 LPROCFS_CLIMP_CHECK(obd);
92 if (obd->u.cli.cl_import->imp_deactive == val)
93 rc = ptlrpc_set_import_active(obd->u.cli.cl_import, val);
95 CDEBUG(D_CONFIG, "activate %u: ignoring repeat request\n",
98 LPROCFS_CLIMP_EXIT(obd);
101 LUSTRE_RW_ATTR(active);
104 * Show number of RPCs in flight
106 * \param[in] m seq_file handle
107 * \param[in] data unused for single entry
108 * \retval 0 on success
109 * \retval negative number on error
111 static ssize_t sync_in_flight_show(struct kobject *kobj,
112 struct attribute *attr,
115 struct dt_device *dt = container_of(kobj, struct dt_device,
117 struct osp_device *osp = dt2osp_dev(dt);
119 return sprintf(buf, "%u\n", atomic_read(&osp->opd_sync_rpcs_in_flight));
121 LUSTRE_RO_ATTR(sync_in_flight);
124 * Show number of RPCs in processing (including uncommitted by OST)
126 * \param[in] m seq_file handle
127 * \param[in] data unused for single entry
128 * \retval 0 on success
129 * \retval negative number on error
131 static ssize_t sync_in_progress_show(struct kobject *kobj,
132 struct attribute *attr,
135 struct dt_device *dt = container_of(kobj, struct dt_device,
137 struct osp_device *osp = dt2osp_dev(dt);
139 return sprintf(buf, "%u\n", atomic_read(&osp->opd_sync_rpcs_in_progress));
141 LUSTRE_RO_ATTR(sync_in_progress);
144 * Show number of changes to sync
146 * \param[in] m seq_file handle
147 * \param[in] data unused for single entry
148 * \retval 0 on success
149 * \retval negative number on error
151 static ssize_t sync_changes_show(struct kobject *kobj,
152 struct attribute *attr,
155 struct dt_device *dt = container_of(kobj, struct dt_device,
157 struct osp_device *osp = dt2osp_dev(dt);
159 return sprintf(buf, "%u\n", atomic_read(&osp->opd_sync_changes));
165 * \param[in] file proc file
166 * \param[in] buffer unused because any input will do
167 * \param[in] count \a buffer length
168 * \param[in] off unused for single entry
169 * \retval \a count on success
170 * \retval negative number on error
172 static ssize_t sync_changes_store(struct kobject *kobj, struct attribute *attr,
173 const char *buffer, size_t count)
175 struct dt_device *dt = container_of(kobj, struct dt_device,
177 struct osp_device *osp = dt2osp_dev(dt);
181 rc = lu_env_init(&env, LCT_LOCAL);
185 rc = dt_sync(&env, &osp->opd_dt_dev);
188 return rc == 0 ? count : rc;
190 LUSTRE_RW_ATTR(sync_changes);
193 * Show maximum number of RPCs in flight allowed
195 * \param[in] m seq_file handle
196 * \param[in] data unused for single entry
197 * \retval 0 on success
198 * \retval negative number on error
200 static ssize_t max_rpcs_in_flight_show(struct kobject *kobj,
201 struct attribute *attr,
204 struct dt_device *dt = container_of(kobj, struct dt_device,
206 struct osp_device *osp = dt2osp_dev(dt);
208 return sprintf(buf, "%u\n", osp->opd_sync_max_rpcs_in_flight);
212 * Change maximum number of RPCs in flight allowed
214 * \param[in] file proc file
215 * \param[in] buffer string which represents maximum number
216 * \param[in] count \a buffer length
217 * \param[in] off unused for single entry
218 * \retval \a count on success
219 * \retval negative number on error
221 static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
222 struct attribute *attr,
226 struct dt_device *dt = container_of(kobj, struct dt_device,
228 struct osp_device *osp = dt2osp_dev(dt);
232 rc = kstrtouint(buffer, 0, &val);
239 osp->opd_sync_max_rpcs_in_flight = val;
242 LUSTRE_RW_ATTR(max_rpcs_in_flight);
245 * Show maximum number of RPCs in processing allowed
247 * \param[in] m seq_file handle
248 * \param[in] data unused
249 * \retval 0 on success
250 * \retval negative number on error
252 static ssize_t max_rpcs_in_progress_show(struct kobject *kobj,
253 struct attribute *attr,
256 struct dt_device *dt = container_of(kobj, struct dt_device,
258 struct osp_device *osp = dt2osp_dev(dt);
260 return sprintf(buf, "%u\n", osp->opd_sync_max_rpcs_in_progress);
264 * Change maximum number of RPCs in processing allowed
266 * \param[in] file proc file
267 * \param[in] buffer string which represents maximum number
268 * \param[in] count \a buffer length
269 * \param[in] off unused for single entry
270 * \retval \a count on success
271 * \retval negative number on error
273 static ssize_t max_rpcs_in_progress_store(struct kobject *kobj,
274 struct attribute *attr,
278 struct dt_device *dt = container_of(kobj, struct dt_device,
280 struct osp_device *osp = dt2osp_dev(dt);
284 rc = kstrtouint(buffer, 0, &val);
291 osp->opd_sync_max_rpcs_in_progress = val;
295 LUSTRE_RW_ATTR(max_rpcs_in_progress);
298 * Show number of objects to precreate next time
300 * \param[in] m seq_file handle
301 * \param[in] data unused for single entry
302 * \retval 0 on success
303 * \retval negative number on error
305 static ssize_t create_count_show(struct kobject *kobj,
306 struct attribute *attr,
309 struct dt_device *dt = container_of(kobj, struct dt_device,
311 struct osp_device *osp = dt2osp_dev(dt);
316 return sprintf(buf, "%d\n", osp->opd_pre_create_count);
320 * Change number of objects to precreate next time
322 * \param[in] file proc file
323 * \param[in] buffer string which represents number of objects to precreate
324 * \param[in] count \a buffer length
325 * \param[in] off unused for single entry
326 * \retval \a count on success
327 * \retval negative number on error
329 static ssize_t create_count_store(struct kobject *kobj, struct attribute *attr,
330 const char *buffer, size_t count)
332 struct dt_device *dt = container_of(kobj, struct dt_device,
334 struct osp_device *osp = dt2osp_dev(dt);
342 rc = kstrtouint(buffer, 0, &val);
346 /* The MDT ALWAYS needs to limit the precreate count to
347 * OST_MAX_PRECREATE, and the constant cannot be changed
348 * because it is a value shared between the OSP and OST
349 * that is the maximum possible number of objects that will
350 * ever be handled by MDT->OST recovery processing.
352 * If the OST ever gets a request to delete more orphans,
353 * this implies that something has gone badly on the MDT
354 * and the OST will refuse to delete so much data from the
355 * filesystem as a safety measure. */
356 if (val < OST_MIN_PRECREATE || val > OST_MAX_PRECREATE)
358 if (val > osp->opd_pre_max_create_count)
361 for (i = 1; (i << 1) <= val; i <<= 1)
363 osp->opd_pre_create_count = i;
367 LUSTRE_RW_ATTR(create_count);
370 * Show maximum number of objects to precreate
372 * \param[in] m seq_file handle
373 * \param[in] data unused for single entry
374 * \retval 0 on success
375 * \retval negative number on error
377 static ssize_t max_create_count_show(struct kobject *kobj,
378 struct attribute *attr,
381 struct dt_device *dt = container_of(kobj, struct dt_device,
383 struct osp_device *osp = dt2osp_dev(dt);
388 return sprintf(buf, "%d\n", osp->opd_pre_max_create_count);
392 * Change maximum number of objects to precreate
394 * \param[in] file proc file
395 * \param[in] buffer string which represents maximum number
396 * \param[in] count \a buffer length
397 * \param[in] off unused for single entry
398 * \retval \a count on success
399 * \retval negative number on error
401 static ssize_t max_create_count_store(struct kobject *kobj,
402 struct attribute *attr,
403 const char *buffer, size_t count)
405 struct dt_device *dt = container_of(kobj, struct dt_device,
407 struct osp_device *osp = dt2osp_dev(dt);
414 rc = kstrtouint(buffer, 0, &val);
418 if (val < 0 || val > INT_MAX)
420 if (val > OST_MAX_PRECREATE)
423 if (osp->opd_pre_create_count > val)
424 osp->opd_pre_create_count = val;
426 osp->opd_pre_max_create_count = val;
430 LUSTRE_RW_ATTR(max_create_count);
433 * Show last id to assign in creation
435 * \param[in] m seq_file handle
436 * \param[in] data unused for single entry
437 * \retval 0 on success
438 * \retval negative number on error
440 static ssize_t prealloc_next_id_show(struct kobject *kobj,
441 struct attribute *attr,
444 struct dt_device *dt = container_of(kobj, struct dt_device,
446 struct osp_device *osp = dt2osp_dev(dt);
453 fid = &osp->opd_pre_used_fid;
454 if (fid_is_idif(fid)) {
455 id = fid_idif_id(fid_seq(fid), fid_oid(fid), fid_ver(fid));
458 id = unlikely(fid_oid(fid) == LUSTRE_DATA_SEQ_MAX_WIDTH) ?
459 1 : fid_oid(fid) + 1;
462 return sprintf(buf, "%llu\n", id);
464 LUSTRE_RO_ATTR(prealloc_next_id);
467 * Show last created id OST reported
469 * \param[in] m seq_file handle
470 * \param[in] data unused for single entry
471 * \retval 0 on success
472 * \retval negative number on error
475 static ssize_t prealloc_last_id_show(struct kobject *kobj,
476 struct attribute *attr,
479 struct dt_device *dt = container_of(kobj, struct dt_device,
481 struct osp_device *osp = dt2osp_dev(dt);
488 fid = &osp->opd_pre_last_created_fid;
489 id = fid_is_idif(fid) ?
490 fid_idif_id(fid_seq(fid), fid_oid(fid), fid_ver(fid)) :
493 return sprintf(buf, "%llu\n", id);
495 LUSTRE_RO_ATTR(prealloc_last_id);
498 * Show next FID sequence to precreate
500 * \param[in] m seq_file handle
501 * \param[in] data unused for single entry
502 * \retval 0 on success
503 * \retval negative number on error
505 static ssize_t prealloc_next_seq_show(struct kobject *kobj,
506 struct attribute *attr,
509 struct dt_device *dt = container_of(kobj, struct dt_device,
511 struct osp_device *osp = dt2osp_dev(dt);
517 fid = &osp->opd_pre_used_fid;
518 return sprintf(buf, "%#llx\n", fid_is_idif(fid) ?
519 fid_seq(fid) & (~0xffff) : fid_seq(fid));
521 LUSTRE_RO_ATTR(prealloc_next_seq);
524 * Show last created FID sequence OST reported
526 * \param[in] m seq_file handle
527 * \param[in] data unused for single entry
528 * \retval 0 on success
529 * \retval negative number on error
531 static ssize_t prealloc_last_seq_show(struct kobject *kobj,
532 struct attribute *attr,
535 struct dt_device *dt = container_of(kobj, struct dt_device,
537 struct osp_device *osp = dt2osp_dev(dt);
543 fid = &osp->opd_pre_last_created_fid;
544 return sprintf(buf, "%#llx\n", fid_is_idif(fid) ?
545 fid_seq(fid) & (~0xffff) : fid_seq(fid));
547 LUSTRE_RO_ATTR(prealloc_last_seq);
550 * Show the number of ids reserved by declare
552 * \param[in] m seq_file handle
553 * \param[in] data unused for single entry
554 * \retval 0 on success
555 * \retval negative number on error
557 static ssize_t prealloc_reserved_show(struct kobject *kobj,
558 struct attribute *attr,
561 struct dt_device *dt = container_of(kobj, struct dt_device,
563 struct osp_device *osp = dt2osp_dev(dt);
568 return sprintf(buf, "%llu\n", osp->opd_pre_reserved);
570 LUSTRE_RO_ATTR(prealloc_reserved);
573 * Show interval (in seconds) to update statfs data
575 * \param[in] m seq_file handle
576 * \param[in] data unused for single entry
577 * \retval 0 on success
578 * \retval negative number on error
580 static ssize_t maxage_show(struct kobject *kobj,
581 struct attribute *attr,
584 struct dt_device *dt = container_of(kobj, struct dt_device,
586 struct osp_device *osp = dt2osp_dev(dt);
588 return sprintf(buf, "%lld\n", osp->opd_statfs_maxage);
592 * Change interval to update statfs data
594 * \param[in] file proc file
595 * \param[in] buffer string which represents statfs interval (in seconds)
596 * \param[in] count \a buffer length
597 * \param[in] off unused for single entry
598 * \retval \a count on success
599 * \retval negative number on error
601 static ssize_t maxage_store(struct kobject *kobj, struct attribute *attr,
602 const char *buffer, size_t count)
604 struct dt_device *dt = container_of(kobj, struct dt_device,
606 struct osp_device *osp = dt2osp_dev(dt);
610 rc = kstrtouint(buffer, 0, &val);
617 osp->opd_statfs_maxage = val;
621 LUSTRE_RW_ATTR(maxage);
624 * Show current precreation status: output 0 means success, otherwise negative
627 * \param[in] m seq_file handle
628 * \param[in] data unused for single entry
629 * \retval 0 on success
630 * \retval negative number on error
632 static ssize_t prealloc_status_show(struct kobject *kobj,
633 struct attribute *attr,
636 struct dt_device *dt = container_of(kobj, struct dt_device,
638 struct osp_device *osp = dt2osp_dev(dt);
643 return sprintf(buf, "%d\n", osp->opd_pre_status);
645 LUSTRE_RO_ATTR(prealloc_status);
648 * Show the number of RPCs in processing (including uncommitted by OST) plus
649 * changes to sync, i.e. this is the total number of changes OST needs to apply
652 * This counter is used to determine if OST has space returned. A zero value
653 * indicates that OST storage space consumed by destroyed objects has been freed
654 * on disk, the associated llog records have been cleared, and no synchronous
655 * RPC are being processed.
657 * \param[in] m seq_file handle
658 * \param[in] data unused for single entry
659 * \retval 0 on success
660 * \retval negative number on error
662 static ssize_t destroys_in_flight_show(struct kobject *kobj,
663 struct attribute *attr,
666 struct dt_device *dt = container_of(kobj, struct dt_device,
668 struct osp_device *osp = dt2osp_dev(dt);
670 return sprintf(buf, "%u\n",
671 atomic_read(&osp->opd_sync_rpcs_in_progress) +
672 atomic_read(&osp->opd_sync_changes));
674 LUSTRE_RO_ATTR(destroys_in_flight);
677 * Show changes synced from previous mount
679 * \param[in] m seq_file handle
680 * \param[in] data unused for single entry
681 * \retval 0 on success
682 * \retval negative number on error
684 static ssize_t old_sync_processed_show(struct kobject *kobj,
685 struct attribute *attr,
688 struct dt_device *dt = container_of(kobj, struct dt_device,
690 struct osp_device *osp = dt2osp_dev(dt);
692 return sprintf(buf, "%d\n", osp->opd_sync_prev_done);
694 LUSTRE_RO_ATTR(old_sync_processed);
697 * Show maximum number of RPCs in flight
699 * \param[in] m seq_file handle
700 * \param[in] data unused for single entry
701 * \retval 0 on success
702 * \retval negative number on error
704 static ssize_t lfsck_max_rpcs_in_flight_show(struct kobject *kobj,
705 struct attribute *attr,
708 struct dt_device *dt = container_of(kobj, struct dt_device,
710 struct lu_device *lu = dt2lu_dev(dt);
711 struct obd_device *obd = lu->ld_obd;
714 max = obd_get_max_rpcs_in_flight(&obd->u.cli);
715 return sprintf(buf, "%u\n", max);
719 * Change maximum number of RPCs in flight
721 * \param[in] file proc file
722 * \param[in] buffer string which represents maximum number of RPCs in flight
723 * \param[in] count \a buffer length
724 * \param[in] off unused for single entry
725 * \retval \a count on success
726 * \retval negative number on error
728 static ssize_t lfsck_max_rpcs_in_flight_store(struct kobject *kobj,
729 struct attribute *attr,
733 struct dt_device *dt = container_of(kobj, struct dt_device,
735 struct lu_device *lu = dt2lu_dev(dt);
736 struct obd_device *obd = lu->ld_obd;
740 rc = kstrtouint(buffer, 0, &val);
744 rc = obd_set_max_rpcs_in_flight(&obd->u.cli, val);
745 return rc ? rc : count;
747 LUSTRE_RW_ATTR(lfsck_max_rpcs_in_flight);
749 ssize_t ping_show(struct kobject *kobj, struct attribute *attr,
752 struct dt_device *dt = container_of(kobj, struct dt_device,
754 struct lu_device *lu = dt2lu_dev(dt);
755 struct obd_device *obd = lu->ld_obd;
758 LPROCFS_CLIMP_CHECK(obd);
759 rc = ptlrpc_obd_ping(obd);
760 LPROCFS_CLIMP_EXIT(obd);
764 LUSTRE_RO_ATTR(ping);
766 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, connect_flags);
767 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, server_uuid);
768 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, conn_uuid);
770 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, timeouts);
772 LPROC_SEQ_FOPS_RW_TYPE(osp, import);
773 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, state);
776 * Show high watermark (in megabytes). If available free space at OST is grater
777 * than high watermark and object allocation for OST is disabled, enable it.
779 * \param[in] m seq_file handle
780 * \param[in] data unused for single entry
781 * \retval 0 on success
782 * \retval negative number on error
784 static int osp_reserved_mb_high_seq_show(struct seq_file *m, void *data)
786 struct obd_device *dev = m->private;
787 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
792 seq_printf(m, "%u\n", osp->opd_reserved_mb_high);
797 * Change high watermark
799 * \param[in] file proc file
800 * \param[in] buffer string which represents new value (in megabytes)
801 * \param[in] count \a buffer length
802 * \param[in] off unused for single entry
803 * \retval \a count on success
804 * \retval negative number on error
807 osp_reserved_mb_high_seq_write(struct file *file, const char __user *buffer,
808 size_t count, loff_t *off)
810 struct seq_file *m = file->private_data;
811 struct obd_device *dev = m->private;
812 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
819 rc = lprocfs_str_with_units_to_s64(buffer, count, &val, 'M');
826 spin_lock(&osp->opd_pre_lock);
827 osp->opd_reserved_mb_high = val;
828 if (val <= osp->opd_reserved_mb_low)
829 osp->opd_reserved_mb_low = val - 1;
830 spin_unlock(&osp->opd_pre_lock);
834 LDEBUGFS_SEQ_FOPS(osp_reserved_mb_high);
837 * Show low watermark (in megabytes). If available free space at OST is less
838 * than low watermark, object allocation for OST is disabled.
840 * \param[in] m seq_file handle
841 * \param[in] data unused for single entry
842 * \retval 0 on success
843 * \retval negative number on error
845 static int osp_reserved_mb_low_seq_show(struct seq_file *m, void *data)
847 struct obd_device *dev = m->private;
848 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
853 seq_printf(m, "%u\n", osp->opd_reserved_mb_low);
858 * Change low watermark
860 * \param[in] file proc file
861 * \param[in] buffer string which represents new value (in megabytes)
862 * \param[in] count \a buffer length
863 * \param[in] off unused for single entry
864 * \retval \a count on success
865 * \retval negative number on error
868 osp_reserved_mb_low_seq_write(struct file *file, const char __user *buffer,
869 size_t count, loff_t *off)
871 struct seq_file *m = file->private_data;
872 struct obd_device *dev = m->private;
873 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
880 rc = lprocfs_str_with_units_to_s64(buffer, count, &val, 'M');
885 spin_lock(&osp->opd_pre_lock);
886 osp->opd_reserved_mb_low = val;
887 if (val >= osp->opd_reserved_mb_high)
888 osp->opd_reserved_mb_high = val + 1;
889 spin_unlock(&osp->opd_pre_lock);
893 LDEBUGFS_SEQ_FOPS(osp_reserved_mb_low);
895 static ssize_t force_sync_store(struct kobject *kobj, struct attribute *attr,
896 const char *buffer, size_t count)
898 struct dt_device *dt = container_of(kobj, struct dt_device,
903 rc = lu_env_init(&env, LCT_LOCAL);
907 rc = dt_sync(&env, dt);
910 return rc == 0 ? count : rc;
912 LUSTRE_WO_ATTR(force_sync);
914 static struct lprocfs_vars lprocfs_osp_obd_vars[] = {
915 { .name = "connect_flags",
916 .fops = &osp_connect_flags_fops },
917 { .name = "ost_server_uuid",
918 .fops = &osp_server_uuid_fops },
919 { .name = "ost_conn_uuid",
920 .fops = &osp_conn_uuid_fops },
921 { .name = "timeouts",
922 .fops = &osp_timeouts_fops },
924 .fops = &osp_import_fops },
926 .fops = &osp_state_fops },
927 { .name = "reserved_mb_high",
928 .fops = &osp_reserved_mb_high_fops },
929 { .name = "reserved_mb_low",
930 .fops = &osp_reserved_mb_low_fops },
934 static struct lprocfs_vars lprocfs_osp_md_vars[] = {
935 { .name = "connect_flags",
936 .fops = &osp_connect_flags_fops },
937 { .name = "mdt_server_uuid",
938 .fops = &osp_server_uuid_fops },
939 { .name = "mdt_conn_uuid",
940 .fops = &osp_conn_uuid_fops },
941 { .name = "timeouts",
942 .fops = &osp_timeouts_fops },
944 .fops = &osp_import_fops },
946 .fops = &osp_state_fops },
950 static struct attribute *osp_obd_attrs[] = {
951 /* First two for compatiability reasons */
952 &lustre_attr_lfsck_max_rpcs_in_flight.attr,
953 &lustre_attr_destroys_in_flight.attr,
954 &lustre_attr_active.attr,
955 &lustre_attr_max_rpcs_in_flight.attr,
956 &lustre_attr_max_rpcs_in_progress.attr,
957 &lustre_attr_maxage.attr,
958 &lustre_attr_ping.attr,
959 &lustre_attr_prealloc_status.attr,
960 &lustre_attr_prealloc_next_id.attr,
961 &lustre_attr_prealloc_last_id.attr,
962 &lustre_attr_prealloc_next_seq.attr,
963 &lustre_attr_prealloc_last_seq.attr,
964 &lustre_attr_prealloc_reserved.attr,
965 &lustre_attr_sync_in_flight.attr,
966 &lustre_attr_sync_in_progress.attr,
967 &lustre_attr_sync_changes.attr,
968 &lustre_attr_force_sync.attr,
969 &lustre_attr_old_sync_processed.attr,
970 &lustre_attr_create_count.attr,
971 &lustre_attr_max_create_count.attr,
975 static struct attribute *osp_md_attrs[] = {
976 /* First two for compatiability reasons */
977 &lustre_attr_lfsck_max_rpcs_in_flight.attr,
978 &lustre_attr_destroys_in_flight.attr,
979 &lustre_attr_active.attr,
980 &lustre_attr_max_rpcs_in_flight.attr,
981 &lustre_attr_max_rpcs_in_progress.attr,
982 &lustre_attr_maxage.attr,
983 &lustre_attr_ping.attr,
984 &lustre_attr_prealloc_status.attr,
988 void osp_tunables_fini(struct osp_device *osp)
990 struct obd_device *obd = osp->opd_obd;
993 osc = kset_find_obj(lustre_kset, "osc");
995 sysfs_remove_link(osc, obd->obd_name);
999 if (!IS_ERR_OR_NULL(osp->opd_debugfs))
1000 ldebugfs_remove(&osp->opd_debugfs);
1002 ptlrpc_lprocfs_unregister_obd(obd);
1004 if (!IS_ERR_OR_NULL(obd->obd_debugfs_entry))
1005 ldebugfs_remove(&obd->obd_debugfs_entry);
1007 dt_tunables_fini(&osp->opd_dt_dev);
1011 * Initialize OSP sysfs / debugfs
1013 * param[in] osp OSP device
1015 void osp_tunables_init(struct osp_device *osp)
1017 struct obd_device *obd = osp->opd_obd;
1018 struct kobject *osc;
1021 if (osp->opd_connect_mdt) {
1022 osp->opd_dt_dev.dd_ktype.default_attrs = osp_md_attrs;
1023 obd->obd_vars = lprocfs_osp_md_vars;
1025 osp->opd_dt_dev.dd_ktype.default_attrs = osp_obd_attrs;
1026 obd->obd_vars = lprocfs_osp_obd_vars;
1029 rc = dt_tunables_init(&osp->opd_dt_dev, obd->obd_type, obd->obd_name,
1032 CERROR("%s: failed to setup DT tunables: %d\n",
1037 /* Since we register the obd device with ptlrpc / sptlrpc we
1038 * have to register debugfs with obd_device
1040 obd->obd_debugfs_entry = ldebugfs_register(obd->obd_name,
1041 obd->obd_type->typ_debugfs_entry,
1042 obd->obd_vars, obd);
1043 if (IS_ERR_OR_NULL(obd->obd_debugfs_entry)) {
1044 rc = obd->obd_debugfs_entry ? PTR_ERR(obd->obd_debugfs_entry)
1046 CERROR("%s: error %d setting up debugfs\n",
1048 obd->obd_debugfs_entry = NULL;
1049 dt_tunables_fini(&osp->opd_dt_dev);
1053 sptlrpc_lprocfs_cliobd_attach(obd);
1054 ptlrpc_lprocfs_register_obd(obd);
1056 if (osp->opd_connect_mdt || !strstr(obd->obd_name, "osc"))
1059 /* If the real OSC is present which is the case for setups
1060 * with both server and clients on the same node then use
1061 * the OSC's proc root
1063 osc = kset_find_obj(lustre_kset, "osc");
1065 rc = sysfs_create_link(osc, &osp->opd_dt_dev.dd_kobj,
1070 osp->opd_debugfs = ldebugfs_add_symlink(obd->obd_name, "osc",
1071 "../osp/%s", obd->obd_name);
1072 if (!osp->opd_debugfs)
1073 CERROR("%s: failed to create OSC debugfs symlink\n",