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/
31 * lustre/osp/lproc_osp.c
33 * Lustre OST Proxy Device (OSP), procfs functions
35 * Author: Alex Zhuravlev <alexey.zhuravlev@intel.com>
38 #define DEBUG_SUBSYSTEM S_CLASS
40 #include "osp_internal.h"
43 * Show OSP active status
45 * \param[in] m seq_file handle
46 * \param[in] data unused for single entry
47 * \retval 0 on success
48 * \retval negative number on error
50 static ssize_t active_show(struct kobject *kobj, struct attribute *attr,
53 struct dt_device *dt = container_of(kobj, struct dt_device,
55 struct lu_device *lu = dt2lu_dev(dt);
56 struct obd_device *obd = lu->ld_obd;
57 struct obd_import *imp;
60 with_imp_locked(obd, imp, rc)
61 rc = sprintf(buf, "%d\n", !imp->imp_deactive);
66 * Activate/Deactivate OSP
68 * \param[in] file proc file
69 * \param[in] buffer string, which is "1" or "0" to activate/deactivate OSP
70 * \param[in] count \a buffer length
71 * \param[in] off unused for single entry
72 * \retval \a count on success
73 * \retval negative number on error
75 static ssize_t active_store(struct kobject *kobj, struct attribute *attr,
76 const char *buffer, size_t count)
78 struct dt_device *dt = container_of(kobj, struct dt_device,
80 struct lu_device *lu = dt2lu_dev(dt);
81 struct obd_device *obd = lu->ld_obd;
82 struct obd_import *imp, *imp0;
86 rc = kstrtobool(buffer, &val);
90 with_imp_locked(obd, imp0, rc)
91 imp = class_import_get(imp0);
95 if (imp->imp_deactive == val)
96 rc = ptlrpc_set_import_active(imp, val);
98 CDEBUG(D_CONFIG, "activate %u: ignoring repeat request\n",
101 class_import_put(imp);
105 LUSTRE_RW_ATTR(active);
108 * Show number of RPCs in flight
110 * \param[in] m seq_file handle
111 * \param[in] data unused for single entry
112 * \retval 0 on success
113 * \retval negative number on error
115 static ssize_t sync_in_flight_show(struct kobject *kobj,
116 struct attribute *attr,
119 struct dt_device *dt = container_of(kobj, struct dt_device,
121 struct osp_device *osp = dt2osp_dev(dt);
123 return sprintf(buf, "%u\n", atomic_read(&osp->opd_sync_rpcs_in_flight));
125 LUSTRE_RO_ATTR(sync_in_flight);
128 * Show number of RPCs in processing (including uncommitted by OST)
130 * \param[in] m seq_file handle
131 * \param[in] data unused for single entry
132 * \retval 0 on success
133 * \retval negative number on error
135 static ssize_t sync_in_progress_show(struct kobject *kobj,
136 struct attribute *attr,
139 struct dt_device *dt = container_of(kobj, struct dt_device,
141 struct osp_device *osp = dt2osp_dev(dt);
143 return sprintf(buf, "%u\n", atomic_read(&osp->opd_sync_rpcs_in_progress));
145 LUSTRE_RO_ATTR(sync_in_progress);
148 * Show number of changes to sync
150 * \param[in] m seq_file handle
151 * \param[in] data unused for single entry
152 * \retval 0 on success
153 * \retval negative number on error
155 static ssize_t sync_changes_show(struct kobject *kobj,
156 struct attribute *attr,
159 struct dt_device *dt = container_of(kobj, struct dt_device,
161 struct osp_device *osp = dt2osp_dev(dt);
163 return sprintf(buf, "%u\n", atomic_read(&osp->opd_sync_changes));
169 * \param[in] file proc file
170 * \param[in] buffer unused because any input will do
171 * \param[in] count \a buffer length
172 * \param[in] off unused for single entry
173 * \retval \a count on success
174 * \retval negative number on error
176 static ssize_t sync_changes_store(struct kobject *kobj, struct attribute *attr,
177 const char *buffer, size_t count)
179 struct dt_device *dt = container_of(kobj, struct dt_device,
181 struct osp_device *osp = dt2osp_dev(dt);
185 rc = lu_env_init(&env, LCT_LOCAL);
189 rc = dt_sync(&env, &osp->opd_dt_dev);
192 return rc == 0 ? count : rc;
194 LUSTRE_RW_ATTR(sync_changes);
197 * Show maximum number of RPCs in flight allowed
199 * \param[in] m seq_file handle
200 * \param[in] data unused for single entry
201 * \retval 0 on success
202 * \retval negative number on error
204 static ssize_t max_rpcs_in_flight_show(struct kobject *kobj,
205 struct attribute *attr,
208 struct dt_device *dt = container_of(kobj, struct dt_device,
210 struct osp_device *osp = dt2osp_dev(dt);
212 return sprintf(buf, "%u\n", osp->opd_sync_max_rpcs_in_flight);
216 * Change maximum number of RPCs in flight allowed
218 * \param[in] file proc file
219 * \param[in] buffer string which represents maximum number
220 * \param[in] count \a buffer length
221 * \param[in] off unused for single entry
222 * \retval \a count on success
223 * \retval negative number on error
225 static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
226 struct attribute *attr,
230 struct dt_device *dt = container_of(kobj, struct dt_device,
232 struct osp_device *osp = dt2osp_dev(dt);
236 rc = kstrtouint(buffer, 0, &val);
243 osp->opd_sync_max_rpcs_in_flight = val;
246 LUSTRE_RW_ATTR(max_rpcs_in_flight);
249 * Show maximum number of RPCs in processing allowed
251 * \param[in] m seq_file handle
252 * \param[in] data unused
253 * \retval 0 on success
254 * \retval negative number on error
256 static ssize_t max_rpcs_in_progress_show(struct kobject *kobj,
257 struct attribute *attr,
260 struct dt_device *dt = container_of(kobj, struct dt_device,
262 struct osp_device *osp = dt2osp_dev(dt);
264 return sprintf(buf, "%u\n", osp->opd_sync_max_rpcs_in_progress);
268 * Change maximum number of RPCs in processing allowed
270 * \param[in] file proc file
271 * \param[in] buffer string which represents maximum number
272 * \param[in] count \a buffer length
273 * \param[in] off unused for single entry
274 * \retval \a count on success
275 * \retval negative number on error
277 static ssize_t max_rpcs_in_progress_store(struct kobject *kobj,
278 struct attribute *attr,
282 struct dt_device *dt = container_of(kobj, struct dt_device,
284 struct osp_device *osp = dt2osp_dev(dt);
288 rc = kstrtouint(buffer, 0, &val);
295 osp->opd_sync_max_rpcs_in_progress = val;
299 LUSTRE_RW_ATTR(max_rpcs_in_progress);
302 * Show number of objects to precreate next time
304 * \param[in] m seq_file handle
305 * \param[in] data unused for single entry
306 * \retval 0 on success
307 * \retval negative number on error
309 static ssize_t create_count_show(struct kobject *kobj,
310 struct attribute *attr,
313 struct dt_device *dt = container_of(kobj, struct dt_device,
315 struct osp_device *osp = dt2osp_dev(dt);
320 return sprintf(buf, "%d\n", osp->opd_pre_create_count);
324 * Change number of objects to precreate next time
326 * \param[in] file proc file
327 * \param[in] buffer string which represents number of objects to precreate
328 * \param[in] count \a buffer length
329 * \param[in] off unused for single entry
330 * \retval \a count on success
331 * \retval negative number on error
333 static ssize_t create_count_store(struct kobject *kobj, struct attribute *attr,
334 const char *buffer, size_t count)
336 struct dt_device *dt = container_of(kobj, struct dt_device,
338 struct osp_device *osp = dt2osp_dev(dt);
346 rc = kstrtouint(buffer, 0, &val);
350 /* The MDT ALWAYS needs to limit the precreate count to
351 * OST_MAX_PRECREATE, and the constant cannot be changed
352 * because it is a value shared between the OSP and OST
353 * that is the maximum possible number of objects that will
354 * ever be handled by MDT->OST recovery processing.
356 * If the OST ever gets a request to delete more orphans,
357 * this implies that something has gone badly on the MDT
358 * and the OST will refuse to delete so much data from the
359 * filesystem as a safety measure. */
360 if (val < OST_MIN_PRECREATE || val > OST_MAX_PRECREATE)
362 if (val > osp->opd_pre_max_create_count)
365 for (i = 1; (i << 1) <= val; i <<= 1)
367 osp->opd_pre_create_count = i;
371 LUSTRE_RW_ATTR(create_count);
374 * Show maximum number of objects to precreate
376 * \param[in] m seq_file handle
377 * \param[in] data unused for single entry
378 * \retval 0 on success
379 * \retval negative number on error
381 static ssize_t max_create_count_show(struct kobject *kobj,
382 struct attribute *attr,
385 struct dt_device *dt = container_of(kobj, struct dt_device,
387 struct osp_device *osp = dt2osp_dev(dt);
392 return sprintf(buf, "%d\n", osp->opd_pre_max_create_count);
396 * Change maximum number of objects to precreate
398 * \param[in] file proc file
399 * \param[in] buffer string which represents maximum number
400 * \param[in] count \a buffer length
401 * \param[in] off unused for single entry
402 * \retval \a count on success
403 * \retval negative number on error
405 static ssize_t max_create_count_store(struct kobject *kobj,
406 struct attribute *attr,
407 const char *buffer, size_t count)
409 struct dt_device *dt = container_of(kobj, struct dt_device,
411 struct osp_device *osp = dt2osp_dev(dt);
418 rc = kstrtouint(buffer, 0, &val);
422 if (val && (val < OST_MIN_PRECREATE ||
423 val > OST_MAX_PRECREATE))
426 if (osp->opd_pre_create_count > val)
427 osp->opd_pre_create_count = val;
429 /* Can be 0 after setting max_create_count to 0 */
430 if (osp->opd_pre_create_count == 0 && val != 0)
431 osp->opd_pre_create_count = OST_MIN_PRECREATE;
433 osp->opd_pre_max_create_count = val;
437 LUSTRE_RW_ATTR(max_create_count);
440 * Show last id to assign in creation
442 * \param[in] m seq_file handle
443 * \param[in] data unused for single entry
444 * \retval 0 on success
445 * \retval negative number on error
447 static ssize_t prealloc_next_id_show(struct kobject *kobj,
448 struct attribute *attr,
451 struct dt_device *dt = container_of(kobj, struct dt_device,
453 struct osp_device *osp = dt2osp_dev(dt);
460 fid = &osp->opd_pre_used_fid;
461 if (fid_is_idif(fid)) {
462 id = fid_idif_id(fid_seq(fid), fid_oid(fid), fid_ver(fid));
465 id = unlikely(fid_oid(fid) == LUSTRE_DATA_SEQ_MAX_WIDTH) ?
466 1 : fid_oid(fid) + 1;
469 return sprintf(buf, "%llu\n", id);
471 LUSTRE_RO_ATTR(prealloc_next_id);
474 * Show last created id OST reported
476 * \param[in] m seq_file handle
477 * \param[in] data unused for single entry
478 * \retval 0 on success
479 * \retval negative number on error
482 static ssize_t prealloc_last_id_show(struct kobject *kobj,
483 struct attribute *attr,
486 struct dt_device *dt = container_of(kobj, struct dt_device,
488 struct osp_device *osp = dt2osp_dev(dt);
495 fid = &osp->opd_pre_last_created_fid;
496 id = fid_is_idif(fid) ?
497 fid_idif_id(fid_seq(fid), fid_oid(fid), fid_ver(fid)) :
500 return sprintf(buf, "%llu\n", id);
502 LUSTRE_RO_ATTR(prealloc_last_id);
505 * Show next FID sequence to precreate
507 * \param[in] m seq_file handle
508 * \param[in] data unused for single entry
509 * \retval 0 on success
510 * \retval negative number on error
512 static ssize_t prealloc_next_seq_show(struct kobject *kobj,
513 struct attribute *attr,
516 struct dt_device *dt = container_of(kobj, struct dt_device,
518 struct osp_device *osp = dt2osp_dev(dt);
524 fid = &osp->opd_pre_used_fid;
525 return sprintf(buf, "%#llx\n", fid_is_idif(fid) ?
526 fid_seq(fid) & (~0xffff) : fid_seq(fid));
528 LUSTRE_RO_ATTR(prealloc_next_seq);
531 * Show last created FID sequence OST reported
533 * \param[in] m seq_file handle
534 * \param[in] data unused for single entry
535 * \retval 0 on success
536 * \retval negative number on error
538 static ssize_t prealloc_last_seq_show(struct kobject *kobj,
539 struct attribute *attr,
542 struct dt_device *dt = container_of(kobj, struct dt_device,
544 struct osp_device *osp = dt2osp_dev(dt);
550 fid = &osp->opd_pre_last_created_fid;
551 return sprintf(buf, "%#llx\n", fid_is_idif(fid) ?
552 fid_seq(fid) & (~0xffff) : fid_seq(fid));
554 LUSTRE_RO_ATTR(prealloc_last_seq);
557 * Show the number of ids reserved by declare
559 * \param[in] m seq_file handle
560 * \param[in] data unused for single entry
561 * \retval 0 on success
562 * \retval negative number on error
564 static ssize_t prealloc_reserved_show(struct kobject *kobj,
565 struct attribute *attr,
568 struct dt_device *dt = container_of(kobj, struct dt_device,
570 struct osp_device *osp = dt2osp_dev(dt);
575 return sprintf(buf, "%llu\n", osp->opd_pre_reserved);
577 LUSTRE_RO_ATTR(prealloc_reserved);
580 * Show interval (in seconds) to update statfs data
582 * \param[in] m seq_file handle
583 * \param[in] data unused for single entry
584 * \retval 0 on success
585 * \retval negative number on error
587 static ssize_t maxage_show(struct kobject *kobj,
588 struct attribute *attr,
591 struct dt_device *dt = container_of(kobj, struct dt_device,
593 struct osp_device *osp = dt2osp_dev(dt);
595 return sprintf(buf, "%lld\n", osp->opd_statfs_maxage);
599 * Change interval to update statfs data
601 * \param[in] file proc file
602 * \param[in] buffer string which represents statfs interval (in seconds)
603 * \param[in] count \a buffer length
604 * \param[in] off unused for single entry
605 * \retval \a count on success
606 * \retval negative number on error
608 static ssize_t maxage_store(struct kobject *kobj, struct attribute *attr,
609 const char *buffer, size_t count)
611 struct dt_device *dt = container_of(kobj, struct dt_device,
613 struct osp_device *osp = dt2osp_dev(dt);
617 rc = kstrtouint(buffer, 0, &val);
624 osp->opd_statfs_maxage = val;
628 LUSTRE_RW_ATTR(maxage);
631 * Show current precreation status: output 0 means success, otherwise negative
634 * \param[in] m seq_file handle
635 * \param[in] data unused for single entry
636 * \retval 0 on success
637 * \retval negative number on error
639 static ssize_t prealloc_status_show(struct kobject *kobj,
640 struct attribute *attr,
643 struct dt_device *dt = container_of(kobj, struct dt_device,
645 struct osp_device *osp = dt2osp_dev(dt);
650 return sprintf(buf, "%d\n", osp->opd_pre_status);
652 LUSTRE_RO_ATTR(prealloc_status);
655 * Show the number of RPCs in processing (including uncommitted by OST) plus
656 * changes to sync, i.e. this is the total number of changes OST needs to apply
659 * This counter is used to determine if OST has space returned. A zero value
660 * indicates that OST storage space consumed by destroyed objects has been freed
661 * on disk, the associated llog records have been cleared, and no synchronous
662 * RPC are being processed.
664 * \param[in] m seq_file handle
665 * \param[in] data unused for single entry
666 * \retval 0 on success
667 * \retval negative number on error
669 static ssize_t destroys_in_flight_show(struct kobject *kobj,
670 struct attribute *attr,
673 struct dt_device *dt = container_of(kobj, struct dt_device,
675 struct osp_device *osp = dt2osp_dev(dt);
677 return sprintf(buf, "%u\n",
678 atomic_read(&osp->opd_sync_rpcs_in_progress) +
679 atomic_read(&osp->opd_sync_changes));
681 LUSTRE_RO_ATTR(destroys_in_flight);
684 * Show changes synced from previous mount
686 * \param[in] m seq_file handle
687 * \param[in] data unused for single entry
688 * \retval 0 on success
689 * \retval negative number on error
691 static ssize_t old_sync_processed_show(struct kobject *kobj,
692 struct attribute *attr,
695 struct dt_device *dt = container_of(kobj, struct dt_device,
697 struct osp_device *osp = dt2osp_dev(dt);
699 return sprintf(buf, "%d\n", osp->opd_sync_prev_done);
701 LUSTRE_RO_ATTR(old_sync_processed);
704 * Show maximum number of RPCs in flight
706 * \param[in] m seq_file handle
707 * \param[in] data unused for single entry
708 * \retval 0 on success
709 * \retval negative number on error
711 static ssize_t lfsck_max_rpcs_in_flight_show(struct kobject *kobj,
712 struct attribute *attr,
715 struct dt_device *dt = container_of(kobj, struct dt_device,
717 struct lu_device *lu = dt2lu_dev(dt);
718 struct obd_device *obd = lu->ld_obd;
721 max = obd_get_max_rpcs_in_flight(&obd->u.cli);
722 return sprintf(buf, "%u\n", max);
726 * Change maximum number of RPCs in flight
728 * \param[in] file proc file
729 * \param[in] buffer string which represents maximum number of RPCs in flight
730 * \param[in] count \a buffer length
731 * \param[in] off unused for single entry
732 * \retval \a count on success
733 * \retval negative number on error
735 static ssize_t lfsck_max_rpcs_in_flight_store(struct kobject *kobj,
736 struct attribute *attr,
740 struct dt_device *dt = container_of(kobj, struct dt_device,
742 struct lu_device *lu = dt2lu_dev(dt);
743 struct obd_device *obd = lu->ld_obd;
747 rc = kstrtouint(buffer, 0, &val);
751 rc = obd_set_max_rpcs_in_flight(&obd->u.cli, val);
752 return rc ? rc : count;
754 LUSTRE_RW_ATTR(lfsck_max_rpcs_in_flight);
756 ssize_t ping_show(struct kobject *kobj, struct attribute *attr,
759 struct dt_device *dt = container_of(kobj, struct dt_device,
761 struct lu_device *lu = dt2lu_dev(dt);
762 struct obd_device *obd = lu->ld_obd;
765 rc = ptlrpc_obd_ping(obd);
769 LUSTRE_RO_ATTR(ping);
771 ssize_t osp_conn_uuid_show(struct kobject *kobj, struct attribute *attr,
774 struct dt_device *dt = container_of(kobj, struct dt_device,
776 struct lu_device *lu = dt2lu_dev(dt);
777 struct obd_device *obd = lu->ld_obd;
778 struct obd_import *imp;
779 struct ptlrpc_connection *conn;
782 with_imp_locked(obd, imp, count) {
783 conn = imp->imp_connection;
785 count = sprintf(buf, "%s\n", conn->c_remote_uuid.uuid);
787 count = sprintf(buf, "%s\n", "<none>");
793 LUSTRE_ATTR(ost_conn_uuid, 0444, osp_conn_uuid_show, NULL);
794 LUSTRE_ATTR(mdt_conn_uuid, 0444, osp_conn_uuid_show, NULL);
796 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, connect_flags);
797 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, server_uuid);
798 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, timeouts);
800 LDEBUGFS_SEQ_FOPS_RW_TYPE(osp, import);
801 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, state);
804 * Show high watermark (in megabytes). If available free space at OST is grater
805 * than high watermark and object allocation for OST is disabled, enable it.
807 * \param[in] m seq_file handle
808 * \param[in] data unused for single entry
809 * \retval 0 on success
810 * \retval negative number on error
812 static int osp_reserved_mb_high_seq_show(struct seq_file *m, void *data)
814 struct obd_device *dev = m->private;
815 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
820 seq_printf(m, "%u\n", osp->opd_reserved_mb_high);
825 * Change high watermark
827 * \param[in] file proc file
828 * \param[in] buffer string which represents new value (in megabytes)
829 * \param[in] count \a buffer length
830 * \param[in] off unused for single entry
831 * \retval \a count on success
832 * \retval negative number on error
835 osp_reserved_mb_high_seq_write(struct file *file, const char __user *buffer,
836 size_t count, loff_t *off)
838 struct seq_file *m = file->private_data;
839 struct obd_device *dev = m->private;
840 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
841 char kernbuf[22] = "";
845 if (osp == NULL || osp->opd_pre == NULL)
848 if (count >= sizeof(kernbuf))
851 if (copy_from_user(kernbuf, buffer, count))
855 rc = sysfs_memparse(kernbuf, count, &val, "MiB");
862 spin_lock(&osp->opd_pre_lock);
863 osp->opd_reserved_mb_high = val;
864 if (val <= osp->opd_reserved_mb_low)
865 osp->opd_reserved_mb_low = val - 1;
866 spin_unlock(&osp->opd_pre_lock);
870 LDEBUGFS_SEQ_FOPS(osp_reserved_mb_high);
873 * Show low watermark (in megabytes). If available free space at OST is less
874 * than low watermark, object allocation for OST is disabled.
876 * \param[in] m seq_file handle
877 * \param[in] data unused for single entry
878 * \retval 0 on success
879 * \retval negative number on error
881 static int osp_reserved_mb_low_seq_show(struct seq_file *m, void *data)
883 struct obd_device *dev = m->private;
884 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
889 seq_printf(m, "%u\n", osp->opd_reserved_mb_low);
894 * Change low watermark
896 * \param[in] file proc file
897 * \param[in] buffer string which represents new value (in megabytes)
898 * \param[in] count \a buffer length
899 * \param[in] off unused for single entry
900 * \retval \a count on success
901 * \retval negative number on error
904 osp_reserved_mb_low_seq_write(struct file *file, const char __user *buffer,
905 size_t count, loff_t *off)
907 struct seq_file *m = file->private_data;
908 struct obd_device *dev = m->private;
909 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
910 char kernbuf[22] = "";
914 if (osp == NULL || osp->opd_pre == NULL)
917 if (count >= sizeof(kernbuf))
920 if (copy_from_user(kernbuf, buffer, count))
924 rc = sysfs_memparse(kernbuf, count, &val, "MiB");
929 spin_lock(&osp->opd_pre_lock);
930 osp->opd_reserved_mb_low = val;
931 if (val >= osp->opd_reserved_mb_high)
932 osp->opd_reserved_mb_high = val + 1;
933 spin_unlock(&osp->opd_pre_lock);
937 LDEBUGFS_SEQ_FOPS(osp_reserved_mb_low);
939 static ssize_t force_sync_store(struct kobject *kobj, struct attribute *attr,
940 const char *buffer, size_t count)
942 struct dt_device *dt = container_of(kobj, struct dt_device,
947 rc = lu_env_init(&env, LCT_LOCAL);
951 rc = dt_sync(&env, dt);
954 return rc == 0 ? count : rc;
956 LUSTRE_WO_ATTR(force_sync);
958 static struct ldebugfs_vars ldebugfs_osp_obd_vars[] = {
959 { .name = "connect_flags",
960 .fops = &osp_connect_flags_fops },
961 { .name = "ost_server_uuid",
962 .fops = &osp_server_uuid_fops },
963 { .name = "timeouts",
964 .fops = &osp_timeouts_fops },
966 .fops = &osp_import_fops },
968 .fops = &osp_state_fops },
969 { .name = "reserved_mb_high",
970 .fops = &osp_reserved_mb_high_fops },
971 { .name = "reserved_mb_low",
972 .fops = &osp_reserved_mb_low_fops },
976 static struct ldebugfs_vars ldebugfs_osp_md_vars[] = {
977 { .name = "connect_flags",
978 .fops = &osp_connect_flags_fops },
979 { .name = "mdt_server_uuid",
980 .fops = &osp_server_uuid_fops },
981 { .name = "timeouts",
982 .fops = &osp_timeouts_fops },
984 .fops = &osp_import_fops },
986 .fops = &osp_state_fops },
990 static struct attribute *osp_obd_attrs[] = {
991 /* First two for compatiability reasons */
992 &lustre_attr_lfsck_max_rpcs_in_flight.attr,
993 &lustre_attr_destroys_in_flight.attr,
994 &lustre_attr_active.attr,
995 &lustre_attr_max_rpcs_in_flight.attr,
996 &lustre_attr_max_rpcs_in_progress.attr,
997 &lustre_attr_maxage.attr,
998 &lustre_attr_ost_conn_uuid.attr,
999 &lustre_attr_ping.attr,
1000 &lustre_attr_prealloc_status.attr,
1001 &lustre_attr_prealloc_next_id.attr,
1002 &lustre_attr_prealloc_last_id.attr,
1003 &lustre_attr_prealloc_next_seq.attr,
1004 &lustre_attr_prealloc_last_seq.attr,
1005 &lustre_attr_prealloc_reserved.attr,
1006 &lustre_attr_sync_in_flight.attr,
1007 &lustre_attr_sync_in_progress.attr,
1008 &lustre_attr_sync_changes.attr,
1009 &lustre_attr_force_sync.attr,
1010 &lustre_attr_old_sync_processed.attr,
1011 &lustre_attr_create_count.attr,
1012 &lustre_attr_max_create_count.attr,
1016 static struct attribute *osp_md_attrs[] = {
1017 /* First two for compatiability reasons */
1018 &lustre_attr_lfsck_max_rpcs_in_flight.attr,
1019 &lustre_attr_destroys_in_flight.attr,
1020 &lustre_attr_active.attr,
1021 &lustre_attr_max_rpcs_in_flight.attr,
1022 &lustre_attr_max_rpcs_in_progress.attr,
1023 &lustre_attr_maxage.attr,
1024 &lustre_attr_mdt_conn_uuid.attr,
1025 &lustre_attr_ping.attr,
1026 &lustre_attr_prealloc_status.attr,
1030 void osp_tunables_fini(struct osp_device *osp)
1032 struct obd_device *obd = osp->opd_obd;
1033 struct kobject *osc;
1035 osc = kset_find_obj(lustre_kset, "osc");
1037 sysfs_remove_link(osc, obd->obd_name);
1041 debugfs_remove_recursive(osp->opd_debugfs);
1042 osp->opd_debugfs = NULL;
1044 ptlrpc_lprocfs_unregister_obd(obd);
1046 debugfs_remove_recursive(obd->obd_debugfs_entry);
1047 obd->obd_debugfs_entry = NULL;
1049 dt_tunables_fini(&osp->opd_dt_dev);
1053 * Initialize OSP sysfs / debugfs
1055 * param[in] osp OSP device
1057 void osp_tunables_init(struct osp_device *osp)
1059 struct obd_device *obd = osp->opd_obd;
1060 struct kobject *osc;
1063 if (osp->opd_connect_mdt) {
1064 osp->opd_dt_dev.dd_ktype.default_attrs = osp_md_attrs;
1065 obd->obd_debugfs_vars = ldebugfs_osp_md_vars;
1067 osp->opd_dt_dev.dd_ktype.default_attrs = osp_obd_attrs;
1068 obd->obd_debugfs_vars = ldebugfs_osp_obd_vars;
1071 rc = dt_tunables_init(&osp->opd_dt_dev, obd->obd_type, obd->obd_name,
1074 CERROR("%s: failed to setup DT tunables: %d\n",
1079 /* Since we register the obd device with ptlrpc / sptlrpc we
1080 * have to register debugfs with obd_device
1082 obd->obd_debugfs_entry = debugfs_create_dir(
1083 obd->obd_name, obd->obd_type->typ_debugfs_entry);
1084 ldebugfs_add_vars(obd->obd_debugfs_entry, obd->obd_debugfs_vars, obd);
1086 sptlrpc_lprocfs_cliobd_attach(obd);
1087 ptlrpc_lprocfs_register_obd(obd);
1089 if (osp->opd_connect_mdt || !strstr(obd->obd_name, "osc"))
1092 /* If the real OSC is present which is the case for setups
1093 * with both server and clients on the same node then use
1094 * the OSC's proc root
1096 osc = kset_find_obj(lustre_kset, "osc");
1098 rc = sysfs_create_link(osc, &osp->opd_dt_dev.dd_kobj,
1103 osp->opd_debugfs = ldebugfs_add_symlink(obd->obd_name, "osc",
1104 "../osp/%s", obd->obd_name);
1105 if (!osp->opd_debugfs)
1106 CERROR("%s: failed to create OSC debugfs symlink\n",