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_OST
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 /* Required for 64 bit division */
30 #include <asm/div64.h>
32 int rd_uuid(char* page, char **start, off_t off,
33 int count, int *eof, void *data)
36 struct obd_device* temp=(struct obd_device*)data;
38 len+=snprintf(page, count, "%s\n", temp->obd_uuid);
43 int rd_blksize(char* page, char **start, off_t off,
44 int count, int *eof, void *data)
47 struct obd_device* temp=(struct obd_device*)data;
48 struct ost_obd *ost=&temp->u.ost;
49 struct lustre_handle *conn=&ost->ost_conn;
50 struct obd_statfs mystats;
53 rc = obd_statfs(conn, &mystats);
55 CERROR("ost: statfs failed: rc %d\n", rc);
58 len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.os_bsize));
62 int rd_blktotal(char* page, char **start, off_t off,
63 int count, int *eof, void *data)
66 struct obd_device* temp=(struct obd_device*)data;
67 struct ost_obd *ost=&temp->u.ost;
68 struct lustre_handle *conn=&ost->ost_conn;
69 struct obd_statfs mystats;
72 rc = obd_statfs(conn, &mystats);
74 CERROR("ost: statfs failed: rc %d\n", rc);
77 len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.os_blocks));
82 int rd_blkfree(char* page, char **start, off_t off,
83 int count, int *eof, void *data)
86 struct obd_device* temp=(struct obd_device*)data;
87 struct ost_obd *ost=&temp->u.ost;
88 struct lustre_handle *conn=&ost->ost_conn;
89 struct obd_statfs mystats;
92 rc = obd_statfs(conn, &mystats);
94 CERROR("ost: statfs failed: rc %d\n", rc);
97 len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.os_bfree));
102 int rd_kbfree(char* page, char **start, off_t off,
103 int count, int *eof, void *data)
106 struct obd_device* temp=(struct obd_device*)data;
107 struct ost_obd *ost=&temp->u.ost;
108 struct lustre_handle *conn=&ost->ost_conn;
109 struct obd_statfs mystats;
115 rc = obd_statfs(conn, &mystats);
117 CERROR("ost: statfs failed: rc %d\n", rc);
120 blk_size=mystats.os_bsize;
122 result=mystats.os_bfree;
123 remainder=do_div(result, blk_size);
125 len+=snprintf(page, count, LPU64"\n", \
133 int rd_numobjects(char* page, char **start, off_t off,
134 int count, int *eof, void *data)
137 struct obd_device* temp=(struct obd_device*)data;
138 struct ost_obd *ost=&temp->u.ost;
139 struct lustre_handle *conn=&ost->ost_conn;
140 struct obd_statfs mystats;
143 rc = obd_statfs(conn, &mystats);
145 CERROR("ost: statfs failed: rc %d\n", rc);
148 len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.os_files));
153 int rd_objfree(char* page, char **start, off_t off,
154 int count, int *eof, void *data)
157 struct obd_device* temp=(struct obd_device*)data;
158 struct ost_obd *ost=&temp->u.ost;
159 struct lustre_handle *conn=&ost->ost_conn;
160 struct obd_statfs mystats;
163 rc = obd_statfs(conn, &mystats);
165 CERROR("ost: statfs failed: rc %d\n", rc);
168 len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.os_ffree));
173 int rd_objgroups(char* page, char **start, off_t off,
174 int count, int *eof, void *data)
179 lprocfs_vars_t snmp_var_nm_1[]={
180 {"snmp/uuid", rd_uuid, 0},
181 {"snmp/f_blocksize",rd_blksize, 0},
182 {"snmp/f_blockstotal",rd_blktotal, 0},
183 {"snmp/f_blocksfree",rd_blkfree, 0},
184 {"snmp/f_kbytesfree", rd_kbfree, 0},
185 {"snmp/f_objects", rd_numobjects, 0},
186 {"snmp/f_objectsfree", rd_objfree, 0},
187 {"snmp/f_objectgroups", rd_objgroups, 0},