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,
33 int rd_fstype(char* page, char **start, off_t off, int count, int *eof,
37 struct super_block *sb = (struct super_block*)data;
39 len += snprintf(page, count, "%s\n", sb->s_type->name);
42 int rd_blksize(char* page, char **start, off_t off, int count, int *eof,
46 struct super_block *sb = (struct super_block*)data;
47 struct statfs mystats;
49 (sb->s_op->statfs)(sb, &mystats);
50 len += snprintf(page, count, LPU64"\n", (__u64)(mystats.f_bsize));
54 int rd_kbytestotal(char* page, char **start, off_t off, int count, int *eof,
58 struct super_block *sb = (struct super_block*)data;
59 struct statfs mystats;
63 (sb->s_op->statfs)(sb, &mystats);
64 blk_size = mystats.f_bsize;
66 result = mystats.f_blocks;
68 while(blk_size >>= 1){
72 len += snprintf(page, count, LPU64"\n", result);
78 int rd_kbytesfree(char* page, char **start, off_t off, int count, int *eof,
82 struct super_block *sb = (struct super_block*)data;
83 struct statfs mystats;
87 (sb->s_op->statfs)(sb, &mystats);
88 blk_size = mystats.f_bsize;
90 result = mystats.f_bfree;
92 while(blk_size >>= 1){
96 len += snprintf(page, count, LPU64"\n", result);
102 int rd_filestotal(char* page, char **start, off_t off, int count, int *eof,
107 struct super_block *sb = (struct super_block*)data;
108 struct statfs mystats;
110 (sb->s_op->statfs)(sb, &mystats);
111 len += snprintf(page, count, LPU64"\n", (__u64)(mystats.f_files));
115 int rd_filesfree(char* page, char **start, off_t off, int count, int *eof,
120 struct super_block *sb = (struct super_block*)data;
121 struct statfs mystats;
123 (sb->s_op->statfs)(sb, &mystats);
124 len += snprintf(page, count, LPU64"\n", (__u64)(mystats.f_ffree));
128 int rd_filegroups(char* page, char **start, off_t off, int count, int *eof,
133 int rd_uuid(char* page, char **start, off_t off, int count, int *eof,
137 struct super_block *sb = (struct super_block*)data;
138 struct ll_sb_info *sbi = ll_s2sbi(sb);
139 len += snprintf(page, count, "%s\n", sbi->ll_sb_uuid);
143 int rd_dev_name(char* page, char **start, off_t off, int count, int *eof,
147 struct obd_device* dev = (struct obd_device*)data;
148 len += snprintf(page, count, "%s\n", dev->obd_name);
152 int rd_dev_uuid(char* page, char **start, off_t off, int count, int *eof,
156 struct obd_device* dev = (struct obd_device*)data;
157 len += snprintf(page, count, "%s\n", dev->obd_uuid);
162 struct lprocfs_vars status_var_nm_1[] = {
163 {"status/uuid", rd_uuid, 0, 0},
164 {"status/mntpt_path", rd_path, 0, 0},
165 {"status/fs_type", rd_fstype, 0, 0},
166 {"status/blocksize",rd_blksize, 0, 0},
167 {"status/kbytestotal",rd_kbytestotal, 0, 0},
168 {"status/kbytesfree", rd_kbytesfree, 0, 0},
169 {"status/filestotal", rd_filestotal, 0, 0},
170 {"status/filesfree", rd_filesfree, 0, 0},
171 {"status/filegroups", rd_filegroups, 0, 0},
176 * Proc registration function for Lustre
181 #define MAX_STRING_SIZE 100
182 void ll_proc_namespace(struct super_block* sb, char* osc, char* mdc)
184 char mnt_name[MAX_STRING_SIZE];
185 char uuid_name[MAX_STRING_SIZE];
186 struct lprocfs_vars d_vars[3];
187 struct ll_sb_info *sbi = ll_s2sbi(sb);
188 struct obd_device* obd;
192 /* Register this mount instance with LProcFS */
193 snprintf(mnt_name, 100, "mount_%s", sbi->ll_sb_uuid);
194 sbi->ll_proc_root = lprocfs_reg_mnt(mnt_name);
195 if (!sbi->ll_proc_root)
196 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");
203 obd = class_uuid2obd(mdc);
206 snprintf(mnt_name, MAX_STRING_SIZE, "status/%s/common_name",
207 obd->obd_type->typ_name);
209 memset(d_vars, 0, sizeof(d_vars));
210 d_vars[0].read_fptr = rd_dev_name;
211 d_vars[0].write_fptr = NULL;
212 d_vars[0].name = mnt_name;
214 snprintf(uuid_name, MAX_STRING_SIZE, "status/%s/uuid",
215 obd->obd_type->typ_name);
216 d_vars[1].read_fptr = rd_dev_uuid;
217 d_vars[1].write_fptr = NULL;
218 d_vars[1].name = uuid_name;
220 err = lprocfs_add_vars(sbi->ll_proc_root, d_vars, obd);
222 CDEBUG(D_OTHER, "Unable to add fs proc dynamic variables\n");
225 obd = class_uuid2obd(osc);
228 snprintf(mnt_name, MAX_STRING_SIZE, "status/%s/common_name",
229 obd->obd_type->typ_name);
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 d_vars[1].read_fptr = rd_dev_uuid;
239 d_vars[1].write_fptr = NULL;
240 d_vars[1].name = uuid_name;
242 err = lprocfs_add_vars(sbi->ll_proc_root, d_vars, obd);
244 CDEBUG(D_OTHER, "Unable to add fs proc dynamic variables\n");
247 #undef MAX_STRING_SIZE