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) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2011, 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/obdclass/lprocfs_status.c
34 * Author: Hariharan Thantry <thantry@users.sourceforge.net>
37 #define DEBUG_SUBSYSTEM S_CLASS
39 #include <obd_class.h>
40 #include <lprocfs_status.h>
44 static int lprocfs_no_percpu_stats = 0;
45 module_param(lprocfs_no_percpu_stats, int, 0644);
46 MODULE_PARM_DESC(lprocfs_no_percpu_stats, "Do not alloc percpu data for lprocfs stats");
48 #define MAX_STRING_SIZE 128
50 int lprocfs_single_release(struct inode *inode, struct file *file)
52 return single_release(inode, file);
54 EXPORT_SYMBOL(lprocfs_single_release);
56 int lprocfs_seq_release(struct inode *inode, struct file *file)
58 return seq_release(inode, file);
60 EXPORT_SYMBOL(lprocfs_seq_release);
62 struct dentry *ldebugfs_add_simple(struct dentry *root,
63 char *name, void *data,
64 const struct file_operations *fops)
69 if (!root || !name || !fops)
70 return ERR_PTR(-EINVAL);
76 entry = debugfs_create_file(name, mode, root, data, fops);
77 if (IS_ERR_OR_NULL(entry)) {
78 CERROR("LprocFS: No memory to create <debugfs> entry %s", name);
79 return entry ?: ERR_PTR(-ENOMEM);
83 EXPORT_SYMBOL(ldebugfs_add_simple);
85 struct proc_dir_entry *
86 lprocfs_add_simple(struct proc_dir_entry *root, char *name,
87 void *data, const struct file_operations *fops)
89 struct proc_dir_entry *proc;
92 if (!root || !name || !fops)
93 return ERR_PTR(-EINVAL);
99 proc = proc_create_data(name, mode, root, fops, data);
101 CERROR("LprocFS: No memory to create /proc entry %s\n",
103 return ERR_PTR(-ENOMEM);
107 EXPORT_SYMBOL(lprocfs_add_simple);
109 struct proc_dir_entry *lprocfs_add_symlink(const char *name,
110 struct proc_dir_entry *parent,
111 const char *format, ...)
113 struct proc_dir_entry *entry;
117 if (!parent || !format)
120 OBD_ALLOC_WAIT(dest, MAX_STRING_SIZE + 1);
124 va_start(ap, format);
125 vsnprintf(dest, MAX_STRING_SIZE, format, ap);
128 entry = proc_symlink(name, parent, dest);
130 CERROR("LprocFS: Could not create symbolic link from "
131 "%s to %s\n", name, dest);
133 OBD_FREE(dest, MAX_STRING_SIZE + 1);
136 EXPORT_SYMBOL(lprocfs_add_symlink);
138 static const struct file_operations lprocfs_generic_fops = { };
140 int ldebugfs_add_vars(struct dentry *parent, struct lprocfs_vars *list,
143 if (IS_ERR_OR_NULL(parent) || IS_ERR_OR_NULL(list))
147 struct dentry *entry;
150 if (list->proc_mode != 0000) {
151 mode = list->proc_mode;
152 } else if (list->fops) {
153 if (list->fops->read)
155 if (list->fops->write)
158 entry = debugfs_create_file(list->name, mode, parent,
160 list->fops ? : &lprocfs_generic_fops);
161 if (IS_ERR_OR_NULL(entry))
162 return entry ? PTR_ERR(entry) : -ENOMEM;
167 EXPORT_SYMBOL_GPL(ldebugfs_add_vars);
172 * \param root [in] The parent proc entry on which new entry will be added.
173 * \param list [in] Array of proc entries to be added.
174 * \param data [in] The argument to be passed when entries read/write routines
175 * are called through /proc file.
177 * \retval 0 on success
181 lprocfs_add_vars(struct proc_dir_entry *root, struct lprocfs_vars *list,
188 struct proc_dir_entry *proc;
191 if (list->proc_mode != 0000) {
192 mode = list->proc_mode;
193 } else if (list->fops) {
194 if (list->fops->read)
196 if (list->fops->write)
199 proc = proc_create_data(list->name, mode, root,
200 list->fops ?: &lprocfs_generic_fops,
208 EXPORT_SYMBOL(lprocfs_add_vars);
210 void lprocfs_remove(struct proc_dir_entry **rooth)
215 EXPORT_SYMBOL(lprocfs_remove);
217 void lprocfs_remove_proc_entry(const char *name, struct proc_dir_entry *parent)
219 LASSERT(parent != NULL);
220 remove_proc_entry(name, parent);
222 EXPORT_SYMBOL(lprocfs_remove_proc_entry);
224 struct dentry *ldebugfs_register(const char *name, struct dentry *parent,
225 struct lprocfs_vars *list, void *data)
227 struct dentry *entry;
229 entry = debugfs_create_dir(name, parent);
230 if (IS_ERR_OR_NULL(entry)) {
231 entry = entry ?: ERR_PTR(-ENOMEM);
235 if (!IS_ERR_OR_NULL(list)) {
238 rc = ldebugfs_add_vars(entry, list, data);
240 debugfs_remove(entry);
247 EXPORT_SYMBOL_GPL(ldebugfs_register);
249 struct proc_dir_entry *
250 lprocfs_register(const char *name, struct proc_dir_entry *parent,
251 struct lprocfs_vars *list, void *data)
253 struct proc_dir_entry *newchild;
255 newchild = proc_mkdir(name, parent);
257 return ERR_PTR(-ENOMEM);
260 int rc = lprocfs_add_vars(newchild, list, data);
262 lprocfs_remove(&newchild);
268 EXPORT_SYMBOL(lprocfs_register);
270 /* Generic callbacks */
271 int lprocfs_uuid_seq_show(struct seq_file *m, void *data)
273 struct obd_device *obd = data;
275 LASSERT(obd != NULL);
276 seq_printf(m, "%s\n", obd->obd_uuid.uuid);
279 EXPORT_SYMBOL(lprocfs_uuid_seq_show);
281 static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr,
284 struct obd_device *obd = container_of(kobj, struct obd_device,
287 return sprintf(buf, "%s\n", obd->obd_uuid.uuid);
289 LUSTRE_RO_ATTR(uuid);
291 static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr,
294 struct obd_device *obd = container_of(kobj, struct obd_device,
296 struct obd_statfs osfs;
299 rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
300 ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS,
303 return sprintf(buf, "%u\n", osfs.os_bsize);
307 LUSTRE_RO_ATTR(blocksize);
309 static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr,
312 struct obd_device *obd = container_of(kobj, struct obd_device,
314 struct obd_statfs osfs;
317 rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
318 ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS,
321 u32 blk_size = osfs.os_bsize >> 10;
322 u64 result = osfs.os_blocks;
324 result *= rounddown_pow_of_two(blk_size ?: 1);
325 return sprintf(buf, "%llu\n", result);
330 LUSTRE_RO_ATTR(kbytestotal);
332 static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr,
335 struct obd_device *obd = container_of(kobj, struct obd_device,
337 struct obd_statfs osfs;
340 rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
341 ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS,
344 u32 blk_size = osfs.os_bsize >> 10;
345 u64 result = osfs.os_bfree;
347 while (blk_size >>= 1)
350 return sprintf(buf, "%llu\n", result);
355 LUSTRE_RO_ATTR(kbytesfree);
357 static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr,
360 struct obd_device *obd = container_of(kobj, struct obd_device,
362 struct obd_statfs osfs;
365 rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
366 ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS,
369 u32 blk_size = osfs.os_bsize >> 10;
370 u64 result = osfs.os_bavail;
372 while (blk_size >>= 1)
375 return sprintf(buf, "%llu\n", result);
380 LUSTRE_RO_ATTR(kbytesavail);
382 static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr,
385 struct obd_device *obd = container_of(kobj, struct obd_device,
387 struct obd_statfs osfs;
390 rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
391 ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS,
394 return sprintf(buf, "%llu\n", osfs.os_files);
398 LUSTRE_RO_ATTR(filestotal);
400 static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr,
403 struct obd_device *obd = container_of(kobj, struct obd_device,
405 struct obd_statfs osfs;
408 rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
409 ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS,
412 return sprintf(buf, "%llu\n", osfs.os_ffree);
416 LUSTRE_RO_ATTR(filesfree);
418 ssize_t conn_uuid_show(struct kobject *kobj, struct attribute *attr, char *buf)
420 struct obd_device *obd = container_of(kobj, struct obd_device,
422 struct obd_import *imp;
423 struct ptlrpc_connection *conn;
426 with_imp_locked(obd, imp, count) {
427 conn = imp->imp_connection;
429 count = sprintf(buf, "%s\n", conn->c_remote_uuid.uuid);
431 count = sprintf(buf, "%s\n", "<none>");
436 EXPORT_SYMBOL(conn_uuid_show);
438 int lprocfs_server_uuid_seq_show(struct seq_file *m, void *data)
440 struct obd_device *obd = data;
441 struct obd_import *imp;
442 char *imp_state_name = NULL;
445 LASSERT(obd != NULL);
446 with_imp_locked(obd, imp, rc) {
447 imp_state_name = ptlrpc_import_state_name(imp->imp_state);
448 seq_printf(m, "%s\t%s%s\n", obd2cli_tgt(obd), imp_state_name,
449 imp->imp_deactive ? "\tDEACTIVATED" : "");
454 EXPORT_SYMBOL(lprocfs_server_uuid_seq_show);
456 /** add up per-cpu counters */
459 * Lock statistics structure for access, possibly only on this CPU.
461 * The statistics struct may be allocated with per-CPU structures for
462 * efficient concurrent update (usually only on server-wide stats), or
463 * as a single global struct (e.g. for per-client or per-job statistics),
464 * so the required locking depends on the type of structure allocated.
466 * For per-CPU statistics, pin the thread to the current cpuid so that
467 * will only access the statistics for that CPU. If the stats structure
468 * for the current CPU has not been allocated (or previously freed),
469 * allocate it now. The per-CPU statistics do not need locking since
470 * the thread is pinned to the CPU during update.
472 * For global statistics, lock the stats structure to prevent concurrent update.
474 * \param[in] stats statistics structure to lock
475 * \param[in] opc type of operation:
476 * LPROCFS_GET_SMP_ID: "lock" and return current CPU index
477 * for incrementing statistics for that CPU
478 * LPROCFS_GET_NUM_CPU: "lock" and return number of used
479 * CPU indices to iterate over all indices
480 * \param[out] flags CPU interrupt saved state for IRQ-safe locking
482 * \retval cpuid of current thread or number of allocated structs
483 * \retval negative on error (only for opc LPROCFS_GET_SMP_ID + per-CPU stats)
485 int lprocfs_stats_lock(struct lprocfs_stats *stats,
486 enum lprocfs_stats_lock_ops opc,
487 unsigned long *flags)
489 if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) {
490 if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE)
491 spin_lock_irqsave(&stats->ls_lock, *flags);
493 spin_lock(&stats->ls_lock);
494 return opc == LPROCFS_GET_NUM_CPU ? 1 : 0;
498 case LPROCFS_GET_SMP_ID: {
499 unsigned int cpuid = get_cpu();
501 if (unlikely(!stats->ls_percpu[cpuid])) {
502 int rc = lprocfs_stats_alloc_one(stats, cpuid);
511 case LPROCFS_GET_NUM_CPU:
512 return stats->ls_biggest_alloc_num;
519 * Unlock statistics structure after access.
521 * Unlock the lock acquired via lprocfs_stats_lock() for global statistics,
522 * or unpin this thread from the current cpuid for per-CPU statistics.
524 * This function must be called using the same arguments as used when calling
525 * lprocfs_stats_lock() so that the correct operation can be performed.
527 * \param[in] stats statistics structure to unlock
528 * \param[in] opc type of operation (current cpuid or number of structs)
529 * \param[in] flags CPU interrupt saved state for IRQ-safe locking
531 void lprocfs_stats_unlock(struct lprocfs_stats *stats,
532 enum lprocfs_stats_lock_ops opc,
533 unsigned long *flags)
535 if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) {
536 if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE)
537 spin_unlock_irqrestore(&stats->ls_lock, *flags);
539 spin_unlock(&stats->ls_lock);
540 } else if (opc == LPROCFS_GET_SMP_ID) {
545 /** add up per-cpu counters */
546 void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
547 struct lprocfs_counter *cnt)
549 unsigned int num_entry;
550 struct lprocfs_counter *percpu_cntr;
552 unsigned long flags = 0;
554 memset(cnt, 0, sizeof(*cnt));
557 /* set count to 1 to avoid divide-by-zero errs in callers */
562 cnt->lc_min = LC_MIN_INIT;
564 num_entry = lprocfs_stats_lock(stats, LPROCFS_GET_NUM_CPU, &flags);
566 for (i = 0; i < num_entry; i++) {
567 if (!stats->ls_percpu[i])
569 percpu_cntr = lprocfs_stats_counter_get(stats, i, idx);
571 cnt->lc_count += percpu_cntr->lc_count;
572 cnt->lc_sum += percpu_cntr->lc_sum;
573 if (percpu_cntr->lc_min < cnt->lc_min)
574 cnt->lc_min = percpu_cntr->lc_min;
575 if (percpu_cntr->lc_max > cnt->lc_max)
576 cnt->lc_max = percpu_cntr->lc_max;
577 cnt->lc_sumsquare += percpu_cntr->lc_sumsquare;
580 lprocfs_stats_unlock(stats, LPROCFS_GET_NUM_CPU, &flags);
583 static void obd_import_flags2str(struct obd_import *imp, struct seq_file *m)
587 if (imp->imp_obd->obd_no_recov) {
588 seq_printf(m, "no_recov");
592 flag2str(imp, invalid);
593 flag2str(imp, deactive);
594 flag2str(imp, replayable);
595 flag2str(imp, delayed_recovery);
596 flag2str(imp, vbr_failed);
597 flag2str(imp, pingable);
598 flag2str(imp, resend_replay);
599 flag2str(imp, no_pinger_recover);
600 flag2str(imp, connect_tried);
603 static const char *obd_connect_names[] = {
622 "remote_client_by_force",
631 "mds_mds_connection",
634 "alt_checksum_algorithm",
670 "file_secctx", /* 0x01 */
671 "lockaheadv2", /* 0x02 */
672 "dir_migrate", /* 0x04 */
673 "sum_statfs", /* 0x08 */
674 "overstriping", /* 0x10 */
677 "lock_convert", /* 0x80 */
678 "archive_id_array", /* 0x100 */
679 "increasing_xid", /* 0x200 */
680 "selinux_policy", /* 0x400 */
683 "crush", /* 0x2000 */
684 "async_discard", /* 0x4000 */
685 "client_encryption", /* 0x8000 */
689 void obd_connect_seq_flags2str(struct seq_file *m, __u64 flags, __u64 flags2,
696 for (i = 0, mask = 1; i < 64; i++, mask <<= 1) {
698 seq_printf(m, "%s%s",
699 first ? "" : sep, obd_connect_names[i]);
704 if (flags & ~(mask - 1)) {
705 seq_printf(m, "%sunknown_%#llx",
706 first ? "" : sep, flags & ~(mask - 1));
710 if (!(flags & OBD_CONNECT_FLAGS2) || flags2 == 0)
713 for (i = 64, mask = 1; obd_connect_names[i] != NULL; i++, mask <<= 1) {
715 seq_printf(m, "%s%s",
716 first ? "" : sep, obd_connect_names[i]);
721 if (flags2 & ~(mask - 1)) {
722 seq_printf(m, "%sunknown2_%#llx",
723 first ? "" : sep, flags2 & ~(mask - 1));
727 EXPORT_SYMBOL(obd_connect_seq_flags2str);
729 int obd_connect_flags2str(char *page, int count, __u64 flags, __u64 flags2,
735 for (i = 0, mask = 1; i < 64; i++, mask <<= 1) {
737 ret += snprintf(page + ret, count - ret, "%s%s",
738 ret ? sep : "", obd_connect_names[i]);
741 if (flags & ~(mask - 1))
742 ret += snprintf(page + ret, count - ret,
744 ret ? sep : "", flags & ~(mask - 1));
746 if (!(flags & OBD_CONNECT_FLAGS2) || flags2 == 0)
749 for (i = 64, mask = 1; obd_connect_names[i] != NULL; i++, mask <<= 1) {
751 ret += snprintf(page + ret, count - ret, "%s%s",
752 ret ? sep : "", obd_connect_names[i]);
755 if (flags2 & ~(mask - 1))
756 ret += snprintf(page + ret, count - ret,
758 ret ? sep : "", flags2 & ~(mask - 1));
762 EXPORT_SYMBOL(obd_connect_flags2str);
765 obd_connect_data_seqprint(struct seq_file *m, struct obd_connect_data *ocd)
769 LASSERT(ocd != NULL);
770 flags = ocd->ocd_connect_flags;
772 seq_printf(m, " connect_data:\n"
775 ocd->ocd_connect_flags,
777 if (flags & OBD_CONNECT_VERSION)
778 seq_printf(m, " target_version: %u.%u.%u.%u\n",
779 OBD_OCD_VERSION_MAJOR(ocd->ocd_version),
780 OBD_OCD_VERSION_MINOR(ocd->ocd_version),
781 OBD_OCD_VERSION_PATCH(ocd->ocd_version),
782 OBD_OCD_VERSION_FIX(ocd->ocd_version));
783 if (flags & OBD_CONNECT_MDS)
784 seq_printf(m, " mdt_index: %d\n", ocd->ocd_group);
785 if (flags & OBD_CONNECT_GRANT)
786 seq_printf(m, " initial_grant: %d\n", ocd->ocd_grant);
787 if (flags & OBD_CONNECT_INDEX)
788 seq_printf(m, " target_index: %u\n", ocd->ocd_index);
789 if (flags & OBD_CONNECT_BRW_SIZE)
790 seq_printf(m, " max_brw_size: %d\n", ocd->ocd_brw_size);
791 if (flags & OBD_CONNECT_IBITS)
792 seq_printf(m, " ibits_known: %#llx\n",
793 ocd->ocd_ibits_known);
794 if (flags & OBD_CONNECT_GRANT_PARAM)
795 seq_printf(m, " grant_block_size: %d\n"
796 " grant_inode_size: %d\n"
797 " grant_max_extent_size: %d\n"
798 " grant_extent_tax: %d\n",
799 1 << ocd->ocd_grant_blkbits,
800 1 << ocd->ocd_grant_inobits,
801 ocd->ocd_grant_max_blks << ocd->ocd_grant_blkbits,
802 ocd->ocd_grant_tax_kb << 10);
803 if (flags & OBD_CONNECT_TRANSNO)
804 seq_printf(m, " first_transno: %#llx\n",
806 if (flags & OBD_CONNECT_CKSUM)
807 seq_printf(m, " cksum_types: %#x\n",
808 ocd->ocd_cksum_types);
809 if (flags & OBD_CONNECT_MAX_EASIZE)
810 seq_printf(m, " max_easize: %d\n", ocd->ocd_max_easize);
811 if (flags & OBD_CONNECT_MAXBYTES)
812 seq_printf(m, " max_object_bytes: %llu\n",
814 if (flags & OBD_CONNECT_MULTIMODRPCS)
815 seq_printf(m, " max_mod_rpcs: %hu\n",
816 ocd->ocd_maxmodrpcs);
819 static void lprocfs_import_seq_show_locked(struct seq_file *m,
820 struct obd_device *obd,
821 struct obd_import *imp)
823 char nidstr[LNET_NIDSTR_SIZE];
824 struct lprocfs_counter ret;
825 struct lprocfs_counter_header *header;
826 struct obd_import_conn *conn;
827 struct obd_connect_data *ocd;
832 ocd = &imp->imp_connect_data;
834 seq_printf(m, "import:\n"
838 " connect_flags: [ ",
841 ptlrpc_import_state_name(imp->imp_state));
842 obd_connect_seq_flags2str(m, imp->imp_connect_data.ocd_connect_flags,
843 imp->imp_connect_data.ocd_connect_flags2,
845 seq_printf(m, " ]\n");
846 obd_connect_data_seqprint(m, ocd);
847 seq_printf(m, " import_flags: [ ");
848 obd_import_flags2str(imp, m);
852 " failover_nids: [ ");
853 spin_lock(&imp->imp_lock);
855 list_for_each_entry(conn, &imp->imp_conn_list, oic_item) {
856 libcfs_nid2str_r(conn->oic_conn->c_peer.nid,
857 nidstr, sizeof(nidstr));
858 seq_printf(m, "%s%s", j ? ", " : "", nidstr);
861 if (imp->imp_connection)
862 libcfs_nid2str_r(imp->imp_connection->c_peer.nid,
863 nidstr, sizeof(nidstr));
865 strncpy(nidstr, "<none>", sizeof(nidstr));
867 " current_connection: %s\n"
868 " connection_attempts: %u\n"
870 " in-progress_invalidations: %u\n"
875 atomic_read(&imp->imp_inval_count),
876 ktime_get_real_seconds() - imp->imp_last_reply_time);
877 spin_unlock(&imp->imp_lock);
879 if (!obd->obd_svc_stats)
882 header = &obd->obd_svc_stats->ls_cnt_header[PTLRPC_REQWAIT_CNTR];
883 lprocfs_stats_collect(obd->obd_svc_stats, PTLRPC_REQWAIT_CNTR, &ret);
884 if (ret.lc_count != 0)
885 ret.lc_sum = div64_s64(ret.lc_sum, ret.lc_count);
888 seq_printf(m, " rpcs:\n"
890 " unregistering: %u\n"
892 " avg_waittime: %llu %s\n",
893 atomic_read(&imp->imp_inflight),
894 atomic_read(&imp->imp_unregistering),
895 atomic_read(&imp->imp_timeouts),
896 ret.lc_sum, header->lc_units);
899 for(j = 0; j < IMP_AT_MAX_PORTALS; j++) {
900 if (imp->imp_at.iat_portal[j] == 0)
902 k = max_t(unsigned int, k,
903 at_get(&imp->imp_at.iat_service_estimate[j]));
905 seq_printf(m, " service_estimates:\n"
906 " services: %u sec\n"
907 " network: %u sec\n",
909 at_get(&imp->imp_at.iat_net_latency));
911 seq_printf(m, " transactions:\n"
912 " last_replay: %llu\n"
913 " peer_committed: %llu\n"
914 " last_checked: %llu\n",
915 imp->imp_last_replay_transno,
916 imp->imp_peer_committed_transno,
917 imp->imp_last_transno_checked);
920 for (rw = 0; rw <= 1; rw++) {
921 lprocfs_stats_collect(obd->obd_svc_stats,
922 PTLRPC_LAST_CNTR + BRW_READ_BYTES + rw,
924 if (ret.lc_sum > 0 && ret.lc_count > 0) {
925 ret.lc_sum = div64_s64(ret.lc_sum, ret.lc_count);
926 seq_printf(m, " %s_data_averages:\n"
927 " bytes_per_rpc: %llu\n",
928 rw ? "write" : "read",
932 j = opcode_offset(OST_READ + rw) + EXTRA_MAX_OPCODES;
933 header = &obd->obd_svc_stats->ls_cnt_header[j];
934 lprocfs_stats_collect(obd->obd_svc_stats, j, &ret);
935 if (ret.lc_sum > 0 && ret.lc_count != 0) {
936 ret.lc_sum = div64_s64(ret.lc_sum, ret.lc_count);
937 seq_printf(m, " %s_per_rpc: %llu\n",
938 header->lc_units, ret.lc_sum);
941 seq_printf(m, " MB_per_sec: %u.%.02u\n",
942 k / j, (100 * k / j) % 100);
947 int lprocfs_import_seq_show(struct seq_file *m, void *data)
949 struct obd_device *obd = (struct obd_device *)data;
950 struct obd_import *imp;
953 LASSERT(obd != NULL);
954 with_imp_locked(obd, imp, rv)
955 lprocfs_import_seq_show_locked(m, obd, imp);
958 EXPORT_SYMBOL(lprocfs_import_seq_show);
960 int lprocfs_state_seq_show(struct seq_file *m, void *data)
962 struct obd_device *obd = (struct obd_device *)data;
963 struct obd_import *imp;
967 LASSERT(obd != NULL);
968 with_imp_locked(obd, imp, rc) {
969 seq_printf(m, "current_state: %s\n",
970 ptlrpc_import_state_name(imp->imp_state));
971 seq_printf(m, "state_history:\n");
972 k = imp->imp_state_hist_idx;
973 for (j = 0; j < IMP_STATE_HIST_LEN; j++) {
974 struct import_state_hist *ish =
975 &imp->imp_state_hist[(k + j) % IMP_STATE_HIST_LEN];
976 if (ish->ish_state == 0)
978 seq_printf(m, " - [ %lld, %s ]\n", (s64)ish->ish_time,
979 ptlrpc_import_state_name(ish->ish_state));
985 EXPORT_SYMBOL(lprocfs_state_seq_show);
987 int lprocfs_at_hist_helper(struct seq_file *m, struct adaptive_timeout *at)
990 for (i = 0; i < AT_BINS; i++)
991 seq_printf(m, "%3u ", at->at_hist[i]);
995 EXPORT_SYMBOL(lprocfs_at_hist_helper);
997 /* See also ptlrpc_lprocfs_timeouts_show_seq */
998 static void lprocfs_timeouts_seq_show_locked(struct seq_file *m,
999 struct obd_device *obd,
1000 struct obd_import *imp)
1002 unsigned int cur, worst;
1003 time64_t now, worstt;
1006 LASSERT(obd != NULL);
1008 now = ktime_get_real_seconds();
1010 /* Some network health info for kicks */
1011 seq_printf(m, "%-10s : %lld, %llds ago\n",
1012 "last reply", (s64)imp->imp_last_reply_time,
1013 (s64)(now - imp->imp_last_reply_time));
1015 cur = at_get(&imp->imp_at.iat_net_latency);
1016 worst = imp->imp_at.iat_net_latency.at_worst_ever;
1017 worstt = imp->imp_at.iat_net_latency.at_worst_time;
1018 seq_printf(m, "%-10s : cur %3u worst %3u (at %lld, %llds ago) ",
1019 "network", cur, worst, (s64)worstt, (s64)(now - worstt));
1020 lprocfs_at_hist_helper(m, &imp->imp_at.iat_net_latency);
1022 for(i = 0; i < IMP_AT_MAX_PORTALS; i++) {
1023 if (imp->imp_at.iat_portal[i] == 0)
1025 cur = at_get(&imp->imp_at.iat_service_estimate[i]);
1026 worst = imp->imp_at.iat_service_estimate[i].at_worst_ever;
1027 worstt = imp->imp_at.iat_service_estimate[i].at_worst_time;
1028 seq_printf(m, "portal %-2d : cur %3u worst %3u (at %lld, %llds ago) ",
1029 imp->imp_at.iat_portal[i], cur, worst, (s64)worstt,
1030 (s64)(now - worstt));
1031 lprocfs_at_hist_helper(m, &imp->imp_at.iat_service_estimate[i]);
1035 int lprocfs_timeouts_seq_show(struct seq_file *m, void *data)
1037 struct obd_device *obd = (struct obd_device *)data;
1038 struct obd_import *imp;
1041 with_imp_locked(obd, imp, rc)
1042 lprocfs_timeouts_seq_show_locked(m, obd, imp);
1045 EXPORT_SYMBOL(lprocfs_timeouts_seq_show);
1047 int lprocfs_connect_flags_seq_show(struct seq_file *m, void *data)
1049 struct obd_device *obd = data;
1052 struct obd_import *imp;
1055 with_imp_locked(obd, imp, rc) {
1056 flags = imp->imp_connect_data.ocd_connect_flags;
1057 flags2 = imp->imp_connect_data.ocd_connect_flags2;
1058 seq_printf(m, "flags=%#llx\n", flags);
1059 seq_printf(m, "flags2=%#llx\n", flags2);
1060 obd_connect_seq_flags2str(m, flags, flags2, "\n");
1061 seq_printf(m, "\n");
1066 EXPORT_SYMBOL(lprocfs_connect_flags_seq_show);
1068 static const struct attribute *obd_def_uuid_attrs[] = {
1069 &lustre_attr_uuid.attr,
1073 static const struct attribute *obd_def_attrs[] = {
1074 &lustre_attr_blocksize.attr,
1075 &lustre_attr_kbytestotal.attr,
1076 &lustre_attr_kbytesfree.attr,
1077 &lustre_attr_kbytesavail.attr,
1078 &lustre_attr_filestotal.attr,
1079 &lustre_attr_filesfree.attr,
1080 &lustre_attr_uuid.attr,
1084 static void obd_sysfs_release(struct kobject *kobj)
1086 struct obd_device *obd = container_of(kobj, struct obd_device,
1089 complete(&obd->obd_kobj_unregister);
1092 int lprocfs_obd_setup(struct obd_device *obd, bool uuid_only)
1094 struct lprocfs_vars *debugfs_vars = NULL;
1097 if (!obd || obd->obd_magic != OBD_DEVICE_MAGIC)
1100 rc = kobject_set_name(&obd->obd_kset.kobj, "%s", obd->obd_name);
1104 obd->obd_ktype.sysfs_ops = &lustre_sysfs_ops;
1105 obd->obd_ktype.release = obd_sysfs_release;
1107 obd->obd_kset.kobj.parent = &obd->obd_type->typ_kobj;
1108 obd->obd_kset.kobj.ktype = &obd->obd_ktype;
1109 init_completion(&obd->obd_kobj_unregister);
1110 rc = kset_register(&obd->obd_kset);
1115 obd->obd_attrs = obd_def_uuid_attrs;
1117 obd->obd_attrs = obd_def_attrs;
1119 rc = sysfs_create_files(&obd->obd_kset.kobj, obd->obd_attrs);
1121 kset_unregister(&obd->obd_kset);
1125 if (!obd->obd_type->typ_procroot)
1126 debugfs_vars = obd->obd_vars;
1127 obd->obd_debugfs_entry = ldebugfs_register(obd->obd_name,
1128 obd->obd_type->typ_debugfs_entry,
1130 if (IS_ERR_OR_NULL(obd->obd_debugfs_entry)) {
1131 rc = obd->obd_debugfs_entry ? PTR_ERR(obd->obd_debugfs_entry)
1133 CERROR("error %d setting up debugfs for %s\n",
1135 obd->obd_debugfs_entry = NULL;
1137 sysfs_remove_files(&obd->obd_kset.kobj, obd->obd_attrs);
1138 obd->obd_attrs = NULL;
1139 kset_unregister(&obd->obd_kset);
1143 if (obd->obd_proc_entry || !obd->obd_type->typ_procroot)
1144 GOTO(already_registered, rc);
1146 obd->obd_proc_entry = lprocfs_register(obd->obd_name,
1147 obd->obd_type->typ_procroot,
1148 obd->obd_vars, obd);
1149 if (IS_ERR(obd->obd_proc_entry)) {
1150 rc = PTR_ERR(obd->obd_proc_entry);
1151 CERROR("error %d setting up lprocfs for %s\n",rc,obd->obd_name);
1152 obd->obd_proc_entry = NULL;
1154 debugfs_remove_recursive(obd->obd_debugfs_entry);
1155 obd->obd_debugfs_entry = NULL;
1157 sysfs_remove_files(&obd->obd_kset.kobj, obd->obd_attrs);
1158 obd->obd_attrs = NULL;
1159 kset_unregister(&obd->obd_kset);
1165 EXPORT_SYMBOL(lprocfs_obd_setup);
1167 int lprocfs_obd_cleanup(struct obd_device *obd)
1172 if (obd->obd_proc_exports_entry) {
1173 /* Should be no exports left */
1174 lprocfs_remove(&obd->obd_proc_exports_entry);
1175 obd->obd_proc_exports_entry = NULL;
1178 if (obd->obd_proc_entry) {
1179 lprocfs_remove(&obd->obd_proc_entry);
1180 obd->obd_proc_entry = NULL;
1183 debugfs_remove_recursive(obd->obd_debugfs_entry);
1184 obd->obd_debugfs_entry = NULL;
1186 /* obd device never allocated a kset */
1187 if (!obd->obd_kset.kobj.state_initialized)
1190 if (obd->obd_attrs) {
1191 sysfs_remove_files(&obd->obd_kset.kobj, obd->obd_attrs);
1192 obd->obd_attrs = NULL;
1195 kset_unregister(&obd->obd_kset);
1196 wait_for_completion(&obd->obd_kobj_unregister);
1199 EXPORT_SYMBOL(lprocfs_obd_cleanup);
1201 int lprocfs_stats_alloc_one(struct lprocfs_stats *stats, unsigned int cpuid)
1203 struct lprocfs_counter *cntr;
1204 unsigned int percpusize;
1206 unsigned long flags = 0;
1209 LASSERT(stats->ls_percpu[cpuid] == NULL);
1210 LASSERT((stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) == 0);
1212 percpusize = lprocfs_stats_counter_size(stats);
1213 LIBCFS_ALLOC_ATOMIC(stats->ls_percpu[cpuid], percpusize);
1214 if (stats->ls_percpu[cpuid]) {
1216 if (unlikely(stats->ls_biggest_alloc_num <= cpuid)) {
1217 if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE)
1218 spin_lock_irqsave(&stats->ls_lock, flags);
1220 spin_lock(&stats->ls_lock);
1221 if (stats->ls_biggest_alloc_num <= cpuid)
1222 stats->ls_biggest_alloc_num = cpuid + 1;
1223 if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) {
1224 spin_unlock_irqrestore(&stats->ls_lock, flags);
1226 spin_unlock(&stats->ls_lock);
1229 /* initialize the ls_percpu[cpuid] non-zero counter */
1230 for (i = 0; i < stats->ls_num; ++i) {
1231 cntr = lprocfs_stats_counter_get(stats, cpuid, i);
1232 cntr->lc_min = LC_MIN_INIT;
1238 struct lprocfs_stats *lprocfs_alloc_stats(unsigned int num,
1239 enum lprocfs_stats_flags flags)
1241 struct lprocfs_stats *stats;
1242 unsigned int num_entry;
1243 unsigned int percpusize = 0;
1249 if (lprocfs_no_percpu_stats != 0)
1250 flags |= LPROCFS_STATS_FLAG_NOPERCPU;
1252 if (flags & LPROCFS_STATS_FLAG_NOPERCPU)
1255 num_entry = num_possible_cpus();
1257 /* alloc percpu pointers for all possible cpu slots */
1258 LIBCFS_ALLOC(stats, offsetof(typeof(*stats), ls_percpu[num_entry]));
1262 stats->ls_num = num;
1263 stats->ls_flags = flags;
1264 spin_lock_init(&stats->ls_lock);
1266 /* alloc num of counter headers */
1267 CFS_ALLOC_PTR_ARRAY(stats->ls_cnt_header, stats->ls_num);
1268 if (!stats->ls_cnt_header)
1271 if ((flags & LPROCFS_STATS_FLAG_NOPERCPU) != 0) {
1272 /* contains only one set counters */
1273 percpusize = lprocfs_stats_counter_size(stats);
1274 LIBCFS_ALLOC_ATOMIC(stats->ls_percpu[0], percpusize);
1275 if (!stats->ls_percpu[0])
1277 stats->ls_biggest_alloc_num = 1;
1278 } else if ((flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0) {
1279 /* alloc all percpu data, currently only obd_memory use this */
1280 for (i = 0; i < num_entry; ++i)
1281 if (lprocfs_stats_alloc_one(stats, i) < 0)
1288 lprocfs_free_stats(&stats);
1291 EXPORT_SYMBOL(lprocfs_alloc_stats);
1293 void lprocfs_free_stats(struct lprocfs_stats **statsh)
1295 struct lprocfs_stats *stats = *statsh;
1296 unsigned int num_entry;
1297 unsigned int percpusize;
1300 if (!stats || stats->ls_num == 0)
1304 if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU)
1307 num_entry = num_possible_cpus();
1309 percpusize = lprocfs_stats_counter_size(stats);
1310 for (i = 0; i < num_entry; i++)
1311 if (stats->ls_percpu[i])
1312 LIBCFS_FREE(stats->ls_percpu[i], percpusize);
1313 if (stats->ls_cnt_header)
1314 CFS_FREE_PTR_ARRAY(stats->ls_cnt_header, stats->ls_num);
1315 LIBCFS_FREE(stats, offsetof(typeof(*stats), ls_percpu[num_entry]));
1317 EXPORT_SYMBOL(lprocfs_free_stats);
1319 u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx,
1320 enum lprocfs_fields_flags field)
1322 unsigned long flags = 0;
1323 unsigned int num_cpu;
1329 num_cpu = lprocfs_stats_lock(stats, LPROCFS_GET_NUM_CPU, &flags);
1330 for (i = 0; i < num_cpu; i++) {
1331 struct lprocfs_counter *cntr;
1333 if (!stats->ls_percpu[i])
1336 cntr = lprocfs_stats_counter_get(stats, i, idx);
1337 ret += lprocfs_read_helper(cntr, &stats->ls_cnt_header[idx],
1338 stats->ls_flags, field);
1340 lprocfs_stats_unlock(stats, LPROCFS_GET_NUM_CPU, &flags);
1343 EXPORT_SYMBOL(lprocfs_stats_collector);
1345 void lprocfs_clear_stats(struct lprocfs_stats *stats)
1347 struct lprocfs_counter *percpu_cntr;
1350 unsigned int num_entry;
1351 unsigned long flags = 0;
1353 num_entry = lprocfs_stats_lock(stats, LPROCFS_GET_NUM_CPU, &flags);
1355 for (i = 0; i < num_entry; i++) {
1356 if (!stats->ls_percpu[i])
1358 for (j = 0; j < stats->ls_num; j++) {
1359 percpu_cntr = lprocfs_stats_counter_get(stats, i, j);
1360 percpu_cntr->lc_count = 0;
1361 percpu_cntr->lc_min = LC_MIN_INIT;
1362 percpu_cntr->lc_max = 0;
1363 percpu_cntr->lc_sumsquare = 0;
1364 percpu_cntr->lc_sum = 0;
1365 if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE)
1366 percpu_cntr->lc_sum_irq = 0;
1370 lprocfs_stats_unlock(stats, LPROCFS_GET_NUM_CPU, &flags);
1372 EXPORT_SYMBOL(lprocfs_clear_stats);
1374 static ssize_t lprocfs_stats_seq_write(struct file *file,
1375 const char __user *buf,
1376 size_t len, loff_t *off)
1378 struct seq_file *seq = file->private_data;
1379 struct lprocfs_stats *stats = seq->private;
1381 lprocfs_clear_stats(stats);
1386 static void *lprocfs_stats_seq_start(struct seq_file *p, loff_t *pos)
1388 struct lprocfs_stats *stats = p->private;
1390 return (*pos < stats->ls_num) ? pos : NULL;
1393 static void lprocfs_stats_seq_stop(struct seq_file *p, void *v)
1397 static void *lprocfs_stats_seq_next(struct seq_file *p, void *v, loff_t *pos)
1401 return lprocfs_stats_seq_start(p, pos);
1404 /* seq file export of one lprocfs counter */
1405 static int lprocfs_stats_seq_show(struct seq_file *p, void *v)
1407 struct lprocfs_stats *stats = p->private;
1408 struct lprocfs_counter_header *hdr;
1409 struct lprocfs_counter ctr;
1410 int idx = *(loff_t *)v;
1413 struct timespec64 now;
1415 ktime_get_real_ts64(&now);
1416 seq_printf(p, "%-25s %llu.%09lu secs.nsecs\n",
1417 "snapshot_time", (s64)now.tv_sec, now.tv_nsec);
1420 hdr = &stats->ls_cnt_header[idx];
1421 lprocfs_stats_collect(stats, idx, &ctr);
1423 if (ctr.lc_count == 0)
1426 seq_printf(p, "%-25s %lld samples [%s]", hdr->lc_name,
1427 ctr.lc_count, hdr->lc_units);
1429 if ((hdr->lc_config & LPROCFS_CNTR_AVGMINMAX) && ctr.lc_count > 0) {
1430 seq_printf(p, " %lld %lld %lld",
1431 ctr.lc_min, ctr.lc_max, ctr.lc_sum);
1432 if (hdr->lc_config & LPROCFS_CNTR_STDDEV)
1433 seq_printf(p, " %llu", ctr.lc_sumsquare);
1439 static const struct seq_operations lprocfs_stats_seq_sops = {
1440 .start = lprocfs_stats_seq_start,
1441 .stop = lprocfs_stats_seq_stop,
1442 .next = lprocfs_stats_seq_next,
1443 .show = lprocfs_stats_seq_show,
1446 static int lprocfs_stats_seq_open(struct inode *inode, struct file *file)
1448 struct seq_file *seq;
1451 rc = seq_open(file, &lprocfs_stats_seq_sops);
1454 seq = file->private_data;
1455 seq->private = inode->i_private ? inode->i_private : PDE_DATA(inode);
1459 static const struct file_operations lprocfs_stats_seq_fops = {
1460 .owner = THIS_MODULE,
1461 .open = lprocfs_stats_seq_open,
1463 .write = lprocfs_stats_seq_write,
1464 .llseek = seq_lseek,
1465 .release = lprocfs_seq_release,
1468 int ldebugfs_register_stats(struct dentry *parent, const char *name,
1469 struct lprocfs_stats *stats)
1471 struct dentry *entry;
1473 LASSERT(!IS_ERR_OR_NULL(parent));
1475 entry = debugfs_create_file(name, 0644, parent, stats,
1476 &lprocfs_stats_seq_fops);
1477 if (IS_ERR_OR_NULL(entry))
1478 return entry ? PTR_ERR(entry) : -ENOMEM;
1482 EXPORT_SYMBOL_GPL(ldebugfs_register_stats);
1484 int lprocfs_register_stats(struct proc_dir_entry *root, const char *name,
1485 struct lprocfs_stats *stats)
1487 struct proc_dir_entry *entry;
1488 LASSERT(root != NULL);
1490 entry = proc_create_data(name, 0644, root,
1491 &lprocfs_stats_seq_fops, stats);
1496 EXPORT_SYMBOL(lprocfs_register_stats);
1498 void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
1499 unsigned conf, const char *name, const char *units)
1501 struct lprocfs_counter_header *header;
1502 struct lprocfs_counter *percpu_cntr;
1503 unsigned long flags = 0;
1505 unsigned int num_cpu;
1507 LASSERT(stats != NULL);
1509 header = &stats->ls_cnt_header[index];
1510 LASSERTF(header != NULL, "Failed to allocate stats header:[%d]%s/%s\n",
1511 index, name, units);
1513 header->lc_config = conf;
1514 header->lc_name = name;
1515 header->lc_units = units;
1517 num_cpu = lprocfs_stats_lock(stats, LPROCFS_GET_NUM_CPU, &flags);
1518 for (i = 0; i < num_cpu; ++i) {
1519 if (!stats->ls_percpu[i])
1521 percpu_cntr = lprocfs_stats_counter_get(stats, i, index);
1522 percpu_cntr->lc_count = 0;
1523 percpu_cntr->lc_min = LC_MIN_INIT;
1524 percpu_cntr->lc_max = 0;
1525 percpu_cntr->lc_sumsquare = 0;
1526 percpu_cntr->lc_sum = 0;
1527 if ((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
1528 percpu_cntr->lc_sum_irq = 0;
1530 lprocfs_stats_unlock(stats, LPROCFS_GET_NUM_CPU, &flags);
1532 EXPORT_SYMBOL(lprocfs_counter_init);
1534 static const char * const mps_stats[] = {
1535 [LPROC_MD_CLOSE] = "close",
1536 [LPROC_MD_CREATE] = "create",
1537 [LPROC_MD_ENQUEUE] = "enqueue",
1538 [LPROC_MD_GETATTR] = "getattr",
1539 [LPROC_MD_INTENT_LOCK] = "intent_lock",
1540 [LPROC_MD_LINK] = "link",
1541 [LPROC_MD_RENAME] = "rename",
1542 [LPROC_MD_SETATTR] = "setattr",
1543 [LPROC_MD_FSYNC] = "fsync",
1544 [LPROC_MD_READ_PAGE] = "read_page",
1545 [LPROC_MD_UNLINK] = "unlink",
1546 [LPROC_MD_SETXATTR] = "setxattr",
1547 [LPROC_MD_GETXATTR] = "getxattr",
1548 [LPROC_MD_INTENT_GETATTR_ASYNC] = "intent_getattr_async",
1549 [LPROC_MD_REVALIDATE_LOCK] = "revalidate_lock",
1552 int lprocfs_alloc_md_stats(struct obd_device *obd,
1553 unsigned int num_private_stats)
1555 struct lprocfs_stats *stats;
1556 unsigned int num_stats;
1560 * TODO Ensure that this function is only used where
1561 * appropriate by adding an assertion to the effect that
1562 * obd->obd_type->typ_md_ops is not NULL. We can't do this now
1563 * because mdt_procfs_init() uses this function to allocate
1564 * the stats backing /proc/fs/lustre/mdt/.../md_stats but the
1565 * mdt layer does not use the md_ops interface. This is
1566 * confusing and a waste of memory. See LU-2484.
1568 LASSERT(obd->obd_proc_entry != NULL);
1569 LASSERT(obd->obd_md_stats == NULL);
1571 num_stats = ARRAY_SIZE(mps_stats) + num_private_stats;
1572 stats = lprocfs_alloc_stats(num_stats, 0);
1576 for (i = 0; i < ARRAY_SIZE(mps_stats); i++) {
1577 lprocfs_counter_init(stats, i, 0, mps_stats[i], "reqs");
1578 if (!stats->ls_cnt_header[i].lc_name) {
1579 CERROR("Missing md_stat initializer md_op operation at offset %d. Aborting.\n",
1585 rc = lprocfs_register_stats(obd->obd_proc_entry, "md_stats", stats);
1587 lprocfs_free_stats(&stats);
1589 obd->obd_md_stats = stats;
1594 EXPORT_SYMBOL(lprocfs_alloc_md_stats);
1596 void lprocfs_free_md_stats(struct obd_device *obd)
1598 struct lprocfs_stats *stats = obd->obd_md_stats;
1601 obd->obd_md_stats = NULL;
1602 lprocfs_free_stats(&stats);
1605 EXPORT_SYMBOL(lprocfs_free_md_stats);
1607 void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats)
1609 lprocfs_counter_init(ldlm_stats,
1610 LDLM_ENQUEUE - LDLM_FIRST_OPC,
1611 0, "ldlm_enqueue", "reqs");
1612 lprocfs_counter_init(ldlm_stats,
1613 LDLM_CONVERT - LDLM_FIRST_OPC,
1614 0, "ldlm_convert", "reqs");
1615 lprocfs_counter_init(ldlm_stats,
1616 LDLM_CANCEL - LDLM_FIRST_OPC,
1617 0, "ldlm_cancel", "reqs");
1618 lprocfs_counter_init(ldlm_stats,
1619 LDLM_BL_CALLBACK - LDLM_FIRST_OPC,
1620 0, "ldlm_bl_callback", "reqs");
1621 lprocfs_counter_init(ldlm_stats,
1622 LDLM_CP_CALLBACK - LDLM_FIRST_OPC,
1623 0, "ldlm_cp_callback", "reqs");
1624 lprocfs_counter_init(ldlm_stats,
1625 LDLM_GL_CALLBACK - LDLM_FIRST_OPC,
1626 0, "ldlm_gl_callback", "reqs");
1628 EXPORT_SYMBOL(lprocfs_init_ldlm_stats);
1630 __s64 lprocfs_read_helper(struct lprocfs_counter *lc,
1631 struct lprocfs_counter_header *header,
1632 enum lprocfs_stats_flags flags,
1633 enum lprocfs_fields_flags field)
1641 case LPROCFS_FIELDS_FLAGS_CONFIG:
1642 ret = header->lc_config;
1644 case LPROCFS_FIELDS_FLAGS_SUM:
1646 if ((flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
1647 ret += lc->lc_sum_irq;
1649 case LPROCFS_FIELDS_FLAGS_MIN:
1652 case LPROCFS_FIELDS_FLAGS_MAX:
1655 case LPROCFS_FIELDS_FLAGS_AVG:
1656 ret = (lc->lc_max - lc->lc_min) / 2;
1658 case LPROCFS_FIELDS_FLAGS_SUMSQUARE:
1659 ret = lc->lc_sumsquare;
1661 case LPROCFS_FIELDS_FLAGS_COUNT:
1669 EXPORT_SYMBOL(lprocfs_read_helper);
1672 * string_to_size - convert ASCII string representing a numerical
1673 * value with optional units to 64-bit binary value
1675 * @size: The numerical value extract out of @buffer
1676 * @buffer: passed in string to parse
1677 * @count: length of the @buffer
1679 * This function returns a 64-bit binary value if @buffer contains a valid
1680 * numerical string. The string is parsed to 3 significant figures after
1681 * the decimal point. Support the string containing an optional units at
1682 * the end which can be base 2 or base 10 in value. If no units are given
1683 * the string is assumed to just a numerical value.
1685 * Returns: @count if the string is successfully parsed,
1686 * -errno on invalid input strings. Error values:
1688 * - ``-EINVAL``: @buffer is not a proper numerical string
1689 * - ``-EOVERFLOW``: results does not fit into 64 bits.
1690 * - ``-E2BIG ``: @buffer is not large
1692 int string_to_size(u64 *size, const char *buffer, size_t count)
1694 /* For string_get_size() it can support values above exabytes,
1695 * (ZiB, YiB) due to breaking the return value into a size and
1696 * bulk size to avoid 64 bit overflow. We don't break the size
1697 * up into block size units so we don't support ZiB or YiB.
1699 static const char *const units_10[] = {
1700 "kB", "MB", "GB", "TB", "PB", "EB"
1702 static const char *const units_2[] = {
1703 "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"
1705 static const char *const *const units_str[] = {
1706 [STRING_UNITS_2] = units_2,
1707 [STRING_UNITS_10] = units_10,
1709 static const unsigned int coeff[] = {
1710 [STRING_UNITS_10] = 1000,
1711 [STRING_UNITS_2] = 1024,
1713 enum string_size_units unit;
1714 u64 whole, blk_size = 1;
1715 char kernbuf[22], *end;
1720 if (count >= sizeof(kernbuf))
1724 /* 'iB' is used for based 2 numbers. If @buffer contains only a 'B'
1725 * or only numbers then we treat it as a direct number which doesn't
1726 * matter if its STRING_UNITS_2 or STRING_UNIT_10.
1728 unit = strstr(buffer, "iB") ? STRING_UNITS_2 : STRING_UNITS_10;
1729 i = unit == STRING_UNITS_2 ? ARRAY_SIZE(units_2) - 1 :
1730 ARRAY_SIZE(units_10) - 1;
1732 end = strstr(buffer, units_str[unit][i]);
1735 blk_size *= coeff[unit];
1741 /* as 'B' is a substring of all units, we need to handle it
1745 /* 'B' is only acceptable letter at this point */
1746 end = strchr(buffer, 'B');
1750 if (count - len > 2 ||
1751 (count - len == 2 && strcmp(end, "B\n") != 0))
1754 /* kstrtoull will error out if it has non digits */
1758 end = strchr(buffer, '.');
1760 /* need to limit 3 decimal places */
1761 char rem[4] = "000";
1768 /* limit to 3 decimal points */
1769 off = min_t(size_t, 3, strspn(end, "0123456789"));
1770 /* need to limit frac_d to a u32 */
1771 memcpy(rem, end, off);
1772 rc = kstrtoull(rem, 10, &frac);
1776 if (fls64(frac) + fls64(blk_size) - 1 > 64)
1784 snprintf(kernbuf, sizeof(kernbuf), "%.*s", (int)len, buffer);
1785 rc = kstrtoull(kernbuf, 10, &whole);
1789 if (whole != 0 && fls64(whole) + fls64(blk_size) - 1 > 64)
1792 *size += whole * blk_size;
1796 EXPORT_SYMBOL(string_to_size);
1799 * sysfs_memparse - parse a ASCII string to 64-bit binary value,
1800 * with optional units
1802 * @buffer: kernel pointer to input string
1803 * @count: number of bytes in the input @buffer
1804 * @val: (output) binary value returned to caller
1805 * @defunit: default unit suffix to use if none is provided
1807 * Parses a string into a number. The number stored at @buffer is
1808 * potentially suffixed with K, M, G, T, P, E. Besides these other
1809 * valid suffix units are shown in the string_to_size() function.
1810 * If the string lacks a suffix then the defunit is used. The defunit
1811 * should be given as a binary unit (e.g. MiB) as that is the standard
1812 * for tunables in Lustre. If no unit suffix is given (e.g. 'G'), then
1813 * it is assumed to be in binary units.
1815 * Returns: 0 on success or -errno on failure.
1817 int sysfs_memparse(const char *buffer, size_t count, u64 *val,
1818 const char *defunit)
1823 if (count >= sizeof(param))
1826 count = strlen(buffer);
1827 if (count && buffer[count - 1] == '\n')
1833 if (isalpha(buffer[count - 1])) {
1834 if (buffer[count - 1] != 'B') {
1835 scnprintf(param, sizeof(param), "%.*siB",
1836 (int)count, buffer);
1838 memcpy(param, buffer, sizeof(param));
1841 scnprintf(param, sizeof(param), "%.*s%s", (int)count,
1845 rc = string_to_size(val, param, strlen(param));
1846 return rc < 0 ? rc : 0;
1848 EXPORT_SYMBOL(sysfs_memparse);
1850 /* Obtains the conversion factor for the unit specified */
1851 static int get_mult(char unit, __u64 *mult)
1856 /* peta, tera, giga, mega, and kilo */
1877 /* some tests expect % to be accepted */
1891 * Ensures the numeric string is valid. The function provides the final
1892 * multiplier in the case a unit exists at the end of the string. It also
1893 * locates the start of the whole and fractional parts (if any). This
1894 * function modifies the string so kstrtoull can be used to parse both
1895 * the whole and fraction portions. This function also figures out
1896 * the base of the number.
1898 static int preprocess_numeric_str(char *buffer, __u64 *mult, __u64 def_mult,
1899 bool allow_units, char **whole, char **frac,
1902 bool hit_decimal = false;
1903 bool hit_unit = false;
1911 /* a hex string if it starts with "0x" */
1912 if (buffer[0] == '0' && tolower(buffer[1]) == 'x') {
1920 /* allow for a single new line before the null terminator */
1921 if (*buffer == '\n') {
1931 /* any chars after our unit indicates a malformed string */
1935 /* ensure we only hit one decimal */
1936 if (*buffer == '.') {
1940 /* if past start, there's a whole part */
1941 if (start != buffer)
1947 } else if (!isdigit(*buffer) &&
1948 !(*base == 16 && isxdigit(*buffer))) {
1950 /* if we allow units, attempt to get mult */
1952 rc = get_mult(*buffer, mult);
1956 /* string stops here, but keep processing */
1968 /* hit a decimal, make sure there's a fractional part */
1974 /* didn't hit a decimal, but may have a whole part */
1975 if (start != buffer && *start)
1979 /* malformed string if we didn't get anything */
1980 if (!*frac && !*whole)
1987 * Parses a numeric string which can contain a whole and fraction portion
1988 * into a __u64. Accepts a multiplier to apply to the value parsed. Also
1989 * allows the string to have a unit at the end. The function handles
1990 * wrapping of the final unsigned value.
1992 static int str_to_u64_parse(char *buffer, unsigned long count,
1993 __u64 *val, __u64 def_mult, bool allow_units)
1997 unsigned int frac_d = 1;
1998 __u64 wrap_indicator = ULLONG_MAX;
2003 unsigned int base = 10;
2005 rc = preprocess_numeric_str(buffer, &mult, def_mult, allow_units,
2006 &strwhole, &strfrac, &base);
2016 /* the multiplier limits how large the value can be */
2017 wrap_indicator = div64_u64(wrap_indicator, mult);
2020 rc = kstrtoull(strwhole, base, &whole);
2024 if (whole > wrap_indicator)
2031 if (strlen(strfrac) > 10)
2034 rc = kstrtoull(strfrac, base, &frac);
2038 /* determine power of fractional portion */
2044 /* fractional portion is too large to perform calculation */
2045 if (frac > wrap_indicator)
2049 do_div(frac, frac_d);
2052 /* check that the sum of whole and fraction fits in u64 */
2053 if (whole > (ULLONG_MAX - frac))
2056 *val = whole + frac;
2062 * This function parses numeric/hex strings into __s64. It accepts a multiplier
2063 * which will apply to the value parsed. It also can allow the string to
2064 * have a unit as the last character. The function handles overflow/underflow
2065 * of the signed integer.
2067 int lu_str_to_s64(char *buffer, unsigned long count, __s64 *val, char defunit)
2071 unsigned int offset = 0;
2072 int signed sign = 1;
2073 __u64 max = LLONG_MAX;
2076 if (defunit != '1') {
2077 rc = get_mult(defunit, &mult);
2082 /* keep track of our sign */
2083 if (*buffer == '-') {
2086 /* equivalent to max = -LLONG_MIN, avoids overflow */
2090 rc = str_to_u64_parse(buffer + offset, count - offset,
2095 /* check for overflow/underflow */
2099 *val = (__s64)tmp * sign;
2103 EXPORT_SYMBOL(lu_str_to_s64);
2105 /* identical to s64 version, but does not handle overflow */
2106 static int str_to_u64_internal(const char __user *buffer, unsigned long count,
2107 __u64 *val, __u64 def_mult, bool allow_units)
2110 unsigned int offset = 0;
2113 if (count > (sizeof(kernbuf) - 1))
2116 if (copy_from_user(kernbuf, buffer, count))
2119 kernbuf[count] = '\0';
2121 rc = str_to_u64_parse(kernbuf + offset, count - offset,
2122 val, def_mult, allow_units);
2129 * Convert a user string into a signed 64 bit number. This function produces
2130 * an error when the value parsed from the string times multiplier underflows or
2131 * overflows. This function only accepts strings that contains digits, an
2132 * optional decimal, and a char representing a unit at the end. If a unit is
2133 * specified in the string, the multiplier provided by the caller is ignored.
2134 * This function can also accept hexadecimal strings which are prefixed with
2137 * \param[in] buffer string consisting of numbers, a decimal, and a unit
2138 * \param[in] count buffer length
2139 * \param[in] val if successful, the value represented by the string
2140 * \param[in] defunit default unit if string doesn't contain one
2142 * \retval 0 on success
2143 * \retval negative number on error
2145 int lprocfs_str_with_units_to_s64(const char __user *buffer,
2146 unsigned long count, __s64 *val, char defunit)
2150 if (count > (sizeof(kernbuf) - 1))
2153 if (copy_from_user(kernbuf, buffer, count))
2156 kernbuf[count] = '\0';
2158 return lu_str_to_s64(kernbuf, count, val, defunit);
2160 EXPORT_SYMBOL(lprocfs_str_with_units_to_s64);
2162 /* identical to s64 version above, but does not handle overflow */
2163 int lprocfs_str_with_units_to_u64(const char __user *buffer,
2164 unsigned long count, __u64 *val, char defunit)
2169 if (defunit != '1') {
2170 rc = get_mult(defunit, &mult);
2175 return str_to_u64_internal(buffer, count, val, mult, true);
2177 EXPORT_SYMBOL(lprocfs_str_with_units_to_u64);
2179 char *lprocfs_strnstr(const char *s1, const char *s2, size_t len)
2188 if (!memcmp(s1, s2, l2))
2194 EXPORT_SYMBOL(lprocfs_strnstr);
2197 * Find the string \a name in the input \a buffer, and return a pointer to the
2198 * value immediately following \a name, reducing \a count appropriately.
2199 * If \a name is not found the original \a buffer is returned.
2201 char *lprocfs_find_named_value(const char *buffer, const char *name,
2205 size_t buflen = *count;
2207 /* there is no strnstr() in rhel5 and ubuntu kernels */
2208 val = lprocfs_strnstr(buffer, name, buflen);
2210 return (char *)buffer;
2212 val += strlen(name); /* skip prefix */
2213 while (val < buffer + buflen && isspace(*val)) /* skip separator */
2217 while (val < buffer + buflen && isalnum(*val)) {
2222 return val - *count;
2224 EXPORT_SYMBOL(lprocfs_find_named_value);
2226 int ldebugfs_seq_create(struct dentry *parent, const char *name, umode_t mode,
2227 const struct file_operations *seq_fops, void *data)
2229 struct dentry *entry;
2231 /* Disallow secretly (un)writable entries. */
2232 LASSERT((!seq_fops->write) == (!(mode & 0222)));
2234 entry = debugfs_create_file(name, mode, parent, data, seq_fops);
2235 if (IS_ERR_OR_NULL(entry))
2236 return entry ? PTR_ERR(entry) : -ENOMEM;
2240 EXPORT_SYMBOL_GPL(ldebugfs_seq_create);
2242 int lprocfs_seq_create(struct proc_dir_entry *parent,
2245 const struct file_operations *seq_fops,
2248 struct proc_dir_entry *entry;
2251 /* Disallow secretly (un)writable entries. */
2252 LASSERT((seq_fops->write == NULL) == ((mode & 0222) == 0));
2254 entry = proc_create_data(name, mode, parent, seq_fops, data);
2261 EXPORT_SYMBOL(lprocfs_seq_create);
2263 int lprocfs_obd_seq_create(struct obd_device *obd,
2266 const struct file_operations *seq_fops,
2269 return lprocfs_seq_create(obd->obd_proc_entry, name,
2270 mode, seq_fops, data);
2272 EXPORT_SYMBOL(lprocfs_obd_seq_create);
2274 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value)
2276 if (value >= OBD_HIST_MAX)
2277 value = OBD_HIST_MAX - 1;
2279 spin_lock(&oh->oh_lock);
2280 oh->oh_buckets[value]++;
2281 spin_unlock(&oh->oh_lock);
2283 EXPORT_SYMBOL(lprocfs_oh_tally);
2285 void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value)
2287 unsigned int val = 0;
2289 if (likely(value != 0))
2290 val = min(fls(value - 1), OBD_HIST_MAX);
2292 lprocfs_oh_tally(oh, val);
2294 EXPORT_SYMBOL(lprocfs_oh_tally_log2);
2296 unsigned long lprocfs_oh_sum(struct obd_histogram *oh)
2298 unsigned long ret = 0;
2301 for (i = 0; i < OBD_HIST_MAX; i++)
2302 ret += oh->oh_buckets[i];
2305 EXPORT_SYMBOL(lprocfs_oh_sum);
2307 void lprocfs_oh_clear(struct obd_histogram *oh)
2309 spin_lock(&oh->oh_lock);
2310 memset(oh->oh_buckets, 0, sizeof(oh->oh_buckets));
2311 spin_unlock(&oh->oh_lock);
2313 EXPORT_SYMBOL(lprocfs_oh_clear);
2315 ssize_t lustre_attr_show(struct kobject *kobj,
2316 struct attribute *attr, char *buf)
2318 struct lustre_attr *a = container_of(attr, struct lustre_attr, attr);
2320 return a->show ? a->show(kobj, attr, buf) : 0;
2322 EXPORT_SYMBOL_GPL(lustre_attr_show);
2324 ssize_t lustre_attr_store(struct kobject *kobj, struct attribute *attr,
2325 const char *buf, size_t len)
2327 struct lustre_attr *a = container_of(attr, struct lustre_attr, attr);
2329 return a->store ? a->store(kobj, attr, buf, len) : len;
2331 EXPORT_SYMBOL_GPL(lustre_attr_store);
2333 const struct sysfs_ops lustre_sysfs_ops = {
2334 .show = lustre_attr_show,
2335 .store = lustre_attr_store,
2337 EXPORT_SYMBOL_GPL(lustre_sysfs_ops);
2339 int lprocfs_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *data)
2341 struct obd_device *obd = data;
2342 struct client_obd *cli = &obd->u.cli;
2344 spin_lock(&cli->cl_loi_list_lock);
2345 seq_printf(m, "%d\n", cli->cl_max_pages_per_rpc);
2346 spin_unlock(&cli->cl_loi_list_lock);
2349 EXPORT_SYMBOL(lprocfs_obd_max_pages_per_rpc_seq_show);
2351 ssize_t lprocfs_obd_max_pages_per_rpc_seq_write(struct file *file,
2352 const char __user *buffer,
2353 size_t count, loff_t *off)
2355 struct seq_file *m = file->private_data;
2356 struct obd_device *obd = m->private;
2357 struct client_obd *cli = &obd->u.cli;
2358 struct obd_import *imp;
2359 struct obd_connect_data *ocd;
2364 if (count > sizeof(kernbuf) - 1)
2367 if (copy_from_user(kernbuf, buffer, count))
2370 kernbuf[count] = '\0';
2372 rc = sysfs_memparse(kernbuf, count, &val, "B");
2376 /* if the max_pages is specified in bytes, convert to pages */
2377 if (val >= ONE_MB_BRW_SIZE)
2380 with_imp_locked(obd, imp, rc) {
2381 ocd = &imp->imp_connect_data;
2382 chunk_mask = ~((1 << (cli->cl_chunkbits - PAGE_SHIFT)) - 1);
2383 /* max_pages_per_rpc must be chunk aligned */
2384 val = (val + ~chunk_mask) & chunk_mask;
2385 if (val == 0 || (ocd->ocd_brw_size != 0 &&
2386 val > ocd->ocd_brw_size >> PAGE_SHIFT)) {
2389 spin_lock(&cli->cl_loi_list_lock);
2390 cli->cl_max_pages_per_rpc = val;
2391 client_adjust_max_dirty(cli);
2392 spin_unlock(&cli->cl_loi_list_lock);
2398 EXPORT_SYMBOL(lprocfs_obd_max_pages_per_rpc_seq_write);
2400 ssize_t short_io_bytes_show(struct kobject *kobj, struct attribute *attr,
2403 struct obd_device *obd = container_of(kobj, struct obd_device,
2405 struct client_obd *cli = &obd->u.cli;
2408 spin_lock(&cli->cl_loi_list_lock);
2409 rc = sprintf(buf, "%d\n", cli->cl_max_short_io_bytes);
2410 spin_unlock(&cli->cl_loi_list_lock);
2413 EXPORT_SYMBOL(short_io_bytes_show);
2415 /* Used to catch people who think they're specifying pages. */
2416 #define MIN_SHORT_IO_BYTES 64U
2418 ssize_t short_io_bytes_store(struct kobject *kobj, struct attribute *attr,
2419 const char *buffer, size_t count)
2421 struct obd_device *obd = container_of(kobj, struct obd_device,
2423 struct client_obd *cli = &obd->u.cli;
2427 if (strcmp(buffer, "-1") == 0) {
2428 val = OBD_DEF_SHORT_IO_BYTES;
2430 rc = sysfs_memparse(buffer, count, &val, "B");
2435 if (val && (val < MIN_SHORT_IO_BYTES || val > LNET_MTU))
2436 GOTO(out, rc = -ERANGE);
2440 spin_lock(&cli->cl_loi_list_lock);
2441 cli->cl_max_short_io_bytes = min_t(u64, val, OST_MAX_SHORT_IO_BYTES);
2442 spin_unlock(&cli->cl_loi_list_lock);
2447 EXPORT_SYMBOL(short_io_bytes_store);
2449 int lprocfs_wr_root_squash(const char __user *buffer, unsigned long count,
2450 struct root_squash_info *squash, char *name)
2453 char kernbuf[64], *tmp, *errmsg;
2454 unsigned long uid, gid;
2457 if (count >= sizeof(kernbuf)) {
2458 errmsg = "string too long";
2459 GOTO(failed_noprint, rc = -EINVAL);
2461 if (copy_from_user(kernbuf, buffer, count)) {
2462 errmsg = "bad address";
2463 GOTO(failed_noprint, rc = -EFAULT);
2465 kernbuf[count] = '\0';
2467 /* look for uid gid separator */
2468 tmp = strchr(kernbuf, ':');
2470 errmsg = "needs uid:gid format";
2471 GOTO(failed, rc = -EINVAL);
2477 if (kstrtoul(kernbuf, 0, &uid) != 0) {
2479 GOTO(failed, rc = -EINVAL);
2483 if (kstrtoul(tmp, 0, &gid) != 0) {
2485 GOTO(failed, rc = -EINVAL);
2488 squash->rsi_uid = uid;
2489 squash->rsi_gid = gid;
2491 LCONSOLE_INFO("%s: root_squash is set to %u:%u\n",
2492 name, squash->rsi_uid, squash->rsi_gid);
2500 CWARN("%s: failed to set root_squash to \"%s\", %s, rc = %d\n",
2501 name, kernbuf, errmsg, rc);
2504 CWARN("%s: failed to set root_squash due to %s, rc = %d\n",
2508 EXPORT_SYMBOL(lprocfs_wr_root_squash);
2511 int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count,
2512 struct root_squash_info *squash, char *name)
2515 char *kernbuf = NULL;
2522 errmsg = "string too long";
2523 GOTO(failed, rc = -EINVAL);
2526 OBD_ALLOC(kernbuf, count + 1);
2528 errmsg = "no memory";
2529 GOTO(failed, rc = -ENOMEM);
2531 if (copy_from_user(kernbuf, buffer, count)) {
2532 errmsg = "bad address";
2533 GOTO(failed, rc = -EFAULT);
2535 kernbuf[count] = '\0';
2537 if (count > 0 && kernbuf[count - 1] == '\n')
2540 if ((len == 4 && strncmp(kernbuf, "NONE", len) == 0) ||
2541 (len == 5 && strncmp(kernbuf, "clear", len) == 0)) {
2542 /* empty string is special case */
2543 spin_lock(&squash->rsi_lock);
2544 if (!list_empty(&squash->rsi_nosquash_nids))
2545 cfs_free_nidlist(&squash->rsi_nosquash_nids);
2546 spin_unlock(&squash->rsi_lock);
2547 LCONSOLE_INFO("%s: nosquash_nids is cleared\n", name);
2548 OBD_FREE(kernbuf, count + 1);
2552 if (cfs_parse_nidlist(kernbuf, count, &tmp) <= 0) {
2553 errmsg = "can't parse";
2554 GOTO(failed, rc = -EINVAL);
2556 LCONSOLE_INFO("%s: nosquash_nids set to %s\n",
2558 OBD_FREE(kernbuf, count + 1);
2561 spin_lock(&squash->rsi_lock);
2562 if (!list_empty(&squash->rsi_nosquash_nids))
2563 cfs_free_nidlist(&squash->rsi_nosquash_nids);
2564 list_splice(&tmp, &squash->rsi_nosquash_nids);
2565 spin_unlock(&squash->rsi_lock);
2571 CWARN("%s: failed to set nosquash_nids to \"%s\", %s rc = %d\n",
2572 name, kernbuf, errmsg, rc);
2573 OBD_FREE(kernbuf, count + 1);
2575 CWARN("%s: failed to set nosquash_nids due to %s rc = %d\n",
2580 EXPORT_SYMBOL(lprocfs_wr_nosquash_nids);
2582 #endif /* CONFIG_PROC_FS*/