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/version.h>
25 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
26 #include <asm/statfs.h>
28 #include <linux/lustre_lite.h>
29 #include <linux/lprocfs_status.h>
31 /* /proc/lustre/llite mount point registration */
34 int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
35 struct super_block *sb, char *osc, char *mdc)
41 #define LPROC_LLITE_STAT_FCT(fct_name, get_statfs_fct) \
42 int fct_name(char *page, char **start, off_t off, \
43 int count, int *eof, void *data) \
47 LASSERT(data != NULL); \
48 rc = get_statfs_fct((struct super_block*)data, &sfs); \
50 ? lprocfs_##fct_name (page, start, off, count, eof, &sfs) \
54 long long mnt_instance;
56 LPROC_LLITE_STAT_FCT(rd_blksize, vfs_statfs);
57 LPROC_LLITE_STAT_FCT(rd_kbytestotal, vfs_statfs);
58 LPROC_LLITE_STAT_FCT(rd_kbytesfree, vfs_statfs);
59 LPROC_LLITE_STAT_FCT(rd_filestotal, vfs_statfs);
60 LPROC_LLITE_STAT_FCT(rd_filesfree, vfs_statfs);
61 LPROC_LLITE_STAT_FCT(rd_filegroups, vfs_statfs);
63 int rd_path(char *page, char **start, off_t off, int count, int *eof,
69 int rd_fstype(char *page, char **start, off_t off, int count, int *eof,
72 struct super_block *sb = (struct super_block*)data;
76 return snprintf(page, count, "%s\n", sb->s_type->name);
79 int rd_sb_uuid(char *page, char **start, off_t off, int count, int *eof,
82 struct super_block *sb = (struct super_block *)data;
86 return snprintf(page, count, "%s\n", ll_s2sbi(sb)->ll_sb_uuid.uuid);
89 struct lprocfs_vars lprocfs_obd_vars[] = {
90 { "uuid", rd_sb_uuid, 0, 0 },
91 { "mntpt_path", rd_path, 0, 0 },
92 { "fstype", rd_fstype, 0, 0 },
93 { "blocksize", rd_blksize, 0, 0 },
94 { "kbytestotal", rd_kbytestotal, 0, 0 },
95 { "kbytesfree", rd_kbytesfree, 0, 0 },
96 { "filestotal", rd_filestotal, 0, 0 },
97 { "filesfree", rd_filesfree, 0, 0 },
98 { "filegroups", rd_filegroups, 0, 0 },
102 #define MAX_STRING_SIZE 128
103 int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
104 struct super_block *sb, char *osc, char *mdc)
106 struct lprocfs_vars lvars[2];
107 struct ll_sb_info *sbi = ll_s2sbi(sb);
108 struct obd_device *obd;
109 struct proc_dir_entry *entry;
110 char name[MAX_STRING_SIZE + 1];
111 struct obd_uuid uuid;
115 memset(lvars, 0, sizeof(lvars));
117 name[MAX_STRING_SIZE] = '\0';
118 lvars[0].name = name;
120 LASSERT(sbi != NULL);
121 LASSERT(mdc != NULL);
122 LASSERT(osc != NULL);
125 snprintf(name, MAX_STRING_SIZE, "fs%llu", mnt_instance);
128 sbi->ll_proc_root = lprocfs_register(name, parent, NULL, NULL);
129 if (IS_ERR(sbi->ll_proc_root)) {
130 err = PTR_ERR(sbi->ll_proc_root);
131 sbi->ll_proc_root = NULL;
134 /* Static configuration info */
135 err = lprocfs_add_vars(sbi->ll_proc_root, lprocfs_obd_vars, sb);
139 /* llite page cache stats */
140 entry = create_proc_entry("pgcache", 0444, sbi->ll_proc_root);
143 entry->proc_fops = &ll_pgcache_seq_fops;
147 strncpy(uuid.uuid, mdc, sizeof(uuid.uuid));
148 obd = class_uuid2obd(&uuid);
150 LASSERT(obd != NULL);
151 LASSERT(obd->obd_type != NULL);
152 LASSERT(obd->obd_type->typ_name != NULL);
154 snprintf(name, MAX_STRING_SIZE, "%s/common_name",
155 obd->obd_type->typ_name);
156 lvars[0].read_fptr = lprocfs_rd_name;
157 err = lprocfs_add_vars(sbi->ll_proc_root, lvars, obd);
161 snprintf(name, MAX_STRING_SIZE, "%s/uuid", obd->obd_type->typ_name);
162 lvars[0].read_fptr = lprocfs_rd_uuid;
163 err = lprocfs_add_vars(sbi->ll_proc_root, lvars, obd);
168 strncpy(uuid.uuid, osc, sizeof(uuid.uuid));
169 obd = class_uuid2obd(&uuid);
171 LASSERT(obd != NULL);
172 LASSERT(obd->obd_type != NULL);
173 LASSERT(obd->obd_type->typ_name != NULL);
175 snprintf(name, MAX_STRING_SIZE, "%s/common_name",
176 obd->obd_type->typ_name);
177 lvars[0].read_fptr = lprocfs_rd_name;
178 err = lprocfs_add_vars(sbi->ll_proc_root, lvars, obd);
182 snprintf(name, MAX_STRING_SIZE, "%s/uuid", obd->obd_type->typ_name);
183 lvars[0].read_fptr = lprocfs_rd_uuid;
184 err = lprocfs_add_vars(sbi->ll_proc_root, lvars, obd);
189 #undef MAX_STRING_SIZE