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.
32 * Copyright (c) 2011 Whamcloud, Inc.
36 * This file is part of Lustre, http://www.lustre.org/
37 * Lustre is a trademark of Sun Microsystems, Inc.
39 * lustre/mdt/mdt_lproc.c
41 * Author: Lai Siyao <lsy@clusterfs.com>
42 * Author: Fan Yong <fanyong@clusterfs.com>
46 # define EXPORT_SYMTAB
48 #define DEBUG_SUBSYSTEM S_MDS
50 #include <linux/version.h>
51 #include <asm/statfs.h>
53 #include <linux/module.h>
55 /* LUSTRE_VERSION_CODE */
56 #include <lustre_ver.h>
58 * struct OBD_{ALLOC,FREE}*()
61 #include <obd_support.h>
62 /* struct obd_export */
63 #include <lustre_export.h>
64 /* struct obd_device */
66 #include <obd_class.h>
67 #include <lustre_mds.h>
68 #include <lustre_mdt.h>
69 #include <lprocfs_status.h>
71 #include "mdt_internal.h"
72 #include <lnet/lib-lnet.h>
77 static const char *mdt_proc_names[LPROC_MDT_NR] = {
80 int mdt_procfs_init(struct mdt_device *mdt, const char *name)
82 struct lu_device *ld = &mdt->mdt_md_dev.md_lu_dev;
83 struct obd_device *obd = ld->ld_obd;
84 struct lprocfs_static_vars lvars;
88 LASSERT(name != NULL);
90 lprocfs_mdt_init_vars(&lvars);
91 rc = lprocfs_obd_setup(obd, lvars.obd_vars);
93 CERROR("Can't init lprocfs, rc %d\n", rc);
96 ptlrpc_lprocfs_register_obd(obd);
98 mdt->mdt_proc_entry = obd->obd_proc_entry;
99 LASSERT(mdt->mdt_proc_entry != NULL);
101 rc = lu_time_init(&mdt->mdt_stats, mdt->mdt_proc_entry,
102 mdt_proc_names, ARRAY_SIZE(mdt_proc_names));
104 rc = lu_time_named_init(&ld->ld_site->ls_time_stats,
105 "site_time", mdt->mdt_proc_entry,
107 ARRAY_SIZE(lu_time_names));
111 obd->obd_proc_exports_entry = proc_mkdir("exports",
112 obd->obd_proc_entry);
113 if (obd->obd_proc_exports_entry)
114 lprocfs_add_simple(obd->obd_proc_exports_entry,
115 "clear", lprocfs_nid_stats_clear_read,
116 lprocfs_nid_stats_clear_write, obd, NULL);
117 rc = lprocfs_alloc_md_stats(obd, LPROC_MDT_LAST);
119 mdt_stats_counter_init(obd->md_stats);
124 int mdt_procfs_fini(struct mdt_device *mdt)
126 struct lu_device *ld = &mdt->mdt_md_dev.md_lu_dev;
127 struct obd_device *obd = ld->ld_obd;
129 if (mdt->mdt_proc_entry) {
130 lu_time_fini(&ld->ld_site->ls_time_stats);
131 lu_time_fini(&mdt->mdt_stats);
132 mdt->mdt_proc_entry = NULL;
134 if (obd->obd_proc_exports_entry) {
135 lprocfs_remove_proc_entry("clear", obd->obd_proc_exports_entry);
136 obd->obd_proc_exports_entry = NULL;
138 ptlrpc_lprocfs_unregister_obd(obd);
139 lprocfs_free_md_stats(obd);
140 lprocfs_obd_cleanup(obd);
145 void mdt_time_start(const struct mdt_thread_info *info)
147 lu_lprocfs_time_start(info->mti_env);
150 void mdt_time_end(const struct mdt_thread_info *info, int idx)
152 lu_lprocfs_time_end(info->mti_env, info->mti_mdt->mdt_stats, idx);
155 static int lprocfs_rd_identity_expire(char *page, char **start, off_t off,
156 int count, int *eof, void *data)
158 struct obd_device *obd = data;
159 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
162 return snprintf(page, count, "%u\n",
163 mdt->mdt_identity_cache->uc_entry_expire);
166 static int lprocfs_wr_identity_expire(struct file *file, const char *buffer,
167 unsigned long count, void *data)
169 struct obd_device *obd = data;
170 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
173 rc = lprocfs_write_helper(buffer, count, &val);
177 mdt->mdt_identity_cache->uc_entry_expire = val;
181 static int lprocfs_rd_identity_acquire_expire(char *page, char **start,
182 off_t off, int count, int *eof,
185 struct obd_device *obd = data;
186 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
189 return snprintf(page, count, "%u\n",
190 mdt->mdt_identity_cache->uc_acquire_expire);
193 static int lprocfs_wr_identity_acquire_expire(struct file *file,
198 struct obd_device *obd = data;
199 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
202 rc = lprocfs_write_helper(buffer, count, &val);
206 mdt->mdt_identity_cache->uc_acquire_expire = val;
210 static int lprocfs_rd_identity_upcall(char *page, char **start, off_t off,
211 int count, int *eof, void *data)
213 struct obd_device *obd = data;
214 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
215 struct upcall_cache *hash = mdt->mdt_identity_cache;
219 cfs_read_lock(&hash->uc_upcall_rwlock);
220 len = snprintf(page, count, "%s\n", hash->uc_upcall);
221 cfs_read_unlock(&hash->uc_upcall_rwlock);
225 static int lprocfs_wr_identity_upcall(struct file *file, const char *buffer,
226 unsigned long count, void *data)
228 struct obd_device *obd = data;
229 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
230 struct upcall_cache *hash = mdt->mdt_identity_cache;
234 if (count >= UC_CACHE_UPCALL_MAXPATH) {
235 CERROR("%s: identity upcall too long\n", obd->obd_name);
238 OBD_ALLOC(kernbuf, count + 1);
240 GOTO(failed, rc = -ENOMEM);
241 if (cfs_copy_from_user(kernbuf, buffer, count))
242 GOTO(failed, rc = -EFAULT);
244 /* Remove any extraneous bits from the upcall (e.g. linefeeds) */
245 cfs_write_lock(&hash->uc_upcall_rwlock);
246 sscanf(kernbuf, "%s", hash->uc_upcall);
247 cfs_write_unlock(&hash->uc_upcall_rwlock);
249 if (strcmp(hash->uc_name, obd->obd_name) != 0)
250 CWARN("%s: write to upcall name %s\n",
251 obd->obd_name, hash->uc_upcall);
253 if (strcmp(hash->uc_upcall, "NONE") == 0 && mdt->mdt_opts.mo_acl)
254 CWARN("%s: disable \"identity_upcall\" with ACL enabled maybe "
255 "cause unexpected \"EACCESS\"\n", obd->obd_name);
257 CWARN("%s: identity upcall set to %s\n", obd->obd_name, hash->uc_upcall);
258 OBD_FREE(kernbuf, count + 1);
263 OBD_FREE(kernbuf, count + 1);
267 static int lprocfs_wr_identity_flush(struct file *file, const char *buffer,
268 unsigned long count, void *data)
270 struct obd_device *obd = data;
271 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
274 rc = lprocfs_write_helper(buffer, count, &uid);
278 mdt_flush_identity(mdt->mdt_identity_cache, uid);
282 static int lprocfs_wr_identity_info(struct file *file, const char *buffer,
283 unsigned long count, void *data)
285 struct obd_device *obd = data;
286 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
287 struct identity_downcall_data *param;
288 int size = sizeof(*param), rc, checked = 0;
292 CERROR("%s: invalid data count = %lu, size = %d\n",
293 obd->obd_name, count, size);
297 OBD_ALLOC(param, size);
301 if (cfs_copy_from_user(param, buffer, size)) {
302 CERROR("%s: bad identity data\n", obd->obd_name);
303 GOTO(out, rc = -EFAULT);
308 if (param->idd_magic != IDENTITY_DOWNCALL_MAGIC) {
309 CERROR("%s: MDS identity downcall bad params\n",
311 GOTO(out, rc = -EINVAL);
314 if (param->idd_nperms > N_PERMS_MAX) {
315 CERROR("%s: perm count %d more than maximum %d\n",
316 obd->obd_name, param->idd_nperms, N_PERMS_MAX);
317 GOTO(out, rc = -EINVAL);
320 if (param->idd_ngroups > NGROUPS_MAX) {
321 CERROR("%s: group count %d more than maximum %d\n",
322 obd->obd_name, param->idd_ngroups, NGROUPS_MAX);
323 GOTO(out, rc = -EINVAL);
326 if (param->idd_ngroups) {
327 rc = param->idd_ngroups; /* save idd_ngroups */
328 OBD_FREE(param, size);
329 size = offsetof(struct identity_downcall_data,
335 rc = upcall_cache_downcall(mdt->mdt_identity_cache, param->idd_err,
336 param->idd_uid, param);
340 OBD_FREE(param, size);
342 return rc ? rc : count;
346 static int lprocfs_rd_capa(char *page, char **start, off_t off,
347 int count, int *eof, void *data)
349 struct obd_device *obd = data;
350 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
352 return snprintf(page, count, "capability on: %s %s\n",
353 mdt->mdt_opts.mo_oss_capa ? "oss" : "",
354 mdt->mdt_opts.mo_mds_capa ? "mds" : "");
357 static int lprocfs_wr_capa(struct file *file, const char *buffer,
358 unsigned long count, void *data)
360 struct obd_device *obd = data;
361 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
364 rc = lprocfs_write_helper(buffer, count, &val);
368 if (val < 0 || val > 3) {
369 CERROR("invalid capability mode, only 0/2/3 is accepted.\n"
370 " 0: disable fid capability\n"
371 " 2: enable MDS fid capability\n"
372 " 3: enable both MDS and OSS fid capability\n");
376 /* OSS fid capability needs enable both MDS and OSS fid capability on
379 CERROR("can't enable OSS fid capability only, you should use "
380 "'3' to enable both MDS and OSS fid capability.\n");
384 mdt->mdt_opts.mo_oss_capa = (val & 0x1);
385 mdt->mdt_opts.mo_mds_capa = !!(val & 0x2);
386 mdt->mdt_capa_conf = 1;
387 LCONSOLE_INFO("MDS %s %s MDS fid capability.\n",
389 mdt->mdt_opts.mo_mds_capa ? "enabled" : "disabled");
390 LCONSOLE_INFO("MDS %s %s OSS fid capability.\n",
392 mdt->mdt_opts.mo_oss_capa ? "enabled" : "disabled");
396 static int lprocfs_rd_capa_count(char *page, char **start, off_t off,
397 int count, int *eof, void *data)
399 return snprintf(page, count, "%d %d\n",
400 capa_count[CAPA_SITE_CLIENT],
401 capa_count[CAPA_SITE_SERVER]);
404 static int lprocfs_rd_site_stats(char *page, char **start, off_t off,
405 int count, int *eof, void *data)
407 struct obd_device *obd = data;
408 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
410 return lu_site_stats_print(mdt_lu_site(mdt), page, count);
413 static int lprocfs_rd_capa_timeout(char *page, char **start, off_t off,
414 int count, int *eof, void *data)
416 struct obd_device *obd = data;
417 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
419 return snprintf(page, count, "%lu\n", mdt->mdt_capa_timeout);
422 static int lprocfs_wr_capa_timeout(struct file *file, const char *buffer,
423 unsigned long count, void *data)
425 struct obd_device *obd = data;
426 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
429 rc = lprocfs_write_helper(buffer, count, &val);
433 mdt->mdt_capa_timeout = (unsigned long)val;
434 mdt->mdt_capa_conf = 1;
438 static int lprocfs_rd_ck_timeout(char *page, char **start, off_t off, int count,
439 int *eof, void *data)
441 struct obd_device *obd = data;
442 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
444 return snprintf(page, count, "%lu\n", mdt->mdt_ck_timeout);
447 static int lprocfs_wr_ck_timeout(struct file *file, const char *buffer,
448 unsigned long count, void *data)
450 struct obd_device *obd = data;
451 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
454 rc = lprocfs_write_helper(buffer, count, &val);
458 mdt->mdt_ck_timeout = (unsigned long)val;
459 mdt->mdt_capa_conf = 1;
463 static int lprocfs_mdt_wr_evict_client(struct file *file, const char *buffer,
464 unsigned long count, void *data)
466 char tmpbuf[sizeof(struct obd_uuid)];
468 sscanf(buffer, "%40s", tmpbuf);
470 if (strncmp(tmpbuf, "nid:", 4) != 0)
471 return lprocfs_wr_evict_client(file, buffer, count, data);
473 CERROR("NOT implement evict client by nid %s\n", tmpbuf);
478 static int lprocfs_rd_sec_level(char *page, char **start, off_t off,
479 int count, int *eof, void *data)
481 struct obd_device *obd = data;
482 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
484 return snprintf(page, count, "%d\n", mdt->mdt_sec_level);
487 static int lprocfs_wr_sec_level(struct file *file, const char *buffer,
488 unsigned long count, void *data)
490 struct obd_device *obd = data;
491 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
494 rc = lprocfs_write_helper(buffer, count, &val);
498 if (val > LUSTRE_SEC_ALL || val < LUSTRE_SEC_NONE)
501 if (val == LUSTRE_SEC_SPECIFY) {
502 CWARN("security level %d will be supported in future.\n",
507 mdt->mdt_sec_level = val;
511 static int lprocfs_rd_cos(char *page, char **start, off_t off,
512 int count, int *eof, void *data)
514 struct obd_device *obd = data;
515 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
517 return snprintf(page, count, "%u\n", mdt_cos_is_enabled(mdt));
520 static int lprocfs_wr_cos(struct file *file, const char *buffer,
521 unsigned long count, void *data)
523 struct obd_device *obd = data;
524 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
527 rc = lprocfs_write_helper(buffer, count, &val);
530 mdt_enable_cos(mdt, val);
534 static int lprocfs_rd_root_squash(char *page, char **start, off_t off,
535 int count, int *eof, void *data)
537 struct obd_device *obd = data;
538 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
541 return snprintf(page, count, "%u:%u\n", mdt->mdt_squash_uid,
542 mdt->mdt_squash_gid);
545 static int safe_strtoul(const char *str, char **endp, unsigned long *res)
549 *res = simple_strtoul(str, endp, 0);
553 sprintf(n, "%lu", *res);
554 if (strncmp(n, str, *endp - str))
560 static int lprocfs_wr_root_squash(struct file *file, const char *buffer,
561 unsigned long count, void *data)
563 struct obd_device *obd = data;
564 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
566 char kernbuf[50], *tmp, *end, *errmsg;
567 unsigned long uid, gid;
571 if (count >= sizeof(kernbuf)) {
572 errmsg = "string too long";
573 GOTO(failed, rc = -EINVAL);
575 if (cfs_copy_from_user(kernbuf, buffer, count)) {
576 errmsg = "bad address";
577 GOTO(failed, rc = -EFAULT);
579 kernbuf[count] = '\0';
582 if (safe_strtoul(buffer, &tmp, &uid)) {
583 uid = mdt->mdt_squash_uid;
590 if (safe_strtoul(tmp, &end, &gid)) {
591 gid = mdt->mdt_squash_gid;
595 gid = mdt->mdt_squash_gid;
599 mdt->mdt_squash_uid = uid;
600 mdt->mdt_squash_gid = gid;
602 if (nouid && nogid) {
603 errmsg = "needs uid:gid format";
604 GOTO(failed, rc = -EINVAL);
607 LCONSOLE_INFO("%s: root_squash is set to %u:%u\n",
609 mdt->mdt_squash_uid, mdt->mdt_squash_gid);
613 CWARN("%s: failed to set root_squash to \"%s\", %s: rc %d\n",
614 obd->obd_name, buffer, errmsg, rc);
618 static int lprocfs_rd_nosquash_nids(char *page, char **start, off_t off,
619 int count, int *eof, void *data)
621 struct obd_device *obd = data;
622 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
624 if (mdt->mdt_nosquash_str)
625 return snprintf(page, count, "%s\n", mdt->mdt_nosquash_str);
626 return snprintf(page, count, "NONE\n");
629 static int lprocfs_wr_nosquash_nids(struct file *file, const char *buffer,
630 unsigned long count, void *data)
632 struct obd_device *obd = data;
633 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
635 char *kernbuf, *errmsg;
639 OBD_ALLOC(kernbuf, count + 1);
640 if (kernbuf == NULL) {
641 errmsg = "no memory";
642 GOTO(failed, rc = -ENOMEM);
644 if (cfs_copy_from_user(kernbuf, buffer, count)) {
645 errmsg = "bad address";
646 GOTO(failed, rc = -EFAULT);
648 kernbuf[count] = '\0';
650 if (!strcmp(kernbuf, "NONE") || !strcmp(kernbuf, "clear")) {
651 /* empty string is special case */
652 cfs_down_write(&mdt->mdt_squash_sem);
653 if (!cfs_list_empty(&mdt->mdt_nosquash_nids)) {
654 cfs_free_nidlist(&mdt->mdt_nosquash_nids);
655 OBD_FREE(mdt->mdt_nosquash_str,
656 mdt->mdt_nosquash_strlen);
657 mdt->mdt_nosquash_str = NULL;
658 mdt->mdt_nosquash_strlen = 0;
660 cfs_up_write(&mdt->mdt_squash_sem);
661 LCONSOLE_INFO("%s: nosquash_nids is cleared\n",
663 OBD_FREE(kernbuf, count + 1);
667 CFS_INIT_LIST_HEAD(&tmp);
668 if (cfs_parse_nidlist(kernbuf, count, &tmp) <= 0) {
669 errmsg = "can't parse";
670 GOTO(failed, rc = -EINVAL);
673 cfs_down_write(&mdt->mdt_squash_sem);
674 if (!cfs_list_empty(&mdt->mdt_nosquash_nids)) {
675 cfs_free_nidlist(&mdt->mdt_nosquash_nids);
676 OBD_FREE(mdt->mdt_nosquash_str, mdt->mdt_nosquash_strlen);
678 mdt->mdt_nosquash_str = kernbuf;
679 mdt->mdt_nosquash_strlen = count + 1;
680 cfs_list_splice(&tmp, &mdt->mdt_nosquash_nids);
682 LCONSOLE_INFO("%s: nosquash_nids is set to %s\n",
683 obd->obd_name, kernbuf);
684 cfs_up_write(&mdt->mdt_squash_sem);
688 CWARN("%s: failed to set nosquash_nids to \"%s\", %s: rc %d\n",
689 obd->obd_name, kernbuf, errmsg, rc);
691 OBD_FREE(kernbuf, count + 1);
695 static int lprocfs_rd_mdt_som(char *page, char **start, off_t off,
696 int count, int *eof, void *data)
698 struct obd_device *obd = data;
699 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
701 return snprintf(page, count, "%sabled\n",
702 mdt->mdt_som_conf ? "en" : "dis");
705 static int lprocfs_wr_mdt_som(struct file *file, const char *buffer,
706 unsigned long count, void *data)
708 struct obd_export *exp;
709 struct obd_device *obd = data;
710 struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
712 unsigned long val = 0;
714 if (count > (sizeof(kernbuf) - 1))
717 if (cfs_copy_from_user(kernbuf, buffer, count))
720 kernbuf[count] = '\0';
722 if (!strcmp(kernbuf, "enabled"))
724 else if (strcmp(kernbuf, "disabled"))
727 if (mdt->mdt_som_conf == val)
730 if (!obd->obd_process_conf) {
731 CERROR("Temporary SOM change is not supported, use lctl "
732 "conf_param for permanent setting\n");
736 /* 1 stands for self export. */
737 cfs_list_for_each_entry(exp, &obd->obd_exports, exp_obd_chain) {
738 if (exp == obd->obd_self_export)
740 if (exp->exp_connect_flags & OBD_CONNECT_MDS_MDS)
742 /* Some clients are already connected, skip the change */
743 LCONSOLE_INFO("%s is already connected, SOM will be %s on "
744 "the next mount\n", exp->exp_client_uuid.uuid,
745 val ? "enabled" : "disabled");
749 mdt->mdt_som_conf = val;
750 LCONSOLE_INFO("Enabling SOM\n");
755 /* Temporary; for testing purposes only */
756 static int lprocfs_mdt_wr_mdc(struct file *file, const char *buffer,
757 unsigned long count, void *data)
759 struct obd_device *obd = data;
760 struct obd_export *exp = NULL;
761 struct obd_uuid uuid;
762 char tmpbuf[sizeof(struct obd_uuid)];
764 sscanf(buffer, "%40s", tmpbuf);
766 obd_str2uuid(&uuid, tmpbuf);
767 exp = cfs_hash_lookup(obd->obd_uuid_hash, &uuid);
769 CERROR("%s: no export %s found\n",
770 obd->obd_name, obd_uuid2str(&uuid));
772 mdt_hsm_copytool_send(exp);
773 class_export_put(exp);
779 static struct lprocfs_vars lprocfs_mdt_obd_vars[] = {
780 { "uuid", lprocfs_rd_uuid, 0, 0 },
781 { "recovery_status", lprocfs_obd_rd_recovery_status, 0, 0 },
782 { "num_exports", lprocfs_rd_num_exports, 0, 0 },
783 { "identity_expire", lprocfs_rd_identity_expire,
784 lprocfs_wr_identity_expire, 0 },
785 { "identity_acquire_expire", lprocfs_rd_identity_acquire_expire,
786 lprocfs_wr_identity_acquire_expire, 0 },
787 { "identity_upcall", lprocfs_rd_identity_upcall,
788 lprocfs_wr_identity_upcall, 0 },
789 { "identity_flush", 0, lprocfs_wr_identity_flush, 0 },
790 { "identity_info", 0, lprocfs_wr_identity_info, 0 },
791 { "capa", lprocfs_rd_capa,
792 lprocfs_wr_capa, 0 },
793 { "capa_timeout", lprocfs_rd_capa_timeout,
794 lprocfs_wr_capa_timeout, 0 },
795 { "capa_key_timeout", lprocfs_rd_ck_timeout,
796 lprocfs_wr_ck_timeout, 0 },
797 { "capa_count", lprocfs_rd_capa_count, 0, 0 },
798 { "site_stats", lprocfs_rd_site_stats, 0, 0 },
799 { "evict_client", 0, lprocfs_mdt_wr_evict_client, 0 },
800 { "hash_stats", lprocfs_obd_rd_hash, 0, 0 },
801 { "sec_level", lprocfs_rd_sec_level,
802 lprocfs_wr_sec_level, 0 },
803 { "commit_on_sharing", lprocfs_rd_cos, lprocfs_wr_cos, 0 },
804 { "root_squash", lprocfs_rd_root_squash,
805 lprocfs_wr_root_squash, 0 },
806 { "nosquash_nids", lprocfs_rd_nosquash_nids,
807 lprocfs_wr_nosquash_nids, 0 },
808 { "som", lprocfs_rd_mdt_som,
809 lprocfs_wr_mdt_som, 0 },
810 { "mdccomm", 0, lprocfs_mdt_wr_mdc, 0 },
814 static struct lprocfs_vars lprocfs_mdt_module_vars[] = {
815 { "num_refs", lprocfs_rd_numrefs, 0, 0 },
819 void lprocfs_mdt_init_vars(struct lprocfs_static_vars *lvars)
821 lvars->module_vars = lprocfs_mdt_module_vars;
822 lvars->obd_vars = lprocfs_mdt_obd_vars;
825 void mdt_counter_incr(struct obd_export *exp, int opcode)
827 if (exp->exp_obd && exp->exp_obd->md_stats)
828 lprocfs_counter_incr(exp->exp_obd->md_stats, opcode);
829 if (exp->exp_nid_stats && exp->exp_nid_stats->nid_stats != NULL)
830 lprocfs_counter_incr(exp->exp_nid_stats->nid_stats, opcode);
834 void mdt_stats_counter_init(struct lprocfs_stats *stats)
836 lprocfs_counter_init(stats, LPROC_MDT_OPEN, 0, "open", "reqs");
837 lprocfs_counter_init(stats, LPROC_MDT_CLOSE, 0, "close", "reqs");
838 lprocfs_counter_init(stats, LPROC_MDT_MKNOD, 0, "mknod", "reqs");
839 lprocfs_counter_init(stats, LPROC_MDT_LINK, 0, "link", "reqs");
840 lprocfs_counter_init(stats, LPROC_MDT_UNLINK, 0, "unlink", "reqs");
841 lprocfs_counter_init(stats, LPROC_MDT_MKDIR, 0, "mkdir", "reqs");
842 lprocfs_counter_init(stats, LPROC_MDT_RMDIR, 0, "rmdir", "reqs");
843 lprocfs_counter_init(stats, LPROC_MDT_RENAME, 0, "rename", "reqs");
844 lprocfs_counter_init(stats, LPROC_MDT_GETATTR, 0, "getattr", "reqs");
845 lprocfs_counter_init(stats, LPROC_MDT_SETATTR, 0, "setattr", "reqs");
846 lprocfs_counter_init(stats, LPROC_MDT_GETXATTR, 0, "getxattr", "reqs");
847 lprocfs_counter_init(stats, LPROC_MDT_SETXATTR, 0, "setxattr", "reqs");
848 lprocfs_counter_init(stats, LPROC_MDT_STATFS, 0, "statfs", "reqs");
849 lprocfs_counter_init(stats, LPROC_MDT_SYNC, 0, "sync", "reqs");