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 #include <asm/statfs.h>
27 #include <lprocfs_status.h>
28 #include <obd_class.h>
31 static struct lprocfs_vars lprocfs_module_vars[] = { {0} };
32 static struct lprocfs_vars lprocfs_obd_vars[] = { {0} };
34 static int lmv_rd_numobd(char *page, char **start, off_t off, int count,
37 struct obd_device *dev = (struct obd_device*)data;
38 struct lmv_desc *desc;
41 desc = &dev->u.lmv.desc;
43 return snprintf(page, count, "%u\n", desc->ld_tgt_count);
47 static int lmv_rd_activeobd(char *page, char **start, off_t off, int count,
50 struct obd_device* dev = (struct obd_device*)data;
51 struct lmv_desc *desc;
54 desc = &dev->u.lmv.desc;
56 return snprintf(page, count, "%u\n", desc->ld_active_tgt_count);
59 static int lmv_rd_desc_uuid(char *page, char **start, off_t off, int count,
62 struct obd_device *dev = (struct obd_device*) data;
68 return snprintf(page, count, "%s\n", lmv->desc.ld_uuid.uuid);
71 static void *lmv_tgt_seq_start(struct seq_file *p, loff_t *pos)
73 struct obd_device *dev = p->private;
74 struct lmv_obd *lmv = &dev->u.lmv;
76 return (*pos >= lmv->desc.ld_tgt_count) ? NULL : &(lmv->tgts[*pos]);
80 static void lmv_tgt_seq_stop(struct seq_file *p, void *v)
85 static void *lmv_tgt_seq_next(struct seq_file *p, void *v, loff_t *pos)
87 struct obd_device *dev = p->private;
88 struct lmv_obd *lmv = &dev->u.lmv;
91 return (*pos >=lmv->desc.ld_tgt_count) ? NULL : &(lmv->tgts[*pos]);
94 static int lmv_tgt_seq_show(struct seq_file *p, void *v)
96 struct lmv_tgt_desc *tgt = v;
97 struct obd_device *dev = p->private;
98 struct lmv_obd *lmv = &dev->u.lmv;
99 int idx = tgt - &(lmv->tgts[0]);
101 return seq_printf(p, "%d: %s %sACTIVE\n", idx, tgt->ltd_uuid.uuid,
102 tgt->ltd_active ? "" : "IN");
105 struct seq_operations lmv_tgt_sops = {
106 .start = lmv_tgt_seq_start,
107 .stop = lmv_tgt_seq_stop,
108 .next = lmv_tgt_seq_next,
109 .show = lmv_tgt_seq_show,
112 static int lmv_target_seq_open(struct inode *inode, struct file *file)
114 struct proc_dir_entry *dp = PDE(inode);
115 struct seq_file *seq;
116 int rc = seq_open(file, &lmv_tgt_sops);
121 seq = file->private_data;
122 seq->private = dp->data;
127 struct lprocfs_vars lprocfs_lmv_obd_vars[] = {
128 { "numobd", lmv_rd_numobd, 0, 0 },
129 { "activeobd", lmv_rd_activeobd, 0, 0 },
130 { "uuid", lprocfs_rd_uuid, 0, 0 },
131 { "desc_uuid", lmv_rd_desc_uuid, 0, 0 },
135 static struct lprocfs_vars lprocfs_lmv_module_vars[] = {
136 { "num_refs", lprocfs_rd_numrefs, 0, 0 },
140 struct file_operations lmv_proc_target_fops = {
141 .owner = THIS_MODULE,
142 .open = lmv_target_seq_open,
145 .release = seq_release,
149 void lprocfs_lmv_init_vars(struct lprocfs_static_vars *lvars)
151 lvars->module_vars = lprocfs_lmv_module_vars;
152 lvars->obd_vars = lprocfs_lmv_obd_vars;