Whamcloud - gitweb
3ac423a4db26011e64e575931976803e95acfd19
[fs/lustre-release.git] / lustre / mdt / mdt_lproc.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
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.
11  *
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).
17  *
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
21  *
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
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  *
36  * lustre/mdt/mdt_lproc.c
37  *
38  * Author: Lai Siyao <lsy@clusterfs.com>
39  * Author: Fan Yong <fanyong@clusterfs.com>
40  */
41
42 #ifndef EXPORT_SYMTAB
43 # define EXPORT_SYMTAB
44 #endif
45 #define DEBUG_SUBSYSTEM S_MDS
46
47 #include <linux/version.h>
48 #include <asm/statfs.h>
49
50 #include <linux/module.h>
51
52 /* LUSTRE_VERSION_CODE */
53 #include <lustre_ver.h>
54 /*
55  * struct OBD_{ALLOC,FREE}*()
56  * MDT_FAIL_CHECK
57  */
58 #include <obd_support.h>
59 /* struct obd_export */
60 #include <lustre_export.h>
61 /* struct obd_device */
62 #include <obd.h>
63 #include <obd_class.h>
64 #include <lustre_mds.h>
65 #include <lustre_mdt.h>
66 #include <lprocfs_status.h>
67 #include <lu_time.h>
68 #include "mdt_internal.h"
69 #include <lnet/lib-lnet.h>
70
71 static const char *mdt_proc_names[LPROC_MDT_NR] = {
72 };
73
74 int mdt_procfs_init(struct mdt_device *mdt, const char *name)
75 {
76         struct lu_device *ld = &mdt->mdt_md_dev.md_lu_dev;
77         int result;
78         ENTRY;
79
80         LASSERT(name != NULL);
81         mdt->mdt_proc_entry = ld->ld_obd->obd_proc_entry;
82         LASSERT(mdt->mdt_proc_entry != NULL);
83
84         result = lu_time_init(&mdt->mdt_stats, mdt->mdt_proc_entry,
85                               mdt_proc_names, ARRAY_SIZE(mdt_proc_names));
86         if (result == 0)
87                 result = lu_time_named_init(&ld->ld_site->ls_time_stats,
88                                             "site_time", mdt->mdt_proc_entry,
89                                             lu_time_names,
90                                             ARRAY_SIZE(lu_time_names));
91         RETURN(result);
92 }
93
94 int mdt_procfs_fini(struct mdt_device *mdt)
95 {
96         struct lu_device *ld = &mdt->mdt_md_dev.md_lu_dev;
97         lu_time_fini(&ld->ld_site->ls_time_stats);
98         lu_time_fini(&mdt->mdt_stats);
99         mdt->mdt_proc_entry = NULL;
100         RETURN(0);
101 }
102
103 void mdt_time_start(const struct mdt_thread_info *info)
104 {
105         lu_lprocfs_time_start(info->mti_env);
106 }
107
108 void mdt_time_end(const struct mdt_thread_info *info, int idx)
109 {
110         lu_lprocfs_time_end(info->mti_env, info->mti_mdt->mdt_stats, idx);
111 }
112
113 static int lprocfs_rd_identity_expire(char *page, char **start, off_t off,
114                                       int count, int *eof, void *data)
115 {
116         struct obd_device *obd = data;
117         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
118
119         *eof = 1;
120         return snprintf(page, count, "%lu\n",
121                         mdt->mdt_identity_cache->uc_entry_expire / HZ);
122 }
123
124 static int lprocfs_wr_identity_expire(struct file *file, const char *buffer,
125                                       unsigned long count, void *data)
126 {
127         struct obd_device *obd = data;
128         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
129         int rc, val;
130
131         rc = lprocfs_write_helper(buffer, count, &val);
132         if (rc)
133                 return rc;
134
135         mdt->mdt_identity_cache->uc_entry_expire = val * HZ;
136         return count;
137 }
138
139 static int lprocfs_rd_identity_acquire_expire(char *page, char **start,
140                                               off_t off, int count, int *eof,
141                                               void *data)
142 {
143         struct obd_device *obd = data;
144         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
145
146         *eof = 1;
147         return snprintf(page, count, "%lu\n",
148                         mdt->mdt_identity_cache->uc_acquire_expire / HZ);
149 }
150
151 static int lprocfs_wr_identity_acquire_expire(struct file *file,
152                                               const char *buffer,
153                                               unsigned long count,
154                                               void *data)
155 {
156         struct obd_device *obd = data;
157         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
158         int rc, val;
159
160         rc = lprocfs_write_helper(buffer, count, &val);
161         if (rc)
162                 return rc;
163
164         mdt->mdt_identity_cache->uc_acquire_expire = val * HZ;
165         return count;
166 }
167
168 static int lprocfs_rd_identity_upcall(char *page, char **start, off_t off,
169                                       int count, int *eof, void *data)
170 {
171         struct obd_device *obd = data;
172         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
173         struct upcall_cache *hash = mdt->mdt_identity_cache;
174         int len;
175
176         *eof = 1;
177         read_lock(&hash->uc_upcall_rwlock);
178         len = snprintf(page, count, "%s\n", hash->uc_upcall);
179         read_unlock(&hash->uc_upcall_rwlock);
180         return len;
181 }
182
183 static int lprocfs_wr_identity_upcall(struct file *file, const char *buffer,
184                                       unsigned long count, void *data)
185 {
186         struct obd_device *obd = data;
187         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
188         struct upcall_cache *hash = mdt->mdt_identity_cache;
189         char kernbuf[UC_CACHE_UPCALL_MAXPATH] = { '\0' };
190
191         if (count >= UC_CACHE_UPCALL_MAXPATH) {
192                 CERROR("%s: identity upcall too long\n", obd->obd_name);
193                 return -EINVAL;
194         }
195
196         if (copy_from_user(kernbuf, buffer, min_t(unsigned long, count,
197                                                   UC_CACHE_UPCALL_MAXPATH - 1)))
198                 return -EFAULT;
199
200         /* Remove any extraneous bits from the upcall (e.g. linefeeds) */
201         write_lock(&hash->uc_upcall_rwlock);
202         sscanf(kernbuf, "%s", hash->uc_upcall);
203         write_unlock(&hash->uc_upcall_rwlock);
204
205         if (strcmp(hash->uc_name, obd->obd_name) != 0)
206                 CWARN("%s: write to upcall name %s\n",
207                       obd->obd_name, hash->uc_upcall);
208
209         if (strcmp(hash->uc_upcall, "NONE") == 0 && mdt->mdt_opts.mo_acl)
210                 CWARN("%s: disable \"identity_upcall\" with ACL enabled maybe "
211                       "cause unexpected \"EACCESS\"\n", obd->obd_name);
212
213         CWARN("%s: identity upcall set to %s\n", obd->obd_name, hash->uc_upcall);
214         return count;
215 }
216
217 static int lprocfs_wr_identity_flush(struct file *file, const char *buffer,
218                                      unsigned long count, void *data)
219 {
220         struct obd_device *obd = data;
221         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
222         int rc, uid;
223
224         rc = lprocfs_write_helper(buffer, count, &uid);
225         if (rc)
226                 return rc;
227
228         mdt_flush_identity(mdt->mdt_identity_cache, uid);
229         return count;
230 }
231
232 static int lprocfs_wr_identity_info(struct file *file, const char *buffer,
233                                     unsigned long count, void *data)
234 {
235         struct obd_device *obd = data;
236         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
237         struct identity_downcall_data sparam, *param = &sparam;
238         int size = 0, rc = 0;
239
240         if (count < sizeof(*param)) {
241                 CERROR("%s: invalid data size %lu\n", obd->obd_name, count);
242                 return count;
243         }
244
245         if (copy_from_user(&sparam, buffer, sizeof(sparam))) {
246                 CERROR("%s: bad identity data\n", obd->obd_name);
247                 GOTO(out, rc = -EFAULT);
248         }
249
250         if (sparam.idd_magic != IDENTITY_DOWNCALL_MAGIC) {
251                 CERROR("%s: MDS identity downcall bad params\n", obd->obd_name);
252                 GOTO(out, rc = -EINVAL);
253         }
254
255         if (sparam.idd_nperms > N_PERMS_MAX) {
256                 CERROR("%s: perm count %d more than maximum %d\n",
257                        obd->obd_name, sparam.idd_nperms, N_PERMS_MAX);
258                 GOTO(out, rc = -EINVAL);
259         }
260
261         if (sparam.idd_ngroups > NGROUPS_MAX) {
262                 CERROR("%s: group count %d more than maximum %d\n",
263                        obd->obd_name, sparam.idd_ngroups, NGROUPS_MAX);
264                 GOTO(out, rc = -EINVAL);
265         }
266
267         if (sparam.idd_ngroups) {
268                 size = offsetof(struct identity_downcall_data,
269                                 idd_groups[sparam.idd_ngroups]);
270                 OBD_ALLOC(param, size);
271                 if (!param) {
272                         CERROR("%s: fail to alloc %d bytes for uid %u"
273                                " with %d groups\n", obd->obd_name, size,
274                                sparam.idd_uid, sparam.idd_ngroups);
275                         param = &sparam;
276                         param->idd_ngroups = 0;
277                 } else if (copy_from_user(param, buffer, size)) {
278                         CERROR("%s: uid %u bad supplementary group data\n",
279                                obd->obd_name, sparam.idd_uid);
280                         OBD_FREE(param, size);
281                         param = &sparam;
282                         param->idd_ngroups = 0;
283                 }
284         }
285
286         rc = upcall_cache_downcall(mdt->mdt_identity_cache, param->idd_err,
287                                    param->idd_uid, param);
288
289 out:
290         if (param && (param != &sparam))
291                 OBD_FREE(param, size);
292
293         return rc ?: count;
294 }
295
296 /* for debug only */
297 static int lprocfs_rd_capa(char *page, char **start, off_t off,
298                            int count, int *eof, void *data)
299 {
300         struct obd_device *obd = data;
301         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
302
303         return snprintf(page, count, "capability on: %s %s\n",
304                         mdt->mdt_opts.mo_oss_capa ? "oss" : "",
305                         mdt->mdt_opts.mo_mds_capa ? "mds" : "");
306 }
307
308 static int lprocfs_wr_capa(struct file *file, const char *buffer,
309                            unsigned long count, void *data)
310 {
311         struct obd_device *obd = data;
312         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
313         int val, rc;
314
315         rc = lprocfs_write_helper(buffer, count, &val);
316         if (rc)
317                 return rc;
318
319         if (val < 0 || val > 3) {
320                 CERROR("invalid capability mode, only 0/2/3 is accepted.\n"
321                        " 0:  disable fid capability\n"
322                        " 2:  enable MDS fid capability\n"
323                        " 3:  enable both MDS and OSS fid capability\n");
324                 return -EINVAL;
325         }
326
327         /* OSS fid capability needs enable both MDS and OSS fid capability on
328          * MDS */
329         if (val == 1) {
330                 CERROR("can't enable OSS fid capability only, you should use "
331                        "'3' to enable both MDS and OSS fid capability.\n");
332                 return -EINVAL;
333         }
334
335         mdt->mdt_opts.mo_oss_capa = (val & 0x1);
336         mdt->mdt_opts.mo_mds_capa = !!(val & 0x2);
337         mdt->mdt_capa_conf = 1;
338         LCONSOLE_INFO("MDS %s %s MDS fid capability.\n",
339                       obd->obd_name,
340                       mdt->mdt_opts.mo_mds_capa ? "enabled" : "disabled");
341         LCONSOLE_INFO("MDS %s %s OSS fid capability.\n",
342                       obd->obd_name,
343                       mdt->mdt_opts.mo_oss_capa ? "enabled" : "disabled");
344         return count;
345 }
346
347 static int lprocfs_rd_capa_count(char *page, char **start, off_t off,
348                                  int count, int *eof, void *data)
349 {
350         return snprintf(page, count, "%d %d\n",
351                         capa_count[CAPA_SITE_CLIENT],
352                         capa_count[CAPA_SITE_SERVER]);
353 }
354
355 static int lprocfs_rd_site_stats(char *page, char **start, off_t off,
356                                  int count, int *eof, void *data)
357 {
358         struct obd_device *obd = data;
359         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
360
361         return lu_site_stats_print(mdt_lu_site(mdt), page, count);
362 }
363
364 static int lprocfs_rd_capa_timeout(char *page, char **start, off_t off,
365                                    int count, int *eof, void *data)
366 {
367         struct obd_device *obd = data;
368         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
369
370         return snprintf(page, count, "%lu\n", mdt->mdt_capa_timeout);
371 }
372
373 static int lprocfs_wr_capa_timeout(struct file *file, const char *buffer,
374                                    unsigned long count, void *data)
375 {
376         struct obd_device *obd = data;
377         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
378         int val, rc;
379
380         rc = lprocfs_write_helper(buffer, count, &val);
381         if (rc)
382                 return rc;
383
384         mdt->mdt_capa_timeout = (unsigned long)val;
385         mdt->mdt_capa_conf = 1;
386         return count;
387 }
388
389 static int lprocfs_rd_ck_timeout(char *page, char **start, off_t off, int count,
390                                  int *eof, void *data)
391 {
392         struct obd_device *obd = data;
393         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
394
395         return snprintf(page, count, "%lu\n", mdt->mdt_ck_timeout);
396 }
397
398 static int lprocfs_wr_ck_timeout(struct file *file, const char *buffer,
399                                  unsigned long count, void *data)
400 {
401         struct obd_device *obd = data;
402         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
403         int val, rc;
404
405         rc = lprocfs_write_helper(buffer, count, &val);
406         if (rc)
407                 return rc;
408
409         mdt->mdt_ck_timeout = (unsigned long)val;
410         mdt->mdt_capa_conf = 1;
411         return count;
412 }
413
414 static int lprocfs_mdt_wr_evict_client(struct file *file, const char *buffer,
415                                        unsigned long count, void *data)
416 {
417         char tmpbuf[sizeof(struct obd_uuid)];
418
419         sscanf(buffer, "%40s", tmpbuf);
420
421         if (strncmp(tmpbuf, "nid:", 4) != 0)
422                 return lprocfs_wr_evict_client(file, buffer, count, data);
423
424         CERROR("NOT implement evict client by nid %s\n", tmpbuf);
425
426         return count;
427 }
428
429 static int lprocfs_rd_sec_level(char *page, char **start, off_t off,
430                                 int count, int *eof, void *data)
431 {
432         struct obd_device *obd = data;
433         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
434
435         return snprintf(page, count, "%d\n", mdt->mdt_sec_level);
436 }
437
438 static int lprocfs_wr_sec_level(struct file *file, const char *buffer,
439                                 unsigned long count, void *data)
440 {
441         struct obd_device *obd = data;
442         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
443         int val, rc;
444
445         rc = lprocfs_write_helper(buffer, count, &val);
446         if (rc)
447                 return rc;
448
449         if (val > LUSTRE_SEC_ALL || val < LUSTRE_SEC_NONE)
450                 return -EINVAL;
451
452         if (val == LUSTRE_SEC_SPECIFY) {
453                 CWARN("security level %d will be supported in future.\n",
454                       LUSTRE_SEC_SPECIFY);
455                 return -EINVAL;
456         }
457
458         mdt->mdt_sec_level = val;
459         return count;
460 }
461
462 static int lprocfs_rd_cos(char *page, char **start, off_t off,
463                               int count, int *eof, void *data)
464 {
465         struct obd_device *obd = data;
466         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
467
468         return snprintf(page, count, "%u\n", mdt_cos_is_enabled(mdt));
469 }
470
471 static int lprocfs_wr_cos(struct file *file, const char *buffer,
472                                   unsigned long count, void *data)
473 {
474         struct obd_device *obd = data;
475         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
476         int val, rc;
477
478         rc = lprocfs_write_helper(buffer, count, &val);
479         if (rc)
480                 return rc;
481         mdt_enable_cos(mdt, val);
482         return count;
483 }
484
485 static int lprocfs_rd_root_squash(char *page, char **start, off_t off,
486                                   int count, int *eof, void *data)
487 {
488         struct obd_device *obd = data;
489         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
490         ENTRY;
491
492         return snprintf(page, count, "%u:%u\n", mdt->mdt_squash_uid,
493                         mdt->mdt_squash_gid);
494 }
495
496 static int safe_strtoul(const char *str, char **endp, unsigned long *res)
497 {
498         char n[24];
499
500         *res = simple_strtoul(str, endp, 0);
501         if (str == *endp)
502                 return 1;
503
504         sprintf(n, "%lu", *res);
505         if (strncmp(n, str, *endp - str))
506                 /* overflow */
507                 return 1;
508         return 0;
509 }
510
511 static int lprocfs_wr_root_squash(struct file *file, const char *buffer,
512                                   unsigned long count, void *data)
513 {
514         struct obd_device *obd = data;
515         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
516         char kernbuf[50], *tmp, *end;
517         unsigned long uid, gid;
518         int nouid, nogid;
519         ENTRY;
520
521         if (count > (sizeof(kernbuf) - 1) ||
522             copy_from_user(kernbuf, buffer, count)) {
523                 CWARN("%s: can't copy string to kernel space, "
524                       "uid:gid is expected, "
525                       "continue with %u:%u, "
526                       "there will be 0:0 on MDS restart\n",
527                       obd->obd_name, mdt->mdt_squash_uid,
528                       mdt->mdt_squash_gid);
529                 RETURN(count);
530         }
531
532         if (copy_from_user(kernbuf, buffer, count))
533                 RETURN(-EFAULT);
534
535         kernbuf[count] = '\0';
536
537         nouid = nogid = 0;
538         if (safe_strtoul(buffer, &tmp, &uid)) {
539                 uid = mdt->mdt_squash_uid;
540                 nouid = 1;
541         }
542
543         /* skip ':' */
544         if (*tmp == ':') {
545                 tmp++;
546                 if (safe_strtoul(tmp, &end, &gid)) {
547                         gid = mdt->mdt_squash_gid;
548                         nogid = 1;
549                 }
550         } else {
551                 gid = mdt->mdt_squash_gid;
552                 nogid = 1;
553         }
554
555         mdt->mdt_squash_uid = uid;
556         mdt->mdt_squash_gid = gid;
557
558         if (nouid || nogid)
559                 CWARN("%s: can't parse \"\%s\", uid:gid is expected, "
560                       "continue with %u:%u, "
561                       "there will be %u:%u on MDS restart\n",
562                       obd->obd_name,
563                       buffer, mdt->mdt_squash_uid, mdt->mdt_squash_gid,
564                       nouid ? 0 : mdt->mdt_squash_uid,
565                       nogid ? 0 : mdt->mdt_squash_gid);
566         else
567                 LCONSOLE_INFO("%s: root_squash is set to %u:%u\n",
568                               obd->obd_name,
569                               mdt->mdt_squash_uid,  mdt->mdt_squash_gid);
570         RETURN(count);
571 }
572
573 static int lprocfs_rd_nosquash_nids(char *page, char **start, off_t off,
574                                     int count, int *eof, void *data)
575 {
576         struct obd_device *obd = data;
577         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
578
579         if (mdt->mdt_nosquash_str)
580                 return snprintf(page, count, "%s\n", mdt->mdt_nosquash_str);
581         return snprintf(page, count, "NONE\n");
582 }
583
584 static int lprocfs_wr_nosquash_nids(struct file *file, const char *buffer,
585                                     unsigned long count, void *data)
586 {
587         struct obd_device *obd = data;
588         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
589         int rc;
590         char *new;
591         struct list_head tmp;
592         ENTRY;
593
594         /* copy to kernel space */
595         OBD_ALLOC(new, count + 1);
596         if (new == 0)
597                 GOTO(failed, rc = -ENOMEM);
598
599         if (copy_from_user(new, buffer, count))
600                 GOTO(failed, rc = -EFAULT);
601
602         new[count] = 0;
603         if (strlen(new) != count)
604                 GOTO(failed, rc = -EINVAL);
605
606         if (!strcmp(new, "NONE") || !strcmp(new, "clear")) {
607                 /* empty string is special case */
608                 down_write(&mdt->mdt_squash_sem);
609                 if (!list_empty(&mdt->mdt_nosquash_nids)) {
610                         cfs_free_nidlist(&mdt->mdt_nosquash_nids);
611                         OBD_FREE(mdt->mdt_nosquash_str,
612                                  mdt->mdt_nosquash_strlen);
613                         mdt->mdt_nosquash_str = NULL;
614                         mdt->mdt_nosquash_strlen = 0;
615                 }
616                 up_write(&mdt->mdt_squash_sem);
617                 LCONSOLE_INFO("%s: nosquash_nids is cleared\n",
618                               obd->obd_name);
619                 OBD_FREE(new, count + 1);
620                 RETURN(0);
621         }
622
623         CFS_INIT_LIST_HEAD(&tmp);
624         if (cfs_parse_nidlist(new, count, &tmp) <= 0)
625                 GOTO(failed, rc = -EINVAL);
626
627         down_write(&mdt->mdt_squash_sem);
628         if (!list_empty(&mdt->mdt_nosquash_nids)) {
629                 cfs_free_nidlist(&mdt->mdt_nosquash_nids);
630                 OBD_FREE(mdt->mdt_nosquash_str, mdt->mdt_nosquash_strlen);
631         }
632         mdt->mdt_nosquash_str = new;
633         mdt->mdt_nosquash_strlen = count + 1;
634         list_splice(&tmp, &mdt->mdt_nosquash_nids);
635
636         LCONSOLE_INFO("%s: nosquash_nids is set to %s\n", obd->obd_name, new);
637         up_write(&mdt->mdt_squash_sem);
638         RETURN(count);
639
640  failed:
641         CWARN("%s: failed to set nosquash_nids (rc %d), "
642               "on MDS restart we will try to set it again, "
643               "continue with current nosquash_nids\n",
644               obd->obd_name, rc);
645         if (new)
646                 OBD_FREE(new, count + 1);
647         RETURN(count);
648 }
649
650 static struct lprocfs_vars lprocfs_mdt_obd_vars[] = {
651         { "uuid",                       lprocfs_rd_uuid,                 0, 0 },
652         { "recovery_status",            lprocfs_obd_rd_recovery_status,  0, 0 },
653         { "num_exports",                lprocfs_rd_num_exports,          0, 0 },
654         { "identity_expire",            lprocfs_rd_identity_expire,
655                                         lprocfs_wr_identity_expire,         0 },
656         { "identity_acquire_expire",    lprocfs_rd_identity_acquire_expire,
657                                         lprocfs_wr_identity_acquire_expire, 0 },
658         { "identity_upcall",            lprocfs_rd_identity_upcall,
659                                         lprocfs_wr_identity_upcall,         0 },
660         { "identity_flush",             0, lprocfs_wr_identity_flush,       0 },
661         { "identity_info",              0, lprocfs_wr_identity_info,        0 },
662         { "capa",                       lprocfs_rd_capa,
663                                         lprocfs_wr_capa,                    0 },
664         { "capa_timeout",               lprocfs_rd_capa_timeout,
665                                         lprocfs_wr_capa_timeout,            0 },
666         { "capa_key_timeout",           lprocfs_rd_ck_timeout,
667                                         lprocfs_wr_ck_timeout,              0 },
668         { "capa_count",                 lprocfs_rd_capa_count,           0, 0 },
669         { "site_stats",                 lprocfs_rd_site_stats,           0, 0 },
670         { "evict_client",               0, lprocfs_mdt_wr_evict_client,     0 },
671         { "hash_stats",                 lprocfs_obd_rd_hash,    0, 0 },
672         { "sec_level",                  lprocfs_rd_sec_level,
673                                         lprocfs_wr_sec_level,               0 },
674         { "commit_on_sharing",          lprocfs_rd_cos, lprocfs_wr_cos, 0 },
675         { "root_squash",                lprocfs_rd_root_squash,
676                                         lprocfs_wr_root_squash,             0 },
677         { "nosquash_nids",              lprocfs_rd_nosquash_nids,
678                                         lprocfs_wr_nosquash_nids,          0 },
679         { 0 }
680 };
681
682 static struct lprocfs_vars lprocfs_mdt_module_vars[] = {
683         { "num_refs",                   lprocfs_rd_numrefs,              0, 0 },
684         { 0 }
685 };
686
687 void lprocfs_mdt_init_vars(struct lprocfs_static_vars *lvars)
688 {
689     lvars->module_vars  = lprocfs_mdt_module_vars;
690     lvars->obd_vars     = lprocfs_mdt_obd_vars;
691 }