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 static int lov_rd_stripesize(char *page, char **start, off_t off, int count,
36 struct obd_device *dev = (struct obd_device *)data;
37 struct lov_desc *desc;
40 desc = &dev->u.lov.desc;
42 return snprintf(page, count, LPU64"\n", desc->ld_default_stripe_size);
45 static int lov_rd_stripeoffset(char *page, char **start, off_t off, int count,
48 struct obd_device *dev = (struct obd_device *)data;
49 struct lov_desc *desc;
52 desc = &dev->u.lov.desc;
54 return snprintf(page, count, LPU64"\n", desc->ld_default_stripe_offset);
57 static int lov_rd_stripetype(char *page, char **start, off_t off, int count,
60 struct obd_device* dev = (struct obd_device*)data;
61 struct lov_desc *desc;
64 desc = &dev->u.lov.desc;
66 return snprintf(page, count, "%u\n", desc->ld_pattern);
69 static int lov_rd_stripecount(char *page, char **start, off_t off, int count,
72 struct obd_device *dev = (struct obd_device *)data;
73 struct lov_desc *desc;
76 desc = &dev->u.lov.desc;
78 return snprintf(page, count, "%u\n", desc->ld_default_stripe_count);
81 static int lov_rd_numobd(char *page, char **start, off_t off, int count,
84 struct obd_device *dev = (struct obd_device*)data;
85 struct lov_desc *desc;
88 desc = &dev->u.lov.desc;
90 return snprintf(page, count, "%u\n", desc->ld_tgt_count);
94 static int lov_rd_activeobd(char *page, char **start, off_t off, int count,
97 struct obd_device* dev = (struct obd_device*)data;
98 struct lov_desc *desc;
100 LASSERT(dev != NULL);
101 desc = &dev->u.lov.desc;
103 return snprintf(page, count, "%u\n", desc->ld_active_tgt_count);
106 static int lov_rd_desc_uuid(char *page, char **start, off_t off, int count,
107 int *eof, void *data)
109 struct obd_device *dev = (struct obd_device*) data;
112 LASSERT(dev != NULL);
115 return snprintf(page, count, "%s\n", lov->desc.ld_uuid.uuid);
118 static void *lov_tgt_seq_start(struct seq_file *p, loff_t *pos)
120 struct obd_device *dev = p->private;
121 struct lov_obd *lov = &dev->u.lov;
123 return (*pos >= lov->desc.ld_tgt_count) ? NULL : &(lov->tgts[*pos]);
127 static void lov_tgt_seq_stop(struct seq_file *p, void *v)
131 static void *lov_tgt_seq_next(struct seq_file *p, void *v, loff_t *pos)
133 struct obd_device *dev = p->private;
134 struct lov_obd *lov = &dev->u.lov;
137 return (*pos >=lov->desc.ld_tgt_count) ? NULL : &(lov->tgts[*pos]);
140 static int lov_tgt_seq_show(struct seq_file *p, void *v)
142 struct lov_tgt_desc *tgt = v;
143 struct obd_device *dev = p->private;
144 struct lov_obd *lov = &dev->u.lov;
145 int idx = tgt - &(lov->tgts[0]);
146 return seq_printf(p, "%d: %s %sACTIVE\n", idx, tgt->uuid.uuid,
147 tgt->active ? "" : "IN");
150 struct seq_operations lov_tgt_sops = {
151 .start = lov_tgt_seq_start,
152 .stop = lov_tgt_seq_stop,
153 .next = lov_tgt_seq_next,
154 .show = lov_tgt_seq_show,
157 static int lov_target_seq_open(struct inode *inode, struct file *file)
159 struct proc_dir_entry *dp = PDE(inode);
160 struct seq_file *seq;
161 int rc = seq_open(file, &lov_tgt_sops);
166 seq = file->private_data;
167 seq->private = dp->data;
172 struct lprocfs_vars lprocfs_obd_vars[] = {
173 { "uuid", lprocfs_rd_uuid, 0, 0 },
174 { "stripesize", lov_rd_stripesize, 0, 0 },
175 { "stripeoffset", lov_rd_stripeoffset, 0, 0 },
176 { "stripecount", lov_rd_stripecount, 0, 0 },
177 { "stripetype", lov_rd_stripetype, 0, 0 },
178 { "numobd", lov_rd_numobd, 0, 0 },
179 { "activeobd", lov_rd_activeobd, 0, 0 },
180 { "filestotal", lprocfs_rd_filestotal, 0, 0 },
181 { "filesfree", lprocfs_rd_filesfree, 0, 0 },
182 //{ "filegroups", lprocfs_rd_filegroups, 0, 0 },
183 { "blocksize", lprocfs_rd_blksize, 0, 0 },
184 { "kbytestotal", lprocfs_rd_kbytestotal, 0, 0 },
185 { "kbytesfree", lprocfs_rd_kbytesfree, 0, 0 },
186 { "kbytesavail", lprocfs_rd_kbytesavail, 0, 0 },
187 { "desc_uuid", lov_rd_desc_uuid, 0, 0 },
191 static struct lprocfs_vars lprocfs_module_vars[] = {
192 { "num_refs", lprocfs_rd_numrefs, 0, 0 },
196 struct file_operations lov_proc_target_fops = {
197 .owner = THIS_MODULE,
198 .open = lov_target_seq_open,
201 .release = seq_release,
204 LPROCFS_INIT_VARS(lov, lprocfs_module_vars, lprocfs_obd_vars)