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 struct lprocfs_vars lprocfs_module_vars[] = { {0} };
34 static struct lprocfs_vars lprocfs_obd_vars[] = { {0} };
37 static int lov_rd_stripesize(char *page, char **start, off_t off, int count,
40 struct obd_device *dev = (struct obd_device *)data;
41 struct lov_desc *desc;
44 desc = &dev->u.lov.desc;
46 return snprintf(page, count, LPU64"\n", desc->ld_default_stripe_size);
49 static int lov_rd_stripeoffset(char *page, char **start, off_t off, int count,
52 struct obd_device *dev = (struct obd_device *)data;
53 struct lov_desc *desc;
56 desc = &dev->u.lov.desc;
58 return snprintf(page, count, LPU64"\n", desc->ld_default_stripe_offset);
61 static int lov_rd_stripetype(char *page, char **start, off_t off, int count,
64 struct obd_device* dev = (struct obd_device*)data;
65 struct lov_desc *desc;
68 desc = &dev->u.lov.desc;
70 return snprintf(page, count, "%u\n", desc->ld_pattern);
73 static int lov_rd_stripecount(char *page, char **start, off_t off, int count,
76 struct obd_device *dev = (struct obd_device *)data;
77 struct lov_desc *desc;
80 desc = &dev->u.lov.desc;
82 return snprintf(page, count, "%u\n", desc->ld_default_stripe_count);
85 static int lov_rd_numobd(char *page, char **start, off_t off, int count,
88 struct obd_device *dev = (struct obd_device*)data;
89 struct lov_desc *desc;
92 desc = &dev->u.lov.desc;
94 return snprintf(page, count, "%u\n", desc->ld_tgt_count);
98 static int lov_rd_activeobd(char *page, char **start, off_t off, int count,
101 struct obd_device* dev = (struct obd_device*)data;
102 struct lov_desc *desc;
104 LASSERT(dev != NULL);
105 desc = &dev->u.lov.desc;
107 return snprintf(page, count, "%u\n", desc->ld_active_tgt_count);
110 static int lov_rd_desc_uuid(char *page, char **start, off_t off, int count,
111 int *eof, void *data)
113 struct obd_device *dev = (struct obd_device*) data;
116 LASSERT(dev != NULL);
119 return snprintf(page, count, "%s\n", lov->desc.ld_uuid.uuid);
122 static void *lov_tgt_seq_start(struct seq_file *p, loff_t *pos)
124 struct obd_device *dev = p->private;
125 struct lov_obd *lov = &dev->u.lov;
127 return (*pos >= lov->desc.ld_tgt_count) ? NULL : &(lov->tgts[*pos]);
131 static void lov_tgt_seq_stop(struct seq_file *p, void *v)
135 static void *lov_tgt_seq_next(struct seq_file *p, void *v, loff_t *pos)
137 struct obd_device *dev = p->private;
138 struct lov_obd *lov = &dev->u.lov;
141 return (*pos >=lov->desc.ld_tgt_count) ? NULL : &(lov->tgts[*pos]);
144 static int lov_tgt_seq_show(struct seq_file *p, void *v)
146 struct lov_tgt_desc *tgt = v;
147 struct obd_device *dev = p->private;
148 struct lov_obd *lov = &dev->u.lov;
149 int idx = tgt - &(lov->tgts[0]);
150 return seq_printf(p, "%d: %s %sACTIVE\n", idx, tgt->uuid.uuid,
151 tgt->active ? "" : "IN");
154 struct seq_operations lov_tgt_sops = {
155 .start = lov_tgt_seq_start,
156 .stop = lov_tgt_seq_stop,
157 .next = lov_tgt_seq_next,
158 .show = lov_tgt_seq_show,
161 static int lov_target_seq_open(struct inode *inode, struct file *file)
163 struct proc_dir_entry *dp = PDE(inode);
164 struct seq_file *seq;
165 int rc = seq_open(file, &lov_tgt_sops);
170 seq = file->private_data;
171 seq->private = dp->data;
176 struct lprocfs_vars lprocfs_obd_vars[] = {
177 { "uuid", lprocfs_rd_uuid, 0, 0 },
178 { "stripesize", lov_rd_stripesize, 0, 0 },
179 { "stripeoffset", lov_rd_stripeoffset, 0, 0 },
180 { "stripecount", lov_rd_stripecount, 0, 0 },
181 { "stripetype", lov_rd_stripetype, 0, 0 },
182 { "numobd", lov_rd_numobd, 0, 0 },
183 { "activeobd", lov_rd_activeobd, 0, 0 },
184 { "filestotal", lprocfs_rd_filestotal, 0, 0 },
185 { "filesfree", lprocfs_rd_filesfree, 0, 0 },
186 //{ "filegroups", lprocfs_rd_filegroups, 0, 0 },
187 { "blocksize", lprocfs_rd_blksize, 0, 0 },
188 { "kbytestotal", lprocfs_rd_kbytestotal, 0, 0 },
189 { "kbytesfree", lprocfs_rd_kbytesfree, 0, 0 },
190 { "kbytesavail", lprocfs_rd_kbytesavail, 0, 0 },
191 { "desc_uuid", lov_rd_desc_uuid, 0, 0 },
195 static struct lprocfs_vars lprocfs_module_vars[] = {
196 { "num_refs", lprocfs_rd_numrefs, 0, 0 },
200 struct file_operations lov_proc_target_fops = {
201 .owner = THIS_MODULE,
202 .open = lov_target_seq_open,
205 .release = seq_release,
209 LPROCFS_INIT_VARS(lov, lprocfs_module_vars, lprocfs_obd_vars)