Whamcloud - gitweb
ab3758937cc70d27e04f15e90472827aed285497
[fs/lustre-release.git] / lustre / obdfilter / lproc_obdfilter.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         int len=0;
32         struct obd_device* dev=(struct obd_device*)data;
33         len+=snprintf(page, count, "%s\n", dev->obd_uuid);
34         return len;
35
36         
37
38 }
39 int rd_blksize(char* page, char **start, off_t off,
40                int count, int *eof, void *data)
41 {
42         struct obd_device* temp=(struct obd_device*)data;
43         struct statfs mystats;
44
45         int len=0;
46
47         vfs_statfs(temp->u.filter.fo_sb, &mystats);
48
49         len+=snprintf(page, count, "%ld\n", mystats.f_bsize); 
50         return len;
51         
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 statfs mystats;
59         int len=0;
60         __u64 result;
61
62         vfs_statfs(temp->u.filter.fo_sb, &mystats);
63         
64         result=((__u64)(mystats.f_blocks*mystats.f_bsize))>>10;
65
66         len+=snprintf(page, count, LPU64"\n", result); 
67
68         return len;   
69 }
70
71 int rd_kbfree(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 statfs mystats;
76
77         int len=0;
78         __u64 result;
79
80         vfs_statfs(temp->u.filter.fo_sb, &mystats);
81         result=((__u64)(mystats.f_bfree*mystats.f_bsize))>>10;
82
83         len+=snprintf(page, count, LPU64"\n", result); 
84         return len;     
85 }
86
87 int rd_fstype(char* page, char **start, off_t off,
88                   int count, int *eof, void *data)
89 {
90         
91         struct obd_device* temp=(struct obd_device*)data;
92         int len=0;
93         
94         len+=snprintf(page, count, "%s\n", temp->u.filter.fo_fstype);
95         return len;
96         
97 }
98 int rd_files(char* page, char **start, off_t off,
99               int count, int *eof, void *data)
100
101         
102         struct obd_device* temp=(struct obd_device*)data;
103         struct statfs mystats;
104
105          int len=0;
106
107          vfs_statfs(temp->u.filter.fo_sb, &mystats);
108
109          len+=snprintf(page, count, "%ld\n", mystats.f_files); 
110         return len;
111 }
112
113 int rd_filesfree(char* page, char **start, off_t off,
114                   int count, int *eof, void *data)
115 {
116         struct obd_device* temp=(struct obd_device*)data;
117         struct statfs mystats;
118         
119         int len=0;
120         
121         vfs_statfs(temp->u.filter.fo_sb, &mystats);
122         
123         len+=snprintf(page, count, "%ld\n", mystats.f_ffree); 
124         return len;
125         
126         
127 }
128
129 lprocfs_vars_t status_var_nm_1[]={
130         {"status/uuid", rd_uuid, 0},
131         {"status/blocksize",rd_blksize, 0},
132         {"status/kbytestotal",rd_kbtotal, 0},
133         {"status/kbytesfree", rd_kbfree, 0},
134         {"status/files", rd_files, 0},
135         {"status/filesfree", rd_filesfree, 0},
136         {"status/fstype", rd_fstype, 0},
137         {0}
138 };
139 int rd_numdevices(char* page, char **start, off_t off,
140                   int count, int *eof, void *data)
141 {
142         struct obd_type* class=(struct obd_type*)data;
143         int len=0;
144         len+=snprintf(page, count, "%d\n", class->typ_refcnt);
145         return len;
146 }
147
148 lprocfs_vars_t status_class_var[]={
149         {"status/num_devices", rd_numdevices, 0},
150         {0}
151 };