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 maximum number of Filter Modification Data (FMD) maintained by OFD.
188 * \param[in] m seq_file handle
189 * \param[in] data unused for single entry
191 * \retval 0 on success
192 * \retval negative value on error
194 static ssize_t client_cache_count_show(struct kobject *kobj,
195 struct attribute *attr,
198 struct obd_device *obd = container_of(kobj, struct obd_device,
200 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
202 return sprintf(buf, "%u\n", ofd->ofd_fmd_max_num);
206 * Change number of FMDs maintained by OFD.
208 * This defines how large the list of FMDs can be.
210 * \param[in] file proc file
211 * \param[in] buffer string which represents maximum number
212 * \param[in] count \a buffer length
213 * \param[in] off unused for single entry
215 * \retval \a count on success
216 * \retval negative number on error
218 static ssize_t client_cache_count_store(struct kobject *kobj,
219 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 = kstrtoint(buffer, 0, &val);
232 if (val < 1 || val > 65536)
235 ofd->ofd_fmd_max_num = val;
238 LUSTRE_RW_ATTR(client_cache_count);
241 * Show the maximum age of FMD data in seconds.
243 * \param[in] m seq_file handle
244 * \param[in] data unused for single entry
246 * \retval 0 on success
247 * \retval negative value on error
249 static ssize_t client_cache_seconds_show(struct kobject *kobj,
250 struct attribute *attr,
253 struct obd_device *obd = container_of(kobj, struct obd_device,
255 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
257 return sprintf(buf, "%lld\n", ofd->ofd_fmd_max_age);
261 * Set the maximum age of FMD data in seconds.
263 * This defines how long FMD data stays in the FMD list.
265 * \param[in] file proc file
266 * \param[in] buffer string which represents maximum number
267 * \param[in] count \a buffer length
268 * \param[in] off unused for single entry
270 * \retval \a count on success
271 * \retval negative number on error
273 static ssize_t client_cache_seconds_store(struct kobject *kobj,
274 struct attribute *attr,
275 const char *buffer, size_t count)
277 struct obd_device *obd = container_of(kobj, struct obd_device,
279 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
283 rc = kstrtoll(buffer, 0, &val);
287 if (val < 1 || val > 65536) /* ~ 18 hour max */
290 ofd->ofd_fmd_max_age = val;
293 LUSTRE_RW_ATTR(client_cache_seconds);
296 * Show if the OFD is in degraded mode.
298 * Degraded means OFD has a failed drive or is undergoing RAID rebuild.
299 * The MDS will try to avoid using this OST for new object allocations
300 * to reduce the impact to global IO performance when clients writing to
301 * this OST are slowed down. It also reduces the contention on the OST
302 * RAID device, allowing it to rebuild more quickly.
304 * \param[in] m seq_file handle
305 * \param[in] data unused for single entry
307 * \retval 0 on success
308 * \retval negative value on error
310 static ssize_t degraded_show(struct kobject *kobj, struct attribute *attr,
313 struct obd_device *obd = container_of(kobj, struct obd_device,
315 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
317 return sprintf(buf, "%u\n", ofd->ofd_raid_degraded);
321 * Set OFD to degraded mode.
323 * This is used to interface to userspace administrative tools for
324 * the underlying RAID storage, so that they can mark an OST
325 * as having degraded performance.
327 * \param[in] file proc file
328 * \param[in] buffer string which represents mode
329 * 1: set degraded mode
330 * 0: unset degraded mode
331 * \param[in] count \a buffer length
332 * \param[in] off unused for single entry
334 * \retval \a count on success
335 * \retval negative number on error
337 static ssize_t degraded_store(struct kobject *kobj, struct attribute *attr,
338 const char *buffer, size_t count)
340 struct obd_device *obd = container_of(kobj, struct obd_device,
342 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
346 rc = kstrtobool(buffer, &val);
350 spin_lock(&ofd->ofd_flags_lock);
351 ofd->ofd_raid_degraded = val;
352 spin_unlock(&ofd->ofd_flags_lock);
355 LUSTRE_RW_ATTR(degraded);
358 * Show OFD filesystem type.
360 * \param[in] m seq_file handle
361 * \param[in] data unused for single entry
363 * \retval 0 on success
364 * \retval negative value on error
366 static ssize_t fstype_show(struct kobject *kobj, struct attribute *attr,
369 struct obd_device *obd = container_of(kobj, struct obd_device,
371 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
374 LASSERT(ofd->ofd_osd);
375 d = &ofd->ofd_osd->dd_lu_dev;
377 return sprintf(buf, "%s\n", d->ld_type->ldt_name);
379 LUSTRE_RO_ATTR(fstype);
382 * Show journal handling mode: synchronous or asynchronous.
384 * When running in asynchronous mode the journal transactions are not
385 * committed to disk before the RPC is replied back to the client.
386 * This will typically improve client performance when only a small number
387 * of clients are writing, since the client(s) can have more write RPCs
388 * in flight. However, it also means that the client has to handle recovery
389 * on bulk RPCs, and will have to keep more dirty pages in cache before they
390 * are committed on the OST.
392 * \param[in] m seq_file handle
393 * \param[in] data unused for single entry
395 * \retval 0 on success
396 * \retval negative value on error
398 static ssize_t syncjournal_show(struct kobject *kobj, struct attribute *attr,
401 struct obd_device *obd = container_of(kobj, struct obd_device,
403 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
405 return sprintf(buf, "%u\n", ofd->ofd_syncjournal);
409 * Set journal mode to synchronous or asynchronous.
411 * \param[in] file proc file
412 * \param[in] buffer string which represents mode
413 * 1: synchronous mode
414 * 0: asynchronous mode
415 * \param[in] count \a buffer length
416 * \param[in] off unused for single entry
418 * \retval \a count on success
419 * \retval negative number on error
421 static ssize_t syncjournal_store(struct kobject *kobj, struct attribute *attr,
422 const char *buffer, size_t count)
424 struct obd_device *obd = container_of(kobj, struct obd_device,
426 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
430 rc = kstrtobool(buffer, &val);
434 spin_lock(&ofd->ofd_flags_lock);
435 ofd->ofd_syncjournal = val;
437 spin_unlock(&ofd->ofd_flags_lock);
441 LUSTRE_RW_ATTR(syncjournal);
443 /* This must be longer than the longest string below */
444 #define SYNC_STATES_MAXLEN 16
446 static int ofd_brw_size_seq_show(struct seq_file *m, void *data)
448 struct obd_device *obd = m->private;
449 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
451 seq_printf(m, "%u\n", ofd->ofd_brw_size / ONE_MB_BRW_SIZE);
456 ofd_brw_size_seq_write(struct file *file, const char __user *buffer,
457 size_t count, loff_t *off)
459 struct seq_file *m = file->private_data;
460 struct obd_device *obd = m->private;
461 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
465 rc = lprocfs_str_with_units_to_s64(buffer, count, &val, 'M');
472 if (val > DT_MAX_BRW_SIZE ||
473 val < (1 << ofd->ofd_lut.lut_tgd.tgd_blockbits))
476 spin_lock(&ofd->ofd_flags_lock);
477 ofd->ofd_brw_size = val;
478 spin_unlock(&ofd->ofd_flags_lock);
483 LPROC_SEQ_FOPS(ofd_brw_size);
485 static char *sync_on_cancel_states[] = {"never",
490 * Show OFD policy for handling dirty data under a lock being cancelled.
492 * \param[in] m seq_file handle
493 * \param[in] data unused for single entry
495 * \retval 0 on success
496 * \retval negative value on error
498 static ssize_t sync_lock_cancel_show(struct kobject *kobj,
499 struct attribute *attr, char *buf)
501 struct obd_device *obd = container_of(kobj, struct obd_device,
503 struct lu_target *tgt = obd->u.obt.obt_lut;
505 return sprintf(buf, "%s\n",
506 sync_on_cancel_states[tgt->lut_sync_lock_cancel]);
510 * Change OFD policy for handling dirty data under a lock being cancelled.
512 * This variable defines what action OFD takes upon lock cancel
513 * There are three possible modes:
514 * 1) never - never do sync upon lock cancel. This can lead to data
515 * inconsistencies if both the OST and client crash while writing a file
516 * that is also concurrently being read by another client. In these cases,
517 * this may allow the file data to "rewind" to an earlier state.
518 * 2) blocking - do sync only if there is blocking lock, e.g. if another
519 * client is trying to access this same object
520 * 3) always - do sync always
522 * \param[in] file proc file
523 * \param[in] buffer string which represents policy
524 * \param[in] count \a buffer length
525 * \param[in] off unused for single entry
527 * \retval \a count on success
528 * \retval negative number on error
530 static ssize_t sync_lock_cancel_store(struct kobject *kobj,
531 struct attribute *attr,
532 const char *buffer, size_t count)
534 struct obd_device *obd = container_of(kobj, struct obd_device,
536 struct lu_target *tgt = obd->u.obt.obt_lut;
540 if (count == 0 || count >= SYNC_STATES_MAXLEN)
543 for (i = 0 ; i < NUM_SYNC_ON_CANCEL_STATES; i++) {
544 if (strcmp(buffer, sync_on_cancel_states[i]) == 0) {
550 /* Legacy numeric codes */
552 int rc = kstrtoint(buffer, 0, &val);
557 if (val < 0 || val > 2)
560 spin_lock(&tgt->lut_flags_lock);
561 tgt->lut_sync_lock_cancel = val;
562 spin_unlock(&tgt->lut_flags_lock);
565 LUSTRE_RW_ATTR(sync_lock_cancel);
568 * Show the limit of soft sync RPCs.
570 * This value defines how many IO RPCs with OBD_BRW_SOFT_SYNC flag
571 * are allowed before sync update will be triggered.
573 * \param[in] m seq_file handle
574 * \param[in] data unused for single entry
576 * \retval 0 on success
577 * \retval negative value on error
579 static ssize_t soft_sync_limit_show(struct kobject *kobj,
580 struct attribute *attr, char *buf)
582 struct obd_device *obd = container_of(kobj, struct obd_device,
584 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
586 return sprintf(buf, "%u\n", ofd->ofd_soft_sync_limit);
590 * Change the limit of soft sync RPCs.
592 * Define how many IO RPCs with OBD_BRW_SOFT_SYNC flag
593 * allowed before sync update will be done.
595 * This limit is global across all exports.
597 * \param[in] file proc file
598 * \param[in] buffer string which represents limit
599 * \param[in] count \a buffer length
600 * \param[in] off unused for single entry
602 * \retval \a count on success
603 * \retval negative number on error
605 static ssize_t soft_sync_limit_store(struct kobject *kobj,
606 struct attribute *attr,
607 const char *buffer, size_t count)
609 struct obd_device *obd = container_of(kobj, struct obd_device,
611 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
615 rc = kstrtouint(buffer, 0, &val);
619 ofd->ofd_soft_sync_limit = val;
622 LUSTRE_RW_ATTR(soft_sync_limit);
625 * Show the LFSCK speed limit.
627 * The maximum number of items scanned per second.
629 * \param[in] m seq_file handle
630 * \param[in] data unused for single entry
632 * \retval 0 on success
633 * \retval negative value on error
635 static ssize_t lfsck_speed_limit_show(struct kobject *kobj,
636 struct attribute *attr, char *buf)
638 struct obd_device *obd = container_of(kobj, struct obd_device,
640 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
642 return lfsck_get_speed(NULL, buf, ofd->ofd_osd);
646 * Change the LFSCK speed limit.
648 * Limit number of items that may be scanned per second.
650 * \param[in] file proc file
651 * \param[in] buffer string which represents limit
652 * \param[in] count \a buffer length
653 * \param[in] off unused for single entry
655 * \retval \a count on success
656 * \retval negative number on error
658 static ssize_t lfsck_speed_limit_store(struct kobject *kobj,
659 struct attribute *attr,
660 const char *buffer, size_t count)
662 struct obd_device *obd = container_of(kobj, struct obd_device,
664 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
668 rc = kstrtouint(buffer, 0, &val);
672 rc = lfsck_set_speed(ofd->ofd_osd, val);
674 return rc != 0 ? rc : count;
676 LUSTRE_RW_ATTR(lfsck_speed_limit);
679 * Show LFSCK layout verification stats from the most recent LFSCK run.
681 * \param[in] m seq_file handle
682 * \param[in] data unused for single entry
684 * \retval 0 on success
685 * \retval negative value on error
687 static int ofd_lfsck_layout_seq_show(struct seq_file *m, void *data)
689 struct obd_device *obd = m->private;
690 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
692 return lfsck_dump(m, ofd->ofd_osd, LFSCK_TYPE_LAYOUT);
695 LPROC_SEQ_FOPS_RO(ofd_lfsck_layout);
698 * Show if LFSCK performed parent FID verification.
700 * \param[in] m seq_file handle
701 * \param[in] data unused for single entry
703 * \retval 0 on success
704 * \retval negative value on error
706 static int ofd_lfsck_verify_pfid_seq_show(struct seq_file *m, void *data)
708 struct obd_device *obd = m->private;
709 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
711 seq_printf(m, "switch: %s\ndetected: %llu\nrepaired: %llu\n",
712 ofd->ofd_lfsck_verify_pfid ? "on" : "off",
713 ofd->ofd_inconsistency_self_detected,
714 ofd->ofd_inconsistency_self_repaired);
719 * Set the LFSCK behavior to verify parent FID correctness.
721 * If flag ofd_lfsck_verify_pfid is set then LFSCK does parent FID
722 * verification during read/write operations.
724 * \param[in] file proc file
725 * \param[in] buffer string which represents behavior
726 * 1: verify parent FID
727 * 0: don't verify parent FID
728 * \param[in] count \a buffer length
729 * \param[in] off unused for single entry
731 * \retval \a count on success
732 * \retval negative number on error
735 ofd_lfsck_verify_pfid_seq_write(struct file *file, const char __user *buffer,
736 size_t count, loff_t *off)
738 struct seq_file *m = file->private_data;
739 struct obd_device *obd = m->private;
740 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
744 rc = kstrtobool_from_user(buffer, count, &val);
748 ofd->ofd_lfsck_verify_pfid = val;
749 if (!ofd->ofd_lfsck_verify_pfid) {
750 ofd->ofd_inconsistency_self_detected = 0;
751 ofd->ofd_inconsistency_self_repaired = 0;
757 LPROC_SEQ_FOPS(ofd_lfsck_verify_pfid);
759 static int ofd_site_stats_seq_show(struct seq_file *m, void *data)
761 struct obd_device *obd = m->private;
763 return lu_site_stats_seq_print(obd->obd_lu_dev->ld_site, m);
766 LPROC_SEQ_FOPS_RO(ofd_site_stats);
769 * Show if the OFD enforces T10PI checksum.
771 * \param[in] m seq_file handle
772 * \param[in] data unused for single entry
774 * \retval 0 on success
775 * \retval negative value on error
777 static ssize_t checksum_t10pi_enforce_show(struct kobject *kobj,
778 struct attribute *attr,
781 struct obd_device *obd = container_of(kobj, struct obd_device,
783 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
785 return sprintf(buf, "%u\n", ofd->ofd_checksum_t10pi_enforce);
789 * Force specific T10PI checksum modes to be enabled
791 * If T10PI *is* supported in hardware, allow only the supported T10PI type
792 * to be used. If T10PI is *not* supported by the OSD, setting the enforce
793 * parameter forces all T10PI types to be enabled (even if slower) for
796 * The final determination of which algorithm to be used depends whether
797 * the client supports T10PI or not, and is handled at client connect time.
799 * \param[in] file proc file
800 * \param[in] buffer string which represents mode
801 * 1: set T10PI checksums enforced
802 * 0: unset T10PI checksums enforced
803 * \param[in] count \a buffer length
804 * \param[in] off unused for single entry
806 * \retval \a count on success
807 * \retval negative number on error
809 static ssize_t checksum_t10pi_enforce_store(struct kobject *kobj,
810 struct attribute *attr,
811 const char *buffer, size_t count)
813 struct obd_device *obd = container_of(kobj, struct obd_device,
815 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
819 rc = kstrtobool(buffer, &enforce);
823 spin_lock(&ofd->ofd_flags_lock);
824 ofd->ofd_checksum_t10pi_enforce = enforce;
825 spin_unlock(&ofd->ofd_flags_lock);
828 LUSTRE_RW_ATTR(checksum_t10pi_enforce);
830 LPROC_SEQ_FOPS_RO_TYPE(ofd, recovery_status);
831 LPROC_SEQ_FOPS_RW_TYPE(ofd, recovery_time_soft);
832 LPROC_SEQ_FOPS_RW_TYPE(ofd, recovery_time_hard);
833 LPROC_SEQ_FOPS_WR_ONLY(ofd, evict_client);
834 LPROC_SEQ_FOPS_RO_TYPE(ofd, num_exports);
835 LPROC_SEQ_FOPS_RO_TYPE(ofd, target_instance);
836 LPROC_SEQ_FOPS_RW_TYPE(ofd, ir_factor);
837 LPROC_SEQ_FOPS_RW_TYPE(ofd, checksum_dump);
838 LPROC_SEQ_FOPS_RW_TYPE(ofd, job_interval);
840 LPROC_SEQ_FOPS_RO(tgt_tot_dirty);
841 LPROC_SEQ_FOPS_RO(tgt_tot_granted);
842 LPROC_SEQ_FOPS_RO(tgt_tot_pending);
843 LPROC_SEQ_FOPS(tgt_grant_compat_disable);
845 struct lprocfs_vars lprocfs_ofd_obd_vars[] = {
847 .fops = &ofd_last_id_fops },
848 { .name = "tot_dirty",
849 .fops = &tgt_tot_dirty_fops },
850 { .name = "tot_pending",
851 .fops = &tgt_tot_pending_fops },
852 { .name = "tot_granted",
853 .fops = &tgt_tot_granted_fops },
854 { .name = "recovery_status",
855 .fops = &ofd_recovery_status_fops },
856 { .name = "recovery_time_soft",
857 .fops = &ofd_recovery_time_soft_fops },
858 { .name = "recovery_time_hard",
859 .fops = &ofd_recovery_time_hard_fops },
860 { .name = "evict_client",
861 .fops = &ofd_evict_client_fops },
862 { .name = "num_exports",
863 .fops = &ofd_num_exports_fops },
864 { .name = "brw_size",
865 .fops = &ofd_brw_size_fops },
866 { .name = "instance",
867 .fops = &ofd_target_instance_fops },
868 { .name = "ir_factor",
869 .fops = &ofd_ir_factor_fops },
870 { .name = "checksum_dump",
871 .fops = &ofd_checksum_dump_fops },
872 { .name = "grant_compat_disable",
873 .fops = &tgt_grant_compat_disable_fops },
874 { .name = "job_cleanup_interval",
875 .fops = &ofd_job_interval_fops },
876 { .name = "lfsck_layout",
877 .fops = &ofd_lfsck_layout_fops },
878 { .name = "lfsck_verify_pfid",
879 .fops = &ofd_lfsck_verify_pfid_fops },
880 { .name = "site_stats",
881 .fops = &ofd_site_stats_fops },
886 * Initialize OFD statistics counters
888 * param[in] stats statistics counters
890 void ofd_stats_counter_init(struct lprocfs_stats *stats)
892 LASSERT(stats && stats->ls_num >= LPROC_OFD_STATS_LAST);
894 lprocfs_counter_init(stats, LPROC_OFD_STATS_READ,
895 LPROCFS_CNTR_AVGMINMAX, "read_bytes", "bytes");
896 lprocfs_counter_init(stats, LPROC_OFD_STATS_WRITE,
897 LPROCFS_CNTR_AVGMINMAX, "write_bytes", "bytes");
898 lprocfs_counter_init(stats, LPROC_OFD_STATS_GETATTR,
899 0, "getattr", "reqs");
900 lprocfs_counter_init(stats, LPROC_OFD_STATS_SETATTR,
901 0, "setattr", "reqs");
902 lprocfs_counter_init(stats, LPROC_OFD_STATS_PUNCH,
904 lprocfs_counter_init(stats, LPROC_OFD_STATS_SYNC,
906 lprocfs_counter_init(stats, LPROC_OFD_STATS_DESTROY,
907 0, "destroy", "reqs");
908 lprocfs_counter_init(stats, LPROC_OFD_STATS_CREATE,
909 0, "create", "reqs");
910 lprocfs_counter_init(stats, LPROC_OFD_STATS_STATFS,
911 0, "statfs", "reqs");
912 lprocfs_counter_init(stats, LPROC_OFD_STATS_GET_INFO,
913 0, "get_info", "reqs");
914 lprocfs_counter_init(stats, LPROC_OFD_STATS_SET_INFO,
915 0, "set_info", "reqs");
916 lprocfs_counter_init(stats, LPROC_OFD_STATS_QUOTACTL,
917 0, "quotactl", "reqs");
920 LPROC_SEQ_FOPS(lprocfs_nid_stats_clear);
922 static struct attribute *ofd_attrs[] = {
923 &lustre_attr_seqs_allocated.attr,
924 &lustre_attr_grant_precreate.attr,
925 &lustre_attr_precreate_batch.attr,
926 &lustre_attr_client_cache_count.attr,
927 &lustre_attr_client_cache_seconds.attr,
928 &lustre_attr_degraded.attr,
929 &lustre_attr_fstype.attr,
930 &lustre_attr_syncjournal.attr,
931 &lustre_attr_sync_lock_cancel.attr,
932 &lustre_attr_soft_sync_limit.attr,
933 &lustre_attr_lfsck_speed_limit.attr,
934 &lustre_attr_checksum_t10pi_enforce.attr,
939 * Initialize all needed procfs entries for OFD device.
941 * \param[in] ofd OFD device
943 * \retval 0 if successful
944 * \retval negative value on error
946 int ofd_tunables_init(struct ofd_device *ofd)
948 struct obd_device *obd = ofd_obd(ofd);
949 struct proc_dir_entry *entry;
953 /* lprocfs must be setup before the ofd so state can be safely added
954 * to /proc incrementally as the ofd is setup
956 obd->obd_ktype.default_attrs = ofd_attrs;
957 obd->obd_vars = lprocfs_ofd_obd_vars;
958 rc = lprocfs_obd_setup(obd, false);
960 CERROR("%s: lprocfs_obd_setup failed: %d.\n",
965 rc = lprocfs_alloc_obd_stats(obd, LPROC_OFD_STATS_LAST);
967 CERROR("%s: lprocfs_alloc_obd_stats failed: %d.\n",
969 GOTO(obd_cleanup, rc);
972 entry = lprocfs_register("exports", obd->obd_proc_entry, NULL, NULL);
975 CERROR("%s: error %d setting up lprocfs for %s\n",
976 obd->obd_name, rc, "exports");
977 GOTO(obd_free_stats, rc);
979 obd->obd_proc_exports_entry = entry;
981 entry = lprocfs_add_simple(obd->obd_proc_exports_entry, "clear",
982 obd, &lprocfs_nid_stats_clear_fops);
985 CERROR("%s: add proc entry 'clear' failed: %d.\n",
987 GOTO(obd_free_stats, rc);
990 ofd_stats_counter_init(obd->obd_stats);
992 rc = lprocfs_job_stats_init(obd, LPROC_OFD_STATS_LAST,
993 ofd_stats_counter_init);
995 GOTO(obd_free_stats, rc);
1000 lprocfs_free_obd_stats(obd);
1002 lprocfs_obd_cleanup(obd);
1006 #endif /* CONFIG_PROC_FS */