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;
58 struct obd_import *imp;
61 with_imp_locked(obd, imp, rc)
62 rc = sprintf(buf, "%d\n", !imp->imp_deactive);
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;
83 struct obd_import *imp, *imp0;
87 rc = kstrtobool(buffer, &val);
91 with_imp_locked(obd, imp0, rc)
92 imp = class_import_get(imp0);
96 if (imp->imp_deactive == val)
97 rc = ptlrpc_set_import_active(imp, val);
99 CDEBUG(D_CONFIG, "activate %u: ignoring repeat request\n",
102 class_import_put(imp);
106 LUSTRE_RW_ATTR(active);
109 * Show number of RPCs in flight
111 * \param[in] m seq_file handle
112 * \param[in] data unused for single entry
113 * \retval 0 on success
114 * \retval negative number on error
116 static ssize_t sync_in_flight_show(struct kobject *kobj,
117 struct attribute *attr,
120 struct dt_device *dt = container_of(kobj, struct dt_device,
122 struct osp_device *osp = dt2osp_dev(dt);
124 return sprintf(buf, "%u\n", atomic_read(&osp->opd_sync_rpcs_in_flight));
126 LUSTRE_RO_ATTR(sync_in_flight);
129 * Show number of RPCs in processing (including uncommitted by OST)
131 * \param[in] m seq_file handle
132 * \param[in] data unused for single entry
133 * \retval 0 on success
134 * \retval negative number on error
136 static ssize_t sync_in_progress_show(struct kobject *kobj,
137 struct attribute *attr,
140 struct dt_device *dt = container_of(kobj, struct dt_device,
142 struct osp_device *osp = dt2osp_dev(dt);
144 return sprintf(buf, "%u\n", atomic_read(&osp->opd_sync_rpcs_in_progress));
146 LUSTRE_RO_ATTR(sync_in_progress);
149 * Show number of changes to sync
151 * \param[in] m seq_file handle
152 * \param[in] data unused for single entry
153 * \retval 0 on success
154 * \retval negative number on error
156 static ssize_t sync_changes_show(struct kobject *kobj,
157 struct attribute *attr,
160 struct dt_device *dt = container_of(kobj, struct dt_device,
162 struct osp_device *osp = dt2osp_dev(dt);
164 return sprintf(buf, "%u\n", atomic_read(&osp->opd_sync_changes));
170 * \param[in] file proc file
171 * \param[in] buffer unused because any input will do
172 * \param[in] count \a buffer length
173 * \param[in] off unused for single entry
174 * \retval \a count on success
175 * \retval negative number on error
177 static ssize_t sync_changes_store(struct kobject *kobj, struct attribute *attr,
178 const char *buffer, size_t count)
180 struct dt_device *dt = container_of(kobj, struct dt_device,
182 struct osp_device *osp = dt2osp_dev(dt);
186 rc = lu_env_init(&env, LCT_LOCAL);
190 rc = dt_sync(&env, &osp->opd_dt_dev);
193 return rc == 0 ? count : rc;
195 LUSTRE_RW_ATTR(sync_changes);
198 * Show maximum number of RPCs in flight allowed
200 * \param[in] m seq_file handle
201 * \param[in] data unused for single entry
202 * \retval 0 on success
203 * \retval negative number on error
205 static ssize_t max_rpcs_in_flight_show(struct kobject *kobj,
206 struct attribute *attr,
209 struct dt_device *dt = container_of(kobj, struct dt_device,
211 struct osp_device *osp = dt2osp_dev(dt);
213 return sprintf(buf, "%u\n", osp->opd_sync_max_rpcs_in_flight);
217 * Change maximum number of RPCs in flight allowed
219 * \param[in] file proc file
220 * \param[in] buffer string which represents maximum number
221 * \param[in] count \a buffer length
222 * \param[in] off unused for single entry
223 * \retval \a count on success
224 * \retval negative number on error
226 static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
227 struct attribute *attr,
231 struct dt_device *dt = container_of(kobj, struct dt_device,
233 struct osp_device *osp = dt2osp_dev(dt);
237 rc = kstrtouint(buffer, 0, &val);
244 osp->opd_sync_max_rpcs_in_flight = val;
247 LUSTRE_RW_ATTR(max_rpcs_in_flight);
250 * Show maximum number of RPCs in processing allowed
252 * \param[in] m seq_file handle
253 * \param[in] data unused
254 * \retval 0 on success
255 * \retval negative number on error
257 static ssize_t max_rpcs_in_progress_show(struct kobject *kobj,
258 struct attribute *attr,
261 struct dt_device *dt = container_of(kobj, struct dt_device,
263 struct osp_device *osp = dt2osp_dev(dt);
265 return sprintf(buf, "%u\n", osp->opd_sync_max_rpcs_in_progress);
269 * Change maximum number of RPCs in processing allowed
271 * \param[in] file proc file
272 * \param[in] buffer string which represents maximum number
273 * \param[in] count \a buffer length
274 * \param[in] off unused for single entry
275 * \retval \a count on success
276 * \retval negative number on error
278 static ssize_t max_rpcs_in_progress_store(struct kobject *kobj,
279 struct attribute *attr,
283 struct dt_device *dt = container_of(kobj, struct dt_device,
285 struct osp_device *osp = dt2osp_dev(dt);
289 rc = kstrtouint(buffer, 0, &val);
296 osp->opd_sync_max_rpcs_in_progress = val;
300 LUSTRE_RW_ATTR(max_rpcs_in_progress);
303 * Show number of objects to precreate next time
305 * \param[in] m seq_file handle
306 * \param[in] data unused for single entry
307 * \retval 0 on success
308 * \retval negative number on error
310 static ssize_t create_count_show(struct kobject *kobj,
311 struct attribute *attr,
314 struct dt_device *dt = container_of(kobj, struct dt_device,
316 struct osp_device *osp = dt2osp_dev(dt);
321 return sprintf(buf, "%d\n", osp->opd_pre_create_count);
325 * Change number of objects to precreate next time
327 * \param[in] file proc file
328 * \param[in] buffer string which represents number of objects to precreate
329 * \param[in] count \a buffer length
330 * \param[in] off unused for single entry
331 * \retval \a count on success
332 * \retval negative number on error
334 static ssize_t create_count_store(struct kobject *kobj, struct attribute *attr,
335 const char *buffer, size_t count)
337 struct dt_device *dt = container_of(kobj, struct dt_device,
339 struct osp_device *osp = dt2osp_dev(dt);
347 rc = kstrtouint(buffer, 0, &val);
351 /* The MDT ALWAYS needs to limit the precreate count to
352 * OST_MAX_PRECREATE, and the constant cannot be changed
353 * because it is a value shared between the OSP and OST
354 * that is the maximum possible number of objects that will
355 * ever be handled by MDT->OST recovery processing.
357 * If the OST ever gets a request to delete more orphans,
358 * this implies that something has gone badly on the MDT
359 * and the OST will refuse to delete so much data from the
360 * filesystem as a safety measure. */
361 if (val < OST_MIN_PRECREATE || val > OST_MAX_PRECREATE)
363 if (val > osp->opd_pre_max_create_count)
366 for (i = 1; (i << 1) <= val; i <<= 1)
368 osp->opd_pre_create_count = i;
372 LUSTRE_RW_ATTR(create_count);
375 * Show maximum number of objects to precreate
377 * \param[in] m seq_file handle
378 * \param[in] data unused for single entry
379 * \retval 0 on success
380 * \retval negative number on error
382 static ssize_t max_create_count_show(struct kobject *kobj,
383 struct attribute *attr,
386 struct dt_device *dt = container_of(kobj, struct dt_device,
388 struct osp_device *osp = dt2osp_dev(dt);
393 return sprintf(buf, "%d\n", osp->opd_pre_max_create_count);
397 * Change maximum number of objects to precreate
399 * \param[in] file proc file
400 * \param[in] buffer string which represents maximum number
401 * \param[in] count \a buffer length
402 * \param[in] off unused for single entry
403 * \retval \a count on success
404 * \retval negative number on error
406 static ssize_t max_create_count_store(struct kobject *kobj,
407 struct attribute *attr,
408 const char *buffer, size_t count)
410 struct dt_device *dt = container_of(kobj, struct dt_device,
412 struct osp_device *osp = dt2osp_dev(dt);
419 rc = kstrtouint(buffer, 0, &val);
423 if (val && (val < OST_MIN_PRECREATE ||
424 val > OST_MAX_PRECREATE))
427 if (osp->opd_pre_create_count > val)
428 osp->opd_pre_create_count = val;
430 /* Can be 0 after setting max_create_count to 0 */
431 if (osp->opd_pre_create_count == 0 && val != 0)
432 osp->opd_pre_create_count = OST_MIN_PRECREATE;
434 osp->opd_pre_max_create_count = val;
438 LUSTRE_RW_ATTR(max_create_count);
441 * Show last id to assign in creation
443 * \param[in] m seq_file handle
444 * \param[in] data unused for single entry
445 * \retval 0 on success
446 * \retval negative number on error
448 static ssize_t prealloc_next_id_show(struct kobject *kobj,
449 struct attribute *attr,
452 struct dt_device *dt = container_of(kobj, struct dt_device,
454 struct osp_device *osp = dt2osp_dev(dt);
461 fid = &osp->opd_pre_used_fid;
462 if (fid_is_idif(fid)) {
463 id = fid_idif_id(fid_seq(fid), fid_oid(fid), fid_ver(fid));
466 id = unlikely(fid_oid(fid) == LUSTRE_DATA_SEQ_MAX_WIDTH) ?
467 1 : fid_oid(fid) + 1;
470 return sprintf(buf, "%llu\n", id);
472 LUSTRE_RO_ATTR(prealloc_next_id);
475 * Show last created id OST reported
477 * \param[in] m seq_file handle
478 * \param[in] data unused for single entry
479 * \retval 0 on success
480 * \retval negative number on error
483 static ssize_t prealloc_last_id_show(struct kobject *kobj,
484 struct attribute *attr,
487 struct dt_device *dt = container_of(kobj, struct dt_device,
489 struct osp_device *osp = dt2osp_dev(dt);
496 fid = &osp->opd_pre_last_created_fid;
497 id = fid_is_idif(fid) ?
498 fid_idif_id(fid_seq(fid), fid_oid(fid), fid_ver(fid)) :
501 return sprintf(buf, "%llu\n", id);
503 LUSTRE_RO_ATTR(prealloc_last_id);
506 * Show next FID sequence to precreate
508 * \param[in] m seq_file handle
509 * \param[in] data unused for single entry
510 * \retval 0 on success
511 * \retval negative number on error
513 static ssize_t prealloc_next_seq_show(struct kobject *kobj,
514 struct attribute *attr,
517 struct dt_device *dt = container_of(kobj, struct dt_device,
519 struct osp_device *osp = dt2osp_dev(dt);
525 fid = &osp->opd_pre_used_fid;
526 return sprintf(buf, "%#llx\n", fid_is_idif(fid) ?
527 fid_seq(fid) & (~0xffff) : fid_seq(fid));
529 LUSTRE_RO_ATTR(prealloc_next_seq);
532 * Show last created FID sequence OST reported
534 * \param[in] m seq_file handle
535 * \param[in] data unused for single entry
536 * \retval 0 on success
537 * \retval negative number on error
539 static ssize_t prealloc_last_seq_show(struct kobject *kobj,
540 struct attribute *attr,
543 struct dt_device *dt = container_of(kobj, struct dt_device,
545 struct osp_device *osp = dt2osp_dev(dt);
551 fid = &osp->opd_pre_last_created_fid;
552 return sprintf(buf, "%#llx\n", fid_is_idif(fid) ?
553 fid_seq(fid) & (~0xffff) : fid_seq(fid));
555 LUSTRE_RO_ATTR(prealloc_last_seq);
558 * Show the number of ids reserved by declare
560 * \param[in] m seq_file handle
561 * \param[in] data unused for single entry
562 * \retval 0 on success
563 * \retval negative number on error
565 static ssize_t prealloc_reserved_show(struct kobject *kobj,
566 struct attribute *attr,
569 struct dt_device *dt = container_of(kobj, struct dt_device,
571 struct osp_device *osp = dt2osp_dev(dt);
576 return sprintf(buf, "%llu\n", osp->opd_pre_reserved);
578 LUSTRE_RO_ATTR(prealloc_reserved);
581 * Show interval (in seconds) to update statfs data
583 * \param[in] m seq_file handle
584 * \param[in] data unused for single entry
585 * \retval 0 on success
586 * \retval negative number on error
588 static ssize_t maxage_show(struct kobject *kobj,
589 struct attribute *attr,
592 struct dt_device *dt = container_of(kobj, struct dt_device,
594 struct osp_device *osp = dt2osp_dev(dt);
596 return sprintf(buf, "%lld\n", osp->opd_statfs_maxage);
600 * Change interval to update statfs data
602 * \param[in] file proc file
603 * \param[in] buffer string which represents statfs interval (in seconds)
604 * \param[in] count \a buffer length
605 * \param[in] off unused for single entry
606 * \retval \a count on success
607 * \retval negative number on error
609 static ssize_t maxage_store(struct kobject *kobj, struct attribute *attr,
610 const char *buffer, size_t count)
612 struct dt_device *dt = container_of(kobj, struct dt_device,
614 struct osp_device *osp = dt2osp_dev(dt);
618 rc = kstrtouint(buffer, 0, &val);
625 osp->opd_statfs_maxage = val;
629 LUSTRE_RW_ATTR(maxage);
632 * Show current precreation status: output 0 means success, otherwise negative
635 * \param[in] m seq_file handle
636 * \param[in] data unused for single entry
637 * \retval 0 on success
638 * \retval negative number on error
640 static ssize_t prealloc_status_show(struct kobject *kobj,
641 struct attribute *attr,
644 struct dt_device *dt = container_of(kobj, struct dt_device,
646 struct osp_device *osp = dt2osp_dev(dt);
651 return sprintf(buf, "%d\n", osp->opd_pre_status);
653 LUSTRE_RO_ATTR(prealloc_status);
656 * Show the number of RPCs in processing (including uncommitted by OST) plus
657 * changes to sync, i.e. this is the total number of changes OST needs to apply
660 * This counter is used to determine if OST has space returned. A zero value
661 * indicates that OST storage space consumed by destroyed objects has been freed
662 * on disk, the associated llog records have been cleared, and no synchronous
663 * RPC are being processed.
665 * \param[in] m seq_file handle
666 * \param[in] data unused for single entry
667 * \retval 0 on success
668 * \retval negative number on error
670 static ssize_t destroys_in_flight_show(struct kobject *kobj,
671 struct attribute *attr,
674 struct dt_device *dt = container_of(kobj, struct dt_device,
676 struct osp_device *osp = dt2osp_dev(dt);
678 return sprintf(buf, "%u\n",
679 atomic_read(&osp->opd_sync_rpcs_in_progress) +
680 atomic_read(&osp->opd_sync_changes));
682 LUSTRE_RO_ATTR(destroys_in_flight);
685 * Show changes synced from previous mount
687 * \param[in] m seq_file handle
688 * \param[in] data unused for single entry
689 * \retval 0 on success
690 * \retval negative number on error
692 static ssize_t old_sync_processed_show(struct kobject *kobj,
693 struct attribute *attr,
696 struct dt_device *dt = container_of(kobj, struct dt_device,
698 struct osp_device *osp = dt2osp_dev(dt);
700 return sprintf(buf, "%d\n", osp->opd_sync_prev_done);
702 LUSTRE_RO_ATTR(old_sync_processed);
705 * Show maximum number of RPCs in flight
707 * \param[in] m seq_file handle
708 * \param[in] data unused for single entry
709 * \retval 0 on success
710 * \retval negative number on error
712 static ssize_t lfsck_max_rpcs_in_flight_show(struct kobject *kobj,
713 struct attribute *attr,
716 struct dt_device *dt = container_of(kobj, struct dt_device,
718 struct lu_device *lu = dt2lu_dev(dt);
719 struct obd_device *obd = lu->ld_obd;
722 max = obd_get_max_rpcs_in_flight(&obd->u.cli);
723 return sprintf(buf, "%u\n", max);
727 * Change maximum number of RPCs in flight
729 * \param[in] file proc file
730 * \param[in] buffer string which represents maximum number of RPCs in flight
731 * \param[in] count \a buffer length
732 * \param[in] off unused for single entry
733 * \retval \a count on success
734 * \retval negative number on error
736 static ssize_t lfsck_max_rpcs_in_flight_store(struct kobject *kobj,
737 struct attribute *attr,
741 struct dt_device *dt = container_of(kobj, struct dt_device,
743 struct lu_device *lu = dt2lu_dev(dt);
744 struct obd_device *obd = lu->ld_obd;
748 rc = kstrtouint(buffer, 0, &val);
752 rc = obd_set_max_rpcs_in_flight(&obd->u.cli, val);
753 return rc ? rc : count;
755 LUSTRE_RW_ATTR(lfsck_max_rpcs_in_flight);
757 ssize_t ping_show(struct kobject *kobj, struct attribute *attr,
760 struct dt_device *dt = container_of(kobj, struct dt_device,
762 struct lu_device *lu = dt2lu_dev(dt);
763 struct obd_device *obd = lu->ld_obd;
766 rc = ptlrpc_obd_ping(obd);
770 LUSTRE_RO_ATTR(ping);
772 ssize_t osp_conn_uuid_show(struct kobject *kobj, struct attribute *attr,
775 struct dt_device *dt = container_of(kobj, struct dt_device,
777 struct lu_device *lu = dt2lu_dev(dt);
778 struct obd_device *obd = lu->ld_obd;
779 struct obd_import *imp;
780 struct ptlrpc_connection *conn;
783 with_imp_locked(obd, imp, count) {
784 conn = imp->imp_connection;
786 count = sprintf(buf, "%s\n", conn->c_remote_uuid.uuid);
788 count = sprintf(buf, "%s\n", "<none>");
794 LUSTRE_ATTR(ost_conn_uuid, 0444, osp_conn_uuid_show, NULL);
795 LUSTRE_ATTR(mdt_conn_uuid, 0444, osp_conn_uuid_show, NULL);
797 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, connect_flags);
798 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, server_uuid);
799 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, timeouts);
801 LDEBUGFS_SEQ_FOPS_RW_TYPE(osp, import);
802 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, state);
805 * Show high watermark (in megabytes). If available free space at OST is grater
806 * than high watermark and object allocation for OST is disabled, enable it.
808 * \param[in] m seq_file handle
809 * \param[in] data unused for single entry
810 * \retval 0 on success
811 * \retval negative number on error
813 static int osp_reserved_mb_high_seq_show(struct seq_file *m, void *data)
815 struct obd_device *dev = m->private;
816 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
821 seq_printf(m, "%u\n", osp->opd_reserved_mb_high);
826 * Change high watermark
828 * \param[in] file proc file
829 * \param[in] buffer string which represents new value (in megabytes)
830 * \param[in] count \a buffer length
831 * \param[in] off unused for single entry
832 * \retval \a count on success
833 * \retval negative number on error
836 osp_reserved_mb_high_seq_write(struct file *file, const char __user *buffer,
837 size_t count, loff_t *off)
839 struct seq_file *m = file->private_data;
840 struct obd_device *dev = m->private;
841 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
842 char kernbuf[22] = "";
846 if (osp == NULL || osp->opd_pre == NULL)
849 if (count >= sizeof(kernbuf))
852 if (copy_from_user(kernbuf, buffer, count))
856 rc = sysfs_memparse(kernbuf, count, &val, "MiB");
863 spin_lock(&osp->opd_pre_lock);
864 osp->opd_reserved_mb_high = val;
865 if (val <= osp->opd_reserved_mb_low)
866 osp->opd_reserved_mb_low = val - 1;
867 spin_unlock(&osp->opd_pre_lock);
871 LDEBUGFS_SEQ_FOPS(osp_reserved_mb_high);
874 * Show low watermark (in megabytes). If available free space at OST is less
875 * than low watermark, object allocation for OST is disabled.
877 * \param[in] m seq_file handle
878 * \param[in] data unused for single entry
879 * \retval 0 on success
880 * \retval negative number on error
882 static int osp_reserved_mb_low_seq_show(struct seq_file *m, void *data)
884 struct obd_device *dev = m->private;
885 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
890 seq_printf(m, "%u\n", osp->opd_reserved_mb_low);
895 * Change low watermark
897 * \param[in] file proc file
898 * \param[in] buffer string which represents new value (in megabytes)
899 * \param[in] count \a buffer length
900 * \param[in] off unused for single entry
901 * \retval \a count on success
902 * \retval negative number on error
905 osp_reserved_mb_low_seq_write(struct file *file, const char __user *buffer,
906 size_t count, loff_t *off)
908 struct seq_file *m = file->private_data;
909 struct obd_device *dev = m->private;
910 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
911 char kernbuf[22] = "";
915 if (osp == NULL || osp->opd_pre == NULL)
918 if (count >= sizeof(kernbuf))
921 if (copy_from_user(kernbuf, buffer, count))
925 rc = sysfs_memparse(kernbuf, count, &val, "MiB");
930 spin_lock(&osp->opd_pre_lock);
931 osp->opd_reserved_mb_low = val;
932 if (val >= osp->opd_reserved_mb_high)
933 osp->opd_reserved_mb_high = val + 1;
934 spin_unlock(&osp->opd_pre_lock);
938 LDEBUGFS_SEQ_FOPS(osp_reserved_mb_low);
940 static ssize_t force_sync_store(struct kobject *kobj, struct attribute *attr,
941 const char *buffer, size_t count)
943 struct dt_device *dt = container_of(kobj, struct dt_device,
948 rc = lu_env_init(&env, LCT_LOCAL);
952 rc = dt_sync(&env, dt);
955 return rc == 0 ? count : rc;
957 LUSTRE_WO_ATTR(force_sync);
959 static struct ldebugfs_vars ldebugfs_osp_obd_vars[] = {
960 { .name = "connect_flags",
961 .fops = &osp_connect_flags_fops },
962 { .name = "ost_server_uuid",
963 .fops = &osp_server_uuid_fops },
964 { .name = "timeouts",
965 .fops = &osp_timeouts_fops },
967 .fops = &osp_import_fops },
969 .fops = &osp_state_fops },
970 { .name = "reserved_mb_high",
971 .fops = &osp_reserved_mb_high_fops },
972 { .name = "reserved_mb_low",
973 .fops = &osp_reserved_mb_low_fops },
977 static struct ldebugfs_vars ldebugfs_osp_md_vars[] = {
978 { .name = "connect_flags",
979 .fops = &osp_connect_flags_fops },
980 { .name = "mdt_server_uuid",
981 .fops = &osp_server_uuid_fops },
982 { .name = "timeouts",
983 .fops = &osp_timeouts_fops },
985 .fops = &osp_import_fops },
987 .fops = &osp_state_fops },
991 static struct attribute *osp_obd_attrs[] = {
992 /* First two for compatiability reasons */
993 &lustre_attr_lfsck_max_rpcs_in_flight.attr,
994 &lustre_attr_destroys_in_flight.attr,
995 &lustre_attr_active.attr,
996 &lustre_attr_max_rpcs_in_flight.attr,
997 &lustre_attr_max_rpcs_in_progress.attr,
998 &lustre_attr_maxage.attr,
999 &lustre_attr_ost_conn_uuid.attr,
1000 &lustre_attr_ping.attr,
1001 &lustre_attr_prealloc_status.attr,
1002 &lustre_attr_prealloc_next_id.attr,
1003 &lustre_attr_prealloc_last_id.attr,
1004 &lustre_attr_prealloc_next_seq.attr,
1005 &lustre_attr_prealloc_last_seq.attr,
1006 &lustre_attr_prealloc_reserved.attr,
1007 &lustre_attr_sync_in_flight.attr,
1008 &lustre_attr_sync_in_progress.attr,
1009 &lustre_attr_sync_changes.attr,
1010 &lustre_attr_force_sync.attr,
1011 &lustre_attr_old_sync_processed.attr,
1012 &lustre_attr_create_count.attr,
1013 &lustre_attr_max_create_count.attr,
1017 static struct attribute *osp_md_attrs[] = {
1018 /* First two for compatiability reasons */
1019 &lustre_attr_lfsck_max_rpcs_in_flight.attr,
1020 &lustre_attr_destroys_in_flight.attr,
1021 &lustre_attr_active.attr,
1022 &lustre_attr_max_rpcs_in_flight.attr,
1023 &lustre_attr_max_rpcs_in_progress.attr,
1024 &lustre_attr_maxage.attr,
1025 &lustre_attr_mdt_conn_uuid.attr,
1026 &lustre_attr_ping.attr,
1027 &lustre_attr_prealloc_status.attr,
1031 void osp_tunables_fini(struct osp_device *osp)
1033 struct obd_device *obd = osp->opd_obd;
1034 struct kobject *osc;
1036 osc = kset_find_obj(lustre_kset, "osc");
1038 sysfs_remove_link(osc, obd->obd_name);
1042 debugfs_remove_recursive(osp->opd_debugfs);
1043 osp->opd_debugfs = NULL;
1045 ptlrpc_lprocfs_unregister_obd(obd);
1047 debugfs_remove_recursive(obd->obd_debugfs_entry);
1048 obd->obd_debugfs_entry = NULL;
1050 dt_tunables_fini(&osp->opd_dt_dev);
1054 * Initialize OSP sysfs / debugfs
1056 * param[in] osp OSP device
1058 void osp_tunables_init(struct osp_device *osp)
1060 struct obd_device *obd = osp->opd_obd;
1061 struct kobject *osc;
1064 if (osp->opd_connect_mdt) {
1065 osp->opd_dt_dev.dd_ktype.default_attrs = osp_md_attrs;
1066 obd->obd_debugfs_vars = ldebugfs_osp_md_vars;
1068 osp->opd_dt_dev.dd_ktype.default_attrs = osp_obd_attrs;
1069 obd->obd_debugfs_vars = ldebugfs_osp_obd_vars;
1072 rc = dt_tunables_init(&osp->opd_dt_dev, obd->obd_type, obd->obd_name,
1075 CERROR("%s: failed to setup DT tunables: %d\n",
1080 /* Since we register the obd device with ptlrpc / sptlrpc we
1081 * have to register debugfs with obd_device
1083 obd->obd_debugfs_entry = debugfs_create_dir(
1084 obd->obd_name, obd->obd_type->typ_debugfs_entry);
1085 ldebugfs_add_vars(obd->obd_debugfs_entry, obd->obd_debugfs_vars, obd);
1087 sptlrpc_lprocfs_cliobd_attach(obd);
1088 ptlrpc_lprocfs_register_obd(obd);
1090 if (osp->opd_connect_mdt || !strstr(obd->obd_name, "osc"))
1093 /* If the real OSC is present which is the case for setups
1094 * with both server and clients on the same node then use
1095 * the OSC's proc root
1097 osc = kset_find_obj(lustre_kset, "osc");
1099 rc = sysfs_create_link(osc, &osp->opd_dt_dev.dd_kobj,
1104 osp->opd_debugfs = ldebugfs_add_symlink(obd->obd_name, "osc",
1105 "../osp/%s", obd->obd_name);
1106 if (!osp->opd_debugfs)
1107 CERROR("%s: failed to create OSC debugfs symlink\n",