Whamcloud - gitweb
5adcaf896774e9acba8628c739dbd6401495df87
[fs/lustre-release.git] / lustre / cobd / lproc_cache.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2002 Cluster File Systems, Inc.
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  */
22 #define DEBUG_SUBSYSTEM S_CLASS
23
24 #include <linux/lustre_lite.h>
25 #include <linux/lprocfs_status.h>
26
27 /*
28  * Common STATUS namespace
29  */
30
31 static int rd_uuid (char *page, char **start, off_t off, int count,
32                     int *eof, void *data)
33 {
34         struct obd_device* dev = (struct obd_device*)data;
35
36         return (snprintf(page, count, "%s\n", dev->obd_uuid));
37 }
38
39 static int rd_target (char *page, char **start, off_t off, int count,
40                       int *eof, void *data)
41 {
42         struct obd_device    *dev = (struct obd_device*)data;
43         struct cache_obd     *cobd = &dev->u.cobd;
44         struct lustre_handle *conn = &cobd->cobd_target;
45         struct obd_export    *exp;
46         int    rc;
47
48         if ((dev->obd_flags & OBD_SET_UP) == 0)
49                 rc = snprintf (page, count, "not set up\n");
50         else {
51                 exp = class_conn2export (conn);
52                 LASSERT (exp != NULL);
53                 rc = snprintf(page, count, "%s\n", exp->exp_obd->obd_uuid);
54         }
55         return (rc);
56 }
57
58 static int rd_cache(char *page, char **start, off_t off, int count,
59                     int *eof, void *data)
60 {
61         struct obd_device    *dev = (struct obd_device*)data;
62         struct cache_obd     *cobd = &dev->u.cobd;
63         struct lustre_handle *conn = &cobd->cobd_cache;
64         struct obd_export    *exp;
65         int    rc;
66
67         if ((dev->obd_flags & OBD_SET_UP) == 0)
68                 rc = snprintf (page, count, "not set up\n");
69         else {
70                 exp = class_conn2export (conn);
71                 LASSERT (exp != NULL);
72                 rc = snprintf(page, count, "%s\n", exp->exp_obd->obd_uuid);
73         }
74         return (rc);
75 }
76
77 struct lprocfs_vars status_var_nm_1[] = {
78         {"status/uuid", rd_uuid, 0, 0},
79         {"status/target_uuid", rd_target, 0, 0},
80         {"status/cache_uuid", rd_cache, 0, 0},
81         {0}
82 };
83
84 int rd_numrefs(char *page, char **start, off_t off, int count,
85                int *eof, void *data)
86 {
87         struct obd_type* class = (struct obd_type*)data;
88
89         return (snprintf(page, count, "%d\n", class->typ_refcnt));
90 }
91
92 struct lprocfs_vars status_class_var[] = {
93         {"status/num_refs", rd_numrefs, 0, 0},
94         {0}
95 };