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 ssize_t osp_conn_uuid_show(struct kobject *kobj, struct attribute *attr,
769 struct dt_device *dt = container_of(kobj, struct dt_device,
771 struct lu_device *lu = dt2lu_dev(dt);
772 struct obd_device *obd = lu->ld_obd;
773 struct ptlrpc_connection *conn;
776 LPROCFS_CLIMP_CHECK(obd);
777 conn = obd->u.cli.cl_import->imp_connection;
778 if (conn && obd->u.cli.cl_import)
779 count = sprintf(buf, "%s\n", conn->c_remote_uuid.uuid);
781 count = sprintf(buf, "%s\n", "<none>");
783 LPROCFS_CLIMP_EXIT(obd);
787 LUSTRE_ATTR(ost_conn_uuid, 0444, osp_conn_uuid_show, NULL);
788 LUSTRE_ATTR(mdt_conn_uuid, 0444, osp_conn_uuid_show, NULL);
790 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, connect_flags);
791 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, server_uuid);
792 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, timeouts);
794 LPROC_SEQ_FOPS_RW_TYPE(osp, import);
795 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, state);
798 * Show high watermark (in megabytes). If available free space at OST is grater
799 * than high watermark and object allocation for OST is disabled, enable it.
801 * \param[in] m seq_file handle
802 * \param[in] data unused for single entry
803 * \retval 0 on success
804 * \retval negative number on error
806 static int osp_reserved_mb_high_seq_show(struct seq_file *m, void *data)
808 struct obd_device *dev = m->private;
809 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
814 seq_printf(m, "%u\n", osp->opd_reserved_mb_high);
819 * Change high watermark
821 * \param[in] file proc file
822 * \param[in] buffer string which represents new value (in megabytes)
823 * \param[in] count \a buffer length
824 * \param[in] off unused for single entry
825 * \retval \a count on success
826 * \retval negative number on error
829 osp_reserved_mb_high_seq_write(struct file *file, const char __user *buffer,
830 size_t count, loff_t *off)
832 struct seq_file *m = file->private_data;
833 struct obd_device *dev = m->private;
834 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
841 rc = lprocfs_str_with_units_to_s64(buffer, count, &val, 'M');
848 spin_lock(&osp->opd_pre_lock);
849 osp->opd_reserved_mb_high = val;
850 if (val <= osp->opd_reserved_mb_low)
851 osp->opd_reserved_mb_low = val - 1;
852 spin_unlock(&osp->opd_pre_lock);
856 LDEBUGFS_SEQ_FOPS(osp_reserved_mb_high);
859 * Show low watermark (in megabytes). If available free space at OST is less
860 * than low watermark, object allocation for OST is disabled.
862 * \param[in] m seq_file handle
863 * \param[in] data unused for single entry
864 * \retval 0 on success
865 * \retval negative number on error
867 static int osp_reserved_mb_low_seq_show(struct seq_file *m, void *data)
869 struct obd_device *dev = m->private;
870 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
875 seq_printf(m, "%u\n", osp->opd_reserved_mb_low);
880 * Change low watermark
882 * \param[in] file proc file
883 * \param[in] buffer string which represents new value (in megabytes)
884 * \param[in] count \a buffer length
885 * \param[in] off unused for single entry
886 * \retval \a count on success
887 * \retval negative number on error
890 osp_reserved_mb_low_seq_write(struct file *file, const char __user *buffer,
891 size_t count, loff_t *off)
893 struct seq_file *m = file->private_data;
894 struct obd_device *dev = m->private;
895 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
902 rc = lprocfs_str_with_units_to_s64(buffer, count, &val, 'M');
907 spin_lock(&osp->opd_pre_lock);
908 osp->opd_reserved_mb_low = val;
909 if (val >= osp->opd_reserved_mb_high)
910 osp->opd_reserved_mb_high = val + 1;
911 spin_unlock(&osp->opd_pre_lock);
915 LDEBUGFS_SEQ_FOPS(osp_reserved_mb_low);
917 static ssize_t force_sync_store(struct kobject *kobj, struct attribute *attr,
918 const char *buffer, size_t count)
920 struct dt_device *dt = container_of(kobj, struct dt_device,
925 rc = lu_env_init(&env, LCT_LOCAL);
929 rc = dt_sync(&env, dt);
932 return rc == 0 ? count : rc;
934 LUSTRE_WO_ATTR(force_sync);
936 static struct lprocfs_vars lprocfs_osp_obd_vars[] = {
937 { .name = "connect_flags",
938 .fops = &osp_connect_flags_fops },
939 { .name = "ost_server_uuid",
940 .fops = &osp_server_uuid_fops },
941 { .name = "timeouts",
942 .fops = &osp_timeouts_fops },
944 .fops = &osp_import_fops },
946 .fops = &osp_state_fops },
947 { .name = "reserved_mb_high",
948 .fops = &osp_reserved_mb_high_fops },
949 { .name = "reserved_mb_low",
950 .fops = &osp_reserved_mb_low_fops },
954 static struct lprocfs_vars lprocfs_osp_md_vars[] = {
955 { .name = "connect_flags",
956 .fops = &osp_connect_flags_fops },
957 { .name = "mdt_server_uuid",
958 .fops = &osp_server_uuid_fops },
959 { .name = "timeouts",
960 .fops = &osp_timeouts_fops },
962 .fops = &osp_import_fops },
964 .fops = &osp_state_fops },
968 static struct attribute *osp_obd_attrs[] = {
969 /* First two for compatiability reasons */
970 &lustre_attr_lfsck_max_rpcs_in_flight.attr,
971 &lustre_attr_destroys_in_flight.attr,
972 &lustre_attr_active.attr,
973 &lustre_attr_max_rpcs_in_flight.attr,
974 &lustre_attr_max_rpcs_in_progress.attr,
975 &lustre_attr_maxage.attr,
976 &lustre_attr_ost_conn_uuid.attr,
977 &lustre_attr_ping.attr,
978 &lustre_attr_prealloc_status.attr,
979 &lustre_attr_prealloc_next_id.attr,
980 &lustre_attr_prealloc_last_id.attr,
981 &lustre_attr_prealloc_next_seq.attr,
982 &lustre_attr_prealloc_last_seq.attr,
983 &lustre_attr_prealloc_reserved.attr,
984 &lustre_attr_sync_in_flight.attr,
985 &lustre_attr_sync_in_progress.attr,
986 &lustre_attr_sync_changes.attr,
987 &lustre_attr_force_sync.attr,
988 &lustre_attr_old_sync_processed.attr,
989 &lustre_attr_create_count.attr,
990 &lustre_attr_max_create_count.attr,
994 static struct attribute *osp_md_attrs[] = {
995 /* First two for compatiability reasons */
996 &lustre_attr_lfsck_max_rpcs_in_flight.attr,
997 &lustre_attr_destroys_in_flight.attr,
998 &lustre_attr_active.attr,
999 &lustre_attr_max_rpcs_in_flight.attr,
1000 &lustre_attr_max_rpcs_in_progress.attr,
1001 &lustre_attr_maxage.attr,
1002 &lustre_attr_mdt_conn_uuid.attr,
1003 &lustre_attr_ping.attr,
1004 &lustre_attr_prealloc_status.attr,
1008 void osp_tunables_fini(struct osp_device *osp)
1010 struct obd_device *obd = osp->opd_obd;
1011 struct kobject *osc;
1013 osc = kset_find_obj(lustre_kset, "osc");
1015 sysfs_remove_link(osc, obd->obd_name);
1019 if (!IS_ERR_OR_NULL(osp->opd_debugfs))
1020 ldebugfs_remove(&osp->opd_debugfs);
1022 ptlrpc_lprocfs_unregister_obd(obd);
1024 if (!IS_ERR_OR_NULL(obd->obd_debugfs_entry))
1025 ldebugfs_remove(&obd->obd_debugfs_entry);
1027 dt_tunables_fini(&osp->opd_dt_dev);
1031 * Initialize OSP sysfs / debugfs
1033 * param[in] osp OSP device
1035 void osp_tunables_init(struct osp_device *osp)
1037 struct obd_device *obd = osp->opd_obd;
1038 struct kobject *osc;
1041 if (osp->opd_connect_mdt) {
1042 osp->opd_dt_dev.dd_ktype.default_attrs = osp_md_attrs;
1043 obd->obd_vars = lprocfs_osp_md_vars;
1045 osp->opd_dt_dev.dd_ktype.default_attrs = osp_obd_attrs;
1046 obd->obd_vars = lprocfs_osp_obd_vars;
1049 rc = dt_tunables_init(&osp->opd_dt_dev, obd->obd_type, obd->obd_name,
1052 CERROR("%s: failed to setup DT tunables: %d\n",
1057 /* Since we register the obd device with ptlrpc / sptlrpc we
1058 * have to register debugfs with obd_device
1060 obd->obd_debugfs_entry = ldebugfs_register(obd->obd_name,
1061 obd->obd_type->typ_debugfs_entry,
1062 obd->obd_vars, obd);
1063 if (IS_ERR_OR_NULL(obd->obd_debugfs_entry)) {
1064 rc = obd->obd_debugfs_entry ? PTR_ERR(obd->obd_debugfs_entry)
1066 CERROR("%s: error %d setting up debugfs\n",
1068 obd->obd_debugfs_entry = NULL;
1069 dt_tunables_fini(&osp->opd_dt_dev);
1073 sptlrpc_lprocfs_cliobd_attach(obd);
1074 ptlrpc_lprocfs_register_obd(obd);
1076 if (osp->opd_connect_mdt || !strstr(obd->obd_name, "osc"))
1079 /* If the real OSC is present which is the case for setups
1080 * with both server and clients on the same node then use
1081 * the OSC's proc root
1083 osc = kset_find_obj(lustre_kset, "osc");
1085 rc = sysfs_create_link(osc, &osp->opd_dt_dev.dd_kobj,
1090 osp->opd_debugfs = ldebugfs_add_symlink(obd->obd_name, "osc",
1091 "../osp/%s", obd->obd_name);
1092 if (!osp->opd_debugfs)
1093 CERROR("%s: failed to create OSC debugfs symlink\n",