1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2002, 2003 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 #include <linux/seq_file.h>
26 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
27 #include <asm/statfs.h>
29 #include <lprocfs_status.h>
30 #include <obd_class.h>
33 static struct lprocfs_vars lprocfs_module_vars[] = { {0} };
34 static struct lprocfs_vars lprocfs_obd_vars[] = { {0} };
36 static int lmv_rd_numobd(char *page, char **start, off_t off, int count,
39 struct obd_device *dev = (struct obd_device*)data;
40 struct lmv_desc *desc;
43 desc = &dev->u.lmv.desc;
45 return snprintf(page, count, "%u\n", desc->ld_tgt_count);
49 static int lmv_rd_activeobd(char *page, char **start, off_t off, int count,
52 struct obd_device* dev = (struct obd_device*)data;
53 struct lmv_desc *desc;
56 desc = &dev->u.lmv.desc;
58 return snprintf(page, count, "%u\n", desc->ld_active_tgt_count);
61 static int lmv_rd_desc_uuid(char *page, char **start, off_t off, int count,
64 struct obd_device *dev = (struct obd_device*) data;
70 return snprintf(page, count, "%s\n", lmv->desc.ld_uuid.uuid);
73 static void *lmv_tgt_seq_start(struct seq_file *p, loff_t *pos)
75 struct obd_device *dev = p->private;
76 struct lmv_obd *lmv = &dev->u.lmv;
78 return (*pos >= lmv->desc.ld_tgt_count) ? NULL : &(lmv->tgts[*pos]);
82 static void lmv_tgt_seq_stop(struct seq_file *p, void *v)
87 static void *lmv_tgt_seq_next(struct seq_file *p, void *v, loff_t *pos)
89 struct obd_device *dev = p->private;
90 struct lmv_obd *lmv = &dev->u.lmv;
93 return (*pos >=lmv->desc.ld_tgt_count) ? NULL : &(lmv->tgts[*pos]);
96 static int lmv_tgt_seq_show(struct seq_file *p, void *v)
98 struct lmv_tgt_desc *tgt = v;
99 struct obd_device *dev = p->private;
100 struct lmv_obd *lmv = &dev->u.lmv;
101 int idx = tgt - &(lmv->tgts[0]);
103 return seq_printf(p, "%d: %s %sACTIVE\n", idx, tgt->ltd_uuid.uuid,
104 tgt->ltd_active ? "" : "IN");
107 struct seq_operations lmv_tgt_sops = {
108 .start = lmv_tgt_seq_start,
109 .stop = lmv_tgt_seq_stop,
110 .next = lmv_tgt_seq_next,
111 .show = lmv_tgt_seq_show,
114 static int lmv_target_seq_open(struct inode *inode, struct file *file)
116 struct proc_dir_entry *dp = PDE(inode);
117 struct seq_file *seq;
118 int rc = seq_open(file, &lmv_tgt_sops);
123 seq = file->private_data;
124 seq->private = dp->data;
129 struct lprocfs_vars lprocfs_obd_vars[] = {
130 { "numobd", lmv_rd_numobd, 0, 0 },
131 { "activeobd", lmv_rd_activeobd, 0, 0 },
132 { "uuid", lprocfs_rd_uuid, 0, 0 },
133 { "desc_uuid", lmv_rd_desc_uuid, 0, 0 },
137 static struct lprocfs_vars lprocfs_module_vars[] = {
138 { "num_refs", lprocfs_rd_numrefs, 0, 0 },
142 struct file_operations lmv_proc_target_fops = {
143 .owner = THIS_MODULE,
144 .open = lmv_target_seq_open,
147 .release = seq_release,
151 LPROCFS_INIT_VARS(lmv, lprocfs_module_vars, lprocfs_obd_vars)