Whamcloud - gitweb
4845f41520c3ed28575f9d57ae211f6e8ee6f66d
[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         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, int count, int *eof, 
42                   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, int count, int *eof, 
54                     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, int count, int *eof, 
66                   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, int count, int *eof, 
77                    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, int count, int *eof, 
88               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, int count, int *eof, 
100                  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, int count, int *eof, 
112                void *data)
113 {
114         return 0;
115 }
116
117
118 int rd_kbtotal(char* page, char **start, off_t off, int count, int *eof, 
119                void *data)
120 {
121         return 0;
122 }
123
124
125 int rd_kbfree(char* page, char **start, off_t off, int count, int *eof, 
126               void *data)
127 {
128         return 0;
129 }
130
131 int rd_filestotal(char* page, char **start, off_t off, int count, int *eof, 
132                   void *data)
133 {
134         return 0;
135 }
136
137 int rd_filesfree(char* page, char **start, off_t off, int count, int *eof, 
138                  void *data)
139 {
140         return 0;
141 }
142
143 int rd_filegroups(char* page, char **start, off_t off, int count, int *eof, 
144                  void *data)
145 {
146         return 0;
147 }
148
149 int rd_target(char* page, char **start, off_t off, int count, int *eof, 
150               void *data)
151 {
152         struct obd_device* dev = (struct obd_device*)data;
153         int len = 0, i = 0;
154         struct lov_obd* lov = &dev->u.lov;
155         struct lov_tgt_desc* tgts = lov->tgts;
156         while(i < lov->desc.ld_tgt_count){
157                 len += snprintf(page, count, "%d: %s\n", i, tgts->uuid);
158                 i++;
159                 tgts++;
160         }
161         
162         return len;
163 }
164 int rd_mdc(char* page, char **start, off_t off, int count, int *eof, void *data)
165 {
166         struct obd_device* dev = (struct obd_device*)data;
167         int len = 0;
168         struct lov_obd* lov = &dev->u.lov;
169         len += snprintf(page, count, "%s\n", lov->mdcobd->obd_uuid);
170         return len;
171 }
172
173 struct lprocfs_vars status_var_nm_1[] = {
174         {"status/uuid", rd_uuid, 0, 0},
175         {"status/stripesize",rd_stripesize, 0, 0},
176         {"status/stripeoffset",rd_stripeoffset, 0, 0},
177         {"status/stripecount",rd_stripecount, 0, 0},
178         {"status/stripetype", rd_stripetype, 0, 0},
179         {"status/numobd",rd_numobd, 0, 0},
180         {"status/activeobd", rd_activeobd, 0, 0},
181         {"status/filestotal", rd_filestotal, 0, 0},
182         {"status/filesfree", rd_filesfree, 0, 0},
183         {"status/filegroups", rd_filegroups, 0, 0},
184         {"status/blocksize", rd_blksize, 0, 0},
185         {"status/kbytestotal", rd_kbtotal, 0, 0},
186         {"status/kbytesfree", rd_kbfree, 0, 0},
187         {"status/target_obd", rd_target, 0, 0},
188         {"status/target_mdc", rd_mdc, 0, 0},
189        
190         {0}
191 };
192 int rd_numrefs(char* page, char **start, off_t off, int count, int *eof, 
193                void *data)
194 {
195         struct obd_type* class = (struct obd_type*)data;
196         int len = 0;
197         len += snprintf(page, count, "%d\n", class->typ_refcnt);
198         return len;
199 }
200
201 struct lprocfs_vars status_class_var[]={
202         {"status/num_refs", rd_numrefs, 0, 0},
203         {0}
204 };