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);
196 static ssize_t max_sync_changes_show(struct kobject *kobj,
197 struct attribute *attr, char *buf)
199 struct dt_device *dt = container_of(kobj, struct dt_device,
201 struct osp_device *osp = dt2osp_dev(dt);
203 return sprintf(buf, "%u\n", osp->opd_sync_max_changes);
207 static ssize_t max_sync_changes_store(struct kobject *kobj,
208 struct attribute *attr, const char *buffer, size_t count)
210 struct dt_device *dt = container_of(kobj, struct dt_device,
212 struct osp_device *osp = dt2osp_dev(dt);
216 rc = kstrtoint(buffer, 0, &val);
221 osp->opd_sync_max_changes = val;
225 LUSTRE_RW_ATTR(max_sync_changes);
228 * Show maximum number of RPCs in flight allowed
230 * \param[in] m seq_file handle
231 * \param[in] data unused for single entry
232 * \retval 0 on success
233 * \retval negative number on error
235 static ssize_t max_rpcs_in_flight_show(struct kobject *kobj,
236 struct attribute *attr,
239 struct dt_device *dt = container_of(kobj, struct dt_device,
241 struct osp_device *osp = dt2osp_dev(dt);
243 return sprintf(buf, "%u\n", osp->opd_sync_max_rpcs_in_flight);
247 * Change maximum number of RPCs in flight allowed
249 * \param[in] file proc file
250 * \param[in] buffer string which represents maximum number
251 * \param[in] count \a buffer length
252 * \param[in] off unused for single entry
253 * \retval \a count on success
254 * \retval negative number on error
256 static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
257 struct attribute *attr,
261 struct dt_device *dt = container_of(kobj, struct dt_device,
263 struct osp_device *osp = dt2osp_dev(dt);
267 rc = kstrtouint(buffer, 0, &val);
274 osp->opd_sync_max_rpcs_in_flight = val;
277 LUSTRE_RW_ATTR(max_rpcs_in_flight);
280 * Show maximum number of RPCs in processing allowed
282 * \param[in] m seq_file handle
283 * \param[in] data unused
284 * \retval 0 on success
285 * \retval negative number on error
287 static ssize_t max_rpcs_in_progress_show(struct kobject *kobj,
288 struct attribute *attr,
291 struct dt_device *dt = container_of(kobj, struct dt_device,
293 struct osp_device *osp = dt2osp_dev(dt);
295 return sprintf(buf, "%u\n", osp->opd_sync_max_rpcs_in_progress);
299 * Change maximum number of RPCs in processing allowed
301 * \param[in] file proc file
302 * \param[in] buffer string which represents maximum number
303 * \param[in] count \a buffer length
304 * \param[in] off unused for single entry
305 * \retval \a count on success
306 * \retval negative number on error
308 static ssize_t max_rpcs_in_progress_store(struct kobject *kobj,
309 struct attribute *attr,
313 struct dt_device *dt = container_of(kobj, struct dt_device,
315 struct osp_device *osp = dt2osp_dev(dt);
319 rc = kstrtouint(buffer, 0, &val);
326 osp->opd_sync_max_rpcs_in_progress = val;
330 LUSTRE_RW_ATTR(max_rpcs_in_progress);
333 * Show number of objects to precreate next time
335 * \param[in] m seq_file handle
336 * \param[in] data unused for single entry
337 * \retval 0 on success
338 * \retval negative number on error
340 static ssize_t create_count_show(struct kobject *kobj,
341 struct attribute *attr,
344 struct dt_device *dt = container_of(kobj, struct dt_device,
346 struct osp_device *osp = dt2osp_dev(dt);
351 return sprintf(buf, "%d\n", osp->opd_pre_create_count);
355 * Change number of objects to precreate next time
357 * \param[in] file proc file
358 * \param[in] buffer string which represents number of objects to precreate
359 * \param[in] count \a buffer length
360 * \param[in] off unused for single entry
361 * \retval \a count on success
362 * \retval negative number on error
364 static ssize_t create_count_store(struct kobject *kobj, struct attribute *attr,
365 const char *buffer, size_t count)
367 struct dt_device *dt = container_of(kobj, struct dt_device,
369 struct osp_device *osp = dt2osp_dev(dt);
376 rc = kstrtouint(buffer, 0, &val);
380 /* The MDT ALWAYS needs to limit the precreate count to
381 * OST_MAX_PRECREATE, and the constant cannot be changed
382 * because it is a value shared between the OSP and OST
383 * that is the maximum possible number of objects that will
384 * ever be handled by MDT->OST recovery processing.
386 * The OSP enforces the pre_create_count to amaximum of
387 * one half of opd_pre_max_create_count.
389 * If the OST ever gets a request to delete more orphans,
390 * this implies that something has gone badly on the MDT
391 * and the OST will refuse to delete so much data from the
392 * filesystem as a safety measure.
394 if (val < OST_MIN_PRECREATE)
396 if (val > osp->opd_pre_max_create_count / 2)
397 val = osp->opd_pre_max_create_count / 2;
399 /* set to largest value <= 32, 64, 128 or a multiple of 256 */
401 osp->opd_pre_create_count = val & 0xffffff00;
403 osp->opd_pre_create_count = rounddown_pow_of_two(val);
407 LUSTRE_RW_ATTR(create_count);
410 * Show maximum number of objects to precreate
412 * \param[in] m seq_file handle
413 * \param[in] data unused for single entry
414 * \retval 0 on success
415 * \retval negative number on error
417 static ssize_t max_create_count_show(struct kobject *kobj,
418 struct attribute *attr,
421 struct dt_device *dt = container_of(kobj, struct dt_device,
423 struct osp_device *osp = dt2osp_dev(dt);
428 return sprintf(buf, "%d\n", osp->opd_pre_max_create_count);
432 * Change maximum number of objects to precreate
434 * \param[in] file proc file
435 * \param[in] buffer string which represents maximum number
436 * \param[in] count \a buffer length
437 * \param[in] off unused for single entry
438 * \retval \a count on success
439 * \retval negative number on error
441 static ssize_t max_create_count_store(struct kobject *kobj,
442 struct attribute *attr,
443 const char *buffer, size_t count)
445 struct dt_device *dt = container_of(kobj, struct dt_device,
447 struct osp_device *osp = dt2osp_dev(dt);
454 rc = kstrtouint(buffer, 0, &val);
458 if (val && (val < OST_MIN_PRECREATE ||
459 val > OST_MAX_PRECREATE))
462 if (osp->opd_pre_create_count > val)
463 osp->opd_pre_create_count = val;
465 /* Can be 0 after setting max_create_count to 0 */
466 if (osp->opd_pre_create_count == 0 && val != 0)
467 osp->opd_pre_create_count = OST_MIN_PRECREATE;
469 osp->opd_pre_max_create_count = val;
473 LUSTRE_RW_ATTR(max_create_count);
476 * Show last id to assign in creation
478 * \param[in] m seq_file handle
479 * \param[in] data unused for single entry
480 * \retval 0 on success
481 * \retval negative number on error
483 static ssize_t prealloc_next_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_used_fid;
497 if (fid_is_idif(fid)) {
498 id = fid_idif_id(fid_seq(fid), fid_oid(fid), fid_ver(fid));
501 id = unlikely(fid_oid(fid) == LUSTRE_DATA_SEQ_MAX_WIDTH) ?
502 1 : fid_oid(fid) + 1;
505 return sprintf(buf, "%llu\n", id);
507 LUSTRE_RO_ATTR(prealloc_next_id);
510 * Show last created id OST reported
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
518 static ssize_t prealloc_last_id_show(struct kobject *kobj,
519 struct attribute *attr,
522 struct dt_device *dt = container_of(kobj, struct dt_device,
524 struct osp_device *osp = dt2osp_dev(dt);
531 fid = &osp->opd_pre_last_created_fid;
532 id = fid_is_idif(fid) ?
533 fid_idif_id(fid_seq(fid), fid_oid(fid), fid_ver(fid)) :
536 return sprintf(buf, "%llu\n", id);
538 LUSTRE_RO_ATTR(prealloc_last_id);
541 * Show next FID sequence to precreate
543 * \param[in] m seq_file handle
544 * \param[in] data unused for single entry
545 * \retval 0 on success
546 * \retval negative number on error
548 static ssize_t prealloc_next_seq_show(struct kobject *kobj,
549 struct attribute *attr,
552 struct dt_device *dt = container_of(kobj, struct dt_device,
554 struct osp_device *osp = dt2osp_dev(dt);
560 fid = &osp->opd_pre_used_fid;
561 return sprintf(buf, "%#llx\n", fid_is_idif(fid) ?
562 fid_seq(fid) & (~0xffff) : fid_seq(fid));
564 LUSTRE_RO_ATTR(prealloc_next_seq);
567 * Show last created FID sequence OST reported
569 * \param[in] m seq_file handle
570 * \param[in] data unused for single entry
571 * \retval 0 on success
572 * \retval negative number on error
574 static ssize_t prealloc_last_seq_show(struct kobject *kobj,
575 struct attribute *attr,
578 struct dt_device *dt = container_of(kobj, struct dt_device,
580 struct osp_device *osp = dt2osp_dev(dt);
586 fid = &osp->opd_pre_last_created_fid;
587 return sprintf(buf, "%#llx\n", fid_is_idif(fid) ?
588 fid_seq(fid) & (~0xffff) : fid_seq(fid));
590 LUSTRE_RO_ATTR(prealloc_last_seq);
593 * Show the number of ids reserved by declare
595 * \param[in] m seq_file handle
596 * \param[in] data unused for single entry
597 * \retval 0 on success
598 * \retval negative number on error
600 static ssize_t prealloc_reserved_show(struct kobject *kobj,
601 struct attribute *attr,
604 struct dt_device *dt = container_of(kobj, struct dt_device,
606 struct osp_device *osp = dt2osp_dev(dt);
611 return sprintf(buf, "%llu\n", osp->opd_pre_reserved);
613 LUSTRE_RO_ATTR(prealloc_reserved);
616 * Show interval (in seconds) to update statfs data
618 * \param[in] m seq_file handle
619 * \param[in] data unused for single entry
620 * \retval 0 on success
621 * \retval negative number on error
623 static ssize_t maxage_show(struct kobject *kobj,
624 struct attribute *attr,
627 struct dt_device *dt = container_of(kobj, struct dt_device,
629 struct osp_device *osp = dt2osp_dev(dt);
631 return sprintf(buf, "%lld\n", osp->opd_statfs_maxage);
635 * Change interval to update statfs data
637 * \param[in] file proc file
638 * \param[in] buffer string which represents statfs interval (in seconds)
639 * \param[in] count \a buffer length
640 * \param[in] off unused for single entry
641 * \retval \a count on success
642 * \retval negative number on error
644 static ssize_t maxage_store(struct kobject *kobj, struct attribute *attr,
645 const char *buffer, size_t count)
647 struct dt_device *dt = container_of(kobj, struct dt_device,
649 struct osp_device *osp = dt2osp_dev(dt);
653 rc = kstrtouint(buffer, 0, &val);
660 osp->opd_statfs_maxage = val;
664 LUSTRE_RW_ATTR(maxage);
667 * Show current precreation status: output 0 means success, otherwise negative
670 * \param[in] m seq_file handle
671 * \param[in] data unused for single entry
672 * \retval 0 on success
673 * \retval negative number on error
675 static ssize_t prealloc_status_show(struct kobject *kobj,
676 struct attribute *attr,
679 struct dt_device *dt = container_of(kobj, struct dt_device,
681 struct osp_device *osp = dt2osp_dev(dt);
686 return sprintf(buf, "%d\n", osp->opd_pre_status);
688 LUSTRE_RO_ATTR(prealloc_status);
691 * Show the number of RPCs in processing (including uncommitted by OST) plus
692 * changes to sync, i.e. this is the total number of changes OST needs to apply
695 * This counter is used to determine if OST has space returned. A zero value
696 * indicates that OST storage space consumed by destroyed objects has been freed
697 * on disk, the associated llog records have been cleared, and no synchronous
698 * RPC are being processed.
700 * \param[in] m seq_file handle
701 * \param[in] data unused for single entry
702 * \retval 0 on success
703 * \retval negative number on error
705 static ssize_t destroys_in_flight_show(struct kobject *kobj,
706 struct attribute *attr,
709 struct dt_device *dt = container_of(kobj, struct dt_device,
711 struct osp_device *osp = dt2osp_dev(dt);
713 return sprintf(buf, "%u\n",
714 atomic_read(&osp->opd_sync_rpcs_in_progress) +
715 atomic_read(&osp->opd_sync_changes));
717 LUSTRE_RO_ATTR(destroys_in_flight);
720 * Show changes synced from previous mount
722 * \param[in] m seq_file handle
723 * \param[in] data unused for single entry
724 * \retval 0 on success
725 * \retval negative number on error
727 static ssize_t old_sync_processed_show(struct kobject *kobj,
728 struct attribute *attr,
731 struct dt_device *dt = container_of(kobj, struct dt_device,
733 struct osp_device *osp = dt2osp_dev(dt);
735 return sprintf(buf, "%d\n", osp->opd_sync_prev_done);
737 LUSTRE_RO_ATTR(old_sync_processed);
740 * Show maximum number of RPCs in flight
742 * \param[in] m seq_file handle
743 * \param[in] data unused for single entry
744 * \retval 0 on success
745 * \retval negative number on error
747 static ssize_t lfsck_max_rpcs_in_flight_show(struct kobject *kobj,
748 struct attribute *attr,
751 struct dt_device *dt = container_of(kobj, struct dt_device,
753 struct lu_device *lu = dt2lu_dev(dt);
754 struct obd_device *obd = lu->ld_obd;
757 max = obd_get_max_rpcs_in_flight(&obd->u.cli);
758 return sprintf(buf, "%u\n", max);
762 * Change maximum number of RPCs in flight
764 * \param[in] file proc file
765 * \param[in] buffer string which represents maximum number of RPCs in flight
766 * \param[in] count \a buffer length
767 * \param[in] off unused for single entry
768 * \retval \a count on success
769 * \retval negative number on error
771 static ssize_t lfsck_max_rpcs_in_flight_store(struct kobject *kobj,
772 struct attribute *attr,
776 struct dt_device *dt = container_of(kobj, struct dt_device,
778 struct lu_device *lu = dt2lu_dev(dt);
779 struct obd_device *obd = lu->ld_obd;
783 rc = kstrtouint(buffer, 0, &val);
787 rc = obd_set_max_rpcs_in_flight(&obd->u.cli, val);
788 return rc ? rc : count;
790 LUSTRE_RW_ATTR(lfsck_max_rpcs_in_flight);
792 ssize_t ping_show(struct kobject *kobj, struct attribute *attr,
795 struct dt_device *dt = container_of(kobj, struct dt_device,
797 struct lu_device *lu = dt2lu_dev(dt);
798 struct obd_device *obd = lu->ld_obd;
801 rc = ptlrpc_obd_ping(obd);
805 LUSTRE_RO_ATTR(ping);
807 ssize_t osp_conn_uuid_show(struct kobject *kobj, struct attribute *attr,
810 struct dt_device *dt = container_of(kobj, struct dt_device,
812 struct lu_device *lu = dt2lu_dev(dt);
813 struct obd_device *obd = lu->ld_obd;
814 struct obd_import *imp;
815 struct ptlrpc_connection *conn;
818 with_imp_locked(obd, imp, count) {
819 conn = imp->imp_connection;
821 count = sprintf(buf, "%s\n", conn->c_remote_uuid.uuid);
823 count = sprintf(buf, "%s\n", "<none>");
829 LUSTRE_ATTR(ost_conn_uuid, 0444, osp_conn_uuid_show, NULL);
830 LUSTRE_ATTR(mdt_conn_uuid, 0444, osp_conn_uuid_show, NULL);
832 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, connect_flags);
833 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, server_uuid);
834 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, timeouts);
836 LDEBUGFS_SEQ_FOPS_RW_TYPE(osp, import);
837 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, state);
840 * Show high watermark (in megabytes). If available free space at OST is grater
841 * than high watermark and object allocation for OST is disabled, enable it.
843 * \param[in] m seq_file handle
844 * \param[in] data unused for single entry
845 * \retval 0 on success
846 * \retval negative number on error
848 static int osp_reserved_mb_high_seq_show(struct seq_file *m, void *data)
850 struct obd_device *dev = m->private;
851 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
856 seq_printf(m, "%u\n", osp->opd_reserved_mb_high);
861 * Change high watermark
863 * \param[in] file proc file
864 * \param[in] buffer string which represents new value (in megabytes)
865 * \param[in] count \a buffer length
866 * \param[in] off unused for single entry
867 * \retval \a count on success
868 * \retval negative number on error
871 osp_reserved_mb_high_seq_write(struct file *file, const char __user *buffer,
872 size_t count, loff_t *off)
874 struct seq_file *m = file->private_data;
875 struct obd_device *dev = m->private;
876 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
877 char kernbuf[22] = "";
881 if (osp == NULL || osp->opd_pre == NULL)
884 if (count >= sizeof(kernbuf))
887 if (copy_from_user(kernbuf, buffer, count))
891 rc = sysfs_memparse(kernbuf, count, &val, "MiB");
898 spin_lock(&osp->opd_pre_lock);
899 osp->opd_reserved_mb_high = val;
900 if (val <= osp->opd_reserved_mb_low)
901 osp->opd_reserved_mb_low = val - 1;
902 spin_unlock(&osp->opd_pre_lock);
906 LDEBUGFS_SEQ_FOPS(osp_reserved_mb_high);
909 * Show low watermark (in megabytes). If available free space at OST is less
910 * than low watermark, object allocation for OST is disabled.
912 * \param[in] m seq_file handle
913 * \param[in] data unused for single entry
914 * \retval 0 on success
915 * \retval negative number on error
917 static int osp_reserved_mb_low_seq_show(struct seq_file *m, void *data)
919 struct obd_device *dev = m->private;
920 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
925 seq_printf(m, "%u\n", osp->opd_reserved_mb_low);
930 * Change low watermark
932 * \param[in] file proc file
933 * \param[in] buffer string which represents new value (in megabytes)
934 * \param[in] count \a buffer length
935 * \param[in] off unused for single entry
936 * \retval \a count on success
937 * \retval negative number on error
940 osp_reserved_mb_low_seq_write(struct file *file, const char __user *buffer,
941 size_t count, loff_t *off)
943 struct seq_file *m = file->private_data;
944 struct obd_device *dev = m->private;
945 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
946 char kernbuf[22] = "";
950 if (osp == NULL || osp->opd_pre == NULL)
953 if (count >= sizeof(kernbuf))
956 if (copy_from_user(kernbuf, buffer, count))
960 rc = sysfs_memparse(kernbuf, count, &val, "MiB");
965 spin_lock(&osp->opd_pre_lock);
966 osp->opd_reserved_mb_low = val;
967 if (val >= osp->opd_reserved_mb_high)
968 osp->opd_reserved_mb_high = val + 1;
969 spin_unlock(&osp->opd_pre_lock);
973 LDEBUGFS_SEQ_FOPS(osp_reserved_mb_low);
975 static ssize_t force_sync_store(struct kobject *kobj, struct attribute *attr,
976 const char *buffer, size_t count)
978 struct dt_device *dt = container_of(kobj, struct dt_device,
983 rc = lu_env_init(&env, LCT_LOCAL);
987 rc = dt_sync(&env, dt);
990 return rc == 0 ? count : rc;
992 LUSTRE_WO_ATTR(force_sync);
994 static struct ldebugfs_vars ldebugfs_osp_obd_vars[] = {
995 { .name = "connect_flags",
996 .fops = &osp_connect_flags_fops },
997 { .name = "ost_server_uuid",
998 .fops = &osp_server_uuid_fops },
999 { .name = "timeouts",
1000 .fops = &osp_timeouts_fops },
1002 .fops = &osp_import_fops },
1004 .fops = &osp_state_fops },
1005 { .name = "reserved_mb_high",
1006 .fops = &osp_reserved_mb_high_fops },
1007 { .name = "reserved_mb_low",
1008 .fops = &osp_reserved_mb_low_fops },
1012 static struct ldebugfs_vars ldebugfs_osp_md_vars[] = {
1013 { .name = "connect_flags",
1014 .fops = &osp_connect_flags_fops },
1015 { .name = "mdt_server_uuid",
1016 .fops = &osp_server_uuid_fops },
1017 { .name = "timeouts",
1018 .fops = &osp_timeouts_fops },
1020 .fops = &osp_import_fops },
1022 .fops = &osp_state_fops },
1026 static struct attribute *osp_obd_attrs[] = {
1027 /* First two for compatiability reasons */
1028 &lustre_attr_lfsck_max_rpcs_in_flight.attr,
1029 &lustre_attr_destroys_in_flight.attr,
1030 &lustre_attr_active.attr,
1031 &lustre_attr_max_rpcs_in_flight.attr,
1032 &lustre_attr_max_rpcs_in_progress.attr,
1033 &lustre_attr_maxage.attr,
1034 &lustre_attr_ost_conn_uuid.attr,
1035 &lustre_attr_ping.attr,
1036 &lustre_attr_prealloc_status.attr,
1037 &lustre_attr_prealloc_next_id.attr,
1038 &lustre_attr_prealloc_last_id.attr,
1039 &lustre_attr_prealloc_next_seq.attr,
1040 &lustre_attr_prealloc_last_seq.attr,
1041 &lustre_attr_prealloc_reserved.attr,
1042 &lustre_attr_sync_in_flight.attr,
1043 &lustre_attr_sync_in_progress.attr,
1044 &lustre_attr_sync_changes.attr,
1045 &lustre_attr_max_sync_changes.attr,
1046 &lustre_attr_force_sync.attr,
1047 &lustre_attr_old_sync_processed.attr,
1048 &lustre_attr_create_count.attr,
1049 &lustre_attr_max_create_count.attr,
1053 static struct attribute *osp_md_attrs[] = {
1054 /* First two for compatiability reasons */
1055 &lustre_attr_lfsck_max_rpcs_in_flight.attr,
1056 &lustre_attr_destroys_in_flight.attr,
1057 &lustre_attr_active.attr,
1058 &lustre_attr_max_rpcs_in_flight.attr,
1059 &lustre_attr_max_rpcs_in_progress.attr,
1060 &lustre_attr_maxage.attr,
1061 &lustre_attr_mdt_conn_uuid.attr,
1062 &lustre_attr_ping.attr,
1063 &lustre_attr_prealloc_status.attr,
1067 void osp_tunables_fini(struct osp_device *osp)
1069 struct obd_device *obd = osp->opd_obd;
1070 struct kobject *osc;
1072 osc = kset_find_obj(lustre_kset, "osc");
1074 sysfs_remove_link(osc, obd->obd_name);
1078 debugfs_remove_recursive(osp->opd_debugfs);
1079 osp->opd_debugfs = NULL;
1081 ptlrpc_lprocfs_unregister_obd(obd);
1083 debugfs_remove_recursive(obd->obd_debugfs_entry);
1084 obd->obd_debugfs_entry = NULL;
1086 dt_tunables_fini(&osp->opd_dt_dev);
1090 * Initialize OSP sysfs / debugfs
1092 * param[in] osp OSP device
1094 void osp_tunables_init(struct osp_device *osp)
1096 struct obd_device *obd = osp->opd_obd;
1097 struct kobject *osc;
1100 if (osp->opd_connect_mdt) {
1101 osp->opd_dt_dev.dd_ktype.default_attrs = osp_md_attrs;
1102 obd->obd_debugfs_vars = ldebugfs_osp_md_vars;
1104 osp->opd_dt_dev.dd_ktype.default_attrs = osp_obd_attrs;
1105 obd->obd_debugfs_vars = ldebugfs_osp_obd_vars;
1108 rc = dt_tunables_init(&osp->opd_dt_dev, obd->obd_type, obd->obd_name,
1111 CERROR("%s: failed to setup DT tunables: %d\n",
1116 /* Since we register the obd device with ptlrpc / sptlrpc we
1117 * have to register debugfs with obd_device
1119 obd->obd_debugfs_entry = debugfs_create_dir(
1120 obd->obd_name, obd->obd_type->typ_debugfs_entry);
1121 ldebugfs_add_vars(obd->obd_debugfs_entry, obd->obd_debugfs_vars, obd);
1123 sptlrpc_lprocfs_cliobd_attach(obd);
1124 ptlrpc_lprocfs_register_obd(obd);
1126 if (osp->opd_connect_mdt || !strstr(obd->obd_name, "osc"))
1129 /* If the real OSC is present which is the case for setups
1130 * with both server and clients on the same node then use
1131 * the OSC's proc root
1133 osc = kset_find_obj(lustre_kset, "osc");
1135 rc = sysfs_create_link(osc, &osp->opd_dt_dev.dd_kobj,
1140 osp->opd_debugfs = ldebugfs_add_symlink(obd->obd_name, "osc",
1141 "../osp/%s", obd->obd_name);
1142 if (!osp->opd_debugfs)
1143 CERROR("%s: failed to create OSC debugfs symlink\n",