1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lustre/mdt/mdt_lproc.c
38 * Author: Lai Siyao <lsy@clusterfs.com>
39 * Author: Fan Yong <fanyong@clusterfs.com>
43 # define EXPORT_SYMTAB
45 #define DEBUG_SUBSYSTEM S_MDS
47 #include <linux/version.h>
48 #include <asm/statfs.h>
50 #include <linux/module.h>
52 /* LUSTRE_VERSION_CODE */
53 #include <lustre_ver.h>
55 * struct OBD_{ALLOC,FREE}*()
58 #include <obd_support.h>
59 /* struct obd_export */
60 #include <lustre_export.h>
61 /* struct obd_device */
63 #include <obd_class.h>
64 #include <lustre_mds.h>
65 #include <lustre_mdt.h>
66 #include <lprocfs_status.h>
68 #include "mdt_internal.h"
69 #include <lnet/lib-lnet.h>
74 static const char *mdt_proc_names[LPROC_MDT_NR] = {
77 int mdt_procfs_init(struct mdt_device *mdt, const char *name)
79 struct lu_device *ld = &mdt->mdt_md_dev.md_lu_dev;
80 struct obd_device *obd = ld->ld_obd;
81 struct lprocfs_static_vars lvars;
85 LASSERT(name != NULL);
87 lprocfs_mdt_init_vars(&lvars);
88 rc = lprocfs_obd_setup(obd, lvars.obd_vars);
90 CERROR("Can't init lprocfs, rc %d\n", rc);
93 ptlrpc_lprocfs_register_obd(obd);
95 mdt->mdt_proc_entry = obd->obd_proc_entry;
96 LASSERT(mdt->mdt_proc_entry != NULL);
98 rc = lu_time_init(&mdt->mdt_stats, mdt->mdt_proc_entry,
99 mdt_proc_names, ARRAY_SIZE(mdt_proc_names));
101 rc = lu_time_named_init(&ld->ld_site->ls_time_stats,
102 "site_time", mdt->mdt_proc_entry,
104 ARRAY_SIZE(lu_time_names));
108 obd->obd_proc_exports_entry = proc_mkdir("exports",
109 obd->obd_proc_entry);
110 if (obd->obd_proc_exports_entry)
111 lprocfs_add_simple(obd->obd_proc_exports_entry,
112 "clear", lprocfs_nid_stats_clear_read,
113 lprocfs_nid_stats_clear_write, obd, NULL);
114 rc = lprocfs_alloc_md_stats(obd, LPROC_MDT_LAST);
116 mdt_stats_counter_init(obd->md_stats);
121 int mdt_procfs_fini(struct mdt_device *mdt)
123 struct lu_device *ld = &mdt->mdt_md_dev.md_lu_dev;
124 struct obd_device *obd = ld->ld_obd;
126 if (mdt->mdt_proc_entry) {
127 lu_time_fini(&ld->ld_site->ls_time_stats);
128 lu_time_fini(&mdt->mdt_stats);
129 mdt->mdt_proc_entry = NULL;
131 if (obd->obd_proc_exports_entry) {
132 lprocfs_remove_proc_entry("clear", obd->obd_proc_exports_entry);
133 obd->obd_proc_exports_entry = NULL;
135 ptlrpc_lprocfs_unregister_obd(obd);
136 lprocfs_free_md_stats(obd);
137 lprocfs_obd_cleanup(obd);
142 void mdt_time_start(const struct mdt_thread_info *info)
144 lu_lprocfs_time_start(info->mti_env);
147 void mdt_time_end(const struct mdt_thread_info *info, int idx)
149 lu_lprocfs_time_end(info->mti_env, info->mti_mdt->mdt_stats, idx);
152 static int lprocfs_rd_identity_expire(char *page, char **start, off_t off,
153 int count, int *eof, void *data)
155 struct obd_device *obd = data;
156 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
159 return snprintf(page, count, "%u\n",
160 mdt->mdt_identity_cache->uc_entry_expire);
163 static int lprocfs_wr_identity_expire(struct file *file, const char *buffer,
164 unsigned long count, void *data)
166 struct obd_device *obd = data;
167 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
170 rc = lprocfs_write_helper(buffer, count, &val);
174 mdt->mdt_identity_cache->uc_entry_expire = val;
178 static int lprocfs_rd_identity_acquire_expire(char *page, char **start,
179 off_t off, int count, int *eof,
182 struct obd_device *obd = data;
183 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
186 return snprintf(page, count, "%u\n",
187 mdt->mdt_identity_cache->uc_acquire_expire);
190 static int lprocfs_wr_identity_acquire_expire(struct file *file,
195 struct obd_device *obd = data;
196 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
199 rc = lprocfs_write_helper(buffer, count, &val);
203 mdt->mdt_identity_cache->uc_acquire_expire = val;
207 static int lprocfs_rd_identity_upcall(char *page, char **start, off_t off,
208 int count, int *eof, void *data)
210 struct obd_device *obd = data;
211 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
212 struct upcall_cache *hash = mdt->mdt_identity_cache;
216 cfs_read_lock(&hash->uc_upcall_rwlock);
217 len = snprintf(page, count, "%s\n", hash->uc_upcall);
218 cfs_read_unlock(&hash->uc_upcall_rwlock);
222 static int lprocfs_wr_identity_upcall(struct file *file, const char *buffer,
223 unsigned long count, void *data)
225 struct obd_device *obd = data;
226 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
227 struct upcall_cache *hash = mdt->mdt_identity_cache;
231 if (count >= UC_CACHE_UPCALL_MAXPATH) {
232 CERROR("%s: identity upcall too long\n", obd->obd_name);
235 OBD_ALLOC(kernbuf, count + 1);
237 GOTO(failed, rc = -ENOMEM);
238 if (cfs_copy_from_user(kernbuf, buffer, count))
239 GOTO(failed, rc = -EFAULT);
241 /* Remove any extraneous bits from the upcall (e.g. linefeeds) */
242 cfs_write_lock(&hash->uc_upcall_rwlock);
243 sscanf(kernbuf, "%s", hash->uc_upcall);
244 cfs_write_unlock(&hash->uc_upcall_rwlock);
246 if (strcmp(hash->uc_name, obd->obd_name) != 0)
247 CWARN("%s: write to upcall name %s\n",
248 obd->obd_name, hash->uc_upcall);
250 if (strcmp(hash->uc_upcall, "NONE") == 0 && mdt->mdt_opts.mo_acl)
251 CWARN("%s: disable \"identity_upcall\" with ACL enabled maybe "
252 "cause unexpected \"EACCESS\"\n", obd->obd_name);
254 CWARN("%s: identity upcall set to %s\n", obd->obd_name, hash->uc_upcall);
255 OBD_FREE(kernbuf, count + 1);
260 OBD_FREE(kernbuf, count + 1);
264 static int lprocfs_wr_identity_flush(struct file *file, const char *buffer,
265 unsigned long count, void *data)
267 struct obd_device *obd = data;
268 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
271 rc = lprocfs_write_helper(buffer, count, &uid);
275 mdt_flush_identity(mdt->mdt_identity_cache, uid);
279 static int lprocfs_wr_identity_info(struct file *file, const char *buffer,
280 unsigned long count, void *data)
282 struct obd_device *obd = data;
283 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
284 struct identity_downcall_data sparam, *param = &sparam;
285 int size = 0, rc = 0;
287 if (count < sizeof(*param)) {
288 CERROR("%s: invalid data size %lu\n", obd->obd_name, count);
292 if (cfs_copy_from_user(&sparam, buffer, sizeof(sparam))) {
293 CERROR("%s: bad identity data\n", obd->obd_name);
294 GOTO(out, rc = -EFAULT);
297 if (sparam.idd_magic != IDENTITY_DOWNCALL_MAGIC) {
298 CERROR("%s: MDS identity downcall bad params\n", obd->obd_name);
299 GOTO(out, rc = -EINVAL);
302 if (sparam.idd_nperms > N_PERMS_MAX) {
303 CERROR("%s: perm count %d more than maximum %d\n",
304 obd->obd_name, sparam.idd_nperms, N_PERMS_MAX);
305 GOTO(out, rc = -EINVAL);
308 if (sparam.idd_ngroups > NGROUPS_MAX) {
309 CERROR("%s: group count %d more than maximum %d\n",
310 obd->obd_name, sparam.idd_ngroups, NGROUPS_MAX);
311 GOTO(out, rc = -EINVAL);
314 if (sparam.idd_ngroups) {
315 size = offsetof(struct identity_downcall_data,
316 idd_groups[sparam.idd_ngroups]);
317 OBD_ALLOC(param, size);
319 CERROR("%s: fail to alloc %d bytes for uid %u"
320 " with %d groups\n", obd->obd_name, size,
321 sparam.idd_uid, sparam.idd_ngroups);
323 param->idd_ngroups = 0;
324 } else if (cfs_copy_from_user(param, buffer, size)) {
325 CERROR("%s: uid %u bad supplementary group data\n",
326 obd->obd_name, sparam.idd_uid);
327 OBD_FREE(param, size);
329 param->idd_ngroups = 0;
333 rc = upcall_cache_downcall(mdt->mdt_identity_cache, param->idd_err,
334 param->idd_uid, param);
337 if (param && (param != &sparam))
338 OBD_FREE(param, size);
344 static int lprocfs_rd_capa(char *page, char **start, off_t off,
345 int count, int *eof, void *data)
347 struct obd_device *obd = data;
348 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
350 return snprintf(page, count, "capability on: %s %s\n",
351 mdt->mdt_opts.mo_oss_capa ? "oss" : "",
352 mdt->mdt_opts.mo_mds_capa ? "mds" : "");
355 static int lprocfs_wr_capa(struct file *file, const char *buffer,
356 unsigned long count, void *data)
358 struct obd_device *obd = data;
359 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
362 rc = lprocfs_write_helper(buffer, count, &val);
366 if (val < 0 || val > 3) {
367 CERROR("invalid capability mode, only 0/2/3 is accepted.\n"
368 " 0: disable fid capability\n"
369 " 2: enable MDS fid capability\n"
370 " 3: enable both MDS and OSS fid capability\n");
374 /* OSS fid capability needs enable both MDS and OSS fid capability on
377 CERROR("can't enable OSS fid capability only, you should use "
378 "'3' to enable both MDS and OSS fid capability.\n");
382 mdt->mdt_opts.mo_oss_capa = (val & 0x1);
383 mdt->mdt_opts.mo_mds_capa = !!(val & 0x2);
384 mdt->mdt_capa_conf = 1;
385 LCONSOLE_INFO("MDS %s %s MDS fid capability.\n",
387 mdt->mdt_opts.mo_mds_capa ? "enabled" : "disabled");
388 LCONSOLE_INFO("MDS %s %s OSS fid capability.\n",
390 mdt->mdt_opts.mo_oss_capa ? "enabled" : "disabled");
394 static int lprocfs_rd_capa_count(char *page, char **start, off_t off,
395 int count, int *eof, void *data)
397 return snprintf(page, count, "%d %d\n",
398 capa_count[CAPA_SITE_CLIENT],
399 capa_count[CAPA_SITE_SERVER]);
402 static int lprocfs_rd_site_stats(char *page, char **start, off_t off,
403 int count, int *eof, void *data)
405 struct obd_device *obd = data;
406 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
408 return lu_site_stats_print(mdt_lu_site(mdt), page, count);
411 static int lprocfs_rd_capa_timeout(char *page, char **start, off_t off,
412 int count, int *eof, void *data)
414 struct obd_device *obd = data;
415 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
417 return snprintf(page, count, "%lu\n", mdt->mdt_capa_timeout);
420 static int lprocfs_wr_capa_timeout(struct file *file, const char *buffer,
421 unsigned long count, void *data)
423 struct obd_device *obd = data;
424 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
427 rc = lprocfs_write_helper(buffer, count, &val);
431 mdt->mdt_capa_timeout = (unsigned long)val;
432 mdt->mdt_capa_conf = 1;
436 static int lprocfs_rd_ck_timeout(char *page, char **start, off_t off, int count,
437 int *eof, void *data)
439 struct obd_device *obd = data;
440 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
442 return snprintf(page, count, "%lu\n", mdt->mdt_ck_timeout);
445 static int lprocfs_wr_ck_timeout(struct file *file, const char *buffer,
446 unsigned long count, void *data)
448 struct obd_device *obd = data;
449 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
452 rc = lprocfs_write_helper(buffer, count, &val);
456 mdt->mdt_ck_timeout = (unsigned long)val;
457 mdt->mdt_capa_conf = 1;
461 static int lprocfs_mdt_wr_evict_client(struct file *file, const char *buffer,
462 unsigned long count, void *data)
464 char tmpbuf[sizeof(struct obd_uuid)];
466 sscanf(buffer, "%40s", tmpbuf);
468 if (strncmp(tmpbuf, "nid:", 4) != 0)
469 return lprocfs_wr_evict_client(file, buffer, count, data);
471 CERROR("NOT implement evict client by nid %s\n", tmpbuf);
476 static int lprocfs_rd_sec_level(char *page, char **start, off_t off,
477 int count, int *eof, void *data)
479 struct obd_device *obd = data;
480 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
482 return snprintf(page, count, "%d\n", mdt->mdt_sec_level);
485 static int lprocfs_wr_sec_level(struct file *file, const char *buffer,
486 unsigned long count, void *data)
488 struct obd_device *obd = data;
489 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
492 rc = lprocfs_write_helper(buffer, count, &val);
496 if (val > LUSTRE_SEC_ALL || val < LUSTRE_SEC_NONE)
499 if (val == LUSTRE_SEC_SPECIFY) {
500 CWARN("security level %d will be supported in future.\n",
505 mdt->mdt_sec_level = val;
509 static int lprocfs_rd_cos(char *page, char **start, off_t off,
510 int count, int *eof, void *data)
512 struct obd_device *obd = data;
513 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
515 return snprintf(page, count, "%u\n", mdt_cos_is_enabled(mdt));
518 static int lprocfs_wr_cos(struct file *file, const char *buffer,
519 unsigned long count, void *data)
521 struct obd_device *obd = data;
522 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
525 rc = lprocfs_write_helper(buffer, count, &val);
528 mdt_enable_cos(mdt, val);
532 static int lprocfs_rd_root_squash(char *page, char **start, off_t off,
533 int count, int *eof, void *data)
535 struct obd_device *obd = data;
536 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
539 return snprintf(page, count, "%u:%u\n", mdt->mdt_squash_uid,
540 mdt->mdt_squash_gid);
543 static int safe_strtoul(const char *str, char **endp, unsigned long *res)
547 *res = simple_strtoul(str, endp, 0);
551 sprintf(n, "%lu", *res);
552 if (strncmp(n, str, *endp - str))
558 static int lprocfs_wr_root_squash(struct file *file, const char *buffer,
559 unsigned long count, void *data)
561 struct obd_device *obd = data;
562 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
564 char kernbuf[50], *tmp, *end, *errmsg;
565 unsigned long uid, gid;
569 if (count >= sizeof(kernbuf)) {
570 errmsg = "string too long";
571 GOTO(failed, rc = -EINVAL);
573 if (cfs_copy_from_user(kernbuf, buffer, count)) {
574 errmsg = "bad address";
575 GOTO(failed, rc = -EFAULT);
577 kernbuf[count] = '\0';
580 if (safe_strtoul(buffer, &tmp, &uid)) {
581 uid = mdt->mdt_squash_uid;
588 if (safe_strtoul(tmp, &end, &gid)) {
589 gid = mdt->mdt_squash_gid;
593 gid = mdt->mdt_squash_gid;
597 mdt->mdt_squash_uid = uid;
598 mdt->mdt_squash_gid = gid;
600 if (nouid && nogid) {
601 errmsg = "needs uid:gid format";
602 GOTO(failed, rc = -EINVAL);
605 LCONSOLE_INFO("%s: root_squash is set to %u:%u\n",
607 mdt->mdt_squash_uid, mdt->mdt_squash_gid);
611 CWARN("%s: failed to set root_squash to \"%s\", %s: rc %d\n",
612 obd->obd_name, buffer, errmsg, rc);
616 static int lprocfs_rd_nosquash_nids(char *page, char **start, off_t off,
617 int count, int *eof, void *data)
619 struct obd_device *obd = data;
620 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
622 if (mdt->mdt_nosquash_str)
623 return snprintf(page, count, "%s\n", mdt->mdt_nosquash_str);
624 return snprintf(page, count, "NONE\n");
627 static int lprocfs_wr_nosquash_nids(struct file *file, const char *buffer,
628 unsigned long count, void *data)
630 struct obd_device *obd = data;
631 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
633 char *kernbuf, *errmsg;
637 OBD_ALLOC(kernbuf, count + 1);
638 if (kernbuf == NULL) {
639 errmsg = "no memory";
640 GOTO(failed, rc = -ENOMEM);
642 if (cfs_copy_from_user(kernbuf, buffer, count)) {
643 errmsg = "bad address";
644 GOTO(failed, rc = -EFAULT);
646 kernbuf[count] = '\0';
648 if (!strcmp(kernbuf, "NONE") || !strcmp(kernbuf, "clear")) {
649 /* empty string is special case */
650 cfs_down_write(&mdt->mdt_squash_sem);
651 if (!cfs_list_empty(&mdt->mdt_nosquash_nids)) {
652 cfs_free_nidlist(&mdt->mdt_nosquash_nids);
653 OBD_FREE(mdt->mdt_nosquash_str,
654 mdt->mdt_nosquash_strlen);
655 mdt->mdt_nosquash_str = NULL;
656 mdt->mdt_nosquash_strlen = 0;
658 cfs_up_write(&mdt->mdt_squash_sem);
659 LCONSOLE_INFO("%s: nosquash_nids is cleared\n",
661 OBD_FREE(kernbuf, count + 1);
665 CFS_INIT_LIST_HEAD(&tmp);
666 if (cfs_parse_nidlist(kernbuf, count, &tmp) <= 0) {
667 errmsg = "can't parse";
668 GOTO(failed, rc = -EINVAL);
671 cfs_down_write(&mdt->mdt_squash_sem);
672 if (!cfs_list_empty(&mdt->mdt_nosquash_nids)) {
673 cfs_free_nidlist(&mdt->mdt_nosquash_nids);
674 OBD_FREE(mdt->mdt_nosquash_str, mdt->mdt_nosquash_strlen);
676 mdt->mdt_nosquash_str = kernbuf;
677 mdt->mdt_nosquash_strlen = count + 1;
678 cfs_list_splice(&tmp, &mdt->mdt_nosquash_nids);
680 LCONSOLE_INFO("%s: nosquash_nids is set to %s\n",
681 obd->obd_name, kernbuf);
682 cfs_up_write(&mdt->mdt_squash_sem);
686 CWARN("%s: failed to set nosquash_nids to \"%s\", %s: rc %d\n",
687 obd->obd_name, kernbuf, errmsg, rc);
689 OBD_FREE(kernbuf, count + 1);
693 static int lprocfs_rd_mdt_som(char *page, char **start, off_t off,
694 int count, int *eof, void *data)
696 struct obd_device *obd = data;
697 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
699 return snprintf(page, count, "%sabled\n",
700 mdt->mdt_som_conf ? "en" : "dis");
703 static int lprocfs_wr_mdt_som(struct file *file, const char *buffer,
704 unsigned long count, void *data)
706 struct obd_export *exp;
707 struct obd_device *obd = data;
708 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
710 unsigned long val = 0;
712 if (count > (sizeof(kernbuf) - 1))
715 if (cfs_copy_from_user(kernbuf, buffer, count))
718 kernbuf[count] = '\0';
720 if (!strcmp(kernbuf, "enabled"))
722 else if (strcmp(kernbuf, "disabled"))
725 if (mdt->mdt_som_conf == val)
728 if (!obd->obd_process_conf) {
729 CERROR("Temporary SOM change is not supported, use lctl "
730 "conf_param for permanent setting\n");
734 /* 1 stands for self export. */
735 cfs_list_for_each_entry(exp, &obd->obd_exports, exp_obd_chain) {
736 if (exp == obd->obd_self_export)
738 if (exp->exp_connect_flags & OBD_CONNECT_MDS_MDS)
740 /* Some clients are already connected, skip the change */
741 LCONSOLE_INFO("%s is already connected, SOM will be %s on "
742 "the next mount\n", exp->exp_client_uuid.uuid,
743 val ? "enabled" : "disabled");
747 mdt->mdt_som_conf = val;
748 LCONSOLE_INFO("Enabling SOM\n");
753 /* Temporary; for testing purposes only */
754 static int lprocfs_mdt_wr_mdc(struct file *file, const char *buffer,
755 unsigned long count, void *data)
757 struct obd_device *obd = data;
758 struct obd_export *exp = NULL;
759 struct obd_uuid uuid;
760 char tmpbuf[sizeof(struct obd_uuid)];
762 sscanf(buffer, "%40s", tmpbuf);
764 obd_str2uuid(&uuid, tmpbuf);
765 exp = cfs_hash_lookup(obd->obd_uuid_hash, &uuid);
767 CERROR("%s: no export %s found\n",
768 obd->obd_name, obd_uuid2str(&uuid));
770 mdt_hsm_copytool_send(exp);
771 class_export_put(exp);
777 static struct lprocfs_vars lprocfs_mdt_obd_vars[] = {
778 { "uuid", lprocfs_rd_uuid, 0, 0 },
779 { "recovery_status", lprocfs_obd_rd_recovery_status, 0, 0 },
780 { "num_exports", lprocfs_rd_num_exports, 0, 0 },
781 { "identity_expire", lprocfs_rd_identity_expire,
782 lprocfs_wr_identity_expire, 0 },
783 { "identity_acquire_expire", lprocfs_rd_identity_acquire_expire,
784 lprocfs_wr_identity_acquire_expire, 0 },
785 { "identity_upcall", lprocfs_rd_identity_upcall,
786 lprocfs_wr_identity_upcall, 0 },
787 { "identity_flush", 0, lprocfs_wr_identity_flush, 0 },
788 { "identity_info", 0, lprocfs_wr_identity_info, 0 },
789 { "capa", lprocfs_rd_capa,
790 lprocfs_wr_capa, 0 },
791 { "capa_timeout", lprocfs_rd_capa_timeout,
792 lprocfs_wr_capa_timeout, 0 },
793 { "capa_key_timeout", lprocfs_rd_ck_timeout,
794 lprocfs_wr_ck_timeout, 0 },
795 { "capa_count", lprocfs_rd_capa_count, 0, 0 },
796 { "site_stats", lprocfs_rd_site_stats, 0, 0 },
797 { "evict_client", 0, lprocfs_mdt_wr_evict_client, 0 },
798 { "hash_stats", lprocfs_obd_rd_hash, 0, 0 },
799 { "sec_level", lprocfs_rd_sec_level,
800 lprocfs_wr_sec_level, 0 },
801 { "commit_on_sharing", lprocfs_rd_cos, lprocfs_wr_cos, 0 },
802 { "root_squash", lprocfs_rd_root_squash,
803 lprocfs_wr_root_squash, 0 },
804 { "nosquash_nids", lprocfs_rd_nosquash_nids,
805 lprocfs_wr_nosquash_nids, 0 },
806 { "som", lprocfs_rd_mdt_som,
807 lprocfs_wr_mdt_som, 0 },
808 { "mdccomm", 0, lprocfs_mdt_wr_mdc, 0 },
812 static struct lprocfs_vars lprocfs_mdt_module_vars[] = {
813 { "num_refs", lprocfs_rd_numrefs, 0, 0 },
817 void lprocfs_mdt_init_vars(struct lprocfs_static_vars *lvars)
819 lvars->module_vars = lprocfs_mdt_module_vars;
820 lvars->obd_vars = lprocfs_mdt_obd_vars;
823 void mdt_counter_incr(struct obd_export *exp, int opcode)
825 if (exp->exp_obd && exp->exp_obd->md_stats)
826 lprocfs_counter_incr(exp->exp_obd->md_stats, opcode);
827 if (exp->exp_nid_stats && exp->exp_nid_stats->nid_stats != NULL)
828 lprocfs_counter_incr(exp->exp_nid_stats->nid_stats, opcode);
832 void mdt_stats_counter_init(struct lprocfs_stats *stats)
834 lprocfs_counter_init(stats, LPROC_MDT_OPEN, 0, "open", "reqs");
835 lprocfs_counter_init(stats, LPROC_MDT_CLOSE, 0, "close", "reqs");
836 lprocfs_counter_init(stats, LPROC_MDT_MKNOD, 0, "mknod", "reqs");
837 lprocfs_counter_init(stats, LPROC_MDT_LINK, 0, "link", "reqs");
838 lprocfs_counter_init(stats, LPROC_MDT_UNLINK, 0, "unlink", "reqs");
839 lprocfs_counter_init(stats, LPROC_MDT_MKDIR, 0, "mkdir", "reqs");
840 lprocfs_counter_init(stats, LPROC_MDT_RMDIR, 0, "rmdir", "reqs");
841 lprocfs_counter_init(stats, LPROC_MDT_RENAME, 0, "rename", "reqs");
842 lprocfs_counter_init(stats, LPROC_MDT_GETATTR, 0, "getattr", "reqs");
843 lprocfs_counter_init(stats, LPROC_MDT_SETATTR, 0, "setattr", "reqs");
844 lprocfs_counter_init(stats, LPROC_MDT_GETXATTR, 0, "getxattr", "reqs");
845 lprocfs_counter_init(stats, LPROC_MDT_SETXATTR, 0, "setxattr", "reqs");
846 lprocfs_counter_init(stats, LPROC_MDT_STATFS, 0, "statfs", "reqs");
847 lprocfs_counter_init(stats, LPROC_MDT_SYNC, 0, "sync", "reqs");