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/
31 * lustre/ofd/lproc_ofd.c
33 * This file provides functions of procfs interface for OBD Filter Device (OFD).
35 * Author: Andreas Dilger <andreas.dilger@intel.com>
36 * Author: Mikhail Pershin <mike.pershin@intel.com>
37 * Author: Johann Lombardi <johann.lombardi@intel.com>
38 * Author: Fan Yong <fan.yong@intel.com>
41 #define DEBUG_SUBSYSTEM S_CLASS
44 #include <lprocfs_status.h>
45 #include <linux/seq_file.h>
46 #include <lustre_lfsck.h>
47 #include <uapi/linux/lustre/lustre_access_log.h>
48 #include <obd_cksum.h>
50 #include "ofd_internal.h"
55 * Show number of FID allocation sequences.
57 * \param[in] m seq_file handle
58 * \param[in] data unused for single entry
60 * \retval 0 on success
61 * \retval negative value on error
63 static ssize_t seqs_allocated_show(struct kobject *kobj, struct attribute *attr,
66 struct obd_device *obd = container_of(kobj, struct obd_device,
68 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
70 return sprintf(buf, "%u\n", ofd->ofd_seq_count);
72 LUSTRE_RO_ATTR(seqs_allocated);
75 * Show total number of grants for precreate.
77 * \param[in] m seq_file handle
78 * \param[in] data unused for single entry
80 * \retval 0 on success
81 * \retval negative value on error
83 static ssize_t grant_precreate_show(struct kobject *kobj,
84 struct attribute *attr,
87 struct obd_device *obd = container_of(kobj, struct obd_device,
90 return sprintf(buf, "%ld\n",
91 obd->obd_self_export->exp_target_data.ted_grant);
93 LUSTRE_RO_ATTR(grant_precreate);
96 * Show number of precreates allowed in a single transaction.
98 * \param[in] m seq_file handle
99 * \param[in] data unused for single entry
101 * \retval 0 on success
102 * \retval negative value on error
104 static ssize_t precreate_batch_show(struct kobject *kobj,
105 struct attribute *attr,
108 struct obd_device *obd = container_of(kobj, struct obd_device,
110 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
112 return sprintf(buf, "%d\n", ofd->ofd_precreate_batch);
116 * Change number of precreates allowed in a single transaction.
118 * \param[in] file proc file
119 * \param[in] buffer string which represents maximum number
120 * \param[in] count \a buffer length
121 * \param[in] off unused for single entry
123 * \retval \a count on success
124 * \retval negative number on error
126 static ssize_t precreate_batch_store(struct kobject *kobj,
127 struct attribute *attr,
128 const char *buffer, size_t count)
130 struct obd_device *obd = container_of(kobj, struct obd_device,
132 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
136 rc = kstrtouint(buffer, 0, &val);
140 if (val < 1 || val > 65536)
143 spin_lock(&ofd->ofd_batch_lock);
144 ofd->ofd_precreate_batch = val;
145 spin_unlock(&ofd->ofd_batch_lock);
148 LUSTRE_RW_ATTR(precreate_batch);
151 * Show number of seconds to delay atime
153 * \param[in] m seq_file handle
154 * \param[in] data unused for single entry
156 * \retval 0 on success
157 * \retval negative value on error
159 static ssize_t atime_diff_show(struct kobject *kobj, struct attribute *attr,
162 struct obd_device *obd = container_of(kobj, struct obd_device,
164 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
166 return scnprintf(buf, PAGE_SIZE, "%lld\n", ofd->ofd_atime_diff);
170 * Change number of seconds to delay atime
172 * \param[in] file proc file
173 * \param[in] buffer string which represents maximum number
174 * \param[in] count \a buffer length
175 * \param[in] off unused for single entry
177 * \retval \a count on success
178 * \retval negative number on error
180 static ssize_t atime_diff_store(struct kobject *kobj, struct attribute *attr,
181 const char *buffer, size_t count)
183 struct obd_device *obd = container_of(kobj, struct obd_device,
185 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
189 rc = kstrtouint(buffer, 0, &val);
196 ofd->ofd_atime_diff = val;
199 LUSTRE_RW_ATTR(atime_diff);
202 * Show the last used ID for each FID sequence used by OFD.
204 * \param[in] m seq_file handle
205 * \param[in] data unused for single entry
207 * \retval 0 on success
208 * \retval negative value on error
210 static int ofd_last_id_seq_show(struct seq_file *m, void *data)
212 struct obd_device *obd = m->private;
213 struct ofd_device *ofd;
214 struct ofd_seq *oseq = NULL;
219 ofd = ofd_dev(obd->obd_lu_dev);
221 read_lock(&ofd->ofd_seq_list_lock);
222 list_for_each_entry(oseq, &ofd->ofd_seq_list, os_list) {
225 seq = ostid_seq(&oseq->os_oi) == 0 ?
226 fid_idif_seq(ostid_id(&oseq->os_oi),
227 ofd->ofd_lut.lut_lsd.lsd_osd_index) & ~0xFFFF :
228 ostid_seq(&oseq->os_oi);
229 seq_printf(m, DOSTID"\n", seq, ostid_id(&oseq->os_oi));
231 read_unlock(&ofd->ofd_seq_list_lock);
235 LPROC_SEQ_FOPS_RO(ofd_last_id);
238 * Show if the OFD is in degraded mode.
240 * Degraded means OFD has a failed drive or is undergoing RAID rebuild.
241 * The MDS will try to avoid using this OST for new object allocations
242 * to reduce the impact to global IO performance when clients writing to
243 * this OST are slowed down. It also reduces the contention on the OST
244 * RAID device, allowing it to rebuild more quickly.
246 * \retval count of bytes written
248 static ssize_t degraded_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 sprintf(buf, "%u\n", ofd->ofd_raid_degraded);
259 * Set OFD to degraded mode.
261 * This is used to interface to userspace administrative tools for
262 * the underlying RAID storage, so that they can mark an OST
263 * as having degraded performance.
265 * \param[in] count \a buffer length
266 * \param[in] off unused for single entry
268 * \retval \a count on success
269 * \retval negative number on error
271 static ssize_t degraded_store(struct kobject *kobj, struct attribute *attr,
272 const char *buffer, size_t count)
274 struct obd_device *obd = container_of(kobj, struct obd_device,
276 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
280 rc = kstrtobool(buffer, &val);
284 spin_lock(&ofd->ofd_flags_lock);
285 ofd->ofd_raid_degraded = val;
286 spin_unlock(&ofd->ofd_flags_lock);
289 LUSTRE_RW_ATTR(degraded);
292 * Show if the OFD is in no precreate mode.
294 * This means OFD has been adminstratively disabled at the OST to prevent
295 * the MDS from creating any new files on the OST, though existing files
296 * can still be read, written, and unlinked.
298 * \retval number of bytes written
300 static ssize_t no_create_show(struct kobject *kobj, struct attribute *attr,
303 struct obd_device *obd = container_of(kobj, struct obd_device,
305 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
307 return scnprintf(buf, PAGE_SIZE, "%u\n", ofd->ofd_lut.lut_no_create);
311 * Set OFD to no create mode.
313 * This is used to interface to userspace administrative tools to
314 * disable new object creation on the OST.
316 * \param[in] count \a buffer length
318 * \retval \a count on success
319 * \retval negative number on error
321 static ssize_t no_create_store(struct kobject *kobj, struct attribute *attr,
322 const char *buffer, size_t count)
324 struct obd_device *obd = container_of(kobj, struct obd_device,
326 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
330 rc = kstrtobool(buffer, &val);
334 spin_lock(&ofd->ofd_flags_lock);
335 ofd->ofd_lut.lut_no_create = val;
336 spin_unlock(&ofd->ofd_flags_lock);
340 LUSTRE_RW_ATTR(no_create);
342 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 20, 53, 0)
343 /* compatibility entry for a few releases */
344 #define no_precreate_show no_create_show
345 #define no_precreate_store no_create_store
346 LUSTRE_RW_ATTR(no_precreate);
350 * Show OFD filesystem type.
352 * \param[in] m seq_file handle
353 * \param[in] data unused for single entry
355 * \retval 0 on success
356 * \retval negative value on error
358 static ssize_t fstype_show(struct kobject *kobj, struct attribute *attr,
361 struct obd_device *obd = container_of(kobj, struct obd_device,
363 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
366 LASSERT(ofd->ofd_osd);
367 d = &ofd->ofd_osd->dd_lu_dev;
369 return sprintf(buf, "%s\n", d->ld_type->ldt_name);
371 LUSTRE_RO_ATTR(fstype);
374 * Show journal handling mode: synchronous or asynchronous.
376 * When running in asynchronous mode the journal transactions are not
377 * committed to disk before the RPC is replied back to the client.
378 * This will typically improve client performance when only a small number
379 * of clients are writing, since the client(s) can have more write RPCs
380 * in flight. However, it also means that the client has to handle recovery
381 * on bulk RPCs, and will have to keep more dirty pages in cache before they
382 * are committed on the OST.
384 * \param[in] m seq_file handle
385 * \param[in] data unused for single entry
387 * \retval 0 on success
388 * \retval negative value on error
390 static ssize_t sync_journal_show(struct kobject *kobj, struct attribute *attr,
393 struct obd_device *obd = container_of(kobj, struct obd_device,
395 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
397 return sprintf(buf, "%u\n", ofd->ofd_sync_journal);
401 * Set journal mode to synchronous or asynchronous.
403 * \param[in] file proc file
404 * \param[in] buffer string which represents mode
405 * 1: synchronous mode
406 * 0: asynchronous mode
407 * \param[in] count \a buffer length
408 * \param[in] off unused for single entry
410 * \retval \a count on success
411 * \retval negative number on error
413 static ssize_t sync_journal_store(struct kobject *kobj, struct attribute *attr,
414 const char *buffer, size_t count)
416 struct obd_device *obd = container_of(kobj, struct obd_device,
418 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
422 rc = kstrtobool(buffer, &val);
426 spin_lock(&ofd->ofd_flags_lock);
427 ofd->ofd_sync_journal = val;
429 spin_unlock(&ofd->ofd_flags_lock);
433 LUSTRE_RW_ATTR(sync_journal);
435 static int ofd_brw_size_seq_show(struct seq_file *m, void *data)
437 struct obd_device *obd = m->private;
438 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
440 seq_printf(m, "%u\n", ofd->ofd_brw_size / ONE_MB_BRW_SIZE);
445 ofd_brw_size_seq_write(struct file *file, const char __user *buffer,
446 size_t count, loff_t *off)
448 struct seq_file *m = file->private_data;
449 struct obd_device *obd = m->private;
450 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
451 char kernbuf[22] = "";
455 if (count >= sizeof(kernbuf))
458 if (copy_from_user(kernbuf, buffer, count))
462 rc = sysfs_memparse(kernbuf, count, &val, "MiB");
469 if (val > DT_MAX_BRW_SIZE ||
470 val < (1 << ofd->ofd_lut.lut_tgd.tgd_blockbits))
473 spin_lock(&ofd->ofd_flags_lock);
474 ofd->ofd_brw_size = val;
475 spin_unlock(&ofd->ofd_flags_lock);
479 LPROC_SEQ_FOPS(ofd_brw_size);
482 * ofd_checksum_type(server) proc handling
486 static int ofd_checksum_type_seq_show(struct seq_file *m, void *data)
488 struct obd_device *obd = m->private;
489 struct lu_target *lut;
490 enum cksum_types pref;
496 lut = obd2obt(obd)->obt_lut;
497 /* select fastest checksum type on the server */
498 pref = obd_cksum_type_select(obd->obd_name,
499 lut->lut_cksum_types_supported,
500 lut->lut_dt_conf.ddp_t10_cksum_type);
502 for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
503 if ((BIT(i) & lut->lut_cksum_types_supported) == 0)
507 seq_printf(m, "[%s] ", cksum_name[i]);
509 seq_printf(m, "%s ", cksum_name[i]);
516 LPROC_SEQ_FOPS_RO(ofd_checksum_type);
519 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 16, 53, 0)
520 static ssize_t sync_on_lock_cancel_show(struct kobject *kobj,
521 struct attribute *attr, char *buf)
523 return sync_lock_cancel_show(kobj, attr, buf);
526 static ssize_t sync_on_lock_cancel_store(struct kobject *kobj,
527 struct attribute *attr,
528 const char *buffer, size_t count)
530 static bool sync_on_lock_cancel_warned;
532 if (!sync_on_lock_cancel_warned) {
533 sync_on_lock_cancel_warned = true;
534 pr_info("ofd: 'obdfilter.*.sync_on_lock_cancel' is deprecated, use 'obdfilter.*.sync_lock_cancel' instead\n");
536 return sync_lock_cancel_store(kobj, attr, buffer, count);
538 LUSTRE_RW_ATTR(sync_on_lock_cancel);
542 * Show the limit of soft sync RPCs.
544 * This value defines how many IO RPCs with OBD_BRW_SOFT_SYNC flag
545 * are allowed before sync update will be triggered.
547 * \param[in] m seq_file handle
548 * \param[in] data unused for single entry
550 * \retval 0 on success
551 * \retval negative value on error
553 static ssize_t soft_sync_limit_show(struct kobject *kobj,
554 struct attribute *attr, char *buf)
556 struct obd_device *obd = container_of(kobj, struct obd_device,
558 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
560 return sprintf(buf, "%u\n", ofd->ofd_soft_sync_limit);
564 * Change the limit of soft sync RPCs.
566 * Define how many IO RPCs with OBD_BRW_SOFT_SYNC flag
567 * allowed before sync update will be done.
569 * This limit is global across all exports.
571 * \param[in] file proc file
572 * \param[in] buffer string which represents limit
573 * \param[in] count \a buffer length
574 * \param[in] off unused for single entry
576 * \retval \a count on success
577 * \retval negative number on error
579 static ssize_t soft_sync_limit_store(struct kobject *kobj,
580 struct attribute *attr,
581 const char *buffer, size_t count)
583 struct obd_device *obd = container_of(kobj, struct obd_device,
585 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
589 rc = kstrtouint(buffer, 0, &val);
593 ofd->ofd_soft_sync_limit = val;
596 LUSTRE_RW_ATTR(soft_sync_limit);
599 * Show the LFSCK speed limit.
601 * The maximum number of items scanned per second.
603 * \param[in] m seq_file handle
604 * \param[in] data unused for single entry
606 * \retval 0 on success
607 * \retval negative value on error
609 static ssize_t lfsck_speed_limit_show(struct kobject *kobj,
610 struct attribute *attr, char *buf)
612 struct obd_device *obd = container_of(kobj, struct obd_device,
614 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
616 return lfsck_get_speed(buf, ofd->ofd_osd);
620 * Change the LFSCK speed limit.
622 * Limit number of items that may be scanned per second.
624 * \param[in] file proc file
625 * \param[in] buffer string which represents limit
626 * \param[in] count \a buffer length
627 * \param[in] off unused for single entry
629 * \retval \a count on success
630 * \retval negative number on error
632 static ssize_t lfsck_speed_limit_store(struct kobject *kobj,
633 struct attribute *attr,
634 const char *buffer, size_t count)
636 struct obd_device *obd = container_of(kobj, struct obd_device,
638 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
642 rc = kstrtouint(buffer, 0, &val);
646 rc = lfsck_set_speed(ofd->ofd_osd, val);
648 return rc != 0 ? rc : count;
650 LUSTRE_RW_ATTR(lfsck_speed_limit);
653 * Show LFSCK layout verification stats from the most recent LFSCK run.
655 * \param[in] m seq_file handle
656 * \param[in] data unused for single entry
658 * \retval 0 on success
659 * \retval negative value on error
661 static int ofd_lfsck_layout_seq_show(struct seq_file *m, void *data)
663 struct obd_device *obd = m->private;
664 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
666 return lfsck_dump(m, ofd->ofd_osd, LFSCK_TYPE_LAYOUT);
669 LPROC_SEQ_FOPS_RO(ofd_lfsck_layout);
672 * Show if LFSCK performed parent FID verification.
674 * \param[in] m seq_file handle
675 * \param[in] data unused for single entry
677 * \retval 0 on success
678 * \retval negative value on error
680 static int ofd_lfsck_verify_pfid_seq_show(struct seq_file *m, void *data)
682 struct obd_device *obd = m->private;
683 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
685 seq_printf(m, "switch: %s\ndetected: %llu\nrepaired: %llu\n",
686 ofd->ofd_lfsck_verify_pfid ? "on" : "off",
687 ofd->ofd_inconsistency_self_detected,
688 ofd->ofd_inconsistency_self_repaired);
693 * Set the LFSCK behavior to verify parent FID correctness.
695 * If flag ofd_lfsck_verify_pfid is set then LFSCK does parent FID
696 * verification during read/write operations.
698 * \param[in] file proc file
699 * \param[in] buffer string which represents behavior
700 * 1: verify parent FID
701 * 0: don't verify parent FID
702 * \param[in] count \a buffer length
703 * \param[in] off unused for single entry
705 * \retval \a count on success
706 * \retval negative number on error
709 ofd_lfsck_verify_pfid_seq_write(struct file *file, const char __user *buffer,
710 size_t count, loff_t *off)
712 struct seq_file *m = file->private_data;
713 struct obd_device *obd = m->private;
714 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
718 rc = kstrtobool_from_user(buffer, count, &val);
722 ofd->ofd_lfsck_verify_pfid = val;
723 if (!ofd->ofd_lfsck_verify_pfid) {
724 ofd->ofd_inconsistency_self_detected = 0;
725 ofd->ofd_inconsistency_self_repaired = 0;
731 LPROC_SEQ_FOPS(ofd_lfsck_verify_pfid);
733 static ssize_t access_log_mask_show(struct kobject *kobj,
734 struct attribute *attr, char *buf)
736 struct obd_device *obd = container_of(kobj, struct obd_device,
738 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
740 return scnprintf(buf, PAGE_SIZE, "%s%s%s\n",
741 (ofd->ofd_access_log_mask == 0) ? "0" : "",
742 (ofd->ofd_access_log_mask & OFD_ACCESS_READ) ? "r" : "",
743 (ofd->ofd_access_log_mask & OFD_ACCESS_WRITE) ? "w" : "");
746 static ssize_t access_log_mask_store(struct kobject *kobj,
747 struct attribute *attr,
748 const char *buffer, size_t count)
750 struct obd_device *obd = container_of(kobj, struct obd_device,
752 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
753 unsigned int mask = 0;
756 for (i = 0; i < count; i++) {
757 switch (tolower(buffer[i])) {
761 mask |= OFD_ACCESS_READ;
764 mask |= OFD_ACCESS_WRITE;
771 ofd->ofd_access_log_mask = mask;
775 LUSTRE_RW_ATTR(access_log_mask);
777 static ssize_t access_log_size_show(struct kobject *kobj,
778 struct attribute *attr, char *buf)
780 struct obd_device *obd = container_of(kobj, struct obd_device,
782 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
784 return scnprintf(buf, PAGE_SIZE, "%u\n", ofd->ofd_access_log_size);
787 static ssize_t access_log_size_store(struct kobject *kobj,
788 struct attribute *attr,
789 const char *buffer, size_t count)
791 struct obd_device *obd = container_of(kobj, struct obd_device,
793 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
794 struct ofd_access_log *oal;
798 rc = kstrtouint(buffer, 0, &size);
802 if (!ofd_access_log_size_is_valid(size))
805 /* The size of the ofd_access_log cannot be changed after it
808 if (ofd->ofd_access_log_size == size)
811 oal = ofd_access_log_create(obd->obd_name, size);
815 spin_lock(&ofd->ofd_flags_lock);
816 if (ofd->ofd_access_log != NULL) {
819 ofd->ofd_access_log = oal;
820 ofd->ofd_access_log_size = size;
824 spin_unlock(&ofd->ofd_flags_lock);
826 ofd_access_log_delete(oal);
830 LUSTRE_RW_ATTR(access_log_size);
832 static int ofd_site_stats_seq_show(struct seq_file *m, void *data)
834 struct obd_device *obd = m->private;
836 return lu_site_stats_seq_print(obd->obd_lu_dev->ld_site, m);
839 LPROC_SEQ_FOPS_RO(ofd_site_stats);
842 * Show if the OFD enforces T10PI checksum.
844 * \param[in] m seq_file handle
845 * \param[in] data unused for single entry
847 * \retval 0 on success
848 * \retval negative value on error
850 static ssize_t checksum_t10pi_enforce_show(struct kobject *kobj,
851 struct attribute *attr,
854 struct obd_device *obd = container_of(kobj, struct obd_device,
856 struct lu_target *lut = obd2obt(obd)->obt_lut;
858 return scnprintf(buf, PAGE_SIZE, "%u\n", lut->lut_cksum_t10pi_enforce);
862 * Force specific T10PI checksum modes to be enabled
864 * If T10PI *is* supported in hardware, allow only the supported T10PI type
865 * to be used. If T10PI is *not* supported by the OSD, setting the enforce
866 * parameter forces all T10PI types to be enabled (even if slower) for
869 * The final determination of which algorithm to be used depends whether
870 * the client supports T10PI or not, and is handled at client connect time.
872 * \param[in] file proc file
873 * \param[in] buffer string which represents mode
874 * 1: set T10PI checksums enforced
875 * 0: unset T10PI checksums enforced
876 * \param[in] count \a buffer length
877 * \param[in] off unused for single entry
879 * \retval \a count on success
880 * \retval negative number on error
882 static ssize_t checksum_t10pi_enforce_store(struct kobject *kobj,
883 struct attribute *attr,
884 const char *buffer, size_t count)
886 struct obd_device *obd = container_of(kobj, struct obd_device,
888 struct lu_target *lut = obd2obt(obd)->obt_lut;
892 rc = kstrtobool(buffer, &enforce);
896 spin_lock(&lut->lut_flags_lock);
897 lut->lut_cksum_t10pi_enforce = enforce;
898 spin_unlock(&lut->lut_flags_lock);
901 LUSTRE_RW_ATTR(checksum_t10pi_enforce);
903 LPROC_SEQ_FOPS_RO_TYPE(ofd, recovery_status);
904 LUSTRE_RW_ATTR(recovery_time_hard);
905 LUSTRE_RW_ATTR(recovery_time_soft);
906 LUSTRE_RW_ATTR(ir_factor);
908 LPROC_SEQ_FOPS_WR_ONLY(ofd, evict_client);
909 LPROC_SEQ_FOPS_RW_TYPE(ofd, checksum_dump);
910 LUSTRE_RW_ATTR(job_cleanup_interval);
912 LUSTRE_RO_ATTR(tot_dirty);
913 LUSTRE_RO_ATTR(tot_granted);
914 LUSTRE_RO_ATTR(tot_pending);
915 LUSTRE_RW_ATTR(grant_compat_disable);
916 LUSTRE_RO_ATTR(instance);
918 LUSTRE_RO_ATTR(num_exports);
919 LUSTRE_RW_ATTR(grant_check_threshold);
920 LUSTRE_RO_ATTR(eviction_count);
922 struct lprocfs_vars lprocfs_ofd_obd_vars[] = {
924 .fops = &ofd_last_id_fops },
925 { .name = "recovery_status",
926 .fops = &ofd_recovery_status_fops },
927 { .name = "evict_client",
928 .fops = &ofd_evict_client_fops },
929 { .name = "brw_size",
930 .fops = &ofd_brw_size_fops },
931 { .name = "checksum_dump",
932 .fops = &ofd_checksum_dump_fops },
933 { .name = "lfsck_layout",
934 .fops = &ofd_lfsck_layout_fops },
935 { .name = "lfsck_verify_pfid",
936 .fops = &ofd_lfsck_verify_pfid_fops },
937 { .name = "site_stats",
938 .fops = &ofd_site_stats_fops },
939 { .name = "checksum_type",
940 .fops = &ofd_checksum_type_fops },
944 LDEBUGFS_SEQ_FOPS_RO_TYPE(ofd, recovery_stale_clients);
946 struct ldebugfs_vars ldebugfs_ofd_obd_vars[] = {
947 { .name = "recovery_stale_clients",
948 .fops = &ofd_recovery_stale_clients_fops},
952 LDEBUGFS_SEQ_FOPS_RO_TYPE(ofd, srpc_serverctx);
954 static struct ldebugfs_vars ldebugfs_ofd_gss_vars[] = {
955 { .name = "srpc_serverctx",
956 .fops = &ofd_srpc_serverctx_fops },
961 * Initialize OFD statistics counters
963 * param[in] stats statistics counters
965 void ofd_stats_counter_init(struct lprocfs_stats *stats, unsigned int offset,
966 enum lprocfs_counter_config cntr_umask)
968 LASSERT(stats && stats->ls_num >= LPROC_OFD_STATS_LAST);
970 lprocfs_counter_init(stats, LPROC_OFD_STATS_READ_BYTES,
971 LPROCFS_TYPE_BYTES_FULL_HISTOGRAM & (~cntr_umask),
973 lprocfs_counter_init(stats, LPROC_OFD_STATS_WRITE_BYTES,
974 LPROCFS_TYPE_BYTES_FULL_HISTOGRAM & (~cntr_umask),
976 lprocfs_counter_init(stats, LPROC_OFD_STATS_READ,
977 LPROCFS_TYPE_LATENCY & (~cntr_umask), "read");
978 lprocfs_counter_init(stats, LPROC_OFD_STATS_WRITE,
979 LPROCFS_TYPE_LATENCY & (~cntr_umask), "write");
980 lprocfs_counter_init(stats, LPROC_OFD_STATS_GETATTR,
981 LPROCFS_TYPE_LATENCY & (~cntr_umask), "getattr");
982 lprocfs_counter_init(stats, LPROC_OFD_STATS_SETATTR,
983 LPROCFS_TYPE_LATENCY & (~cntr_umask), "setattr");
984 lprocfs_counter_init(stats, LPROC_OFD_STATS_PUNCH,
985 LPROCFS_TYPE_LATENCY & (~cntr_umask), "punch");
986 lprocfs_counter_init(stats, LPROC_OFD_STATS_SYNC,
987 LPROCFS_TYPE_LATENCY & (~cntr_umask), "sync");
988 lprocfs_counter_init(stats, LPROC_OFD_STATS_DESTROY,
989 LPROCFS_TYPE_LATENCY & (~cntr_umask), "destroy");
990 lprocfs_counter_init(stats, LPROC_OFD_STATS_CREATE,
991 LPROCFS_TYPE_LATENCY & (~cntr_umask), "create");
992 lprocfs_counter_init(stats, LPROC_OFD_STATS_STATFS,
993 LPROCFS_TYPE_LATENCY & (~cntr_umask), "statfs");
994 lprocfs_counter_init(stats, LPROC_OFD_STATS_GET_INFO,
995 LPROCFS_TYPE_LATENCY & (~cntr_umask), "get_info");
996 lprocfs_counter_init(stats, LPROC_OFD_STATS_SET_INFO,
997 LPROCFS_TYPE_LATENCY & (~cntr_umask), "set_info");
998 lprocfs_counter_init(stats, LPROC_OFD_STATS_QUOTACTL,
999 LPROCFS_TYPE_LATENCY & (~cntr_umask), "quotactl");
1000 lprocfs_counter_init(stats, LPROC_OFD_STATS_PREALLOC,
1001 LPROCFS_TYPE_LATENCY & (~cntr_umask), "prealloc");
1004 LPROC_SEQ_FOPS(lprocfs_nid_stats_clear);
1006 LUSTRE_OBD_UINT_PARAM_ATTR(at_min);
1007 LUSTRE_OBD_UINT_PARAM_ATTR(at_max);
1008 LUSTRE_OBD_UINT_PARAM_ATTR(at_history);
1010 static struct attribute *ofd_attrs[] = {
1011 &lustre_attr_access_log_mask.attr,
1012 &lustre_attr_access_log_size.attr,
1013 &lustre_attr_atime_diff.attr,
1014 &lustre_attr_checksum_t10pi_enforce.attr,
1015 &lustre_attr_degraded.attr,
1016 &lustre_attr_eviction_count.attr,
1017 &lustre_attr_fstype.attr,
1018 &lustre_attr_grant_check_threshold.attr,
1019 &lustre_attr_grant_compat_disable.attr,
1020 &lustre_attr_grant_precreate.attr,
1021 &lustre_attr_instance.attr,
1022 &lustre_attr_ir_factor.attr,
1023 &lustre_attr_job_cleanup_interval.attr,
1024 &lustre_attr_lfsck_speed_limit.attr,
1025 &lustre_attr_no_create.attr,
1026 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 20, 53, 0)
1027 &lustre_attr_no_precreate.attr,
1029 &lustre_attr_num_exports.attr,
1030 &lustre_attr_precreate_batch.attr,
1031 &lustre_attr_recovery_time_hard.attr,
1032 &lustre_attr_recovery_time_soft.attr,
1033 &lustre_attr_seqs_allocated.attr,
1034 &lustre_attr_tot_dirty.attr,
1035 &lustre_attr_tot_granted.attr,
1036 &lustre_attr_tot_pending.attr,
1037 &lustre_attr_soft_sync_limit.attr,
1038 &lustre_attr_sync_journal.attr,
1039 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 16, 53, 0)
1040 &lustre_attr_sync_on_lock_cancel.attr,
1042 &lustre_attr_at_min.attr,
1043 &lustre_attr_at_max.attr,
1044 &lustre_attr_at_history.attr,
1048 KOBJ_ATTRIBUTE_GROUPS(ofd); /* creates ofd_groups from ofd_attrs */
1051 * Initialize all needed procfs entries for OFD device.
1053 * \param[in] ofd OFD device
1055 * \retval 0 if successful
1056 * \retval negative value on error
1058 int ofd_tunables_init(struct ofd_device *ofd)
1060 struct obd_device *obd = ofd_obd(ofd);
1061 struct proc_dir_entry *entry;
1065 /* lprocfs must be setup before the ofd so state can be safely added
1066 * to /proc incrementally as the ofd is setup
1068 obd->obd_ktype.default_groups = KOBJ_ATTR_GROUPS(ofd);
1069 obd->obd_vars = lprocfs_ofd_obd_vars;
1070 rc = lprocfs_obd_setup(obd, false);
1072 CERROR("%s: lprocfs_obd_setup failed: %d.\n",
1076 ldebugfs_add_vars(obd->obd_debugfs_entry, ldebugfs_ofd_obd_vars, obd);
1078 rc = tgt_tunables_init(&ofd->ofd_lut);
1080 CERROR("%s: tgt_tunables_init failed: rc = %d\n",
1082 GOTO(obd_cleanup, rc);
1085 rc = lprocfs_alloc_obd_stats(obd, LPROC_OFD_STATS_LAST);
1087 CERROR("%s: lprocfs_alloc_obd_stats failed: %d.\n",
1089 GOTO(tgt_cleanup, rc);
1092 obd->obd_debugfs_gss_dir = debugfs_create_dir("gss",
1093 obd->obd_debugfs_entry);
1094 if (obd->obd_debugfs_gss_dir)
1095 ldebugfs_add_vars(obd->obd_debugfs_gss_dir,
1096 ldebugfs_ofd_gss_vars, obd);
1098 entry = lprocfs_register("exports", obd->obd_proc_entry, NULL, NULL);
1099 if (IS_ERR(entry)) {
1100 rc = PTR_ERR(entry);
1101 CERROR("%s: error %d setting up lprocfs for %s\n",
1102 obd->obd_name, rc, "exports");
1103 GOTO(obd_free_stats, rc);
1105 obd->obd_proc_exports_entry = entry;
1107 entry = lprocfs_add_simple(obd->obd_proc_exports_entry, "clear",
1108 obd, &lprocfs_nid_stats_clear_fops);
1109 if (IS_ERR(entry)) {
1110 rc = PTR_ERR(entry);
1111 CERROR("%s: add proc entry 'clear' failed: %d.\n",
1113 GOTO(obd_free_stats, rc);
1116 ofd_stats_counter_init(obd->obd_stats, 0, LPROCFS_CNTR_HISTOGRAM);
1118 rc = lprocfs_job_stats_init(obd, LPROC_OFD_STATS_LAST,
1119 ofd_stats_counter_init);
1121 GOTO(obd_free_stats, rc);
1126 lprocfs_free_obd_stats(obd);
1128 tgt_tunables_fini(&ofd->ofd_lut);
1130 lprocfs_obd_cleanup(obd);
1134 #endif /* CONFIG_PROC_FS */