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);
345 rc = kstrtouint(buffer, 0, &val);
349 /* The MDT ALWAYS needs to limit the precreate count to
350 * OST_MAX_PRECREATE, and the constant cannot be changed
351 * because it is a value shared between the OSP and OST
352 * that is the maximum possible number of objects that will
353 * ever be handled by MDT->OST recovery processing.
355 * The OSP enforces the pre_create_count to amaximum of
356 * one half of opd_pre_max_create_count.
358 * If the OST ever gets a request to delete more orphans,
359 * this implies that something has gone badly on the MDT
360 * and the OST will refuse to delete so much data from the
361 * filesystem as a safety measure.
363 if (val < OST_MIN_PRECREATE)
365 if (val > osp->opd_pre_max_create_count / 2)
366 val = osp->opd_pre_max_create_count / 2;
368 /* set to largest value <= 32, 64, 128 or a multiple of 256 */
370 osp->opd_pre_create_count = val & 0xffffff00;
372 osp->opd_pre_create_count = rounddown_pow_of_two(val);
376 LUSTRE_RW_ATTR(create_count);
379 * Show maximum number of objects to precreate
381 * \param[in] m seq_file handle
382 * \param[in] data unused for single entry
383 * \retval 0 on success
384 * \retval negative number on error
386 static ssize_t max_create_count_show(struct kobject *kobj,
387 struct attribute *attr,
390 struct dt_device *dt = container_of(kobj, struct dt_device,
392 struct osp_device *osp = dt2osp_dev(dt);
397 return sprintf(buf, "%d\n", osp->opd_pre_max_create_count);
401 * Change maximum number of objects to precreate
403 * \param[in] file proc file
404 * \param[in] buffer string which represents maximum number
405 * \param[in] count \a buffer length
406 * \param[in] off unused for single entry
407 * \retval \a count on success
408 * \retval negative number on error
410 static ssize_t max_create_count_store(struct kobject *kobj,
411 struct attribute *attr,
412 const char *buffer, size_t count)
414 struct dt_device *dt = container_of(kobj, struct dt_device,
416 struct osp_device *osp = dt2osp_dev(dt);
423 rc = kstrtouint(buffer, 0, &val);
427 if (val && (val < OST_MIN_PRECREATE ||
428 val > OST_MAX_PRECREATE))
431 if (osp->opd_pre_create_count > val)
432 osp->opd_pre_create_count = val;
434 /* Can be 0 after setting max_create_count to 0 */
435 if (osp->opd_pre_create_count == 0 && val != 0)
436 osp->opd_pre_create_count = OST_MIN_PRECREATE;
438 osp->opd_pre_max_create_count = val;
442 LUSTRE_RW_ATTR(max_create_count);
445 * Show last id to assign in creation
447 * \param[in] m seq_file handle
448 * \param[in] data unused for single entry
449 * \retval 0 on success
450 * \retval negative number on error
452 static ssize_t prealloc_next_id_show(struct kobject *kobj,
453 struct attribute *attr,
456 struct dt_device *dt = container_of(kobj, struct dt_device,
458 struct osp_device *osp = dt2osp_dev(dt);
465 fid = &osp->opd_pre_used_fid;
466 if (fid_is_idif(fid)) {
467 id = fid_idif_id(fid_seq(fid), fid_oid(fid), fid_ver(fid));
470 id = unlikely(fid_oid(fid) == LUSTRE_DATA_SEQ_MAX_WIDTH) ?
471 1 : fid_oid(fid) + 1;
474 return sprintf(buf, "%llu\n", id);
476 LUSTRE_RO_ATTR(prealloc_next_id);
479 * Show last created id OST reported
481 * \param[in] m seq_file handle
482 * \param[in] data unused for single entry
483 * \retval 0 on success
484 * \retval negative number on error
487 static ssize_t prealloc_last_id_show(struct kobject *kobj,
488 struct attribute *attr,
491 struct dt_device *dt = container_of(kobj, struct dt_device,
493 struct osp_device *osp = dt2osp_dev(dt);
500 fid = &osp->opd_pre_last_created_fid;
501 id = fid_is_idif(fid) ?
502 fid_idif_id(fid_seq(fid), fid_oid(fid), fid_ver(fid)) :
505 return sprintf(buf, "%llu\n", id);
507 LUSTRE_RO_ATTR(prealloc_last_id);
510 * Show next FID sequence to precreate
512 * \param[in] m seq_file handle
513 * \param[in] data unused for single entry
514 * \retval 0 on success
515 * \retval negative number on error
517 static ssize_t prealloc_next_seq_show(struct kobject *kobj,
518 struct attribute *attr,
521 struct dt_device *dt = container_of(kobj, struct dt_device,
523 struct osp_device *osp = dt2osp_dev(dt);
529 fid = &osp->opd_pre_used_fid;
530 return sprintf(buf, "%#llx\n", fid_is_idif(fid) ?
531 fid_seq(fid) & (~0xffff) : fid_seq(fid));
533 LUSTRE_RO_ATTR(prealloc_next_seq);
536 * Show last created FID sequence OST reported
538 * \param[in] m seq_file handle
539 * \param[in] data unused for single entry
540 * \retval 0 on success
541 * \retval negative number on error
543 static ssize_t prealloc_last_seq_show(struct kobject *kobj,
544 struct attribute *attr,
547 struct dt_device *dt = container_of(kobj, struct dt_device,
549 struct osp_device *osp = dt2osp_dev(dt);
555 fid = &osp->opd_pre_last_created_fid;
556 return sprintf(buf, "%#llx\n", fid_is_idif(fid) ?
557 fid_seq(fid) & (~0xffff) : fid_seq(fid));
559 LUSTRE_RO_ATTR(prealloc_last_seq);
562 * Show the number of ids reserved by declare
564 * \param[in] m seq_file handle
565 * \param[in] data unused for single entry
566 * \retval 0 on success
567 * \retval negative number on error
569 static ssize_t prealloc_reserved_show(struct kobject *kobj,
570 struct attribute *attr,
573 struct dt_device *dt = container_of(kobj, struct dt_device,
575 struct osp_device *osp = dt2osp_dev(dt);
580 return sprintf(buf, "%llu\n", osp->opd_pre_reserved);
582 LUSTRE_RO_ATTR(prealloc_reserved);
585 * Show interval (in seconds) to update statfs data
587 * \param[in] m seq_file handle
588 * \param[in] data unused for single entry
589 * \retval 0 on success
590 * \retval negative number on error
592 static ssize_t maxage_show(struct kobject *kobj,
593 struct attribute *attr,
596 struct dt_device *dt = container_of(kobj, struct dt_device,
598 struct osp_device *osp = dt2osp_dev(dt);
600 return sprintf(buf, "%lld\n", osp->opd_statfs_maxage);
604 * Change interval to update statfs data
606 * \param[in] file proc file
607 * \param[in] buffer string which represents statfs interval (in seconds)
608 * \param[in] count \a buffer length
609 * \param[in] off unused for single entry
610 * \retval \a count on success
611 * \retval negative number on error
613 static ssize_t maxage_store(struct kobject *kobj, struct attribute *attr,
614 const char *buffer, size_t count)
616 struct dt_device *dt = container_of(kobj, struct dt_device,
618 struct osp_device *osp = dt2osp_dev(dt);
622 rc = kstrtouint(buffer, 0, &val);
629 osp->opd_statfs_maxage = val;
633 LUSTRE_RW_ATTR(maxage);
636 * Show current precreation status: output 0 means success, otherwise negative
639 * \param[in] m seq_file handle
640 * \param[in] data unused for single entry
641 * \retval 0 on success
642 * \retval negative number on error
644 static ssize_t prealloc_status_show(struct kobject *kobj,
645 struct attribute *attr,
648 struct dt_device *dt = container_of(kobj, struct dt_device,
650 struct osp_device *osp = dt2osp_dev(dt);
655 return sprintf(buf, "%d\n", osp->opd_pre_status);
657 LUSTRE_RO_ATTR(prealloc_status);
660 * Show the number of RPCs in processing (including uncommitted by OST) plus
661 * changes to sync, i.e. this is the total number of changes OST needs to apply
664 * This counter is used to determine if OST has space returned. A zero value
665 * indicates that OST storage space consumed by destroyed objects has been freed
666 * on disk, the associated llog records have been cleared, and no synchronous
667 * RPC are being processed.
669 * \param[in] m seq_file handle
670 * \param[in] data unused for single entry
671 * \retval 0 on success
672 * \retval negative number on error
674 static ssize_t destroys_in_flight_show(struct kobject *kobj,
675 struct attribute *attr,
678 struct dt_device *dt = container_of(kobj, struct dt_device,
680 struct osp_device *osp = dt2osp_dev(dt);
682 return sprintf(buf, "%u\n",
683 atomic_read(&osp->opd_sync_rpcs_in_progress) +
684 atomic_read(&osp->opd_sync_changes));
686 LUSTRE_RO_ATTR(destroys_in_flight);
689 * Show changes synced from previous mount
691 * \param[in] m seq_file handle
692 * \param[in] data unused for single entry
693 * \retval 0 on success
694 * \retval negative number on error
696 static ssize_t old_sync_processed_show(struct kobject *kobj,
697 struct attribute *attr,
700 struct dt_device *dt = container_of(kobj, struct dt_device,
702 struct osp_device *osp = dt2osp_dev(dt);
704 return sprintf(buf, "%d\n", osp->opd_sync_prev_done);
706 LUSTRE_RO_ATTR(old_sync_processed);
709 * Show maximum number of RPCs in flight
711 * \param[in] m seq_file handle
712 * \param[in] data unused for single entry
713 * \retval 0 on success
714 * \retval negative number on error
716 static ssize_t lfsck_max_rpcs_in_flight_show(struct kobject *kobj,
717 struct attribute *attr,
720 struct dt_device *dt = container_of(kobj, struct dt_device,
722 struct lu_device *lu = dt2lu_dev(dt);
723 struct obd_device *obd = lu->ld_obd;
726 max = obd_get_max_rpcs_in_flight(&obd->u.cli);
727 return sprintf(buf, "%u\n", max);
731 * Change maximum number of RPCs in flight
733 * \param[in] file proc file
734 * \param[in] buffer string which represents maximum number of RPCs in flight
735 * \param[in] count \a buffer length
736 * \param[in] off unused for single entry
737 * \retval \a count on success
738 * \retval negative number on error
740 static ssize_t lfsck_max_rpcs_in_flight_store(struct kobject *kobj,
741 struct attribute *attr,
745 struct dt_device *dt = container_of(kobj, struct dt_device,
747 struct lu_device *lu = dt2lu_dev(dt);
748 struct obd_device *obd = lu->ld_obd;
752 rc = kstrtouint(buffer, 0, &val);
756 rc = obd_set_max_rpcs_in_flight(&obd->u.cli, val);
757 return rc ? rc : count;
759 LUSTRE_RW_ATTR(lfsck_max_rpcs_in_flight);
761 ssize_t ping_show(struct kobject *kobj, struct attribute *attr,
764 struct dt_device *dt = container_of(kobj, struct dt_device,
766 struct lu_device *lu = dt2lu_dev(dt);
767 struct obd_device *obd = lu->ld_obd;
770 rc = ptlrpc_obd_ping(obd);
774 LUSTRE_RO_ATTR(ping);
776 ssize_t osp_conn_uuid_show(struct kobject *kobj, struct attribute *attr,
779 struct dt_device *dt = container_of(kobj, struct dt_device,
781 struct lu_device *lu = dt2lu_dev(dt);
782 struct obd_device *obd = lu->ld_obd;
783 struct obd_import *imp;
784 struct ptlrpc_connection *conn;
787 with_imp_locked(obd, imp, count) {
788 conn = imp->imp_connection;
790 count = sprintf(buf, "%s\n", conn->c_remote_uuid.uuid);
792 count = sprintf(buf, "%s\n", "<none>");
798 LUSTRE_ATTR(ost_conn_uuid, 0444, osp_conn_uuid_show, NULL);
799 LUSTRE_ATTR(mdt_conn_uuid, 0444, osp_conn_uuid_show, NULL);
801 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, connect_flags);
802 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, server_uuid);
803 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, timeouts);
805 LDEBUGFS_SEQ_FOPS_RW_TYPE(osp, import);
806 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, state);
809 * Show high watermark (in megabytes). If available free space at OST is grater
810 * than high watermark and object allocation for OST is disabled, enable it.
812 * \param[in] m seq_file handle
813 * \param[in] data unused for single entry
814 * \retval 0 on success
815 * \retval negative number on error
817 static int osp_reserved_mb_high_seq_show(struct seq_file *m, void *data)
819 struct obd_device *dev = m->private;
820 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
825 seq_printf(m, "%u\n", osp->opd_reserved_mb_high);
830 * Change high watermark
832 * \param[in] file proc file
833 * \param[in] buffer string which represents new value (in megabytes)
834 * \param[in] count \a buffer length
835 * \param[in] off unused for single entry
836 * \retval \a count on success
837 * \retval negative number on error
840 osp_reserved_mb_high_seq_write(struct file *file, const char __user *buffer,
841 size_t count, loff_t *off)
843 struct seq_file *m = file->private_data;
844 struct obd_device *dev = m->private;
845 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
846 char kernbuf[22] = "";
850 if (osp == NULL || osp->opd_pre == NULL)
853 if (count >= sizeof(kernbuf))
856 if (copy_from_user(kernbuf, buffer, count))
860 rc = sysfs_memparse(kernbuf, count, &val, "MiB");
867 spin_lock(&osp->opd_pre_lock);
868 osp->opd_reserved_mb_high = val;
869 if (val <= osp->opd_reserved_mb_low)
870 osp->opd_reserved_mb_low = val - 1;
871 spin_unlock(&osp->opd_pre_lock);
875 LDEBUGFS_SEQ_FOPS(osp_reserved_mb_high);
878 * Show low watermark (in megabytes). If available free space at OST is less
879 * than low watermark, object allocation for OST is disabled.
881 * \param[in] m seq_file handle
882 * \param[in] data unused for single entry
883 * \retval 0 on success
884 * \retval negative number on error
886 static int osp_reserved_mb_low_seq_show(struct seq_file *m, void *data)
888 struct obd_device *dev = m->private;
889 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
894 seq_printf(m, "%u\n", osp->opd_reserved_mb_low);
899 * Change low watermark
901 * \param[in] file proc file
902 * \param[in] buffer string which represents new value (in megabytes)
903 * \param[in] count \a buffer length
904 * \param[in] off unused for single entry
905 * \retval \a count on success
906 * \retval negative number on error
909 osp_reserved_mb_low_seq_write(struct file *file, const char __user *buffer,
910 size_t count, loff_t *off)
912 struct seq_file *m = file->private_data;
913 struct obd_device *dev = m->private;
914 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
915 char kernbuf[22] = "";
919 if (osp == NULL || osp->opd_pre == NULL)
922 if (count >= sizeof(kernbuf))
925 if (copy_from_user(kernbuf, buffer, count))
929 rc = sysfs_memparse(kernbuf, count, &val, "MiB");
934 spin_lock(&osp->opd_pre_lock);
935 osp->opd_reserved_mb_low = val;
936 if (val >= osp->opd_reserved_mb_high)
937 osp->opd_reserved_mb_high = val + 1;
938 spin_unlock(&osp->opd_pre_lock);
942 LDEBUGFS_SEQ_FOPS(osp_reserved_mb_low);
944 static ssize_t force_sync_store(struct kobject *kobj, struct attribute *attr,
945 const char *buffer, size_t count)
947 struct dt_device *dt = container_of(kobj, struct dt_device,
952 rc = lu_env_init(&env, LCT_LOCAL);
956 rc = dt_sync(&env, dt);
959 return rc == 0 ? count : rc;
961 LUSTRE_WO_ATTR(force_sync);
963 static struct ldebugfs_vars ldebugfs_osp_obd_vars[] = {
964 { .name = "connect_flags",
965 .fops = &osp_connect_flags_fops },
966 { .name = "ost_server_uuid",
967 .fops = &osp_server_uuid_fops },
968 { .name = "timeouts",
969 .fops = &osp_timeouts_fops },
971 .fops = &osp_import_fops },
973 .fops = &osp_state_fops },
974 { .name = "reserved_mb_high",
975 .fops = &osp_reserved_mb_high_fops },
976 { .name = "reserved_mb_low",
977 .fops = &osp_reserved_mb_low_fops },
981 static struct ldebugfs_vars ldebugfs_osp_md_vars[] = {
982 { .name = "connect_flags",
983 .fops = &osp_connect_flags_fops },
984 { .name = "mdt_server_uuid",
985 .fops = &osp_server_uuid_fops },
986 { .name = "timeouts",
987 .fops = &osp_timeouts_fops },
989 .fops = &osp_import_fops },
991 .fops = &osp_state_fops },
995 static struct attribute *osp_obd_attrs[] = {
996 /* First two for compatiability reasons */
997 &lustre_attr_lfsck_max_rpcs_in_flight.attr,
998 &lustre_attr_destroys_in_flight.attr,
999 &lustre_attr_active.attr,
1000 &lustre_attr_max_rpcs_in_flight.attr,
1001 &lustre_attr_max_rpcs_in_progress.attr,
1002 &lustre_attr_maxage.attr,
1003 &lustre_attr_ost_conn_uuid.attr,
1004 &lustre_attr_ping.attr,
1005 &lustre_attr_prealloc_status.attr,
1006 &lustre_attr_prealloc_next_id.attr,
1007 &lustre_attr_prealloc_last_id.attr,
1008 &lustre_attr_prealloc_next_seq.attr,
1009 &lustre_attr_prealloc_last_seq.attr,
1010 &lustre_attr_prealloc_reserved.attr,
1011 &lustre_attr_sync_in_flight.attr,
1012 &lustre_attr_sync_in_progress.attr,
1013 &lustre_attr_sync_changes.attr,
1014 &lustre_attr_force_sync.attr,
1015 &lustre_attr_old_sync_processed.attr,
1016 &lustre_attr_create_count.attr,
1017 &lustre_attr_max_create_count.attr,
1021 static struct attribute *osp_md_attrs[] = {
1022 /* First two for compatiability reasons */
1023 &lustre_attr_lfsck_max_rpcs_in_flight.attr,
1024 &lustre_attr_destroys_in_flight.attr,
1025 &lustre_attr_active.attr,
1026 &lustre_attr_max_rpcs_in_flight.attr,
1027 &lustre_attr_max_rpcs_in_progress.attr,
1028 &lustre_attr_maxage.attr,
1029 &lustre_attr_mdt_conn_uuid.attr,
1030 &lustre_attr_ping.attr,
1031 &lustre_attr_prealloc_status.attr,
1035 void osp_tunables_fini(struct osp_device *osp)
1037 struct obd_device *obd = osp->opd_obd;
1038 struct kobject *osc;
1040 osc = kset_find_obj(lustre_kset, "osc");
1042 sysfs_remove_link(osc, obd->obd_name);
1046 debugfs_remove_recursive(osp->opd_debugfs);
1047 osp->opd_debugfs = NULL;
1049 ptlrpc_lprocfs_unregister_obd(obd);
1051 debugfs_remove_recursive(obd->obd_debugfs_entry);
1052 obd->obd_debugfs_entry = NULL;
1054 dt_tunables_fini(&osp->opd_dt_dev);
1058 * Initialize OSP sysfs / debugfs
1060 * param[in] osp OSP device
1062 void osp_tunables_init(struct osp_device *osp)
1064 struct obd_device *obd = osp->opd_obd;
1065 struct kobject *osc;
1068 if (osp->opd_connect_mdt) {
1069 osp->opd_dt_dev.dd_ktype.default_attrs = osp_md_attrs;
1070 obd->obd_debugfs_vars = ldebugfs_osp_md_vars;
1072 osp->opd_dt_dev.dd_ktype.default_attrs = osp_obd_attrs;
1073 obd->obd_debugfs_vars = ldebugfs_osp_obd_vars;
1076 rc = dt_tunables_init(&osp->opd_dt_dev, obd->obd_type, obd->obd_name,
1079 CERROR("%s: failed to setup DT tunables: %d\n",
1084 /* Since we register the obd device with ptlrpc / sptlrpc we
1085 * have to register debugfs with obd_device
1087 obd->obd_debugfs_entry = debugfs_create_dir(
1088 obd->obd_name, obd->obd_type->typ_debugfs_entry);
1089 ldebugfs_add_vars(obd->obd_debugfs_entry, obd->obd_debugfs_vars, obd);
1091 sptlrpc_lprocfs_cliobd_attach(obd);
1092 ptlrpc_lprocfs_register_obd(obd);
1094 if (osp->opd_connect_mdt || !strstr(obd->obd_name, "osc"))
1097 /* If the real OSC is present which is the case for setups
1098 * with both server and clients on the same node then use
1099 * the OSC's proc root
1101 osc = kset_find_obj(lustre_kset, "osc");
1103 rc = sysfs_create_link(osc, &osp->opd_dt_dev.dd_kobj,
1108 osp->opd_debugfs = ldebugfs_add_symlink(obd->obd_name, "osc",
1109 "../osp/%s", obd->obd_name);
1110 if (!osp->opd_debugfs)
1111 CERROR("%s: failed to create OSC debugfs symlink\n",