Whamcloud - gitweb
1. Fixed cleanup issue where I was *indeed* accesing a zapped pointer.
[fs/lustre-release.git] / lustre / ost / lproc_ost.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_OST
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          
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
38 }
39 int rd_blksize(char* page, char **start, off_t off,
40                int count, int *eof, void *data)
41 {
42         
43         struct obd_device* temp=(struct obd_device*)data;
44         struct ost_obd *ost=&temp->u.ost;
45         struct lustre_handle *conn=&ost->ost_conn;
46         struct obd_statfs mystats;
47         int len=0;
48         
49         obd_statfs(conn, &mystats);
50         len+=snprintf(page, count, "%d\n", mystats.os_bsize); 
51         return len;
52         
53 }
54 int rd_kbtotal(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 ost_obd *ost=&temp->u.ost;
59         struct lustre_handle *conn=&ost->ost_conn;
60         struct obd_statfs mystats;
61         int len=0;
62         __u32 blk_size;
63         __u64 result;
64         
65         
66         obd_statfs(conn, &mystats);
67
68         blk_size=mystats.os_bsize;
69         blk_size>>=10;
70         
71         result=mystats.os_blocks;
72         
73         while(blk_size>>=1){
74                 result<<=1;
75         }
76        
77         len+=snprintf(page, count, LPU64"\n", result);
78         return len;
79         
80         
81 }
82
83
84 int rd_kbfree(char* page, char **start, off_t off,
85               int count, int *eof, void *data)
86 {
87         
88         struct obd_device* temp=(struct obd_device*)data;
89         struct ost_obd *ost=&temp->u.ost;
90         struct lustre_handle *conn=&ost->ost_conn;
91         struct obd_statfs mystats;
92         int len=0;
93         __u32 blk_size;
94         __u64 result;
95
96         obd_statfs(conn, &mystats);
97         
98         blk_size=mystats.os_bsize;
99         blk_size>>=10;
100
101         result=mystats.os_bfree;
102
103         while(blk_size>>=1){
104                 result<<=1;
105         }
106         
107         len+=snprintf(page, count, LPU64"\n", result);
108         return len;  
109         
110 }
111
112 int rd_files(char* page, char **start, off_t off,
113                   int count, int *eof, void *data)
114 {
115         
116         struct obd_device* temp=(struct obd_device*)data;
117         struct ost_obd *ost=&temp->u.ost;
118         struct lustre_handle *conn=&ost->ost_conn;
119         struct obd_statfs mystats;
120         int len=0;
121         
122         obd_statfs(conn, &mystats);
123         
124         len+=snprintf(page, count, LPU64"\n",mystats.os_files); 
125         return len;
126         
127 }
128
129 int rd_filesfree(char* page, char **start, off_t off,
130                int count, int *eof, void *data)
131 {
132         
133         struct obd_device* temp=(struct obd_device*)data;
134         struct ost_obd *ost=&temp->u.ost;
135         struct lustre_handle *conn=&ost->ost_conn;
136         struct obd_statfs mystats;
137         int len=0;
138         
139         obd_statfs(conn, &mystats);
140         len+=snprintf(page, count, LPU64"\n", mystats.os_ffree); 
141         return len;
142         
143 }
144
145 int rd_objgroups(char* page, char **start, off_t off,
146                  int count, int *eof, void *data)
147 {
148         return 0;
149 }
150
151 struct lprocfs_vars status_var_nm_1[]={
152         {"status/uuid", rd_uuid, 0},
153         {"status/blocksize",rd_blksize, 0},
154         {"status/kbytesfree", rd_kbfree, 0},
155         {"status/kbytestotal", rd_kbtotal, 0},
156         {"status/files", rd_files, 0},
157         {"status/filesfree", rd_filesfree, 0},
158         {"status/objectgroups", rd_objgroups, 0},
159         {0}
160 };
161
162 int rd_numdevices(char* page, char **start, off_t off,
163                   int count, int *eof, void *data)
164 {
165         struct obd_type* class=(struct obd_type*)data;
166         int len=0;
167         len+=snprintf(page, count, "%d\n", class->typ_refcnt);
168         return len;
169 }
170
171 struct lprocfs_vars status_class_var[]={
172         {"status/num_devices", rd_numdevices, 0},
173         {0}
174 };