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_LLITE
24 #include <linux/lustre_lite.h>
25 #include <linux/lprocfs_status.h>
28 int rd_path(char* page, char **start, off_t off, int count, int *eof,
34 int rd_fstype(char* page, char **start, off_t off, int count, int *eof,
38 struct super_block *sb = (struct super_block*)data;
40 len += snprintf(page, count, "%s\n", sb->s_type->name);
44 int rd_blksize(char* page, char **start, off_t off, int count, int *eof,
48 struct super_block *sb = (struct super_block*)data;
49 struct statfs mystats;
51 (sb->s_op->statfs)(sb, &mystats);
52 len += snprintf(page, count, "%lu\n", mystats.f_bsize);
57 int rd_kbytestotal(char* page, char **start, off_t off, int count, int *eof,
61 struct super_block *sb = (struct super_block*)data;
62 struct statfs mystats;
66 (sb->s_op->statfs)(sb, &mystats);
67 blk_size = mystats.f_bsize;
69 result = mystats.f_blocks;
74 len += snprintf(page, count, LPU64"\n", result);
79 int rd_kbytesfree(char* page, char **start, off_t off, int count, int *eof,
83 struct super_block *sb = (struct super_block*)data;
84 struct statfs mystats;
88 (sb->s_op->statfs)(sb, &mystats);
89 blk_size = mystats.f_bsize;
91 result = mystats.f_bfree;
96 len += snprintf(page, count, LPU64"\n", result);
100 int rd_filestotal(char* page, char **start, off_t off, int count, int *eof,
104 struct super_block *sb = (struct super_block*)data;
105 struct statfs mystats;
107 (sb->s_op->statfs)(sb, &mystats);
108 len += snprintf(page, count, LPU64"\n", (__u64)(mystats.f_files));
112 int rd_filesfree(char* page, char **start, off_t off, int count, int *eof,
116 struct super_block *sb = (struct super_block*)data;
117 struct statfs mystats;
119 (sb->s_op->statfs)(sb, &mystats);
120 len += snprintf(page, count, LPU64"\n", (__u64)(mystats.f_ffree));
124 int rd_filegroups(char* page, char **start, off_t off, int count, int *eof,
129 int rd_uuid(char* page, char **start, off_t off, int count, int *eof,
133 struct super_block *sb = (struct super_block*)data;
134 struct ll_sb_info *sbi = ll_s2sbi(sb);
136 len += snprintf(page, count, "%s\n", sbi->ll_sb_uuid);
141 int rd_dev_name(char* page, char **start, off_t off, int count, int *eof,
145 struct obd_device* dev = (struct obd_device*)data;
146 len += snprintf(page, count, "%s\n", dev->obd_name);
150 int rd_dev_uuid(char* page, char **start, off_t off, int count, int *eof,
154 struct obd_device* dev = (struct obd_device*)data;
155 len += snprintf(page, count, "%s\n", dev->obd_uuid);
160 struct lprocfs_vars status_var_nm_1[] = {
161 {"status/uuid", rd_uuid, 0, 0},
162 {"status/mntpt_path", rd_path, 0, 0},
163 {"status/fstype", rd_fstype, 0, 0},
164 {"status/blocksize",rd_blksize, 0, 0},
165 {"status/kbytestotal",rd_kbytestotal, 0, 0},
166 {"status/kbytesfree", rd_kbytesfree, 0, 0},
167 {"status/filestotal", rd_filestotal, 0, 0},
168 {"status/filesfree", rd_filesfree, 0, 0},
169 {"status/filegroups", rd_filegroups, 0, 0},
174 * Proc registration function for Lustre
179 #define MAX_STRING_SIZE 100
180 void ll_proc_namespace(struct super_block* sb, char* osc, char* mdc)
182 char mnt_name[MAX_STRING_SIZE+1];
183 char uuid_name[MAX_STRING_SIZE+1];
184 struct lprocfs_vars d_vars[3];
185 struct ll_sb_info *sbi = ll_s2sbi(sb);
186 struct obd_device* obd;
189 /* Register this mount instance with LProcFS */
190 snprintf(mnt_name, MAX_STRING_SIZE, "mount_%s", sbi->ll_sb_uuid);
191 mnt_name[MAX_STRING_SIZE] = '\0';
192 sbi->ll_proc_root = lprocfs_reg_mnt(mnt_name);
193 if (sbi->ll_proc_root == NULL) {
194 CDEBUG(D_OTHER, "Could not register FS");
197 /* Add the static configuration info */
198 err = lprocfs_add_vars(sbi->ll_proc_root,status_var_nm_1, sb);
200 CDEBUG(D_OTHER, "Unable to add procfs variables\n");
204 obd = class_uuid2obd(mdc);
205 snprintf(mnt_name, MAX_STRING_SIZE, "status/%s/common_name",
206 obd->obd_type->typ_name);
207 mnt_name[MAX_STRING_SIZE] = '\0';
208 memset(d_vars, 0, sizeof(d_vars));
209 d_vars[0].read_fptr = rd_dev_name;
210 d_vars[0].write_fptr = NULL;
211 d_vars[0].name = mnt_name;
212 snprintf(uuid_name, MAX_STRING_SIZE, "status/%s/uuid",
213 obd->obd_type->typ_name);
214 uuid_name[MAX_STRING_SIZE] = '\0';
215 d_vars[1].read_fptr = rd_dev_uuid;
216 d_vars[1].write_fptr = NULL;
217 d_vars[1].name = uuid_name;
219 err = lprocfs_add_vars(sbi->ll_proc_root, d_vars, obd);
221 CDEBUG(D_OTHER, "Unable to add fs proc dynamic variables\n");
225 obd = class_uuid2obd(osc);
228 snprintf(mnt_name, MAX_STRING_SIZE,
229 "status/%s/common_name", obd->obd_type->typ_name);
230 mnt_name[MAX_STRING_SIZE] = '\0';
231 memset(d_vars, 0, sizeof(d_vars));
232 d_vars[0].read_fptr = rd_dev_name;
233 d_vars[0].write_fptr = NULL;
234 d_vars[0].name = mnt_name;
236 snprintf(uuid_name, MAX_STRING_SIZE, "status/%s/uuid",
237 obd->obd_type->typ_name);
238 uuid_name[MAX_STRING_SIZE] = '\0';
239 d_vars[1].read_fptr = rd_dev_uuid;
240 d_vars[1].write_fptr = NULL;
241 d_vars[1].name = uuid_name;
243 err = lprocfs_add_vars(sbi->ll_proc_root, d_vars, obd);
245 CDEBUG(D_OTHER, "Unable to add fs proc dynamic variables\n");
249 #undef MAX_STRING_SIZE