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>
27 /* /proc/lustre/llite mount point registration */
30 int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
31 struct super_block *sb, char *osc, char *mdc)
37 long long mnt_instance;
39 static inline int lprocfs_llite_statfs(void *data, struct statfs *sfs)
41 struct super_block *sb = (struct super_block*)data;
42 return (sb->s_op->statfs)(sb, sfs);
45 DEFINE_LPROCFS_STATFS_FCT(rd_blksize, lprocfs_llite_statfs);
46 DEFINE_LPROCFS_STATFS_FCT(rd_kbytestotal, lprocfs_llite_statfs);
47 DEFINE_LPROCFS_STATFS_FCT(rd_kbytesfree, lprocfs_llite_statfs);
48 DEFINE_LPROCFS_STATFS_FCT(rd_filestotal, lprocfs_llite_statfs);
49 DEFINE_LPROCFS_STATFS_FCT(rd_filesfree, lprocfs_llite_statfs);
50 DEFINE_LPROCFS_STATFS_FCT(rd_filegroups, lprocfs_llite_statfs);
52 int rd_path(char *page, char **start, off_t off, int count, int *eof,
58 int rd_fstype(char *page, char **start, off_t off, int count, int *eof,
61 struct super_block *sb = (struct super_block*)data;
64 return snprintf(page, count, "%s\n", sb->s_type->name);
67 int rd_sb_uuid(char *page, char **start, off_t off, int count, int *eof,
70 struct super_block *sb = (struct super_block *)data;
73 return snprintf(page, count, "%s\n", ll_s2sbi(sb)->ll_sb_uuid.uuid);
76 struct lprocfs_vars lprocfs_obd_vars[] = {
77 { "uuid", rd_sb_uuid, 0, 0 },
78 { "mntpt_path", rd_path, 0, 0 },
79 { "fstype", rd_fstype, 0, 0 },
80 { "blocksize", rd_blksize, 0, 0 },
81 { "kbytestotal", rd_kbytestotal, 0, 0 },
82 { "kbytesfree", rd_kbytesfree, 0, 0 },
83 { "filestotal", rd_filestotal, 0, 0 },
84 { "filesfree", rd_filesfree, 0, 0 },
85 { "filegroups", rd_filegroups, 0, 0 },
89 #define MAX_STRING_SIZE 128
90 int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
91 struct super_block *sb, char *osc, char *mdc)
93 struct lprocfs_vars lvars[2];
94 struct ll_sb_info *sbi = ll_s2sbi(sb);
95 struct obd_device *obd;
96 char name[MAX_STRING_SIZE + 1];
101 memset(lvars, 0, sizeof(lvars));
103 name[MAX_STRING_SIZE] = '\0';
104 lvars[0].name = name;
107 snprintf(name, MAX_STRING_SIZE, "fs%llu", mnt_instance);
110 sbi->ll_proc_root = lprocfs_register(name, parent, NULL, NULL);
111 if (IS_ERR(sbi->ll_proc_root))
112 RETURN(err = PTR_ERR(sbi->ll_proc_root));
114 /* Static configuration info */
115 err = lprocfs_add_vars(sbi->ll_proc_root, lprocfs_obd_vars, sb);
120 strncpy(uuid.uuid, mdc, sizeof(uuid.uuid));
121 obd = class_uuid2obd(&uuid);
122 snprintf(name, MAX_STRING_SIZE, "%s/common_name",
123 obd->obd_type->typ_name);
124 lvars[0].read_fptr = lprocfs_rd_name;
125 err = lprocfs_add_vars(sbi->ll_proc_root, lvars, obd);
129 snprintf(name, MAX_STRING_SIZE, "%s/uuid", obd->obd_type->typ_name);
130 lvars[0].read_fptr = lprocfs_rd_uuid;
131 err = lprocfs_add_vars(sbi->ll_proc_root, lvars, obd);
136 strncpy(uuid.uuid, osc, sizeof(uuid.uuid));
137 obd = class_uuid2obd(&uuid);
139 snprintf(name, MAX_STRING_SIZE, "%s/common_name",
140 obd->obd_type->typ_name);
141 lvars[0].read_fptr = lprocfs_rd_name;
142 err = lprocfs_add_vars(sbi->ll_proc_root, lvars, obd);
146 snprintf(name, MAX_STRING_SIZE, "%s/uuid", obd->obd_type->typ_name);
147 lvars[0].read_fptr = lprocfs_rd_uuid;
148 err = lprocfs_add_vars(sbi->ll_proc_root, lvars, obd);
153 #undef MAX_STRING_SIZE