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 && (val < OST_MIN_PRECREATE ||
419 val > OST_MAX_PRECREATE))
422 if (osp->opd_pre_create_count > val)
423 osp->opd_pre_create_count = val;
425 /* Can be 0 after setting max_create_count to 0 */
426 if (osp->opd_pre_create_count == 0 && val != 0)
427 osp->opd_pre_create_count = OST_MIN_PRECREATE;
429 osp->opd_pre_max_create_count = val;
433 LUSTRE_RW_ATTR(max_create_count);
436 * Show last id to assign in creation
438 * \param[in] m seq_file handle
439 * \param[in] data unused for single entry
440 * \retval 0 on success
441 * \retval negative number on error
443 static ssize_t prealloc_next_id_show(struct kobject *kobj,
444 struct attribute *attr,
447 struct dt_device *dt = container_of(kobj, struct dt_device,
449 struct osp_device *osp = dt2osp_dev(dt);
456 fid = &osp->opd_pre_used_fid;
457 if (fid_is_idif(fid)) {
458 id = fid_idif_id(fid_seq(fid), fid_oid(fid), fid_ver(fid));
461 id = unlikely(fid_oid(fid) == LUSTRE_DATA_SEQ_MAX_WIDTH) ?
462 1 : fid_oid(fid) + 1;
465 return sprintf(buf, "%llu\n", id);
467 LUSTRE_RO_ATTR(prealloc_next_id);
470 * Show last created id OST reported
472 * \param[in] m seq_file handle
473 * \param[in] data unused for single entry
474 * \retval 0 on success
475 * \retval negative number on error
478 static ssize_t prealloc_last_id_show(struct kobject *kobj,
479 struct attribute *attr,
482 struct dt_device *dt = container_of(kobj, struct dt_device,
484 struct osp_device *osp = dt2osp_dev(dt);
491 fid = &osp->opd_pre_last_created_fid;
492 id = fid_is_idif(fid) ?
493 fid_idif_id(fid_seq(fid), fid_oid(fid), fid_ver(fid)) :
496 return sprintf(buf, "%llu\n", id);
498 LUSTRE_RO_ATTR(prealloc_last_id);
501 * Show next FID sequence to precreate
503 * \param[in] m seq_file handle
504 * \param[in] data unused for single entry
505 * \retval 0 on success
506 * \retval negative number on error
508 static ssize_t prealloc_next_seq_show(struct kobject *kobj,
509 struct attribute *attr,
512 struct dt_device *dt = container_of(kobj, struct dt_device,
514 struct osp_device *osp = dt2osp_dev(dt);
520 fid = &osp->opd_pre_used_fid;
521 return sprintf(buf, "%#llx\n", fid_is_idif(fid) ?
522 fid_seq(fid) & (~0xffff) : fid_seq(fid));
524 LUSTRE_RO_ATTR(prealloc_next_seq);
527 * Show last created FID sequence OST reported
529 * \param[in] m seq_file handle
530 * \param[in] data unused for single entry
531 * \retval 0 on success
532 * \retval negative number on error
534 static ssize_t prealloc_last_seq_show(struct kobject *kobj,
535 struct attribute *attr,
538 struct dt_device *dt = container_of(kobj, struct dt_device,
540 struct osp_device *osp = dt2osp_dev(dt);
546 fid = &osp->opd_pre_last_created_fid;
547 return sprintf(buf, "%#llx\n", fid_is_idif(fid) ?
548 fid_seq(fid) & (~0xffff) : fid_seq(fid));
550 LUSTRE_RO_ATTR(prealloc_last_seq);
553 * Show the number of ids reserved by declare
555 * \param[in] m seq_file handle
556 * \param[in] data unused for single entry
557 * \retval 0 on success
558 * \retval negative number on error
560 static ssize_t prealloc_reserved_show(struct kobject *kobj,
561 struct attribute *attr,
564 struct dt_device *dt = container_of(kobj, struct dt_device,
566 struct osp_device *osp = dt2osp_dev(dt);
571 return sprintf(buf, "%llu\n", osp->opd_pre_reserved);
573 LUSTRE_RO_ATTR(prealloc_reserved);
576 * Show interval (in seconds) to update statfs data
578 * \param[in] m seq_file handle
579 * \param[in] data unused for single entry
580 * \retval 0 on success
581 * \retval negative number on error
583 static ssize_t maxage_show(struct kobject *kobj,
584 struct attribute *attr,
587 struct dt_device *dt = container_of(kobj, struct dt_device,
589 struct osp_device *osp = dt2osp_dev(dt);
591 return sprintf(buf, "%lld\n", osp->opd_statfs_maxage);
595 * Change interval to update statfs data
597 * \param[in] file proc file
598 * \param[in] buffer string which represents statfs interval (in seconds)
599 * \param[in] count \a buffer length
600 * \param[in] off unused for single entry
601 * \retval \a count on success
602 * \retval negative number on error
604 static ssize_t maxage_store(struct kobject *kobj, struct attribute *attr,
605 const char *buffer, size_t count)
607 struct dt_device *dt = container_of(kobj, struct dt_device,
609 struct osp_device *osp = dt2osp_dev(dt);
613 rc = kstrtouint(buffer, 0, &val);
620 osp->opd_statfs_maxage = val;
624 LUSTRE_RW_ATTR(maxage);
627 * Show current precreation status: output 0 means success, otherwise negative
630 * \param[in] m seq_file handle
631 * \param[in] data unused for single entry
632 * \retval 0 on success
633 * \retval negative number on error
635 static ssize_t prealloc_status_show(struct kobject *kobj,
636 struct attribute *attr,
639 struct dt_device *dt = container_of(kobj, struct dt_device,
641 struct osp_device *osp = dt2osp_dev(dt);
646 return sprintf(buf, "%d\n", osp->opd_pre_status);
648 LUSTRE_RO_ATTR(prealloc_status);
651 * Show the number of RPCs in processing (including uncommitted by OST) plus
652 * changes to sync, i.e. this is the total number of changes OST needs to apply
655 * This counter is used to determine if OST has space returned. A zero value
656 * indicates that OST storage space consumed by destroyed objects has been freed
657 * on disk, the associated llog records have been cleared, and no synchronous
658 * RPC are being processed.
660 * \param[in] m seq_file handle
661 * \param[in] data unused for single entry
662 * \retval 0 on success
663 * \retval negative number on error
665 static ssize_t destroys_in_flight_show(struct kobject *kobj,
666 struct attribute *attr,
669 struct dt_device *dt = container_of(kobj, struct dt_device,
671 struct osp_device *osp = dt2osp_dev(dt);
673 return sprintf(buf, "%u\n",
674 atomic_read(&osp->opd_sync_rpcs_in_progress) +
675 atomic_read(&osp->opd_sync_changes));
677 LUSTRE_RO_ATTR(destroys_in_flight);
680 * Show changes synced from previous mount
682 * \param[in] m seq_file handle
683 * \param[in] data unused for single entry
684 * \retval 0 on success
685 * \retval negative number on error
687 static ssize_t old_sync_processed_show(struct kobject *kobj,
688 struct attribute *attr,
691 struct dt_device *dt = container_of(kobj, struct dt_device,
693 struct osp_device *osp = dt2osp_dev(dt);
695 return sprintf(buf, "%d\n", osp->opd_sync_prev_done);
697 LUSTRE_RO_ATTR(old_sync_processed);
700 * Show maximum number of RPCs in flight
702 * \param[in] m seq_file handle
703 * \param[in] data unused for single entry
704 * \retval 0 on success
705 * \retval negative number on error
707 static ssize_t lfsck_max_rpcs_in_flight_show(struct kobject *kobj,
708 struct attribute *attr,
711 struct dt_device *dt = container_of(kobj, struct dt_device,
713 struct lu_device *lu = dt2lu_dev(dt);
714 struct obd_device *obd = lu->ld_obd;
717 max = obd_get_max_rpcs_in_flight(&obd->u.cli);
718 return sprintf(buf, "%u\n", max);
722 * Change maximum number of RPCs in flight
724 * \param[in] file proc file
725 * \param[in] buffer string which represents maximum number of RPCs in flight
726 * \param[in] count \a buffer length
727 * \param[in] off unused for single entry
728 * \retval \a count on success
729 * \retval negative number on error
731 static ssize_t lfsck_max_rpcs_in_flight_store(struct kobject *kobj,
732 struct attribute *attr,
736 struct dt_device *dt = container_of(kobj, struct dt_device,
738 struct lu_device *lu = dt2lu_dev(dt);
739 struct obd_device *obd = lu->ld_obd;
743 rc = kstrtouint(buffer, 0, &val);
747 rc = obd_set_max_rpcs_in_flight(&obd->u.cli, val);
748 return rc ? rc : count;
750 LUSTRE_RW_ATTR(lfsck_max_rpcs_in_flight);
752 ssize_t ping_show(struct kobject *kobj, struct attribute *attr,
755 struct dt_device *dt = container_of(kobj, struct dt_device,
757 struct lu_device *lu = dt2lu_dev(dt);
758 struct obd_device *obd = lu->ld_obd;
761 LPROCFS_CLIMP_CHECK(obd);
762 rc = ptlrpc_obd_ping(obd);
763 LPROCFS_CLIMP_EXIT(obd);
767 LUSTRE_RO_ATTR(ping);
769 ssize_t osp_conn_uuid_show(struct kobject *kobj, struct attribute *attr,
772 struct dt_device *dt = container_of(kobj, struct dt_device,
774 struct lu_device *lu = dt2lu_dev(dt);
775 struct obd_device *obd = lu->ld_obd;
776 struct ptlrpc_connection *conn;
779 LPROCFS_CLIMP_CHECK(obd);
780 conn = obd->u.cli.cl_import->imp_connection;
781 if (conn && obd->u.cli.cl_import)
782 count = sprintf(buf, "%s\n", conn->c_remote_uuid.uuid);
784 count = sprintf(buf, "%s\n", "<none>");
786 LPROCFS_CLIMP_EXIT(obd);
790 LUSTRE_ATTR(ost_conn_uuid, 0444, osp_conn_uuid_show, NULL);
791 LUSTRE_ATTR(mdt_conn_uuid, 0444, osp_conn_uuid_show, NULL);
793 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, connect_flags);
794 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, server_uuid);
795 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, timeouts);
797 LPROC_SEQ_FOPS_RW_TYPE(osp, import);
798 LDEBUGFS_SEQ_FOPS_RO_TYPE(osp, state);
801 * Show high watermark (in megabytes). If available free space at OST is grater
802 * than high watermark and object allocation for OST is disabled, enable it.
804 * \param[in] m seq_file handle
805 * \param[in] data unused for single entry
806 * \retval 0 on success
807 * \retval negative number on error
809 static int osp_reserved_mb_high_seq_show(struct seq_file *m, void *data)
811 struct obd_device *dev = m->private;
812 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
817 seq_printf(m, "%u\n", osp->opd_reserved_mb_high);
822 * Change high watermark
824 * \param[in] file proc file
825 * \param[in] buffer string which represents new value (in megabytes)
826 * \param[in] count \a buffer length
827 * \param[in] off unused for single entry
828 * \retval \a count on success
829 * \retval negative number on error
832 osp_reserved_mb_high_seq_write(struct file *file, const char __user *buffer,
833 size_t count, loff_t *off)
835 struct seq_file *m = file->private_data;
836 struct obd_device *dev = m->private;
837 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
838 char kernbuf[22] = "";
842 if (osp == NULL || osp->opd_pre == NULL)
845 if (count >= sizeof(kernbuf))
848 if (copy_from_user(kernbuf, buffer, count))
852 rc = sysfs_memparse(kernbuf, count, &val, "MiB");
859 spin_lock(&osp->opd_pre_lock);
860 osp->opd_reserved_mb_high = val;
861 if (val <= osp->opd_reserved_mb_low)
862 osp->opd_reserved_mb_low = val - 1;
863 spin_unlock(&osp->opd_pre_lock);
867 LDEBUGFS_SEQ_FOPS(osp_reserved_mb_high);
870 * Show low watermark (in megabytes). If available free space at OST is less
871 * than low watermark, object allocation for OST is disabled.
873 * \param[in] m seq_file handle
874 * \param[in] data unused for single entry
875 * \retval 0 on success
876 * \retval negative number on error
878 static int osp_reserved_mb_low_seq_show(struct seq_file *m, void *data)
880 struct obd_device *dev = m->private;
881 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
886 seq_printf(m, "%u\n", osp->opd_reserved_mb_low);
891 * Change low watermark
893 * \param[in] file proc file
894 * \param[in] buffer string which represents new value (in megabytes)
895 * \param[in] count \a buffer length
896 * \param[in] off unused for single entry
897 * \retval \a count on success
898 * \retval negative number on error
901 osp_reserved_mb_low_seq_write(struct file *file, const char __user *buffer,
902 size_t count, loff_t *off)
904 struct seq_file *m = file->private_data;
905 struct obd_device *dev = m->private;
906 struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
907 char kernbuf[22] = "";
911 if (osp == NULL || osp->opd_pre == NULL)
914 if (count >= sizeof(kernbuf))
917 if (copy_from_user(kernbuf, buffer, count))
921 rc = sysfs_memparse(kernbuf, count, &val, "MiB");
926 spin_lock(&osp->opd_pre_lock);
927 osp->opd_reserved_mb_low = val;
928 if (val >= osp->opd_reserved_mb_high)
929 osp->opd_reserved_mb_high = val + 1;
930 spin_unlock(&osp->opd_pre_lock);
934 LDEBUGFS_SEQ_FOPS(osp_reserved_mb_low);
936 static ssize_t force_sync_store(struct kobject *kobj, struct attribute *attr,
937 const char *buffer, size_t count)
939 struct dt_device *dt = container_of(kobj, struct dt_device,
944 rc = lu_env_init(&env, LCT_LOCAL);
948 rc = dt_sync(&env, dt);
951 return rc == 0 ? count : rc;
953 LUSTRE_WO_ATTR(force_sync);
955 static struct lprocfs_vars lprocfs_osp_obd_vars[] = {
956 { .name = "connect_flags",
957 .fops = &osp_connect_flags_fops },
958 { .name = "ost_server_uuid",
959 .fops = &osp_server_uuid_fops },
960 { .name = "timeouts",
961 .fops = &osp_timeouts_fops },
963 .fops = &osp_import_fops },
965 .fops = &osp_state_fops },
966 { .name = "reserved_mb_high",
967 .fops = &osp_reserved_mb_high_fops },
968 { .name = "reserved_mb_low",
969 .fops = &osp_reserved_mb_low_fops },
973 static struct lprocfs_vars lprocfs_osp_md_vars[] = {
974 { .name = "connect_flags",
975 .fops = &osp_connect_flags_fops },
976 { .name = "mdt_server_uuid",
977 .fops = &osp_server_uuid_fops },
978 { .name = "timeouts",
979 .fops = &osp_timeouts_fops },
981 .fops = &osp_import_fops },
983 .fops = &osp_state_fops },
987 static struct attribute *osp_obd_attrs[] = {
988 /* First two for compatiability reasons */
989 &lustre_attr_lfsck_max_rpcs_in_flight.attr,
990 &lustre_attr_destroys_in_flight.attr,
991 &lustre_attr_active.attr,
992 &lustre_attr_max_rpcs_in_flight.attr,
993 &lustre_attr_max_rpcs_in_progress.attr,
994 &lustre_attr_maxage.attr,
995 &lustre_attr_ost_conn_uuid.attr,
996 &lustre_attr_ping.attr,
997 &lustre_attr_prealloc_status.attr,
998 &lustre_attr_prealloc_next_id.attr,
999 &lustre_attr_prealloc_last_id.attr,
1000 &lustre_attr_prealloc_next_seq.attr,
1001 &lustre_attr_prealloc_last_seq.attr,
1002 &lustre_attr_prealloc_reserved.attr,
1003 &lustre_attr_sync_in_flight.attr,
1004 &lustre_attr_sync_in_progress.attr,
1005 &lustre_attr_sync_changes.attr,
1006 &lustre_attr_force_sync.attr,
1007 &lustre_attr_old_sync_processed.attr,
1008 &lustre_attr_create_count.attr,
1009 &lustre_attr_max_create_count.attr,
1013 static struct attribute *osp_md_attrs[] = {
1014 /* First two for compatiability reasons */
1015 &lustre_attr_lfsck_max_rpcs_in_flight.attr,
1016 &lustre_attr_destroys_in_flight.attr,
1017 &lustre_attr_active.attr,
1018 &lustre_attr_max_rpcs_in_flight.attr,
1019 &lustre_attr_max_rpcs_in_progress.attr,
1020 &lustre_attr_maxage.attr,
1021 &lustre_attr_mdt_conn_uuid.attr,
1022 &lustre_attr_ping.attr,
1023 &lustre_attr_prealloc_status.attr,
1027 void osp_tunables_fini(struct osp_device *osp)
1029 struct obd_device *obd = osp->opd_obd;
1030 struct kobject *osc;
1032 osc = kset_find_obj(lustre_kset, "osc");
1034 sysfs_remove_link(osc, obd->obd_name);
1038 debugfs_remove_recursive(osp->opd_debugfs);
1039 osp->opd_debugfs = NULL;
1041 ptlrpc_lprocfs_unregister_obd(obd);
1043 debugfs_remove_recursive(obd->obd_debugfs_entry);
1044 obd->obd_debugfs_entry = NULL;
1046 dt_tunables_fini(&osp->opd_dt_dev);
1050 * Initialize OSP sysfs / debugfs
1052 * param[in] osp OSP device
1054 void osp_tunables_init(struct osp_device *osp)
1056 struct obd_device *obd = osp->opd_obd;
1057 struct kobject *osc;
1060 if (osp->opd_connect_mdt) {
1061 osp->opd_dt_dev.dd_ktype.default_attrs = osp_md_attrs;
1062 obd->obd_vars = lprocfs_osp_md_vars;
1064 osp->opd_dt_dev.dd_ktype.default_attrs = osp_obd_attrs;
1065 obd->obd_vars = lprocfs_osp_obd_vars;
1068 rc = dt_tunables_init(&osp->opd_dt_dev, obd->obd_type, obd->obd_name,
1071 CERROR("%s: failed to setup DT tunables: %d\n",
1076 /* Since we register the obd device with ptlrpc / sptlrpc we
1077 * have to register debugfs with obd_device
1079 obd->obd_debugfs_entry = ldebugfs_register(obd->obd_name,
1080 obd->obd_type->typ_debugfs_entry,
1081 obd->obd_vars, obd);
1082 if (IS_ERR_OR_NULL(obd->obd_debugfs_entry)) {
1083 rc = obd->obd_debugfs_entry ? PTR_ERR(obd->obd_debugfs_entry)
1085 CERROR("%s: error %d setting up debugfs\n",
1087 obd->obd_debugfs_entry = NULL;
1088 dt_tunables_fini(&osp->opd_dt_dev);
1092 sptlrpc_lprocfs_cliobd_attach(obd);
1093 ptlrpc_lprocfs_register_obd(obd);
1095 if (osp->opd_connect_mdt || !strstr(obd->obd_name, "osc"))
1098 /* If the real OSC is present which is the case for setups
1099 * with both server and clients on the same node then use
1100 * the OSC's proc root
1102 osc = kset_find_obj(lustre_kset, "osc");
1104 rc = sysfs_create_link(osc, &osp->opd_dt_dev.dd_kobj,
1109 osp->opd_debugfs = ldebugfs_add_symlink(obd->obd_name, "osc",
1110 "../osp/%s", obd->obd_name);
1111 if (!osp->opd_debugfs)
1112 CERROR("%s: failed to create OSC debugfs symlink\n",