Whamcloud - gitweb
Merge b_md to HEAD for 0.5.19 release.
[fs/lustre-release.git] / lustre / lov / lproc_lov.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 int rd_uuid(char *page, char **start, off_t off, int count, int *eof,
32             void *data)
33 {
34         struct obd_device* dev = (struct obd_device*)data;
35         return snprintf(page, count, "%s\n", dev->obd_uuid);
36 }
37
38 int rd_stripesize(char *page, char **start, off_t off, int count, int *eof,
39                   void *data)
40 {
41         struct obd_device *dev = (struct obd_device*)data;
42         struct lov_desc *desc = &dev->u.lov.desc;
43
44         return snprintf(page, count, LPU64"\n", desc->ld_default_stripe_size);
45 }
46
47 int rd_stripeoffset(char *page, char **start, off_t off, int count, int *eof,
48                     void *data)
49 {
50         struct obd_device* dev = (struct obd_device*)data;
51         struct lov_obd* lov = &dev->u.lov;
52
53         return snprintf(page, count, LPU64"\n",
54                         lov->desc.ld_default_stripe_offset);
55 }
56
57 int rd_stripetype(char *page, char **start, off_t off, int count, int *eof,
58                   void *data)
59 {
60         struct obd_device* dev = (struct obd_device*)data;
61         struct lov_obd* lov = &dev->u.lov;
62
63         return snprintf(page, count, "%u\n", lov->desc.ld_pattern);
64 }
65
66 int rd_stripecount(char *page, char **start, off_t off, int count, int *eof,
67                    void *data)
68 {
69         struct obd_device* dev = (struct obd_device*)data;
70         struct lov_obd* lov = &dev->u.lov;
71
72         return snprintf(page, count, "%u\n", lov->desc.ld_default_stripe_count);
73 }
74
75 int rd_numobd(char *page, char **start, off_t off, int count, int *eof,
76               void *data)
77 {
78         struct obd_device *dev = (struct obd_device*)data;
79         struct lov_obd *lov = &dev->u.lov;
80
81         return snprintf(page, count, "%u\n", lov->desc.ld_tgt_count);
82
83 }
84
85 int rd_activeobd(char *page, char **start, off_t off, int count, int *eof,
86                  void *data)
87 {
88         struct obd_device* dev = (struct obd_device*)data;
89         struct lov_obd* lov = &dev->u.lov;
90
91         return snprintf(page, count, "%u\n", lov->desc.ld_active_tgt_count);
92 }
93
94 int rd_blksize(char *page, char **start, off_t off, int count, int *eof,
95                void *data)
96 {
97         return 0;
98 }
99
100
101 int rd_kbtotal(char *page, char **start, off_t off, int count, int *eof,
102                void *data)
103 {
104         return 0;
105 }
106
107
108 int rd_kbfree(char *page, char **start, off_t off, int count, int *eof,
109               void *data)
110 {
111         return 0;
112 }
113
114 int rd_filestotal(char *page, char **start, off_t off, int count, int *eof,
115                   void *data)
116 {
117         return 0;
118 }
119
120 int rd_filesfree(char* page, char **start, off_t off, int count, int *eof,
121                  void *data)
122 {
123         return 0;
124 }
125
126 int rd_filegroups(char* page, char **start, off_t off, int count, int *eof,
127                   void *data)
128 {
129         return 0;
130 }
131
132 int rd_target(char *page, char **start, off_t off, int count, int *eof,
133               void *data)
134 {
135         struct obd_device* dev = (struct obd_device*)data;
136         int len = 0, i = 0;
137         struct lov_obd* lov = &dev->u.lov;
138         struct lov_tgt_desc* tgts = lov->tgts;
139         while (i < lov->desc.ld_tgt_count) {
140                 len += snprintf(&page[len], count - len, "%d: %s %sACTIVE\n",
141                                 i, tgts->uuid, tgts->active ? "" : "IN");
142                 i++;
143                 tgts++;
144         }
145
146         return len;
147 }
148
149 int rd_mdc(char* page, char **start, off_t off, int count, int *eof, void *data)
150 {
151         struct obd_device* dev = (struct obd_device*)data;
152         int len = 0;
153         struct lov_obd* lov = &dev->u.lov;
154         len += snprintf(page, count, "%s\n", lov->mdcobd->obd_uuid);
155         return len;
156 }
157
158 struct lprocfs_vars status_var_nm_1[] = {
159         {"status/uuid", rd_uuid, 0, 0},
160         {"status/stripesize",rd_stripesize, 0, 0},
161         {"status/stripeoffset",rd_stripeoffset, 0, 0},
162         {"status/stripecount",rd_stripecount, 0, 0},
163         {"status/stripetype", rd_stripetype, 0, 0},
164         {"status/numobd",rd_numobd, 0, 0},
165         {"status/activeobd", rd_activeobd, 0, 0},
166         {"status/filestotal", rd_filestotal, 0, 0},
167         {"status/filesfree", rd_filesfree, 0, 0},
168         {"status/filegroups", rd_filegroups, 0, 0},
169         {"status/blocksize", rd_blksize, 0, 0},
170         {"status/kbytestotal", rd_kbtotal, 0, 0},
171         {"status/kbytesfree", rd_kbfree, 0, 0},
172         {"status/target_obd", rd_target, 0, 0},
173         {"status/target_mdc", rd_mdc, 0, 0},
174         {0}
175 };
176
177 int rd_numrefs(char *page, char **start, off_t off, int count, int *eof,
178                void *data)
179 {
180         struct obd_type* class = (struct obd_type*)data;
181
182         return snprintf(page, count, "%d\n", class->typ_refcnt);
183 }
184
185 struct lprocfs_vars status_class_var[]={
186         {"status/num_refs", rd_numrefs, 0, 0},
187         {0}
188 };