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, 2014 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 int ofd_seqs_seq_show(struct seq_file *m, void *data)
64 struct obd_device *obd = m->private;
65 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
67 return seq_printf(m, "%u\n", ofd->ofd_seq_count);
69 LPROC_SEQ_FOPS_RO(ofd_seqs);
72 * Show estimate of total amount of dirty data on clients.
74 * \param[in] m seq_file handle
75 * \param[in] data unused for single entry
77 * \retval 0 on success
78 * \retval negative value on error
80 static int ofd_tot_dirty_seq_show(struct seq_file *m, void *data)
82 struct obd_device *obd = m->private;
83 struct ofd_device *ofd;
86 ofd = ofd_dev(obd->obd_lu_dev);
87 return seq_printf(m, LPU64"\n", ofd->ofd_tot_dirty);
89 LPROC_SEQ_FOPS_RO(ofd_tot_dirty);
92 * Show total amount of space granted to clients.
94 * \param[in] m seq_file handle
95 * \param[in] data unused for single entry
97 * \retval 0 on success
98 * \retval negative value on error
100 static int ofd_tot_granted_seq_show(struct seq_file *m, void *data)
102 struct obd_device *obd = m->private;
103 struct ofd_device *ofd;
105 LASSERT(obd != NULL);
106 ofd = ofd_dev(obd->obd_lu_dev);
107 return seq_printf(m, LPU64"\n", ofd->ofd_tot_granted);
109 LPROC_SEQ_FOPS_RO(ofd_tot_granted);
112 * Show total amount of space used by IO in progress.
114 * \param[in] m seq_file handle
115 * \param[in] data unused for single entry
117 * \retval 0 on success
118 * \retval negative value on error
120 static int ofd_tot_pending_seq_show(struct seq_file *m, void *data)
122 struct obd_device *obd = m->private;
123 struct ofd_device *ofd;
125 LASSERT(obd != NULL);
126 ofd = ofd_dev(obd->obd_lu_dev);
127 return seq_printf(m, LPU64"\n", ofd->ofd_tot_pending);
129 LPROC_SEQ_FOPS_RO(ofd_tot_pending);
132 * Show total number of grants for precreate.
134 * \param[in] m seq_file handle
135 * \param[in] data unused for single entry
137 * \retval 0 on success
138 * \retval negative value on error
140 static int ofd_grant_precreate_seq_show(struct seq_file *m, void *data)
142 struct obd_device *obd = m->private;
144 LASSERT(obd != NULL);
145 return seq_printf(m, "%ld\n",
146 obd->obd_self_export->exp_filter_data.fed_grant);
148 LPROC_SEQ_FOPS_RO(ofd_grant_precreate);
151 * Show total amount of free space reserved for grants.
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 int ofd_grant_ratio_seq_show(struct seq_file *m, void *data)
161 struct obd_device *obd = m->private;
162 struct ofd_device *ofd;
164 LASSERT(obd != NULL);
165 ofd = ofd_dev(obd->obd_lu_dev);
166 return seq_printf(m, "%d%%\n",
167 (int) ofd_grant_reserved(ofd, 100));
171 * Change amount of free space reserved for grants.
173 * \param[in] file proc file
174 * \param[in] buffer string which represents maximum number
175 * \param[in] count \a buffer length
176 * \param[in] off unused for single entry
178 * \retval \a count on success
179 * \retval negative number on error
182 ofd_grant_ratio_seq_write(struct file *file, const char __user *buffer,
183 size_t count, loff_t *off)
185 struct seq_file *m = file->private_data;
186 struct obd_device *obd = m->private;
187 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
191 rc = lprocfs_write_helper(buffer, count, &val);
195 if (val > 100 || val < 0)
199 CWARN("%s: disabling grant error margin\n", obd->obd_name);
201 CWARN("%s: setting grant error margin >50%%, be warned that "
202 "a huge part of the free space is now reserved for "
203 "grants\n", obd->obd_name);
205 spin_lock(&ofd->ofd_grant_lock);
206 ofd->ofd_grant_ratio = ofd_grant_ratio_conv(val);
207 spin_unlock(&ofd->ofd_grant_lock);
210 LPROC_SEQ_FOPS(ofd_grant_ratio);
213 * Show number of precreates allowed in a single transaction.
215 * \param[in] m seq_file handle
216 * \param[in] data unused for single entry
218 * \retval 0 on success
219 * \retval negative value on error
221 static int ofd_precreate_batch_seq_show(struct seq_file *m, void *data)
223 struct obd_device *obd = m->private;
224 struct ofd_device *ofd;
226 LASSERT(obd != NULL);
227 ofd = ofd_dev(obd->obd_lu_dev);
228 return seq_printf(m, "%d\n", ofd->ofd_precreate_batch);
232 * Change number of precreates allowed in a single transaction.
234 * \param[in] file proc file
235 * \param[in] buffer string which represents maximum number
236 * \param[in] count \a buffer length
237 * \param[in] off unused for single entry
239 * \retval \a count on success
240 * \retval negative number on error
243 ofd_precreate_batch_seq_write(struct file *file, const char __user *buffer,
244 size_t count, loff_t *off)
246 struct seq_file *m = file->private_data;
247 struct obd_device *obd = m->private;
248 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
252 rc = lprocfs_write_helper(buffer, count, &val);
259 spin_lock(&ofd->ofd_batch_lock);
260 ofd->ofd_precreate_batch = val;
261 spin_unlock(&ofd->ofd_batch_lock);
264 LPROC_SEQ_FOPS(ofd_precreate_batch);
267 * Show the last used ID for each FID sequence used by OFD.
269 * \param[in] m seq_file handle
270 * \param[in] data unused for single entry
272 * \retval 0 on success
273 * \retval negative value on error
275 static int ofd_last_id_seq_show(struct seq_file *m, void *data)
277 struct obd_device *obd = m->private;
278 struct ofd_device *ofd;
279 struct ofd_seq *oseq = NULL;
285 ofd = ofd_dev(obd->obd_lu_dev);
287 read_lock(&ofd->ofd_seq_list_lock);
288 list_for_each_entry(oseq, &ofd->ofd_seq_list, os_list) {
291 seq = ostid_seq(&oseq->os_oi) == 0 ?
292 fid_idif_seq(ostid_id(&oseq->os_oi),
293 ofd->ofd_lut.lut_lsd.lsd_osd_index) :
294 ostid_seq(&oseq->os_oi);
295 rc = seq_printf(m, DOSTID"\n", seq, ostid_id(&oseq->os_oi));
302 read_unlock(&ofd->ofd_seq_list_lock);
305 LPROC_SEQ_FOPS_RO(ofd_last_id);
308 * Show maximum number of Filter Modification Data (FMD) maintained by OFD.
310 * \param[in] m seq_file handle
311 * \param[in] data unused for single entry
313 * \retval 0 on success
314 * \retval negative value on error
316 static int ofd_fmd_max_num_seq_show(struct seq_file *m, void *data)
318 struct obd_device *obd = m->private;
319 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
321 return seq_printf(m, "%u\n", ofd->ofd_fmd_max_num);
325 * Change number of FMDs maintained by OFD.
327 * This defines how large the list of FMDs can be.
329 * \param[in] file proc file
330 * \param[in] buffer string which represents maximum number
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
338 ofd_fmd_max_num_seq_write(struct file *file, const char __user *buffer,
339 size_t count, loff_t *off)
341 struct seq_file *m = file->private_data;
342 struct obd_device *obd = m->private;
343 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
347 rc = lprocfs_write_helper(buffer, count, &val);
351 if (val > 65536 || val < 1)
354 ofd->ofd_fmd_max_num = val;
357 LPROC_SEQ_FOPS(ofd_fmd_max_num);
360 * Show the maximum age of FMD data in seconds.
362 * Though it is shown in seconds, it is stored internally in units
363 * of jiffies for efficiency.
365 * \param[in] m seq_file handle
366 * \param[in] data unused for single entry
368 * \retval 0 on success
369 * \retval negative value on error
371 static int ofd_fmd_max_age_seq_show(struct seq_file *m, void *data)
373 struct obd_device *obd = m->private;
374 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
376 return seq_printf(m, "%ld\n", ofd->ofd_fmd_max_age / HZ);
380 * Set the maximum age of FMD data in seconds.
382 * This defines how long FMD data stays in the FMD list.
383 * It is stored internally in units of jiffies for efficiency.
385 * \param[in] file proc file
386 * \param[in] buffer string which represents maximum number
387 * \param[in] count \a buffer length
388 * \param[in] off unused for single entry
390 * \retval \a count on success
391 * \retval negative number on error
394 ofd_fmd_max_age_seq_write(struct file *file, const char __user *buffer,
395 size_t count, loff_t *off)
397 struct seq_file *m = file->private_data;
398 struct obd_device *obd = m->private;
399 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
403 rc = lprocfs_write_helper(buffer, count, &val);
407 if (val > 65536 || val < 1)
410 ofd->ofd_fmd_max_age = val * HZ;
413 LPROC_SEQ_FOPS(ofd_fmd_max_age);
416 * Show if OSS FID capability is enabled or disabled
418 * \param[in] m seq_file handle
419 * \param[in] data unused for single entry
421 * \retval 0 on success
422 * \retval negative value on error
424 static int ofd_capa_seq_show(struct seq_file *m, void *data)
426 struct obd_device *obd = m->private;
428 return seq_printf(m, "capability on: %s\n",
429 obd->u.filter.fo_fl_oss_capa ? "oss" : "");
433 * Enable or disable OSS FID capability mode.
435 * \param[in] file proc file
436 * \param[in] buffer string which represents mode
439 * \param[in] count \a buffer length
440 * \param[in] off unused for single entry
442 * \retval \a count on success
443 * \retval negative number on error
446 ofd_capa_seq_write(struct file *file, const char *__user buffer, size_t count,
449 struct seq_file *m = file->private_data;
450 struct obd_device *obd = m->private;
453 rc = lprocfs_write_helper(buffer, count, &val);
458 CERROR("invalid capability mode, only 0/1 are accepted.\n"
459 " 1: enable oss fid capability\n"
460 " 0: disable oss fid capability\n");
464 obd->u.filter.fo_fl_oss_capa = val;
465 LCONSOLE_INFO("OSS %s %s fid capability.\n", obd->obd_name,
466 val ? "enabled" : "disabled");
469 LPROC_SEQ_FOPS(ofd_capa);
472 * Show capability count on client and server side.
474 * \param[in] m seq_file handle
475 * \param[in] data unused for single entry
477 * \retval 0 on success
478 * \retval negative value on error
480 static int ofd_capa_count_seq_show(struct seq_file *m, void *data)
482 return seq_printf(m, "%d %d\n", capa_count[CAPA_SITE_CLIENT],
483 capa_count[CAPA_SITE_SERVER]);
485 LPROC_SEQ_FOPS_RO(ofd_capa_count);
488 * Show if the OFD is in degraded mode.
490 * Degraded means OFD has a failed drive or is undergoing RAID rebuild.
491 * The MDS will try to avoid using this OST for new object allocations
492 * to reduce the impact to global IO performance when clients writing to
493 * this OST are slowed down. It also reduces the contention on the OST
494 * RAID device, allowing it to rebuild more quickly.
496 * \param[in] m seq_file handle
497 * \param[in] data unused for single entry
499 * \retval 0 on success
500 * \retval negative value on error
502 static int ofd_degraded_seq_show(struct seq_file *m, void *data)
504 struct obd_device *obd = m->private;
505 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
507 return seq_printf(m, "%u\n", ofd->ofd_raid_degraded);
511 * Set OFD to degraded mode.
513 * This is used to interface to userspace administrative tools for
514 * the underlying RAID storage, so that they can mark an OST
515 * as having degraded performance.
517 * \param[in] file proc file
518 * \param[in] buffer string which represents mode
519 * 1: set degraded mode
520 * 0: unset degraded mode
521 * \param[in] count \a buffer length
522 * \param[in] off unused for single entry
524 * \retval \a count on success
525 * \retval negative number on error
528 ofd_degraded_seq_write(struct file *file, const char __user *buffer,
529 size_t count, loff_t *off)
531 struct seq_file *m = file->private_data;
532 struct obd_device *obd = m->private;
533 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
536 rc = lprocfs_write_helper(buffer, count, &val);
540 spin_lock(&ofd->ofd_flags_lock);
541 ofd->ofd_raid_degraded = !!val;
542 spin_unlock(&ofd->ofd_flags_lock);
545 LPROC_SEQ_FOPS(ofd_degraded);
548 * Show OFD filesystem type.
550 * \param[in] m seq_file handle
551 * \param[in] data unused for single entry
553 * \retval 0 on success
554 * \retval negative value on error
556 static int ofd_fstype_seq_show(struct seq_file *m, void *data)
558 struct obd_device *obd = m->private;
559 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
562 LASSERT(ofd->ofd_osd);
563 d = &ofd->ofd_osd->dd_lu_dev;
565 return seq_printf(m, "%s\n", d->ld_type->ldt_name);
567 LPROC_SEQ_FOPS_RO(ofd_fstype);
570 * Show journal handling mode: synchronous or asynchronous.
572 * When running in asynchronous mode the journal transactions are not
573 * committed to disk before the RPC is replied back to the client.
574 * This will typically improve client performance when only a small number
575 * of clients are writing, since the client(s) can have more write RPCs
576 * in flight. However, it also means that the client has to handle recovery
577 * on bulk RPCs, and will have to keep more dirty pages in cache before they
578 * are committed on the OST.
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_syncjournal_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 return seq_printf(m, "%u\n", ofd->ofd_syncjournal);
595 * Set journal mode to synchronous or asynchronous.
597 * \param[in] file proc file
598 * \param[in] buffer string which represents mode
599 * 1: synchronous mode
600 * 0: asynchronous mode
601 * \param[in] count \a buffer length
602 * \param[in] off unused for single entry
604 * \retval \a count on success
605 * \retval negative number on error
608 ofd_syncjournal_seq_write(struct file *file, const char __user *buffer,
609 size_t count, loff_t *off)
611 struct seq_file *m = file->private_data;
612 struct obd_device *obd = m->private;
613 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
617 rc = lprocfs_write_helper(buffer, count, &val);
624 spin_lock(&ofd->ofd_flags_lock);
625 ofd->ofd_syncjournal = !!val;
627 spin_unlock(&ofd->ofd_flags_lock);
631 LPROC_SEQ_FOPS(ofd_syncjournal);
633 /* This must be longer than the longest string below */
634 #define SYNC_STATES_MAXLEN 16
635 static char *sync_on_cancel_states[] = {"never",
640 * Show OFD policy for handling dirty data under a lock being cancelled.
642 * \param[in] m seq_file handle
643 * \param[in] data unused for single entry
645 * \retval 0 on success
646 * \retval negative value on error
648 static int ofd_sync_lock_cancel_seq_show(struct seq_file *m, void *data)
650 struct obd_device *obd = m->private;
651 struct lu_target *tgt = obd->u.obt.obt_lut;
653 return seq_printf(m, "%s\n",
654 sync_on_cancel_states[tgt->lut_sync_lock_cancel]);
658 * Change OFD policy for handling dirty data under a lock being cancelled.
660 * This variable defines what action OFD takes upon lock cancel
661 * There are three possible modes:
662 * 1) never - never do sync upon lock cancel. This can lead to data
663 * inconsistencies if both the OST and client crash while writing a file
664 * that is also concurrently being read by another client. In these cases,
665 * this may allow the file data to "rewind" to an earlier state.
666 * 2) blocking - do sync only if there is blocking lock, e.g. if another
667 * client is trying to access this same object
668 * 3) always - do sync always
670 * \param[in] file proc file
671 * \param[in] buffer string which represents policy
672 * \param[in] count \a buffer length
673 * \param[in] off unused for single entry
675 * \retval \a count on success
676 * \retval negative number on error
679 ofd_sync_lock_cancel_seq_write(struct file *file, const char __user *buffer,
680 size_t count, loff_t *off)
682 struct seq_file *m = file->private_data;
683 struct obd_device *obd = m->private;
684 struct lu_target *tgt = obd->u.obt.obt_lut;
685 char kernbuf[SYNC_STATES_MAXLEN];
689 if (count == 0 || count >= sizeof(kernbuf))
692 if (copy_from_user(kernbuf, buffer, count))
696 if (kernbuf[count - 1] == '\n')
697 kernbuf[count - 1] = 0;
699 for (i = 0 ; i < NUM_SYNC_ON_CANCEL_STATES; i++) {
700 if (strcmp(kernbuf, sync_on_cancel_states[i]) == 0) {
706 /* Legacy numeric codes */
710 /* Safe to use userspace buffer as lprocfs_write_helper will
711 * use copy from user for parsing */
712 rc = lprocfs_write_helper(buffer, count, &val);
717 if (val < 0 || val > 2)
720 spin_lock(&tgt->lut_flags_lock);
721 tgt->lut_sync_lock_cancel = val;
722 spin_unlock(&tgt->lut_flags_lock);
725 LPROC_SEQ_FOPS(ofd_sync_lock_cancel);
728 * Show if grants compatibility mode is disabled.
730 * When ofd_grant_compat_disable is set, we don't grant any space to clients
731 * not supporting OBD_CONNECT_GRANT_PARAM. Otherwise, space granted to such
732 * a client is inflated since it consumes PAGE_CACHE_SIZE of grant space per
733 * block, (i.e. typically 4kB units), but underlaying file system might have
734 * block size bigger than page size, e.g. ZFS. See LU-2049 for details.
736 * \param[in] m seq_file handle
737 * \param[in] data unused for single entry
739 * \retval 0 on success
740 * \retval negative value on error
742 static int ofd_grant_compat_disable_seq_show(struct seq_file *m, void *data)
744 struct obd_device *obd = m->private;
745 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
747 return seq_printf(m, "%u\n", ofd->ofd_grant_compat_disable);
751 * Change grant compatibility mode.
753 * Setting ofd_grant_compat_disable prohibit any space granting to clients
754 * not supporting OBD_CONNECT_GRANT_PARAM. See details above.
756 * \param[in] file proc file
757 * \param[in] buffer string which represents mode
758 * 1: disable compatibility mode
759 * 0: enable compatibility mode
760 * \param[in] count \a buffer length
761 * \param[in] off unused for single entry
763 * \retval \a count on success
764 * \retval negative number on error
767 ofd_grant_compat_disable_seq_write(struct file *file,
768 const char __user *buffer,
769 size_t count, loff_t *off)
771 struct seq_file *m = file->private_data;
772 struct obd_device *obd = m->private;
773 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
777 rc = lprocfs_write_helper(buffer, count, &val);
784 spin_lock(&ofd->ofd_flags_lock);
785 ofd->ofd_grant_compat_disable = !!val;
786 spin_unlock(&ofd->ofd_flags_lock);
790 LPROC_SEQ_FOPS(ofd_grant_compat_disable);
793 * Show the limit of soft sync RPCs.
795 * This value defines how many IO RPCs with OBD_BRW_SOFT_SYNC flag
796 * are allowed before sync update will be triggered.
798 * \param[in] m seq_file handle
799 * \param[in] data unused for single entry
801 * \retval 0 on success
802 * \retval negative value on error
804 static int ofd_soft_sync_limit_seq_show(struct seq_file *m, void *data)
806 struct obd_device *obd = m->private;
807 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
809 return lprocfs_uint_seq_show(m, &ofd->ofd_soft_sync_limit);
813 * Change the limit of soft sync RPCs.
815 * Define how many IO RPCs with OBD_BRW_SOFT_SYNC flag
816 * allowed before sync update will be done.
818 * This limit is global across all exports.
820 * \param[in] file proc file
821 * \param[in] buffer string which represents limit
822 * \param[in] count \a buffer length
823 * \param[in] off unused for single entry
825 * \retval \a count on success
826 * \retval negative number on error
829 ofd_soft_sync_limit_seq_write(struct file *file, const char __user *buffer,
830 size_t count, loff_t *off)
832 struct seq_file *m = file->private_data;
833 struct obd_device *obd = m->private;
834 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
836 return lprocfs_uint_seq_write(file, buffer, count,
837 (loff_t *) &ofd->ofd_soft_sync_limit);
839 LPROC_SEQ_FOPS(ofd_soft_sync_limit);
842 * Show the LFSCK speed limit.
844 * The maximum number of items scanned per second.
846 * \param[in] m seq_file handle
847 * \param[in] data unused for single entry
849 * \retval 0 on success
850 * \retval negative value on error
852 static int ofd_lfsck_speed_limit_seq_show(struct seq_file *m, void *data)
854 struct obd_device *obd = m->private;
855 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
857 return lfsck_get_speed(m, ofd->ofd_osd);
861 * Change the LFSCK speed limit.
863 * Limit number of items that may be scanned per second.
865 * \param[in] file proc file
866 * \param[in] buffer string which represents limit
867 * \param[in] count \a buffer length
868 * \param[in] off unused for single entry
870 * \retval \a count on success
871 * \retval negative number on error
874 ofd_lfsck_speed_limit_seq_write(struct file *file, const char __user *buffer,
875 size_t count, loff_t *off)
877 struct seq_file *m = file->private_data;
878 struct obd_device *obd = m->private;
879 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
883 rc = lprocfs_write_helper(buffer, count, &val);
887 rc = lfsck_set_speed(ofd->ofd_osd, val);
889 return rc != 0 ? rc : count;
891 LPROC_SEQ_FOPS(ofd_lfsck_speed_limit);
894 * Show LFSCK layout verification stats from the most recent LFSCK run.
896 * \param[in] m seq_file handle
897 * \param[in] data unused for single entry
899 * \retval 0 on success
900 * \retval negative value on error
902 static int ofd_lfsck_layout_seq_show(struct seq_file *m, void *data)
904 struct obd_device *obd = m->private;
905 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
907 return lfsck_dump(m, ofd->ofd_osd, LFSCK_TYPE_LAYOUT);
909 LPROC_SEQ_FOPS_RO(ofd_lfsck_layout);
912 * Show if LFSCK performed parent FID verification.
914 * \param[in] m seq_file handle
915 * \param[in] data unused for single entry
917 * \retval 0 on success
918 * \retval negative value on error
920 static int ofd_lfsck_verify_pfid_seq_show(struct seq_file *m, void *data)
922 struct obd_device *obd = m->private;
923 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
926 "switch: %s\ndetected: "LPU64"\nrepaired: "LPU64"\n",
927 ofd->ofd_lfsck_verify_pfid ? "on" : "off",
928 ofd->ofd_inconsistency_self_detected,
929 ofd->ofd_inconsistency_self_repaired);
933 * Set the LFSCK behavior to verify parent FID correctness.
935 * If flag ofd_lfsck_verify_pfid is set then LFSCK does parent FID
936 * verification during read/write operations.
938 * \param[in] file proc file
939 * \param[in] buffer string which represents behavior
940 * 1: verify parent FID
941 * 0: don't verify parent FID
942 * \param[in] count \a buffer length
943 * \param[in] off unused for single entry
945 * \retval \a count on success
946 * \retval negative number on error
949 ofd_lfsck_verify_pfid_seq_write(struct file *file, const char __user *buffer,
950 size_t count, loff_t *off)
952 struct seq_file *m = file->private_data;
953 struct obd_device *obd = m->private;
954 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
958 rc = lprocfs_write_helper(buffer, count, &val);
962 ofd->ofd_lfsck_verify_pfid = !!val;
966 LPROC_SEQ_FOPS(ofd_lfsck_verify_pfid);
968 LPROC_SEQ_FOPS_RO_TYPE(ofd, uuid);
969 LPROC_SEQ_FOPS_RO_TYPE(ofd, blksize);
970 LPROC_SEQ_FOPS_RO_TYPE(ofd, kbytestotal);
971 LPROC_SEQ_FOPS_RO_TYPE(ofd, kbytesfree);
972 LPROC_SEQ_FOPS_RO_TYPE(ofd, kbytesavail);
973 LPROC_SEQ_FOPS_RO_TYPE(ofd, filestotal);
974 LPROC_SEQ_FOPS_RO_TYPE(ofd, filesfree);
976 LPROC_SEQ_FOPS_RO_TYPE(ofd, recovery_status);
977 LPROC_SEQ_FOPS_RW_TYPE(ofd, recovery_time_soft);
978 LPROC_SEQ_FOPS_RW_TYPE(ofd, recovery_time_hard);
979 LPROC_SEQ_FOPS_WO_TYPE(ofd, evict_client);
980 LPROC_SEQ_FOPS_RO_TYPE(ofd, num_exports);
981 LPROC_SEQ_FOPS_RO_TYPE(ofd, target_instance);
982 LPROC_SEQ_FOPS_RW_TYPE(ofd, ir_factor);
983 LPROC_SEQ_FOPS_RW_TYPE(ofd, job_interval);
985 struct lprocfs_seq_vars lprocfs_ofd_obd_vars[] = {
987 .fops = &ofd_uuid_fops },
988 { .name = "blocksize",
989 .fops = &ofd_blksize_fops },
990 { .name = "kbytestotal",
991 .fops = &ofd_kbytestotal_fops },
992 { .name = "kbytesfree",
993 .fops = &ofd_kbytesfree_fops },
994 { .name = "kbytesavail",
995 .fops = &ofd_kbytesavail_fops },
996 { .name = "filestotal",
997 .fops = &ofd_filestotal_fops },
998 { .name = "filesfree",
999 .fops = &ofd_filesfree_fops },
1000 { .name = "seqs_allocated",
1001 .fops = &ofd_seqs_fops },
1003 .fops = &ofd_fstype_fops },
1004 { .name = "last_id",
1005 .fops = &ofd_last_id_fops },
1006 { .name = "tot_dirty",
1007 .fops = &ofd_tot_dirty_fops },
1008 { .name = "tot_pending",
1009 .fops = &ofd_tot_pending_fops },
1010 { .name = "tot_granted",
1011 .fops = &ofd_tot_granted_fops },
1012 { .name = "grant_precreate",
1013 .fops = &ofd_grant_precreate_fops },
1014 { .name = "grant_ratio",
1015 .fops = &ofd_grant_ratio_fops },
1016 { .name = "precreate_batch",
1017 .fops = &ofd_precreate_batch_fops },
1018 { .name = "recovery_status",
1019 .fops = &ofd_recovery_status_fops },
1020 { .name = "recovery_time_soft",
1021 .fops = &ofd_recovery_time_soft_fops },
1022 { .name = "recovery_time_hard",
1023 .fops = &ofd_recovery_time_hard_fops },
1024 { .name = "evict_client",
1025 .fops = &ofd_evict_client_fops },
1026 { .name = "num_exports",
1027 .fops = &ofd_num_exports_fops },
1028 { .name = "degraded",
1029 .fops = &ofd_degraded_fops },
1030 { .name = "sync_journal",
1031 .fops = &ofd_syncjournal_fops },
1032 { .name = "sync_on_lock_cancel",
1033 .fops = &ofd_sync_lock_cancel_fops },
1034 { .name = "instance",
1035 .fops = &ofd_target_instance_fops },
1036 { .name = "ir_factor",
1037 .fops = &ofd_ir_factor_fops },
1038 { .name = "grant_compat_disable",
1039 .fops = &ofd_grant_compat_disable_fops },
1040 { .name = "client_cache_count",
1041 .fops = &ofd_fmd_max_num_fops },
1042 { .name = "client_cache_seconds",
1043 .fops = &ofd_fmd_max_age_fops },
1045 .fops = &ofd_capa_fops },
1046 { .name = "capa_count",
1047 .fops = &ofd_capa_count_fops },
1048 { .name = "job_cleanup_interval",
1049 .fops = &ofd_job_interval_fops },
1050 { .name = "soft_sync_limit",
1051 .fops = &ofd_soft_sync_limit_fops },
1052 { .name = "lfsck_speed_limit",
1053 .fops = &ofd_lfsck_speed_limit_fops },
1054 { .name = "lfsck_layout",
1055 .fops = &ofd_lfsck_layout_fops },
1056 { .name = "lfsck_verify_pfid",
1057 .fops = &ofd_lfsck_verify_pfid_fops },
1062 * Initialize OFD statistics counters
1064 * param[in] stats statistics counters
1066 void ofd_stats_counter_init(struct lprocfs_stats *stats)
1068 LASSERT(stats && stats->ls_num >= LPROC_OFD_STATS_LAST);
1070 lprocfs_counter_init(stats, LPROC_OFD_STATS_READ,
1071 LPROCFS_CNTR_AVGMINMAX, "read_bytes", "bytes");
1072 lprocfs_counter_init(stats, LPROC_OFD_STATS_WRITE,
1073 LPROCFS_CNTR_AVGMINMAX, "write_bytes", "bytes");
1074 lprocfs_counter_init(stats, LPROC_OFD_STATS_GETATTR,
1075 0, "getattr", "reqs");
1076 lprocfs_counter_init(stats, LPROC_OFD_STATS_SETATTR,
1077 0, "setattr", "reqs");
1078 lprocfs_counter_init(stats, LPROC_OFD_STATS_PUNCH,
1079 0, "punch", "reqs");
1080 lprocfs_counter_init(stats, LPROC_OFD_STATS_SYNC,
1082 lprocfs_counter_init(stats, LPROC_OFD_STATS_DESTROY,
1083 0, "destroy", "reqs");
1084 lprocfs_counter_init(stats, LPROC_OFD_STATS_CREATE,
1085 0, "create", "reqs");
1086 lprocfs_counter_init(stats, LPROC_OFD_STATS_STATFS,
1087 0, "statfs", "reqs");
1088 lprocfs_counter_init(stats, LPROC_OFD_STATS_GET_INFO,
1089 0, "get_info", "reqs");
1090 lprocfs_counter_init(stats, LPROC_OFD_STATS_SET_INFO,
1091 0, "set_info", "reqs");
1092 lprocfs_counter_init(stats, LPROC_OFD_STATS_QUOTACTL,
1093 0, "quotactl", "reqs");
1096 #endif /* LPROCFS */