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_CLASS
24 #include <linux/version.h>
25 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
26 #include <asm/statfs.h>
28 #include <linux/lprocfs_status.h>
29 #include <linux/obd_class.h>
30 #include <linux/seq_file.h>
33 struct lprocfs_vars lprocfs_module_vars[] = { {0} };
34 struct lprocfs_vars lprocfs_obd_vars[] = { {0} };
37 DEFINE_LPROCFS_STATFS_FCT(rd_blksize, obd_self_statfs);
38 DEFINE_LPROCFS_STATFS_FCT(rd_kbytestotal, obd_self_statfs);
39 DEFINE_LPROCFS_STATFS_FCT(rd_kbytesfree, obd_self_statfs);
40 DEFINE_LPROCFS_STATFS_FCT(rd_filestotal, obd_self_statfs);
41 DEFINE_LPROCFS_STATFS_FCT(rd_filesfree, obd_self_statfs);
42 DEFINE_LPROCFS_STATFS_FCT(rd_filegroups, obd_self_statfs);
44 int rd_stripesize(char *page, char **start, off_t off, int count, int *eof,
47 struct obd_device *dev = (struct obd_device *)data;
48 struct lov_desc *desc;
51 desc = &dev->u.lov.desc;
53 return snprintf(page, count, LPU64"\n", desc->ld_default_stripe_size);
56 int rd_stripeoffset(char *page, char **start, off_t off, int count, int *eof,
59 struct obd_device *dev = (struct obd_device *)data;
60 struct lov_desc *desc;
63 desc = &dev->u.lov.desc;
65 return snprintf(page, count, LPU64"\n", desc->ld_default_stripe_offset);
68 int rd_stripetype(char *page, char **start, off_t off, int count, int *eof,
71 struct obd_device* dev = (struct obd_device*)data;
72 struct lov_desc *desc;
75 desc = &dev->u.lov.desc;
77 return snprintf(page, count, "%u\n", desc->ld_pattern);
80 int rd_stripecount(char *page, char **start, off_t off, int count, int *eof,
83 struct obd_device *dev = (struct obd_device *)data;
84 struct lov_desc *desc;
87 desc = &dev->u.lov.desc;
89 return snprintf(page, count, "%u\n", desc->ld_default_stripe_count);
92 int rd_numobd(char *page, char **start, off_t off, int count, int *eof,
95 struct obd_device *dev = (struct obd_device*)data;
96 struct lov_desc *desc;
99 desc = &dev->u.lov.desc;
101 return snprintf(page, count, "%u\n", desc->ld_tgt_count);
105 int rd_activeobd(char *page, char **start, off_t off, int count, int *eof,
108 struct obd_device* dev = (struct obd_device*)data;
109 struct lov_desc *desc;
111 LASSERT(dev != NULL);
112 desc = &dev->u.lov.desc;
114 return snprintf(page, count, "%u\n", desc->ld_active_tgt_count);
117 int rd_mdc(char *page, char **start, off_t off, int count, int *eof, void *data)
119 struct obd_device *dev = (struct obd_device*) data;
122 LASSERT(dev != NULL);
125 return snprintf(page, count, "%s\n", lov->mdcobd->obd_uuid.uuid);
128 static void *ll_tgt_seq_start(struct seq_file *p, loff_t *pos)
130 struct obd_device *dev = p->private;
131 struct lov_obd *lov = &dev->u.lov;
133 return (*pos >= lov->desc.ld_tgt_count) ? NULL : &(lov->tgts[*pos]);
136 static void ll_tgt_seq_stop(struct seq_file *p, void *v)
141 static void *ll_tgt_seq_next(struct seq_file *p, void *v, loff_t *pos)
143 struct obd_device *dev = p->private;
144 struct lov_obd *lov = &dev->u.lov;
147 return (*pos >=lov->desc.ld_tgt_count) ? NULL : &(lov->tgts[*pos]);
150 static int ll_tgt_seq_show(struct seq_file *p, void *v)
152 struct lov_tgt_desc *tgt = v;
153 struct obd_device *dev = p->private;
154 struct lov_obd *lov = &dev->u.lov;
155 int idx = tgt - &(lov->tgts[0]);
156 return seq_printf(p, "%d: %s %sACTIVE\n", idx+1, tgt->uuid.uuid,
157 tgt->active ? "" : "IN");
160 struct seq_operations ll_tgt_sops = {
161 .start = ll_tgt_seq_start,
162 .stop = ll_tgt_seq_stop,
163 .next = ll_tgt_seq_next,
164 .show = ll_tgt_seq_show,
167 static int ll_target_seq_open(struct inode *inode, struct file *file)
169 struct proc_dir_entry *dp = inode->u.generic_ip;
170 struct seq_file *seq;
171 int rc = seq_open(file, &ll_tgt_sops);
176 seq = file->private_data;
177 seq->private = dp->data;
181 struct lprocfs_vars lprocfs_obd_vars[] = {
182 { "uuid", lprocfs_rd_uuid, 0, 0 },
183 { "stripesize", rd_stripesize, 0, 0 },
184 { "stripeoffset", rd_stripeoffset, 0, 0 },
185 { "stripecount", rd_stripecount, 0, 0 },
186 { "stripetype", rd_stripetype, 0, 0 },
187 { "numobd", rd_numobd, 0, 0 },
188 { "activeobd", rd_activeobd, 0, 0 },
189 { "filestotal", rd_filestotal, 0, 0 },
190 { "filesfree", rd_filesfree, 0, 0 },
191 { "filegroups", rd_filegroups, 0, 0 },
192 { "blocksize", rd_blksize, 0, 0 },
193 { "kbytestotal", rd_kbytestotal, 0, 0 },
194 { "kbytesfree", rd_kbytesfree, 0, 0 },
195 { "target_mdc", rd_mdc, 0, 0 },
199 struct lprocfs_vars lprocfs_module_vars[] = {
200 { "num_refs", lprocfs_rd_numrefs, 0, 0 },
204 struct file_operations ll_proc_target_fops = {
205 .open = ll_target_seq_open,
208 .release = seq_release,
212 LPROCFS_INIT_VARS(lprocfs_module_vars, lprocfs_obd_vars)