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 char name[MAX_STRING_SIZE + 1];
110 struct obd_uuid uuid;
114 memset(lvars, 0, sizeof(lvars));
116 name[MAX_STRING_SIZE] = '\0';
117 lvars[0].name = name;
119 LASSERT(sbi != NULL);
120 LASSERT(mdc != NULL);
121 LASSERT(osc != NULL);
124 snprintf(name, MAX_STRING_SIZE, "fs%llu", mnt_instance);
127 sbi->ll_proc_root = lprocfs_register(name, parent, NULL, NULL);
128 if (IS_ERR(sbi->ll_proc_root)) {
129 err = PTR_ERR(sbi->ll_proc_root);
130 sbi->ll_proc_root = NULL;
133 /* Static configuration info */
134 err = lprocfs_add_vars(sbi->ll_proc_root, lprocfs_obd_vars, sb);
139 strncpy(uuid.uuid, mdc, sizeof(uuid.uuid));
140 obd = class_uuid2obd(&uuid);
142 LASSERT(obd != NULL);
143 LASSERT(obd->obd_type != NULL);
144 LASSERT(obd->obd_type->typ_name != NULL);
146 snprintf(name, MAX_STRING_SIZE, "%s/common_name",
147 obd->obd_type->typ_name);
148 lvars[0].read_fptr = lprocfs_rd_name;
149 err = lprocfs_add_vars(sbi->ll_proc_root, lvars, obd);
153 snprintf(name, MAX_STRING_SIZE, "%s/uuid", obd->obd_type->typ_name);
154 lvars[0].read_fptr = lprocfs_rd_uuid;
155 err = lprocfs_add_vars(sbi->ll_proc_root, lvars, obd);
160 strncpy(uuid.uuid, osc, sizeof(uuid.uuid));
161 obd = class_uuid2obd(&uuid);
163 LASSERT(obd != NULL);
164 LASSERT(obd->obd_type != NULL);
165 LASSERT(obd->obd_type->typ_name != NULL);
167 snprintf(name, MAX_STRING_SIZE, "%s/common_name",
168 obd->obd_type->typ_name);
169 lvars[0].read_fptr = lprocfs_rd_name;
170 err = lprocfs_add_vars(sbi->ll_proc_root, lvars, obd);
174 snprintf(name, MAX_STRING_SIZE, "%s/uuid", obd->obd_type->typ_name);
175 lvars[0].read_fptr = lprocfs_rd_uuid;
176 err = lprocfs_add_vars(sbi->ll_proc_root, lvars, obd);
181 #undef MAX_STRING_SIZE