Whamcloud - gitweb
1. Bug fix for Bug #320, also needs repair of lconf, since it tries
[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, int count, int *eof, 
29             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 int rd_blksize(char* page, char **start, off_t off, int count, int *eof, 
37                void *data)
38 {
39         struct obd_device* temp = (struct obd_device*)data;
40         struct statfs mystats;
41         int len = 0;
42
43         vfs_statfs(temp->u.filter.fo_sb, &mystats);
44         len+=snprintf(page, count, "%ld\n", mystats.f_bsize); 
45         return len;
46 }
47 int rd_kbtotal(char* page, char **start, off_t off, int count, int *eof, 
48                void *data)
49 {
50         struct obd_device* temp = (struct obd_device*)data;
51         struct statfs mystats;
52         int len = 0;
53         __u32 blk_size;
54         __u64 result;
55
56         vfs_statfs(temp->u.filter.fo_sb, &mystats);
57         blk_size = mystats.f_bsize;
58         blk_size >>= 10;
59         result = mystats.f_blocks;
60         while(blk_size >>= 1){
61                 result <<= 1;
62         }
63         len+=snprintf(page, count, LPU64"\n", result); 
64         return len;   
65 }
66
67 int rd_kbfree(char* page, char **start, off_t off, int count, int *eof, 
68               void *data)
69 {
70         struct obd_device* temp = (struct obd_device*)data;
71         struct statfs mystats;
72         int len = 0;
73         __u32 blk_size;
74         __u64 result;
75
76         vfs_statfs(temp->u.filter.fo_sb, &mystats);
77         blk_size = mystats.f_bsize;
78         blk_size >>= 10;
79         result = mystats.f_bfree;
80         while(blk_size >>= 1){
81                 result <<= 1;
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, int count, int *eof, 
88               void *data)
89 {
90         struct obd_device* temp = (struct obd_device*)data;
91         int len = 0;
92         len += snprintf(page, count, "%s\n", temp->u.filter.fo_fstype);
93         return len;
94 }
95 int rd_files(char* page, char **start, off_t off, int count, int *eof, 
96              void *data)
97
98         struct obd_device* temp = (struct obd_device*)data;
99         struct statfs mystats;
100         int len = 0;
101         vfs_statfs(temp->u.filter.fo_sb, &mystats);
102         len += snprintf(page, count, "%ld\n", mystats.f_files); 
103         return len;
104 }
105
106 int rd_filesfree(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 statfs mystats;
111         int len = 0;
112         vfs_statfs(temp->u.filter.fo_sb, &mystats);
113         len += snprintf(page, count, "%ld\n", mystats.f_ffree); 
114         return len;
115 }
116
117 struct lprocfs_vars status_var_nm_1[] = {
118         {"status/uuid", rd_uuid, 0, 0},
119         {"status/blocksize",rd_blksize, 0, 0},
120         {"status/kbytestotal",rd_kbtotal, 0, 0},
121         {"status/kbytesfree", rd_kbfree, 0, 0},
122         {"status/files", rd_files, 0, 0},
123         {"status/filesfree", rd_filesfree, 0, 0},
124         {"status/fstype", rd_fstype, 0, 0},
125         {0}
126 };
127 int rd_numrefs(char* page, char **start, off_t off, int count, int *eof, 
128                void *data)
129 {
130         struct obd_type* class = (struct obd_type*)data;
131         int len = 0;
132         len += snprintf(page, count, "%d\n", class->typ_refcnt);
133         return len;
134 }
135
136 struct lprocfs_vars status_class_var[] = {
137         {"status/num_refs", rd_numrefs, 0, 0},
138         {0}
139 };