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