Whamcloud - gitweb
a65816f28cc7065acfdbc361fd145a2c65fbc35f
[fs/lustre-release.git] / lustre / mds / lproc_mds.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 int rd_uuid(char* page, char **start, off_t off,
29                int count, int *eof, void *data)
30 {
31         struct obd_device* temp=(struct obd_device*)data;
32         int len=0;
33         len+=snprintf(page, count, "%s\n", temp->obd_uuid); 
34         return len;  
35 }
36 int rd_blksize(char* page, char **start, off_t off,
37                int count, int *eof, void *data)
38 {
39         struct obd_device* temp=(struct obd_device*)data;
40         struct mds_obd *mds=&temp->u.mds;
41         struct statfs mystats;
42         int rc, len=0;
43         
44         rc = vfs_statfs(mds->mds_sb, &mystats);
45         if (rc) {
46                 CERROR("mds: statfs failed: rc %d\n", rc);
47                 return 0;
48         }
49         len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_bsize)); 
50         return len;
51
52 }
53 int rd_blktotal(char* page, char **start, off_t off,
54                 int count, int *eof, void *data)
55 {
56        struct obd_device* temp=(struct obd_device*)data;
57         struct mds_obd *mds=&temp->u.mds;
58         struct statfs mystats;
59         int rc, len=0;
60         
61         rc = vfs_statfs(mds->mds_sb, &mystats);
62         if (rc) {
63                 CERROR("mds: statfs failed: rc %d\n", rc);
64                 return 0;
65         }
66         len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_blocks)); 
67         return len;  
68         
69 }
70
71 int rd_blkfree(char* page, char **start, off_t off,
72                int count, int *eof, void *data)
73 {
74         struct obd_device* temp=(struct obd_device*)data;
75         struct mds_obd *mds=&temp->u.mds;
76         struct statfs mystats;
77         int rc, len=0;
78         
79         rc = vfs_statfs(mds->mds_sb, &mystats);
80         if (rc) {
81                 CERROR("mds: statfs failed: rc %d\n", rc);
82                 return 0;
83         }
84         len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_bfree)); 
85         return len;  
86         
87 }
88
89 int rd_kbfree(char* page, char **start, off_t off,
90               int count, int *eof, void *data)
91 {
92         struct obd_device* temp=(struct obd_device*)data;
93         struct mds_obd *mds=&temp->u.mds;
94         struct statfs mystats;
95         int rc, blk_size, len=0;
96         
97         rc = vfs_statfs(mds->mds_sb, &mystats);
98         if (rc) {
99                 CERROR("mds: statfs failed: rc %d\n", rc);
100                 return 0;
101         }
102         blk_size=mystats.f_bsize;
103         len+=snprintf(page, count, LPU64"\n", 
104                       (__u64)((mystats.f_bfree)/(blk_size*1024))); 
105         return len;  
106        
107 }
108
109 int rd_fstype(char* page, char **start, off_t off,
110                   int count, int *eof, void *data)
111 {               
112         struct obd_device* temp=(struct obd_device*)data;
113         struct mds_obd *mds=&temp->u.mds;
114         int len=0;
115         len+=snprintf(page, count, "%s\n", mds->mds_fstype); 
116         return len;  
117  
118 }
119
120 int rd_ffiles(char* page, char **start, off_t off,
121                int count, int *eof, void *data)
122 {
123         struct obd_device* temp=(struct obd_device*)data;
124         struct mds_obd *mds=&temp->u.mds;
125         struct statfs mystats;
126         int rc, len=0;
127         
128         rc = vfs_statfs(mds->mds_sb, &mystats);
129         if (rc) {
130                 CERROR("mds: statfs failed: rc %d\n", rc);
131                 return 0;
132         }
133         
134         len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_files));
135         return len;  
136
137         
138 }
139
140 int rd_inodesfree(char* page, char **start, off_t off,
141                  int count, int *eof, void *data)
142 {
143         struct obd_device* temp=(struct obd_device*)data;
144         struct mds_obd *mds=&temp->u.mds;
145         struct statfs mystats;
146         int rc, len=0;
147         
148         rc = vfs_statfs(mds->mds_sb, &mystats);
149         if (rc) {
150                 CERROR("mds: statfs failed: rc %d\n", rc);
151                 return 0;
152         }
153         
154         len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_ffree));
155         return len; 
156 }
157
158 int rd_filesets(char* page, char **start, off_t off,
159                  int count, int *eof, void *data)
160 {
161         return 0;
162 }
163 lprocfs_vars_t status_var_nm_1[]={
164         {"status/uuid", rd_uuid, 0},
165         {"status/f_blocksize",rd_blksize, 0},
166         {"status/f_blockstotal",rd_blktotal, 0},
167         {"status/f_blocksfree",rd_blkfree, 0},
168         {"status/f_kbytesfree", rd_kbfree, 0},
169         {"status/f_fstype", rd_fstype, 0},
170         {"status/f_files", rd_ffiles, 0},
171         {"status/f_inodesfree", rd_inodesfree, 0},
172         {"status/f_filesets", rd_filesets, 0},
173         {0}
174 };
175 int rd_numdevices(char* page, char **start, off_t off,
176                   int count, int *eof, void *data)
177 {
178         struct obd_type* class=(struct obd_type*)data;
179         int len=0;
180         len+=snprintf(page, count, "%d\n", class->typ_refcnt);
181         return len;
182 }
183
184 lprocfs_vars_t status_class_var[]={
185         {"status/num_devices", rd_numdevices, 0},
186         {0}
187 };