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) 2009, 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/ofd/lproc_ofd.c
34 * This file provides functions of procfs interface for OBD Filter Device (OFD).
36 * Author: Andreas Dilger <andreas.dilger@intel.com>
37 * Author: Mikhail Pershin <mike.pershin@intel.com>
38 * Author: Johann Lombardi <johann.lombardi@intel.com>
39 * Author: Fan Yong <fan.yong@intel.com>
42 #define DEBUG_SUBSYSTEM S_CLASS
45 #include <lprocfs_status.h>
46 #include <linux/seq_file.h>
47 #include <lustre_lfsck.h>
49 #include "ofd_internal.h"
54 * Show number of FID allocation sequences.
56 * \param[in] m seq_file handle
57 * \param[in] data unused for single entry
59 * \retval 0 on success
60 * \retval negative value on error
62 static ssize_t seqs_allocated_show(struct kobject *kobj, struct attribute *attr,
65 struct obd_device *obd = container_of(kobj, struct obd_device,
67 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
69 return sprintf(buf, "%u\n", ofd->ofd_seq_count);
71 LUSTRE_RO_ATTR(seqs_allocated);
74 * Show total number of grants for precreate.
76 * \param[in] m seq_file handle
77 * \param[in] data unused for single entry
79 * \retval 0 on success
80 * \retval negative value on error
82 static ssize_t grant_precreate_show(struct kobject *kobj,
83 struct attribute *attr,
86 struct obd_device *obd = container_of(kobj, struct obd_device,
89 return sprintf(buf, "%ld\n",
90 obd->obd_self_export->exp_target_data.ted_grant);
92 LUSTRE_RO_ATTR(grant_precreate);
95 * Show number of precreates allowed in a single transaction.
97 * \param[in] m seq_file handle
98 * \param[in] data unused for single entry
100 * \retval 0 on success
101 * \retval negative value on error
103 static ssize_t precreate_batch_show(struct kobject *kobj,
104 struct attribute *attr,
107 struct obd_device *obd = container_of(kobj, struct obd_device,
109 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
111 return sprintf(buf, "%d\n", ofd->ofd_precreate_batch);
115 * Change number of precreates allowed in a single transaction.
117 * \param[in] file proc file
118 * \param[in] buffer string which represents maximum number
119 * \param[in] count \a buffer length
120 * \param[in] off unused for single entry
122 * \retval \a count on success
123 * \retval negative number on error
125 static ssize_t precreate_batch_store(struct kobject *kobj,
126 struct attribute *attr,
127 const char *buffer, size_t count)
129 struct obd_device *obd = container_of(kobj, struct obd_device,
131 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
135 rc = kstrtouint(buffer, 0, &val);
139 if (val < 1 || val > 65536)
142 spin_lock(&ofd->ofd_batch_lock);
143 ofd->ofd_precreate_batch = val;
144 spin_unlock(&ofd->ofd_batch_lock);
147 LUSTRE_RW_ATTR(precreate_batch);
150 * Show the last used ID for each FID sequence used by OFD.
152 * \param[in] m seq_file handle
153 * \param[in] data unused for single entry
155 * \retval 0 on success
156 * \retval negative value on error
158 static int ofd_last_id_seq_show(struct seq_file *m, void *data)
160 struct obd_device *obd = m->private;
161 struct ofd_device *ofd;
162 struct ofd_seq *oseq = NULL;
167 ofd = ofd_dev(obd->obd_lu_dev);
169 read_lock(&ofd->ofd_seq_list_lock);
170 list_for_each_entry(oseq, &ofd->ofd_seq_list, os_list) {
173 seq = ostid_seq(&oseq->os_oi) == 0 ?
174 fid_idif_seq(ostid_id(&oseq->os_oi),
175 ofd->ofd_lut.lut_lsd.lsd_osd_index) :
176 ostid_seq(&oseq->os_oi);
177 seq_printf(m, DOSTID"\n", seq, ostid_id(&oseq->os_oi));
179 read_unlock(&ofd->ofd_seq_list_lock);
183 LPROC_SEQ_FOPS_RO(ofd_last_id);
186 * Show if the OFD is in degraded mode.
188 * Degraded means OFD has a failed drive or is undergoing RAID rebuild.
189 * The MDS will try to avoid using this OST for new object allocations
190 * to reduce the impact to global IO performance when clients writing to
191 * this OST are slowed down. It also reduces the contention on the OST
192 * RAID device, allowing it to rebuild more quickly.
194 * \retval count of bytes written
196 static ssize_t degraded_show(struct kobject *kobj, struct attribute *attr,
199 struct obd_device *obd = container_of(kobj, struct obd_device,
201 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
203 return sprintf(buf, "%u\n", ofd->ofd_raid_degraded);
207 * Set OFD to degraded mode.
209 * This is used to interface to userspace administrative tools for
210 * the underlying RAID storage, so that they can mark an OST
211 * as having degraded performance.
213 * \param[in] count \a buffer length
214 * \param[in] off unused for single entry
216 * \retval \a count on success
217 * \retval negative number on error
219 static ssize_t degraded_store(struct kobject *kobj, struct attribute *attr,
220 const char *buffer, size_t count)
222 struct obd_device *obd = container_of(kobj, struct obd_device,
224 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
228 rc = kstrtobool(buffer, &val);
232 spin_lock(&ofd->ofd_flags_lock);
233 ofd->ofd_raid_degraded = val;
234 spin_unlock(&ofd->ofd_flags_lock);
237 LUSTRE_RW_ATTR(degraded);
240 * Show if the OFD is in no precreate mode.
242 * This means OFD has been adminstratively disabled at the OST to prevent
243 * the MDS from creating any new files on the OST, though existing files
244 * can still be read, written, and unlinked.
246 * \retval number of bytes written
248 static ssize_t no_precreate_show(struct kobject *kobj, struct attribute *attr,
251 struct obd_device *obd = container_of(kobj, struct obd_device,
253 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
255 return snprintf(buf, PAGE_SIZE, "%u\n", ofd->ofd_no_precreate);
259 * Set OFD to no precreate mode.
261 * This is used to interface to userspace administrative tools to
262 * disable new object creation on the OST.
264 * \param[in] count \a buffer length
266 * \retval \a count on success
267 * \retval negative number on error
269 static ssize_t no_precreate_store(struct kobject *kobj, struct attribute *attr,
270 const char *buffer, size_t count)
272 struct obd_device *obd = container_of(kobj, struct obd_device,
274 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
278 rc = kstrtobool(buffer, &val);
282 spin_lock(&ofd->ofd_flags_lock);
283 ofd->ofd_no_precreate = val;
284 spin_unlock(&ofd->ofd_flags_lock);
288 LUSTRE_RW_ATTR(no_precreate);
291 * Show OFD filesystem type.
293 * \param[in] m seq_file handle
294 * \param[in] data unused for single entry
296 * \retval 0 on success
297 * \retval negative value on error
299 static ssize_t fstype_show(struct kobject *kobj, struct attribute *attr,
302 struct obd_device *obd = container_of(kobj, struct obd_device,
304 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
307 LASSERT(ofd->ofd_osd);
308 d = &ofd->ofd_osd->dd_lu_dev;
310 return sprintf(buf, "%s\n", d->ld_type->ldt_name);
312 LUSTRE_RO_ATTR(fstype);
315 * Show journal handling mode: synchronous or asynchronous.
317 * When running in asynchronous mode the journal transactions are not
318 * committed to disk before the RPC is replied back to the client.
319 * This will typically improve client performance when only a small number
320 * of clients are writing, since the client(s) can have more write RPCs
321 * in flight. However, it also means that the client has to handle recovery
322 * on bulk RPCs, and will have to keep more dirty pages in cache before they
323 * are committed on the OST.
325 * \param[in] m seq_file handle
326 * \param[in] data unused for single entry
328 * \retval 0 on success
329 * \retval negative value on error
331 static ssize_t sync_journal_show(struct kobject *kobj, struct attribute *attr,
334 struct obd_device *obd = container_of(kobj, struct obd_device,
336 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
338 return sprintf(buf, "%u\n", ofd->ofd_sync_journal);
342 * Set journal mode to synchronous or asynchronous.
344 * \param[in] file proc file
345 * \param[in] buffer string which represents mode
346 * 1: synchronous mode
347 * 0: asynchronous mode
348 * \param[in] count \a buffer length
349 * \param[in] off unused for single entry
351 * \retval \a count on success
352 * \retval negative number on error
354 static ssize_t sync_journal_store(struct kobject *kobj, struct attribute *attr,
355 const char *buffer, size_t count)
357 struct obd_device *obd = container_of(kobj, struct obd_device,
359 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
363 rc = kstrtobool(buffer, &val);
367 spin_lock(&ofd->ofd_flags_lock);
368 ofd->ofd_sync_journal = val;
370 spin_unlock(&ofd->ofd_flags_lock);
374 LUSTRE_RW_ATTR(sync_journal);
376 static int ofd_brw_size_seq_show(struct seq_file *m, void *data)
378 struct obd_device *obd = m->private;
379 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
381 seq_printf(m, "%u\n", ofd->ofd_brw_size / ONE_MB_BRW_SIZE);
386 ofd_brw_size_seq_write(struct file *file, const char __user *buffer,
387 size_t count, loff_t *off)
389 struct seq_file *m = file->private_data;
390 struct obd_device *obd = m->private;
391 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
392 char kernbuf[22] = "";
396 if (count >= sizeof(kernbuf))
399 if (copy_from_user(kernbuf, buffer, count))
403 rc = sysfs_memparse(kernbuf, count, &val, "MiB");
410 if (val > DT_MAX_BRW_SIZE ||
411 val < (1 << ofd->ofd_lut.lut_tgd.tgd_blockbits))
414 spin_lock(&ofd->ofd_flags_lock);
415 ofd->ofd_brw_size = val;
416 spin_unlock(&ofd->ofd_flags_lock);
420 LPROC_SEQ_FOPS(ofd_brw_size);
422 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 16, 53, 0)
423 static bool sync_on_lock_cancel_warned;
424 static ssize_t sync_on_lock_cancel_show(struct kobject *kobj,
425 struct attribute *attr, char *buf)
427 if (!sync_on_lock_cancel_warned) {
428 sync_on_lock_cancel_warned = true;
429 pr_info("ofd: 'obdfilter.*.sync_on_lock_cancel' is deprecated, use 'obdfilter.*.sync_lock_cancel' instead\n");
431 return sync_lock_cancel_show(kobj, attr, buf);
434 static ssize_t sync_on_lock_cancel_store(struct kobject *kobj,
435 struct attribute *attr,
436 const char *buffer, size_t count)
438 if (!sync_on_lock_cancel_warned) {
439 sync_on_lock_cancel_warned = true;
440 pr_info("ofd: 'obdfilter.*.sync_on_lock_cancel' is deprecated, use 'obdfilter.*.sync_lock_cancel' instead\n");
442 return sync_lock_cancel_store(kobj, attr, buffer, count);
444 LUSTRE_RW_ATTR(sync_on_lock_cancel);
448 * Show the limit of soft sync RPCs.
450 * This value defines how many IO RPCs with OBD_BRW_SOFT_SYNC flag
451 * are allowed before sync update will be triggered.
453 * \param[in] m seq_file handle
454 * \param[in] data unused for single entry
456 * \retval 0 on success
457 * \retval negative value on error
459 static ssize_t soft_sync_limit_show(struct kobject *kobj,
460 struct attribute *attr, char *buf)
462 struct obd_device *obd = container_of(kobj, struct obd_device,
464 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
466 return sprintf(buf, "%u\n", ofd->ofd_soft_sync_limit);
470 * Change the limit of soft sync RPCs.
472 * Define how many IO RPCs with OBD_BRW_SOFT_SYNC flag
473 * allowed before sync update will be done.
475 * This limit is global across all exports.
477 * \param[in] file proc file
478 * \param[in] buffer string which represents limit
479 * \param[in] count \a buffer length
480 * \param[in] off unused for single entry
482 * \retval \a count on success
483 * \retval negative number on error
485 static ssize_t soft_sync_limit_store(struct kobject *kobj,
486 struct attribute *attr,
487 const char *buffer, size_t count)
489 struct obd_device *obd = container_of(kobj, struct obd_device,
491 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
495 rc = kstrtouint(buffer, 0, &val);
499 ofd->ofd_soft_sync_limit = val;
502 LUSTRE_RW_ATTR(soft_sync_limit);
505 * Show the LFSCK speed limit.
507 * The maximum number of items scanned per second.
509 * \param[in] m seq_file handle
510 * \param[in] data unused for single entry
512 * \retval 0 on success
513 * \retval negative value on error
515 static ssize_t lfsck_speed_limit_show(struct kobject *kobj,
516 struct attribute *attr, char *buf)
518 struct obd_device *obd = container_of(kobj, struct obd_device,
520 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
522 return lfsck_get_speed(buf, ofd->ofd_osd);
526 * Change the LFSCK speed limit.
528 * Limit number of items that may be scanned per second.
530 * \param[in] file proc file
531 * \param[in] buffer string which represents limit
532 * \param[in] count \a buffer length
533 * \param[in] off unused for single entry
535 * \retval \a count on success
536 * \retval negative number on error
538 static ssize_t lfsck_speed_limit_store(struct kobject *kobj,
539 struct attribute *attr,
540 const char *buffer, size_t count)
542 struct obd_device *obd = container_of(kobj, struct obd_device,
544 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
548 rc = kstrtouint(buffer, 0, &val);
552 rc = lfsck_set_speed(ofd->ofd_osd, val);
554 return rc != 0 ? rc : count;
556 LUSTRE_RW_ATTR(lfsck_speed_limit);
559 * Show LFSCK layout verification stats from the most recent LFSCK run.
561 * \param[in] m seq_file handle
562 * \param[in] data unused for single entry
564 * \retval 0 on success
565 * \retval negative value on error
567 static int ofd_lfsck_layout_seq_show(struct seq_file *m, void *data)
569 struct obd_device *obd = m->private;
570 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
572 return lfsck_dump(m, ofd->ofd_osd, LFSCK_TYPE_LAYOUT);
575 LPROC_SEQ_FOPS_RO(ofd_lfsck_layout);
578 * Show if LFSCK performed parent FID verification.
580 * \param[in] m seq_file handle
581 * \param[in] data unused for single entry
583 * \retval 0 on success
584 * \retval negative value on error
586 static int ofd_lfsck_verify_pfid_seq_show(struct seq_file *m, void *data)
588 struct obd_device *obd = m->private;
589 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
591 seq_printf(m, "switch: %s\ndetected: %llu\nrepaired: %llu\n",
592 ofd->ofd_lfsck_verify_pfid ? "on" : "off",
593 ofd->ofd_inconsistency_self_detected,
594 ofd->ofd_inconsistency_self_repaired);
599 * Set the LFSCK behavior to verify parent FID correctness.
601 * If flag ofd_lfsck_verify_pfid is set then LFSCK does parent FID
602 * verification during read/write operations.
604 * \param[in] file proc file
605 * \param[in] buffer string which represents behavior
606 * 1: verify parent FID
607 * 0: don't verify parent FID
608 * \param[in] count \a buffer length
609 * \param[in] off unused for single entry
611 * \retval \a count on success
612 * \retval negative number on error
615 ofd_lfsck_verify_pfid_seq_write(struct file *file, const char __user *buffer,
616 size_t count, loff_t *off)
618 struct seq_file *m = file->private_data;
619 struct obd_device *obd = m->private;
620 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
624 rc = kstrtobool_from_user(buffer, count, &val);
628 ofd->ofd_lfsck_verify_pfid = val;
629 if (!ofd->ofd_lfsck_verify_pfid) {
630 ofd->ofd_inconsistency_self_detected = 0;
631 ofd->ofd_inconsistency_self_repaired = 0;
637 LPROC_SEQ_FOPS(ofd_lfsck_verify_pfid);
639 static int ofd_site_stats_seq_show(struct seq_file *m, void *data)
641 struct obd_device *obd = m->private;
643 return lu_site_stats_seq_print(obd->obd_lu_dev->ld_site, m);
646 LPROC_SEQ_FOPS_RO(ofd_site_stats);
649 * Show if the OFD enforces T10PI checksum.
651 * \param[in] m seq_file handle
652 * \param[in] data unused for single entry
654 * \retval 0 on success
655 * \retval negative value on error
657 static ssize_t checksum_t10pi_enforce_show(struct kobject *kobj,
658 struct attribute *attr,
661 struct obd_device *obd = container_of(kobj, struct obd_device,
663 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
665 return sprintf(buf, "%u\n", ofd->ofd_checksum_t10pi_enforce);
669 * Force specific T10PI checksum modes to be enabled
671 * If T10PI *is* supported in hardware, allow only the supported T10PI type
672 * to be used. If T10PI is *not* supported by the OSD, setting the enforce
673 * parameter forces all T10PI types to be enabled (even if slower) for
676 * The final determination of which algorithm to be used depends whether
677 * the client supports T10PI or not, and is handled at client connect time.
679 * \param[in] file proc file
680 * \param[in] buffer string which represents mode
681 * 1: set T10PI checksums enforced
682 * 0: unset T10PI checksums enforced
683 * \param[in] count \a buffer length
684 * \param[in] off unused for single entry
686 * \retval \a count on success
687 * \retval negative number on error
689 static ssize_t checksum_t10pi_enforce_store(struct kobject *kobj,
690 struct attribute *attr,
691 const char *buffer, size_t count)
693 struct obd_device *obd = container_of(kobj, struct obd_device,
695 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
699 rc = kstrtobool(buffer, &enforce);
703 spin_lock(&ofd->ofd_flags_lock);
704 ofd->ofd_checksum_t10pi_enforce = enforce;
705 spin_unlock(&ofd->ofd_flags_lock);
708 LUSTRE_RW_ATTR(checksum_t10pi_enforce);
710 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 14, 53, 0)
711 static bool max_file_warned;
712 static bool rd_cache_warned;
713 static bool wr_cache_warned;
715 static ssize_t read_cache_enable_show(struct kobject *kobj,
716 struct attribute *attr,
719 struct obd_device *obd = container_of(kobj, struct obd_device,
721 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
723 if (!rd_cache_warned) {
724 rd_cache_warned = true;
725 pr_info("ofd: 'obdfilter.*.read_cache_enabled' is deprecated, use 'osd-*.read_cache_enabled' instead\n");
728 if (!ofd->ofd_read_cache_enable)
731 return lustre_attr_show(&ofd->ofd_osd->dd_kobj,
732 ofd->ofd_read_cache_enable, buf);
735 static ssize_t read_cache_enable_store(struct kobject *kobj,
736 struct attribute *attr,
737 const char *buffer, size_t count)
739 struct obd_device *obd = container_of(kobj, struct obd_device,
741 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
743 if (!rd_cache_warned) {
744 rd_cache_warned = true;
745 pr_info("ofd: 'obdfilter.*.read_cache_enabled' is deprecated, use 'osd-*.read_cache_enabled' instead\n");
748 if (!ofd->ofd_read_cache_enable)
751 return lustre_attr_store(&ofd->ofd_osd->dd_kobj,
752 ofd->ofd_read_cache_enable, buffer, count);
754 LUSTRE_RW_ATTR(read_cache_enable);
756 static ssize_t readcache_max_filesize_show(struct kobject *kobj,
757 struct attribute *attr,
760 struct obd_device *obd = container_of(kobj, struct obd_device,
762 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
764 if (!max_file_warned) {
765 max_file_warned = true;
766 pr_info("ofd: 'obdfilter.*.readcache_max_filesize' is deprecated, use 'osd-*.readcache_max_filesize' instead\n");
769 if (!ofd->ofd_read_cache_max_filesize)
772 return lustre_attr_show(&ofd->ofd_osd->dd_kobj,
773 ofd->ofd_read_cache_max_filesize, buf);
776 static ssize_t readcache_max_filesize_store(struct kobject *kobj,
777 struct attribute *attr,
778 const char *buffer, size_t count)
780 struct obd_device *obd = container_of(kobj, struct obd_device,
782 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
784 if (!max_file_warned) {
785 max_file_warned = true;
786 pr_info("ofd: 'obdfilter.*.readcache_max_filesize' is deprecated, use 'osd-*.readcache_max_filesize' instead\n");
789 if (!ofd->ofd_read_cache_max_filesize)
792 return lustre_attr_store(&ofd->ofd_osd->dd_kobj,
793 ofd->ofd_read_cache_max_filesize,
796 LUSTRE_RW_ATTR(readcache_max_filesize);
798 static ssize_t writethrough_cache_enable_show(struct kobject *kobj,
799 struct attribute *attr,
802 struct obd_device *obd = container_of(kobj, struct obd_device,
804 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
806 if (!wr_cache_warned) {
807 wr_cache_warned = true;
808 pr_info("ofd: 'obdfilter.*.writethrough_cache_enabled' is deprecated, use 'osd-*.writethrough_cache_enabled' instead\n");
811 if (!ofd->ofd_write_cache_enable)
814 return lustre_attr_show(&ofd->ofd_osd->dd_kobj,
815 ofd->ofd_write_cache_enable, buf);
818 static ssize_t writethrough_cache_enable_store(struct kobject *kobj,
819 struct attribute *attr,
820 const char *buffer, size_t count)
822 struct obd_device *obd = container_of(kobj, struct obd_device,
824 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
826 if (!ofd->ofd_write_cache_enable)
829 return lustre_attr_store(&ofd->ofd_osd->dd_kobj,
830 ofd->ofd_write_cache_enable,
833 LUSTRE_RW_ATTR(writethrough_cache_enable);
836 LPROC_SEQ_FOPS_RO_TYPE(ofd, recovery_status);
837 LUSTRE_RW_ATTR(recovery_time_hard);
838 LUSTRE_RW_ATTR(recovery_time_soft);
839 LUSTRE_RW_ATTR(ir_factor);
841 LPROC_SEQ_FOPS_WR_ONLY(ofd, evict_client);
842 LPROC_SEQ_FOPS_RW_TYPE(ofd, checksum_dump);
843 LUSTRE_RW_ATTR(job_cleanup_interval);
845 LUSTRE_RO_ATTR(tot_dirty);
846 LUSTRE_RO_ATTR(tot_granted);
847 LUSTRE_RO_ATTR(tot_pending);
848 LUSTRE_RW_ATTR(grant_compat_disable);
849 LUSTRE_RO_ATTR(instance);
851 LUSTRE_RO_ATTR(num_exports);
853 struct lprocfs_vars lprocfs_ofd_obd_vars[] = {
855 .fops = &ofd_last_id_fops },
856 { .name = "recovery_status",
857 .fops = &ofd_recovery_status_fops },
858 { .name = "evict_client",
859 .fops = &ofd_evict_client_fops },
860 { .name = "brw_size",
861 .fops = &ofd_brw_size_fops },
862 { .name = "checksum_dump",
863 .fops = &ofd_checksum_dump_fops },
864 { .name = "lfsck_layout",
865 .fops = &ofd_lfsck_layout_fops },
866 { .name = "lfsck_verify_pfid",
867 .fops = &ofd_lfsck_verify_pfid_fops },
868 { .name = "site_stats",
869 .fops = &ofd_site_stats_fops },
874 * Initialize OFD statistics counters
876 * param[in] stats statistics counters
878 void ofd_stats_counter_init(struct lprocfs_stats *stats)
880 LASSERT(stats && stats->ls_num >= LPROC_OFD_STATS_LAST);
882 lprocfs_counter_init(stats, LPROC_OFD_STATS_READ,
883 LPROCFS_CNTR_AVGMINMAX, "read_bytes", "bytes");
884 lprocfs_counter_init(stats, LPROC_OFD_STATS_WRITE,
885 LPROCFS_CNTR_AVGMINMAX, "write_bytes", "bytes");
886 lprocfs_counter_init(stats, LPROC_OFD_STATS_GETATTR,
887 0, "getattr", "reqs");
888 lprocfs_counter_init(stats, LPROC_OFD_STATS_SETATTR,
889 0, "setattr", "reqs");
890 lprocfs_counter_init(stats, LPROC_OFD_STATS_PUNCH,
892 lprocfs_counter_init(stats, LPROC_OFD_STATS_SYNC,
894 lprocfs_counter_init(stats, LPROC_OFD_STATS_DESTROY,
895 0, "destroy", "reqs");
896 lprocfs_counter_init(stats, LPROC_OFD_STATS_CREATE,
897 0, "create", "reqs");
898 lprocfs_counter_init(stats, LPROC_OFD_STATS_STATFS,
899 0, "statfs", "reqs");
900 lprocfs_counter_init(stats, LPROC_OFD_STATS_GET_INFO,
901 0, "get_info", "reqs");
902 lprocfs_counter_init(stats, LPROC_OFD_STATS_SET_INFO,
903 0, "set_info", "reqs");
904 lprocfs_counter_init(stats, LPROC_OFD_STATS_QUOTACTL,
905 0, "quotactl", "reqs");
908 LPROC_SEQ_FOPS(lprocfs_nid_stats_clear);
910 static struct attribute *ofd_attrs[] = {
911 &lustre_attr_tot_dirty.attr,
912 &lustre_attr_tot_granted.attr,
913 &lustre_attr_tot_pending.attr,
914 &lustre_attr_grant_compat_disable.attr,
915 &lustre_attr_instance.attr,
916 &lustre_attr_recovery_time_hard.attr,
917 &lustre_attr_recovery_time_soft.attr,
918 &lustre_attr_ir_factor.attr,
919 &lustre_attr_num_exports.attr,
920 &lustre_attr_seqs_allocated.attr,
921 &lustre_attr_grant_precreate.attr,
922 &lustre_attr_precreate_batch.attr,
923 &lustre_attr_degraded.attr,
924 &lustre_attr_fstype.attr,
925 &lustre_attr_no_precreate.attr,
926 &lustre_attr_sync_journal.attr,
927 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 16, 53, 0)
928 &lustre_attr_sync_on_lock_cancel.attr,
930 &lustre_attr_soft_sync_limit.attr,
931 &lustre_attr_lfsck_speed_limit.attr,
932 &lustre_attr_job_cleanup_interval.attr,
933 &lustre_attr_checksum_t10pi_enforce.attr,
934 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 14, 53, 0)
935 &lustre_attr_read_cache_enable.attr,
936 &lustre_attr_readcache_max_filesize.attr,
937 &lustre_attr_writethrough_cache_enable.attr,
943 * Initialize all needed procfs entries for OFD device.
945 * \param[in] ofd OFD device
947 * \retval 0 if successful
948 * \retval negative value on error
950 int ofd_tunables_init(struct ofd_device *ofd)
952 struct obd_device *obd = ofd_obd(ofd);
953 struct proc_dir_entry *entry;
957 /* lprocfs must be setup before the ofd so state can be safely added
958 * to /proc incrementally as the ofd is setup
960 obd->obd_ktype.default_attrs = ofd_attrs;
961 obd->obd_vars = lprocfs_ofd_obd_vars;
962 rc = lprocfs_obd_setup(obd, false);
964 CERROR("%s: lprocfs_obd_setup failed: %d.\n",
969 rc = tgt_tunables_init(&ofd->ofd_lut);
971 CERROR("%s: tgt_tunables_init failed: rc = %d\n",
973 GOTO(obd_cleanup, rc);
976 rc = lprocfs_alloc_obd_stats(obd, LPROC_OFD_STATS_LAST);
978 CERROR("%s: lprocfs_alloc_obd_stats failed: %d.\n",
980 GOTO(tgt_cleanup, rc);
983 entry = lprocfs_register("exports", obd->obd_proc_entry, NULL, NULL);
986 CERROR("%s: error %d setting up lprocfs for %s\n",
987 obd->obd_name, rc, "exports");
988 GOTO(obd_free_stats, rc);
990 obd->obd_proc_exports_entry = entry;
992 entry = lprocfs_add_simple(obd->obd_proc_exports_entry, "clear",
993 obd, &lprocfs_nid_stats_clear_fops);
996 CERROR("%s: add proc entry 'clear' failed: %d.\n",
998 GOTO(obd_free_stats, rc);
1001 ofd_stats_counter_init(obd->obd_stats);
1003 rc = lprocfs_job_stats_init(obd, LPROC_OFD_STATS_LAST,
1004 ofd_stats_counter_init);
1006 GOTO(obd_free_stats, rc);
1011 lprocfs_free_obd_stats(obd);
1013 tgt_tunables_fini(&ofd->ofd_lut);
1015 lprocfs_obd_cleanup(obd);
1019 #endif /* CONFIG_PROC_FS */