Whamcloud - gitweb
1. Fixed cleanup issue where I was *indeed* accesing a zapped pointer.
[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,
32                int count, int *eof, void *data)
33 {
34         int len=0;
35         struct obd_device* dev=(struct obd_device*)data;
36         len+=snprintf(page, count, "%s\n", dev->obd_uuid);
37         return len;
38         
39
40 }
41 int rd_stripesize(char* page, char **start, off_t off,
42                int count, int *eof, void *data)
43 {
44         struct obd_device* dev=(struct obd_device*)data;
45         int len=0;
46         struct lov_obd* lov=&dev->u.lov;
47         len+=snprintf(page, count, LPU64"\n", 
48                       (__u64)(lov->desc.ld_default_stripe_size));
49         
50         return len;
51 }
52
53 int rd_stripeoffset(char* page, char **start, off_t off,
54                int count, int *eof, void *data)
55 {
56         struct obd_device* dev=(struct obd_device*)data;
57         int len=0;
58         struct lov_obd* lov=&dev->u.lov;
59         len+=snprintf(page, count, LPU64"\n", 
60                       lov->desc.ld_default_stripe_offset);
61         return len;
62
63 }
64
65 int rd_stripetype(char* page, char **start, off_t off,
66                int count, int *eof, void *data)
67 {
68         struct obd_device* dev=(struct obd_device*)data;
69         int len=0;
70         struct lov_obd* lov=&dev->u.lov;
71         len+=snprintf(page, count, LPU64"\n", 
72                       (__u64)(lov->desc.ld_pattern));
73         return len;
74
75 }
76 int rd_stripecount(char* page, char **start, off_t off,
77                int count, int *eof, void *data)
78 {       
79         struct obd_device* dev=(struct obd_device*)data;
80         int len=0;
81         struct lov_obd* lov=&dev->u.lov;
82         len+=snprintf(page, count, LPU64"\n", 
83                       (__u64)(lov->desc.ld_default_stripe_count));
84         return len;
85
86 }
87 int rd_numobd(char* page, char **start, off_t off,
88                int count, int *eof, void *data)
89 {       
90         struct obd_device* dev=(struct obd_device*)data;
91         int len=0;
92         struct lov_obd* lov=&dev->u.lov;
93         len+=snprintf(page, count, LPU64"\n", 
94                       (__u64)(lov->desc.ld_tgt_count));
95         return len;
96
97 }
98
99 int rd_activeobd(char* page, char **start, off_t off,
100                int count, int *eof, void *data)
101 {       
102         struct obd_device* dev=(struct obd_device*)data;
103         int len=0;
104         struct lov_obd* lov=&dev->u.lov;
105         len+=snprintf(page, count, LPU64"\n", 
106                       (__u64)(lov->desc.ld_active_tgt_count));
107         return len;
108
109 }
110
111 int rd_blksize(char* page, char **start, off_t off,
112                 int count, int *eof, void *data)
113 {
114         return 0;
115 }
116
117
118 int rd_blktotal(char* page, char **start, off_t off,
119                 int count, int *eof, void *data)
120 {
121         return 0;
122 }
123
124 int rd_blkfree(char* page, char **start, off_t off,
125                int count, int *eof, void *data)
126 {
127         return 0;
128 }
129
130 int rd_kbfree(char* page, char **start, off_t off,
131               int count, int *eof, void *data)
132 {
133         return 0;
134 }
135
136 int rd_numobjects(char* page, char **start, off_t off,
137                   int count, int *eof, void *data)
138 {
139         return 0;
140 }
141
142 int rd_objfree(char* page, char **start, off_t off,
143                int count, int *eof, void *data)
144 {
145         return 0;
146 }
147
148 int rd_objgroups(char* page, char **start, off_t off,
149                  int count, int *eof, void *data)
150 {
151         return 0;
152 }
153
154 int rd_target(char* page, char **start, off_t off,
155                  int count, int *eof, void *data)
156 {
157         struct obd_device* dev=(struct obd_device*)data;
158         int len=0, i=0;
159         struct lov_obd* lov=&dev->u.lov;
160         struct lov_tgt_desc* tgts=lov->tgts;
161         while(i<lov->desc.ld_tgt_count){
162                 len+=snprintf(page, count, "%d: %s\n", i, tgts->uuid);
163                 i++;
164                 tgts++;
165         }
166         
167         return len;
168 }
169 int rd_mdc(char* page, char **start, off_t off,
170                  int count, int *eof, void *data)
171 {
172         struct obd_device* dev=(struct obd_device*)data;
173         int len=0;
174         struct lov_obd* lov=&dev->u.lov;
175         len+=snprintf(page, count, "%s\n", lov->mdcobd->obd_uuid);
176         return len;
177 }
178
179 struct lprocfs_vars status_var_nm_1[]={
180         {"status/uuid", rd_uuid, 0},
181         {"status/stripesize",rd_stripesize, 0},
182         {"status/stripeoffset",rd_stripeoffset, 0},
183         {"status/stripecount",rd_stripecount, 0},
184         {"status/stripetype", rd_stripetype, 0},
185         {"status/numobd",rd_numobd, 0},
186         {"status/activeobd", rd_activeobd, 0},
187         {"status/objects", rd_numobjects, 0},
188         {"status/objectsfree", rd_objfree, 0},
189         {"status/objectgroups", rd_objgroups, 0},
190         {"status/blocksize", rd_blksize, 0},
191         {"status/blockstotal", rd_blktotal, 0},
192         {"status/kbytesfree", rd_kbfree, 0},
193         {"status/blocksfree", rd_blkfree, 0},
194         {"status/target_obd", rd_target, 0},
195         {"status/target_mdc", rd_mdc, 0},
196        
197         {0}
198 };
199 int rd_numdevices(char* page, char **start, off_t off,
200                   int count, int *eof, void *data)
201 {
202         struct obd_type* class=(struct obd_type*)data;
203         int len=0;
204         len+=snprintf(page, count, "%d\n", class->typ_refcnt);
205         return len;
206 }
207
208 struct lprocfs_vars status_class_var[]={
209         {"status/num_devices", rd_numdevices, 0},
210         {0}
211 };