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 number of seconds to delay atime
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 ssize_t atime_diff_show(struct kobject *kobj, struct attribute *attr,
161 struct obd_device *obd = container_of(kobj, struct obd_device,
163 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
165 return snprintf(buf, PAGE_SIZE, "%lld\n", ofd->ofd_atime_diff);
169 * Change number of seconds to delay atime
171 * \param[in] file proc file
172 * \param[in] buffer string which represents maximum number
173 * \param[in] count \a buffer length
174 * \param[in] off unused for single entry
176 * \retval \a count on success
177 * \retval negative number on error
179 static ssize_t atime_diff_store(struct kobject *kobj, struct attribute *attr,
180 const char *buffer, size_t count)
182 struct obd_device *obd = container_of(kobj, struct obd_device,
184 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
188 rc = kstrtouint(buffer, 0, &val);
195 ofd->ofd_atime_diff = val;
198 LUSTRE_RW_ATTR(atime_diff);
201 * Show the last used ID for each FID sequence used by OFD.
203 * \param[in] m seq_file handle
204 * \param[in] data unused for single entry
206 * \retval 0 on success
207 * \retval negative value on error
209 static int ofd_last_id_seq_show(struct seq_file *m, void *data)
211 struct obd_device *obd = m->private;
212 struct ofd_device *ofd;
213 struct ofd_seq *oseq = NULL;
218 ofd = ofd_dev(obd->obd_lu_dev);
220 read_lock(&ofd->ofd_seq_list_lock);
221 list_for_each_entry(oseq, &ofd->ofd_seq_list, os_list) {
224 seq = ostid_seq(&oseq->os_oi) == 0 ?
225 fid_idif_seq(ostid_id(&oseq->os_oi),
226 ofd->ofd_lut.lut_lsd.lsd_osd_index) & ~0xFFFF :
227 ostid_seq(&oseq->os_oi);
228 seq_printf(m, DOSTID"\n", seq, ostid_id(&oseq->os_oi));
230 read_unlock(&ofd->ofd_seq_list_lock);
234 LPROC_SEQ_FOPS_RO(ofd_last_id);
237 * Show if the OFD is in degraded mode.
239 * Degraded means OFD has a failed drive or is undergoing RAID rebuild.
240 * The MDS will try to avoid using this OST for new object allocations
241 * to reduce the impact to global IO performance when clients writing to
242 * this OST are slowed down. It also reduces the contention on the OST
243 * RAID device, allowing it to rebuild more quickly.
245 * \retval count of bytes written
247 static ssize_t degraded_show(struct kobject *kobj, struct attribute *attr,
250 struct obd_device *obd = container_of(kobj, struct obd_device,
252 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
254 return sprintf(buf, "%u\n", ofd->ofd_raid_degraded);
258 * Set OFD to degraded mode.
260 * This is used to interface to userspace administrative tools for
261 * the underlying RAID storage, so that they can mark an OST
262 * as having degraded performance.
264 * \param[in] count \a buffer length
265 * \param[in] off unused for single entry
267 * \retval \a count on success
268 * \retval negative number on error
270 static ssize_t degraded_store(struct kobject *kobj, struct attribute *attr,
271 const char *buffer, size_t count)
273 struct obd_device *obd = container_of(kobj, struct obd_device,
275 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
279 rc = kstrtobool(buffer, &val);
283 spin_lock(&ofd->ofd_flags_lock);
284 ofd->ofd_raid_degraded = val;
285 spin_unlock(&ofd->ofd_flags_lock);
288 LUSTRE_RW_ATTR(degraded);
291 * Show if the OFD is in no precreate mode.
293 * This means OFD has been adminstratively disabled at the OST to prevent
294 * the MDS from creating any new files on the OST, though existing files
295 * can still be read, written, and unlinked.
297 * \retval number of bytes written
299 static ssize_t no_precreate_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);
306 return snprintf(buf, PAGE_SIZE, "%u\n", ofd->ofd_no_precreate);
310 * Set OFD to no precreate mode.
312 * This is used to interface to userspace administrative tools to
313 * disable new object creation on the OST.
315 * \param[in] count \a buffer length
317 * \retval \a count on success
318 * \retval negative number on error
320 static ssize_t no_precreate_store(struct kobject *kobj, struct attribute *attr,
321 const char *buffer, size_t count)
323 struct obd_device *obd = container_of(kobj, struct obd_device,
325 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
329 rc = kstrtobool(buffer, &val);
333 spin_lock(&ofd->ofd_flags_lock);
334 ofd->ofd_no_precreate = val;
335 spin_unlock(&ofd->ofd_flags_lock);
339 LUSTRE_RW_ATTR(no_precreate);
342 * Show OFD filesystem type.
344 * \param[in] m seq_file handle
345 * \param[in] data unused for single entry
347 * \retval 0 on success
348 * \retval negative value on error
350 static ssize_t fstype_show(struct kobject *kobj, struct attribute *attr,
353 struct obd_device *obd = container_of(kobj, struct obd_device,
355 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
358 LASSERT(ofd->ofd_osd);
359 d = &ofd->ofd_osd->dd_lu_dev;
361 return sprintf(buf, "%s\n", d->ld_type->ldt_name);
363 LUSTRE_RO_ATTR(fstype);
366 * Show journal handling mode: synchronous or asynchronous.
368 * When running in asynchronous mode the journal transactions are not
369 * committed to disk before the RPC is replied back to the client.
370 * This will typically improve client performance when only a small number
371 * of clients are writing, since the client(s) can have more write RPCs
372 * in flight. However, it also means that the client has to handle recovery
373 * on bulk RPCs, and will have to keep more dirty pages in cache before they
374 * are committed on the OST.
376 * \param[in] m seq_file handle
377 * \param[in] data unused for single entry
379 * \retval 0 on success
380 * \retval negative value on error
382 static ssize_t sync_journal_show(struct kobject *kobj, struct attribute *attr,
385 struct obd_device *obd = container_of(kobj, struct obd_device,
387 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
389 return sprintf(buf, "%u\n", ofd->ofd_sync_journal);
393 * Set journal mode to synchronous or asynchronous.
395 * \param[in] file proc file
396 * \param[in] buffer string which represents mode
397 * 1: synchronous mode
398 * 0: asynchronous mode
399 * \param[in] count \a buffer length
400 * \param[in] off unused for single entry
402 * \retval \a count on success
403 * \retval negative number on error
405 static ssize_t sync_journal_store(struct kobject *kobj, struct attribute *attr,
406 const char *buffer, size_t count)
408 struct obd_device *obd = container_of(kobj, struct obd_device,
410 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
414 rc = kstrtobool(buffer, &val);
418 spin_lock(&ofd->ofd_flags_lock);
419 ofd->ofd_sync_journal = val;
421 spin_unlock(&ofd->ofd_flags_lock);
425 LUSTRE_RW_ATTR(sync_journal);
427 static int ofd_brw_size_seq_show(struct seq_file *m, void *data)
429 struct obd_device *obd = m->private;
430 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
432 seq_printf(m, "%u\n", ofd->ofd_brw_size / ONE_MB_BRW_SIZE);
437 ofd_brw_size_seq_write(struct file *file, const char __user *buffer,
438 size_t count, loff_t *off)
440 struct seq_file *m = file->private_data;
441 struct obd_device *obd = m->private;
442 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
443 char kernbuf[22] = "";
447 if (count >= sizeof(kernbuf))
450 if (copy_from_user(kernbuf, buffer, count))
454 rc = sysfs_memparse(kernbuf, count, &val, "MiB");
461 if (val > DT_MAX_BRW_SIZE ||
462 val < (1 << ofd->ofd_lut.lut_tgd.tgd_blockbits))
465 spin_lock(&ofd->ofd_flags_lock);
466 ofd->ofd_brw_size = val;
467 spin_unlock(&ofd->ofd_flags_lock);
471 LPROC_SEQ_FOPS(ofd_brw_size);
473 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 16, 53, 0)
474 static bool sync_on_lock_cancel_warned;
475 static ssize_t sync_on_lock_cancel_show(struct kobject *kobj,
476 struct attribute *attr, char *buf)
478 if (!sync_on_lock_cancel_warned) {
479 sync_on_lock_cancel_warned = true;
480 pr_info("ofd: 'obdfilter.*.sync_on_lock_cancel' is deprecated, use 'obdfilter.*.sync_lock_cancel' instead\n");
482 return sync_lock_cancel_show(kobj, attr, buf);
485 static ssize_t sync_on_lock_cancel_store(struct kobject *kobj,
486 struct attribute *attr,
487 const char *buffer, size_t count)
489 if (!sync_on_lock_cancel_warned) {
490 sync_on_lock_cancel_warned = true;
491 pr_info("ofd: 'obdfilter.*.sync_on_lock_cancel' is deprecated, use 'obdfilter.*.sync_lock_cancel' instead\n");
493 return sync_lock_cancel_store(kobj, attr, buffer, count);
495 LUSTRE_RW_ATTR(sync_on_lock_cancel);
499 * Show the limit of soft sync RPCs.
501 * This value defines how many IO RPCs with OBD_BRW_SOFT_SYNC flag
502 * are allowed before sync update will be triggered.
504 * \param[in] m seq_file handle
505 * \param[in] data unused for single entry
507 * \retval 0 on success
508 * \retval negative value on error
510 static ssize_t soft_sync_limit_show(struct kobject *kobj,
511 struct attribute *attr, char *buf)
513 struct obd_device *obd = container_of(kobj, struct obd_device,
515 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
517 return sprintf(buf, "%u\n", ofd->ofd_soft_sync_limit);
521 * Change the limit of soft sync RPCs.
523 * Define how many IO RPCs with OBD_BRW_SOFT_SYNC flag
524 * allowed before sync update will be done.
526 * This limit is global across all exports.
528 * \param[in] file proc file
529 * \param[in] buffer string which represents limit
530 * \param[in] count \a buffer length
531 * \param[in] off unused for single entry
533 * \retval \a count on success
534 * \retval negative number on error
536 static ssize_t soft_sync_limit_store(struct kobject *kobj,
537 struct attribute *attr,
538 const char *buffer, size_t count)
540 struct obd_device *obd = container_of(kobj, struct obd_device,
542 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
546 rc = kstrtouint(buffer, 0, &val);
550 ofd->ofd_soft_sync_limit = val;
553 LUSTRE_RW_ATTR(soft_sync_limit);
556 * Show the LFSCK speed limit.
558 * The maximum number of items scanned per second.
560 * \param[in] m seq_file handle
561 * \param[in] data unused for single entry
563 * \retval 0 on success
564 * \retval negative value on error
566 static ssize_t lfsck_speed_limit_show(struct kobject *kobj,
567 struct attribute *attr, char *buf)
569 struct obd_device *obd = container_of(kobj, struct obd_device,
571 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
573 return lfsck_get_speed(buf, ofd->ofd_osd);
577 * Change the LFSCK speed limit.
579 * Limit number of items that may be scanned per second.
581 * \param[in] file proc file
582 * \param[in] buffer string which represents limit
583 * \param[in] count \a buffer length
584 * \param[in] off unused for single entry
586 * \retval \a count on success
587 * \retval negative number on error
589 static ssize_t lfsck_speed_limit_store(struct kobject *kobj,
590 struct attribute *attr,
591 const char *buffer, size_t count)
593 struct obd_device *obd = container_of(kobj, struct obd_device,
595 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
599 rc = kstrtouint(buffer, 0, &val);
603 rc = lfsck_set_speed(ofd->ofd_osd, val);
605 return rc != 0 ? rc : count;
607 LUSTRE_RW_ATTR(lfsck_speed_limit);
610 * Show LFSCK layout verification stats from the most recent LFSCK run.
612 * \param[in] m seq_file handle
613 * \param[in] data unused for single entry
615 * \retval 0 on success
616 * \retval negative value on error
618 static int ofd_lfsck_layout_seq_show(struct seq_file *m, void *data)
620 struct obd_device *obd = m->private;
621 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
623 return lfsck_dump(m, ofd->ofd_osd, LFSCK_TYPE_LAYOUT);
626 LPROC_SEQ_FOPS_RO(ofd_lfsck_layout);
629 * Show if LFSCK performed parent FID verification.
631 * \param[in] m seq_file handle
632 * \param[in] data unused for single entry
634 * \retval 0 on success
635 * \retval negative value on error
637 static int ofd_lfsck_verify_pfid_seq_show(struct seq_file *m, void *data)
639 struct obd_device *obd = m->private;
640 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
642 seq_printf(m, "switch: %s\ndetected: %llu\nrepaired: %llu\n",
643 ofd->ofd_lfsck_verify_pfid ? "on" : "off",
644 ofd->ofd_inconsistency_self_detected,
645 ofd->ofd_inconsistency_self_repaired);
650 * Set the LFSCK behavior to verify parent FID correctness.
652 * If flag ofd_lfsck_verify_pfid is set then LFSCK does parent FID
653 * verification during read/write operations.
655 * \param[in] file proc file
656 * \param[in] buffer string which represents behavior
657 * 1: verify parent FID
658 * 0: don't verify parent FID
659 * \param[in] count \a buffer length
660 * \param[in] off unused for single entry
662 * \retval \a count on success
663 * \retval negative number on error
666 ofd_lfsck_verify_pfid_seq_write(struct file *file, const char __user *buffer,
667 size_t count, loff_t *off)
669 struct seq_file *m = file->private_data;
670 struct obd_device *obd = m->private;
671 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
675 rc = kstrtobool_from_user(buffer, count, &val);
679 ofd->ofd_lfsck_verify_pfid = val;
680 if (!ofd->ofd_lfsck_verify_pfid) {
681 ofd->ofd_inconsistency_self_detected = 0;
682 ofd->ofd_inconsistency_self_repaired = 0;
688 LPROC_SEQ_FOPS(ofd_lfsck_verify_pfid);
690 static int ofd_site_stats_seq_show(struct seq_file *m, void *data)
692 struct obd_device *obd = m->private;
694 return lu_site_stats_seq_print(obd->obd_lu_dev->ld_site, m);
697 LPROC_SEQ_FOPS_RO(ofd_site_stats);
700 * Show if the OFD enforces T10PI checksum.
702 * \param[in] m seq_file handle
703 * \param[in] data unused for single entry
705 * \retval 0 on success
706 * \retval negative value on error
708 static ssize_t checksum_t10pi_enforce_show(struct kobject *kobj,
709 struct attribute *attr,
712 struct obd_device *obd = container_of(kobj, struct obd_device,
714 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
716 return sprintf(buf, "%u\n", ofd->ofd_checksum_t10pi_enforce);
720 * Force specific T10PI checksum modes to be enabled
722 * If T10PI *is* supported in hardware, allow only the supported T10PI type
723 * to be used. If T10PI is *not* supported by the OSD, setting the enforce
724 * parameter forces all T10PI types to be enabled (even if slower) for
727 * The final determination of which algorithm to be used depends whether
728 * the client supports T10PI or not, and is handled at client connect time.
730 * \param[in] file proc file
731 * \param[in] buffer string which represents mode
732 * 1: set T10PI checksums enforced
733 * 0: unset T10PI checksums enforced
734 * \param[in] count \a buffer length
735 * \param[in] off unused for single entry
737 * \retval \a count on success
738 * \retval negative number on error
740 static ssize_t checksum_t10pi_enforce_store(struct kobject *kobj,
741 struct attribute *attr,
742 const char *buffer, size_t count)
744 struct obd_device *obd = container_of(kobj, struct obd_device,
746 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
750 rc = kstrtobool(buffer, &enforce);
754 spin_lock(&ofd->ofd_flags_lock);
755 ofd->ofd_checksum_t10pi_enforce = enforce;
756 spin_unlock(&ofd->ofd_flags_lock);
759 LUSTRE_RW_ATTR(checksum_t10pi_enforce);
761 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 14, 53, 0)
762 static bool max_file_warned;
763 static bool rd_cache_warned;
764 static bool wr_cache_warned;
766 static ssize_t read_cache_enable_show(struct kobject *kobj,
767 struct attribute *attr,
770 struct obd_device *obd = container_of(kobj, struct obd_device,
772 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
774 if (!rd_cache_warned) {
775 rd_cache_warned = true;
776 pr_info("ofd: 'obdfilter.*.read_cache_enabled' is deprecated, use 'osd-*.read_cache_enabled' instead\n");
779 if (!ofd->ofd_read_cache_enable)
782 return lustre_attr_show(&ofd->ofd_osd->dd_kobj,
783 ofd->ofd_read_cache_enable, buf);
786 static ssize_t read_cache_enable_store(struct kobject *kobj,
787 struct attribute *attr,
788 const char *buffer, size_t count)
790 struct obd_device *obd = container_of(kobj, struct obd_device,
792 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
794 if (!rd_cache_warned) {
795 rd_cache_warned = true;
796 pr_info("ofd: 'obdfilter.*.read_cache_enabled' is deprecated, use 'osd-*.read_cache_enabled' instead\n");
799 if (!ofd->ofd_read_cache_enable)
802 return lustre_attr_store(&ofd->ofd_osd->dd_kobj,
803 ofd->ofd_read_cache_enable, buffer, count);
805 LUSTRE_RW_ATTR(read_cache_enable);
807 static ssize_t readcache_max_filesize_show(struct kobject *kobj,
808 struct attribute *attr,
811 struct obd_device *obd = container_of(kobj, struct obd_device,
813 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
815 if (!max_file_warned) {
816 max_file_warned = true;
817 pr_info("ofd: 'obdfilter.*.readcache_max_filesize' is deprecated, use 'osd-*.readcache_max_filesize' instead\n");
820 if (!ofd->ofd_read_cache_max_filesize)
823 return lustre_attr_show(&ofd->ofd_osd->dd_kobj,
824 ofd->ofd_read_cache_max_filesize, buf);
827 static ssize_t readcache_max_filesize_store(struct kobject *kobj,
828 struct attribute *attr,
829 const char *buffer, size_t count)
831 struct obd_device *obd = container_of(kobj, struct obd_device,
833 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
835 if (!max_file_warned) {
836 max_file_warned = true;
837 pr_info("ofd: 'obdfilter.*.readcache_max_filesize' is deprecated, use 'osd-*.readcache_max_filesize' instead\n");
840 if (!ofd->ofd_read_cache_max_filesize)
843 return lustre_attr_store(&ofd->ofd_osd->dd_kobj,
844 ofd->ofd_read_cache_max_filesize,
847 LUSTRE_RW_ATTR(readcache_max_filesize);
849 static ssize_t writethrough_cache_enable_show(struct kobject *kobj,
850 struct attribute *attr,
853 struct obd_device *obd = container_of(kobj, struct obd_device,
855 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
857 if (!wr_cache_warned) {
858 wr_cache_warned = true;
859 pr_info("ofd: 'obdfilter.*.writethrough_cache_enabled' is deprecated, use 'osd-*.writethrough_cache_enabled' instead\n");
862 if (!ofd->ofd_write_cache_enable)
865 return lustre_attr_show(&ofd->ofd_osd->dd_kobj,
866 ofd->ofd_write_cache_enable, buf);
869 static ssize_t writethrough_cache_enable_store(struct kobject *kobj,
870 struct attribute *attr,
871 const char *buffer, size_t count)
873 struct obd_device *obd = container_of(kobj, struct obd_device,
875 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
877 if (!ofd->ofd_write_cache_enable)
880 return lustre_attr_store(&ofd->ofd_osd->dd_kobj,
881 ofd->ofd_write_cache_enable,
884 LUSTRE_RW_ATTR(writethrough_cache_enable);
887 LPROC_SEQ_FOPS_RO_TYPE(ofd, recovery_status);
888 LUSTRE_RW_ATTR(recovery_time_hard);
889 LUSTRE_RW_ATTR(recovery_time_soft);
890 LUSTRE_RW_ATTR(ir_factor);
892 LPROC_SEQ_FOPS_WR_ONLY(ofd, evict_client);
893 LPROC_SEQ_FOPS_RW_TYPE(ofd, checksum_dump);
894 LUSTRE_RW_ATTR(job_cleanup_interval);
896 LUSTRE_RO_ATTR(tot_dirty);
897 LUSTRE_RO_ATTR(tot_granted);
898 LUSTRE_RO_ATTR(tot_pending);
899 LUSTRE_RW_ATTR(grant_compat_disable);
900 LUSTRE_RO_ATTR(instance);
902 LUSTRE_RO_ATTR(num_exports);
904 struct lprocfs_vars lprocfs_ofd_obd_vars[] = {
906 .fops = &ofd_last_id_fops },
907 { .name = "recovery_status",
908 .fops = &ofd_recovery_status_fops },
909 { .name = "evict_client",
910 .fops = &ofd_evict_client_fops },
911 { .name = "brw_size",
912 .fops = &ofd_brw_size_fops },
913 { .name = "checksum_dump",
914 .fops = &ofd_checksum_dump_fops },
915 { .name = "lfsck_layout",
916 .fops = &ofd_lfsck_layout_fops },
917 { .name = "lfsck_verify_pfid",
918 .fops = &ofd_lfsck_verify_pfid_fops },
919 { .name = "site_stats",
920 .fops = &ofd_site_stats_fops },
925 * Initialize OFD statistics counters
927 * param[in] stats statistics counters
929 void ofd_stats_counter_init(struct lprocfs_stats *stats)
931 LASSERT(stats && stats->ls_num >= LPROC_OFD_STATS_LAST);
933 lprocfs_counter_init(stats, LPROC_OFD_STATS_READ,
934 LPROCFS_CNTR_AVGMINMAX, "read_bytes", "bytes");
935 lprocfs_counter_init(stats, LPROC_OFD_STATS_WRITE,
936 LPROCFS_CNTR_AVGMINMAX, "write_bytes", "bytes");
937 lprocfs_counter_init(stats, LPROC_OFD_STATS_GETATTR,
938 0, "getattr", "reqs");
939 lprocfs_counter_init(stats, LPROC_OFD_STATS_SETATTR,
940 0, "setattr", "reqs");
941 lprocfs_counter_init(stats, LPROC_OFD_STATS_PUNCH,
943 lprocfs_counter_init(stats, LPROC_OFD_STATS_SYNC,
945 lprocfs_counter_init(stats, LPROC_OFD_STATS_DESTROY,
946 0, "destroy", "reqs");
947 lprocfs_counter_init(stats, LPROC_OFD_STATS_CREATE,
948 0, "create", "reqs");
949 lprocfs_counter_init(stats, LPROC_OFD_STATS_STATFS,
950 0, "statfs", "reqs");
951 lprocfs_counter_init(stats, LPROC_OFD_STATS_GET_INFO,
952 0, "get_info", "reqs");
953 lprocfs_counter_init(stats, LPROC_OFD_STATS_SET_INFO,
954 0, "set_info", "reqs");
955 lprocfs_counter_init(stats, LPROC_OFD_STATS_QUOTACTL,
956 0, "quotactl", "reqs");
959 LPROC_SEQ_FOPS(lprocfs_nid_stats_clear);
961 static struct attribute *ofd_attrs[] = {
962 &lustre_attr_tot_dirty.attr,
963 &lustre_attr_tot_granted.attr,
964 &lustre_attr_tot_pending.attr,
965 &lustre_attr_grant_compat_disable.attr,
966 &lustre_attr_instance.attr,
967 &lustre_attr_recovery_time_hard.attr,
968 &lustre_attr_recovery_time_soft.attr,
969 &lustre_attr_ir_factor.attr,
970 &lustre_attr_num_exports.attr,
971 &lustre_attr_seqs_allocated.attr,
972 &lustre_attr_grant_precreate.attr,
973 &lustre_attr_precreate_batch.attr,
974 &lustre_attr_atime_diff.attr,
975 &lustre_attr_degraded.attr,
976 &lustre_attr_fstype.attr,
977 &lustre_attr_no_precreate.attr,
978 &lustre_attr_sync_journal.attr,
979 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 16, 53, 0)
980 &lustre_attr_sync_on_lock_cancel.attr,
982 &lustre_attr_soft_sync_limit.attr,
983 &lustre_attr_lfsck_speed_limit.attr,
984 &lustre_attr_job_cleanup_interval.attr,
985 &lustre_attr_checksum_t10pi_enforce.attr,
986 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 14, 53, 0)
987 &lustre_attr_read_cache_enable.attr,
988 &lustre_attr_readcache_max_filesize.attr,
989 &lustre_attr_writethrough_cache_enable.attr,
995 * Initialize all needed procfs entries for OFD device.
997 * \param[in] ofd OFD device
999 * \retval 0 if successful
1000 * \retval negative value on error
1002 int ofd_tunables_init(struct ofd_device *ofd)
1004 struct obd_device *obd = ofd_obd(ofd);
1005 struct proc_dir_entry *entry;
1009 /* lprocfs must be setup before the ofd so state can be safely added
1010 * to /proc incrementally as the ofd is setup
1012 obd->obd_ktype.default_attrs = ofd_attrs;
1013 obd->obd_vars = lprocfs_ofd_obd_vars;
1014 rc = lprocfs_obd_setup(obd, false);
1016 CERROR("%s: lprocfs_obd_setup failed: %d.\n",
1021 rc = tgt_tunables_init(&ofd->ofd_lut);
1023 CERROR("%s: tgt_tunables_init failed: rc = %d\n",
1025 GOTO(obd_cleanup, rc);
1028 rc = lprocfs_alloc_obd_stats(obd, LPROC_OFD_STATS_LAST);
1030 CERROR("%s: lprocfs_alloc_obd_stats failed: %d.\n",
1032 GOTO(tgt_cleanup, rc);
1035 entry = lprocfs_register("exports", obd->obd_proc_entry, NULL, NULL);
1036 if (IS_ERR(entry)) {
1037 rc = PTR_ERR(entry);
1038 CERROR("%s: error %d setting up lprocfs for %s\n",
1039 obd->obd_name, rc, "exports");
1040 GOTO(obd_free_stats, rc);
1042 obd->obd_proc_exports_entry = entry;
1044 entry = lprocfs_add_simple(obd->obd_proc_exports_entry, "clear",
1045 obd, &lprocfs_nid_stats_clear_fops);
1046 if (IS_ERR(entry)) {
1047 rc = PTR_ERR(entry);
1048 CERROR("%s: add proc entry 'clear' failed: %d.\n",
1050 GOTO(obd_free_stats, rc);
1053 ofd_stats_counter_init(obd->obd_stats);
1055 rc = lprocfs_job_stats_init(obd, LPROC_OFD_STATS_LAST,
1056 ofd_stats_counter_init);
1058 GOTO(obd_free_stats, rc);
1063 lprocfs_free_obd_stats(obd);
1065 tgt_tunables_fini(&ofd->ofd_lut);
1067 lprocfs_obd_cleanup(obd);
1071 #endif /* CONFIG_PROC_FS */