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;
87 rc = kstrtobool(buffer, &val);
91 with_imp_locked(obd, imp, rc) {
93 if (obd->u.cli.cl_import->imp_deactive == val)
94 rc = ptlrpc_set_import_active(imp, val);
97 "activate %u: ignoring repeat request\n",
103 LUSTRE_RW_ATTR(active);
106 * Show number of RPCs in flight
108 * \param[in] m seq_file handle
109 * \param[in] data unused for single entry
110 * \retval 0 on success
111 * \retval negative number on error
113 static ssize_t sync_in_flight_show(struct kobject *kobj,
114 struct attribute *attr,
117 struct dt_device *dt = container_of(kobj, struct dt_device,
119 struct osp_device *osp = dt2osp_dev(dt);
121 return sprintf(buf, "%u\n", atomic_read(&osp->opd_sync_rpcs_in_flight));
123 LUSTRE_RO_ATTR(sync_in_flight);
126 * Show number of RPCs in processing (including uncommitted by OST)
128 * \param[in] m seq_file handle
129 * \param[in] data unused for single entry
130 * \retval 0 on success
131 * \retval negative number on error
133 static ssize_t sync_in_progress_show(struct kobject *kobj,
134 struct attribute *attr,
137 struct dt_device *dt = container_of(kobj, struct dt_device,
139 struct osp_device *osp = dt2osp_dev(dt);
141 return sprintf(buf, "%u\n", atomic_read(&osp->opd_sync_rpcs_in_progress));
143 LUSTRE_RO_ATTR(sync_in_progress);
146 * Show number of changes to sync
148 * \param[in] m seq_file handle
149 * \param[in] data unused for single entry
150 * \retval 0 on success
151 * \retval negative number on error
153 static ssize_t sync_changes_show(struct kobject *kobj,
154 struct attribute *attr,
157 struct dt_device *dt = container_of(kobj, struct dt_device,
159 struct osp_device *osp = dt2osp_dev(dt);
161 return sprintf(buf, "%u\n", atomic_read(&osp->opd_sync_changes));
167 * \param[in] file proc file
168 * \param[in] buffer unused because any input will do
169 * \param[in] count \a buffer length
170 * \param[in] off unused for single entry
171 * \retval \a count on success
172 * \retval negative number on error
174 static ssize_t sync_changes_store(struct kobject *kobj, struct attribute *attr,
175 const char *buffer, size_t count)
177 struct dt_device *dt = container_of(kobj, struct dt_device,
179 struct osp_device *osp = dt2osp_dev(dt);
183 rc = lu_env_init(&env, LCT_LOCAL);
187 rc = dt_sync(&env, &osp->opd_dt_dev);
190 return rc == 0 ? count : rc;
192 LUSTRE_RW_ATTR(sync_changes);
195 * Show maximum number of RPCs in flight allowed
197 * \param[in] m seq_file handle
198 * \param[in] data unused for single entry
199 * \retval 0 on success
200 * \retval negative number on error
202 static ssize_t max_rpcs_in_flight_show(struct kobject *kobj,
203 struct attribute *attr,
206 struct dt_device *dt = container_of(kobj, struct dt_device,
208 struct osp_device *osp = dt2osp_dev(dt);
210 return sprintf(buf, "%u\n", osp->opd_sync_max_rpcs_in_flight);
214 * Change maximum number of RPCs in flight allowed
216 * \param[in] file proc file
217 * \param[in] buffer string which represents maximum number
218 * \param[in] count \a buffer length
219 * \param[in] off unused for single entry
220 * \retval \a count on success
221 * \retval negative number on error
223 static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
224 struct attribute *attr,
228 struct dt_device *dt = container_of(kobj, struct dt_device,
230 struct osp_device *osp = dt2osp_dev(dt);
234 rc = kstrtouint(buffer, 0, &val);
241 osp->opd_sync_max_rpcs_in_flight = val;
244 LUSTRE_RW_ATTR(max_rpcs_in_flight);
247 * Show maximum number of RPCs in processing allowed
249 * \param[in] m seq_file handle
250 * \param[in] data unused
251 * \retval 0 on success
252 * \retval negative number on error
254 static ssize_t max_rpcs_in_progress_show(struct kobject *kobj,
255 struct attribute *attr,
258 struct dt_device *dt = container_of(kobj, struct dt_device,
260 struct osp_device *osp = dt2osp_dev(dt);
262 return sprintf(buf, "%u\n", osp->opd_sync_max_rpcs_in_progress);
266 * Change maximum number of RPCs in processing allowed
268 * \param[in] file proc file
269 * \param[in] buffer string which represents maximum number
270 * \param[in] count \a buffer length
271 * \param[in] off unused for single entry
272 * \retval \a count on success
273 * \retval negative number on error
275 static ssize_t max_rpcs_in_progress_store(struct kobject *kobj,
276 struct attribute *attr,
280 struct dt_device *dt = container_of(kobj, struct dt_device,
282 struct osp_device *osp = dt2osp_dev(dt);
286 rc = kstrtouint(buffer, 0, &val);
293 osp->opd_sync_max_rpcs_in_progress = val;
297 LUSTRE_RW_ATTR(max_rpcs_in_progress);
300 * Show number of objects to precreate next time
302 * \param[in] m seq_file handle
303 * \param[in] data unused for single entry
304 * \retval 0 on success
305 * \retval negative number on error
307 static ssize_t create_count_show(struct kobject *kobj,
308 struct attribute *attr,
311 struct dt_device *dt = container_of(kobj, struct dt_device,
313 struct osp_device *osp = dt2osp_dev(dt);
318 return sprintf(buf, "%d\n", osp->opd_pre_create_count);
322 * Change number of objects to precreate next time
324 * \param[in] file proc file
325 * \param[in] buffer string which represents number of objects to precreate
326 * \param[in] count \a buffer length
327 * \param[in] off unused for single entry
328 * \retval \a count on success
329 * \retval negative number on error
331 static ssize_t create_count_store(struct kobject *kobj, struct attribute *attr,
332 const char *buffer, size_t count)
334 struct dt_device *dt = container_of(kobj, struct dt_device,
336 struct osp_device *osp = dt2osp_dev(dt);
344 rc = kstrtouint(buffer, 0, &val);
348 /* The MDT ALWAYS needs to limit the precreate count to
349 * OST_MAX_PRECREATE, and the constant cannot be changed
350 * because it is a value shared between the OSP and OST
351 * that is the maximum possible number of objects that will
352 * ever be handled by MDT->OST recovery processing.
354 * If the OST ever gets a request to delete more orphans,
355 * this implies that something has gone badly on the MDT
356 * and the OST will refuse to delete so much data from the
357 * filesystem as a safety measure. */
358 if (val < OST_MIN_PRECREATE || val > OST_MAX_PRECREATE)
360 if (val > osp->opd_pre_max_create_count)
363 for (i = 1; (i << 1) <= val; i <<= 1)
365 osp->opd_pre_create_count = i;
369 LUSTRE_RW_ATTR(create_count);
372 * Show maximum number of objects to precreate
374 * \param[in] m seq_file handle
375 * \param[in] data unused for single entry
376 * \retval 0 on success
377 * \retval negative number on error
379 static ssize_t max_create_count_show(struct kobject *kobj,
380 struct attribute *attr,
383 struct dt_device *dt = container_of(kobj, struct dt_device,
385 struct osp_device *osp = dt2osp_dev(dt);
390 return sprintf(buf, "%d\n", osp->opd_pre_max_create_count);
394 * Change maximum number of objects to precreate
396 * \param[in] file proc file
397 * \param[in] buffer string which represents maximum number
398 * \param[in] count \a buffer length
399 * \param[in] off unused for single entry
400 * \retval \a count on success
401 * \retval negative number on error
403 static ssize_t max_create_count_store(struct kobject *kobj,
404 struct attribute *attr,
405 const char *buffer, size_t count)
407 struct dt_device *dt = container_of(kobj, struct dt_device,
409 struct osp_device *osp = dt2osp_dev(dt);
416 rc = kstrtouint(buffer, 0, &val);
420 if (val && (val < OST_MIN_PRECREATE ||
421 val > OST_MAX_PRECREATE))
424 if (osp->opd_pre_create_count > val)
425 osp->opd_pre_create_count = val;
427 /* Can be 0 after setting max_create_count to 0 */
428 if (osp->opd_pre_create_count == 0 && val != 0)
429 osp->opd_pre_create_count = OST_MIN_PRECREATE;
431 osp->opd_pre_max_create_count = val;
435 LUSTRE_RW_ATTR(max_create_count);
438 * Show last id to assign in creation
440 * \param[in] m seq_file handle
441 * \param[in] data unused for single entry
442 * \retval 0 on success
443 * \retval negative number on error
445 static ssize_t prealloc_next_id_show(struct kobject *kobj,
446 struct attribute *attr,
449 struct dt_device *dt = container_of(kobj, struct dt_device,
451 struct osp_device *osp = dt2osp_dev(dt);
458 fid = &osp->opd_pre_used_fid;
459 if (fid_is_idif(fid)) {
460 id = fid_idif_id(fid_seq(fid), fid_oid(fid), fid_ver(fid));
463 id = unlikely(fid_oid(fid) == LUSTRE_DATA_SEQ_MAX_WIDTH) ?
464 1 : fid_oid(fid) + 1;
467 return sprintf(buf, "%llu\n", id);
469 LUSTRE_RO_ATTR(prealloc_next_id);
472 * Show last created id OST reported
474 * \param[in] m seq_file handle
475 * \param[in] data unused for single entry
476 * \retval 0 on success
477 * \retval negative number on error
480 static ssize_t prealloc_last_id_show(struct kobject *kobj,
481 struct attribute *attr,
484 struct dt_device *dt = container_of(kobj, struct dt_device,
486 struct osp_device *osp = dt2osp_dev(dt);
493 fid = &osp->opd_pre_last_created_fid;
494 id = fid_is_idif(fid) ?
495 fid_idif_id(fid_seq(fid), fid_oid(fid), fid_ver(fid)) :
498 return sprintf(buf, "%llu\n", id);
500 LUSTRE_RO_ATTR(prealloc_last_id);
503 * Show next FID sequence to precreate
505 * \param[in] m seq_file handle
506 * \param[in] data unused for single entry
507 * \retval 0 on success
508 * \retval negative number on error
510 static ssize_t prealloc_next_seq_show(struct kobject *kobj,
511 struct attribute *attr,
514 struct dt_device *dt = container_of(kobj, struct dt_device,
516 struct osp_device *osp = dt2osp_dev(dt);
522 fid = &osp->opd_pre_used_fid;
523 return sprintf(buf, "%#llx\n", fid_is_idif(fid) ?
524 fid_seq(fid) & (~0xffff) : fid_seq(fid));
526 LUSTRE_RO_ATTR(prealloc_next_seq);
529 * Show last created FID sequence OST reported
531 * \param[in] m seq_file handle
532 * \param[in] data unused for single entry
533 * \retval 0 on success
534 * \retval negative number on error
536 static ssize_t prealloc_last_seq_show(struct kobject *kobj,
537 struct attribute *attr,
540 struct dt_device *dt = container_of(kobj, struct dt_device,
542 struct osp_device *osp = dt2osp_dev(dt);
548 fid = &osp->opd_pre_last_created_fid;
549 return sprintf(buf, "%#llx\n", fid_is_idif(fid) ?
550 fid_seq(fid) & (~0xffff) : fid_seq(fid));
552 LUSTRE_RO_ATTR(prealloc_last_seq);
555 * Show the number of ids reserved by declare
557 * \param[in] m seq_file handle
558 * \param[in] data unused for single entry
559 * \retval 0 on success
560 * \retval negative number on error
562 static ssize_t prealloc_reserved_show(struct kobject *kobj,
563 struct attribute *attr,
566 struct dt_device *dt = container_of(kobj, struct dt_device,
568 struct osp_device *osp = dt2osp_dev(dt);
573 return sprintf(buf, "%llu\n", osp->opd_pre_reserved);
575 LUSTRE_RO_ATTR(prealloc_reserved);
578 * Show interval (in seconds) to update statfs data
580 * \param[in] m seq_file handle
581 * \param[in] data unused for single entry
582 * \retval 0 on success
583 * \retval negative number on error
585 static ssize_t maxage_show(struct kobject *kobj,
586 struct attribute *attr,
589 struct dt_device *dt = container_of(kobj, struct dt_device,
591 struct osp_device *osp = dt2osp_dev(dt);
593 return sprintf(buf, "%lld\n", osp->opd_statfs_maxage);
597 * Change interval to update statfs data
599 * \param[in] file proc file
600 * \param[in] buffer string which represents statfs interval (in seconds)
601 * \param[in] count \a buffer length
602 * \param[in] off unused for single entry
603 * \retval \a count on success
604 * \retval negative number on error
606 static ssize_t maxage_store(struct kobject *kobj, struct attribute *attr,
607 const char *buffer, size_t count)
609 struct dt_device *dt = container_of(kobj, struct dt_device,
611 struct osp_device *osp = dt2osp_dev(dt);
615 rc = kstrtouint(buffer, 0, &val);
622 osp->opd_statfs_maxage = val;
626 LUSTRE_RW_ATTR(maxage);
629 * Show current precreation status: output 0 means success, otherwise negative
632 * \param[in] m seq_file handle
633 * \param[in] data unused for single entry
634 * \retval 0 on success
635 * \retval negative number on error
637 static ssize_t prealloc_status_show(struct kobject *kobj,
638 struct attribute *attr,
641 struct dt_device *dt = container_of(kobj, struct dt_device,
643 struct osp_device *osp = dt2osp_dev(dt);
648 return sprintf(buf, "%d\n", osp->opd_pre_status);
650 LUSTRE_RO_ATTR(prealloc_status);
653 * Show the number of RPCs in processing (including uncommitted by OST) plus
654 * changes to sync, i.e. this is the total number of changes OST needs to apply
657 * This counter is used to determine if OST has space returned. A zero value
658 * indicates that OST storage space consumed by destroyed objects has been freed
659 * on disk, the associated llog records have been cleared, and no synchronous
660 * RPC are being processed.
662 * \param[in] m seq_file handle
663 * \param[in] data unused for single entry
664 * \retval 0 on success
665 * \retval negative number on error
667 static ssize_t destroys_in_flight_show(struct kobject *kobj,
668 struct attribute *attr,
671 struct dt_device *dt = container_of(kobj, struct dt_device,
673 struct osp_device *osp = dt2osp_dev(dt);
675 return sprintf(buf, "%u\n",
676 atomic_read(&osp->opd_sync_rpcs_in_progress) +
677 atomic_read(&osp->opd_sync_changes));
679 LUSTRE_RO_ATTR(destroys_in_flight);
682 * Show changes synced from previous mount
684 * \param[in] m seq_file handle
685 * \param[in] data unused for single entry
686 * \retval 0 on success
687 * \retval negative number on error
689 static ssize_t old_sync_processed_show(struct kobject *kobj,
690 struct attribute *attr,
693 struct dt_device *dt = container_of(kobj, struct dt_device,
695 struct osp_device *osp = dt2osp_dev(dt);
697 return sprintf(buf, "%d\n", osp->opd_sync_prev_done);
699 LUSTRE_RO_ATTR(old_sync_processed);
702 * Show maximum number of RPCs in flight
704 * \param[in] m seq_file handle
705 * \param[in] data unused for single entry
706 * \retval 0 on success
707 * \retval negative number on error
709 static ssize_t lfsck_max_rpcs_in_flight_show(struct kobject *kobj,
710 struct attribute *attr,
713 struct dt_device *dt = container_of(kobj, struct dt_device,
715 struct lu_device *lu = dt2lu_dev(dt);
716 struct obd_device *obd = lu->ld_obd;
719 max = obd_get_max_rpcs_in_flight(&obd->u.cli);
720 return sprintf(buf, "%u\n", max);
724 * Change maximum number of RPCs in flight
726 * \param[in] file proc file
727 * \param[in] buffer string which represents maximum number of RPCs in flight
728 * \param[in] count \a buffer length
729 * \param[in] off unused for single entry
730 * \retval \a count on success
731 * \retval negative number on error
733 static ssize_t lfsck_max_rpcs_in_flight_store(struct kobject *kobj,
734 struct attribute *attr,
738 struct dt_device *dt = container_of(kobj, struct dt_device,
740 struct lu_device *lu = dt2lu_dev(dt);
741 struct obd_device *obd = lu->ld_obd;
745 rc = kstrtouint(buffer, 0, &val);
749 rc = obd_set_max_rpcs_in_flight(&obd->u.cli, val);
750 return rc ? rc : count;
752 LUSTRE_RW_ATTR(lfsck_max_rpcs_in_flight);
754 ssize_t ping_show(struct kobject *kobj, struct attribute *attr,
757 struct dt_device *dt = container_of(kobj, struct dt_device,
759 struct lu_device *lu = dt2lu_dev(dt);
760 struct obd_device *obd = lu->ld_obd;
761 struct obd_import *imp;
764 with_imp_locked(obd, imp, rc)
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",