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