1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2002 Cluster File Systems, Inc.
6 * This file is part of Lustre, http://www.lustre.org.
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.
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.
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.
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>
29 int rd_uuid(char* page, char **start, off_t off,
30 int count, int *eof, void *data)
32 struct obd_device* temp=(struct obd_device*)data;
34 len+=snprintf(page, count, "%s\n", temp->obd_uuid);
37 int rd_blksize(char* page, char **start, off_t off,
38 int count, int *eof, void *data)
40 struct obd_device* temp=(struct obd_device*)data;
41 struct mds_obd *mds=&temp->u.mds;
42 struct statfs mystats;
45 rc = vfs_statfs(mds->mds_sb, &mystats);
47 CERROR("mds: statfs failed: rc %d\n", rc);
50 len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_bsize));
54 int rd_blktotal(char* page, char **start, off_t off,
55 int count, int *eof, void *data)
57 struct obd_device* temp=(struct obd_device*)data;
58 struct mds_obd *mds=&temp->u.mds;
59 struct statfs mystats;
62 rc = vfs_statfs(mds->mds_sb, &mystats);
64 CERROR("mds: statfs failed: rc %d\n", rc);
67 len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_blocks));
72 int rd_blkfree(char* page, char **start, off_t off,
73 int count, int *eof, void *data)
75 struct obd_device* temp=(struct obd_device*)data;
76 struct mds_obd *mds=&temp->u.mds;
77 struct statfs mystats;
80 rc = vfs_statfs(mds->mds_sb, &mystats);
82 CERROR("mds: statfs failed: rc %d\n", rc);
85 len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_bfree));
90 int rd_kbfree(char* page, char **start, off_t off,
91 int count, int *eof, void *data)
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;
98 rc = vfs_statfs(mds->mds_sb, &mystats);
100 CERROR("mds: statfs failed: rc %d\n", rc);
103 blk_size=mystats.f_bsize;
104 len+=snprintf(page, count, LPU64"\n", \
105 (__u64)((mystats.f_bfree)/(blk_size*1024)));
110 int rd_fstype(char* page, char **start, off_t off,
111 int count, int *eof, void *data)
113 struct obd_device* temp=(struct obd_device*)data;
114 struct mds_obd *mds=&temp->u.mds;
116 len+=snprintf(page, count, "%s\n", mds->mds_fstype);
121 int rd_ffiles(char* page, char **start, off_t off,
122 int count, int *eof, void *data)
124 struct obd_device* temp=(struct obd_device*)data;
125 struct mds_obd *mds=&temp->u.mds;
126 struct statfs mystats;
129 rc = vfs_statfs(mds->mds_sb, &mystats);
131 CERROR("mds: statfs failed: rc %d\n", rc);
135 len+=snprintf(page, count, LPU64"\n", \
136 (__u64)(mystats.f_files));
142 int rd_inodesfree(char* page, char **start, off_t off,
143 int count, int *eof, void *data)
145 struct obd_device* temp=(struct obd_device*)data;
146 struct mds_obd *mds=&temp->u.mds;
147 struct statfs mystats;
150 rc = vfs_statfs(mds->mds_sb, &mystats);
152 CERROR("mds: statfs failed: rc %d\n", rc);
156 len+=snprintf(page, count, LPU64"\n", \
157 (__u64)(mystats.f_ffree));
161 int rd_filesets(char* page, char **start, off_t off,
162 int count, int *eof, void *data)
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},