4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2012, 2016, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
33 #define DEBUG_SUBSYSTEM S_CLASS
35 #include <linux/version.h>
36 #include <linux/seq_file.h>
37 #include <asm/statfs.h>
38 #include <lprocfs_status.h>
39 #include <obd_class.h>
41 #include "lmv_internal.h"
43 #ifndef CONFIG_PROC_FS
44 static struct lprocfs_vars lprocfs_module_vars[] = { {0} };
45 static struct lprocfs_vars lprocfs_obd_vars[] = { {0} };
47 static int lmv_numobd_seq_show(struct seq_file *m, void *v)
49 struct obd_device *dev = (struct obd_device *)m->private;
50 struct lmv_desc *desc;
53 desc = &dev->u.lmv.desc;
54 seq_printf(m, "%u\n", desc->ld_tgt_count);
57 LPROC_SEQ_FOPS_RO(lmv_numobd);
59 static int lmv_activeobd_seq_show(struct seq_file *m, void *v)
61 struct obd_device *dev = (struct obd_device *)m->private;
62 struct lmv_desc *desc;
65 desc = &dev->u.lmv.desc;
66 seq_printf(m, "%u\n", desc->ld_active_tgt_count);
69 LPROC_SEQ_FOPS_RO(lmv_activeobd);
71 static int lmv_desc_uuid_seq_show(struct seq_file *m, void *v)
73 struct obd_device *dev = (struct obd_device*)m->private;
78 seq_printf(m, "%s\n", lmv->desc.ld_uuid.uuid);
81 LPROC_SEQ_FOPS_RO(lmv_desc_uuid);
83 static void *lmv_tgt_seq_start(struct seq_file *p, loff_t *pos)
85 struct obd_device *dev = p->private;
86 struct lmv_obd *lmv = &dev->u.lmv;
88 while (*pos < lmv->tgts_size) {
89 if (lmv->tgts[*pos] != NULL)
90 return lmv->tgts[*pos];
98 static void lmv_tgt_seq_stop(struct seq_file *p, void *v)
103 static void *lmv_tgt_seq_next(struct seq_file *p, void *v, loff_t *pos)
105 struct obd_device *dev = p->private;
106 struct lmv_obd *lmv = &dev->u.lmv;
109 while (*pos < lmv->tgts_size) {
110 if (lmv->tgts[*pos] != NULL)
111 return lmv->tgts[*pos];
119 static int lmv_tgt_seq_show(struct seq_file *p, void *v)
121 struct lmv_tgt_desc *tgt = v;
125 seq_printf(p, "%u: %s %sACTIVE\n", tgt->ltd_idx,
126 tgt->ltd_uuid.uuid, tgt->ltd_active ? "" : "IN");
130 static const struct seq_operations lmv_tgt_sops = {
131 .start = lmv_tgt_seq_start,
132 .stop = lmv_tgt_seq_stop,
133 .next = lmv_tgt_seq_next,
134 .show = lmv_tgt_seq_show,
137 static int lmv_target_seq_open(struct inode *inode, struct file *file)
139 struct seq_file *seq;
142 rc = seq_open(file, &lmv_tgt_sops);
146 seq = file->private_data;
147 seq->private = PDE_DATA(inode);
151 LPROC_SEQ_FOPS_RO_TYPE(lmv, uuid);
153 struct lprocfs_vars lprocfs_lmv_obd_vars[] = {
155 .fops = &lmv_numobd_fops },
156 { .name = "activeobd",
157 .fops = &lmv_activeobd_fops },
159 .fops = &lmv_uuid_fops },
160 { .name = "desc_uuid",
161 .fops = &lmv_desc_uuid_fops },
165 struct file_operations lmv_proc_target_fops = {
166 .owner = THIS_MODULE,
167 .open = lmv_target_seq_open,
170 .release = seq_release,
172 #endif /* CONFIG_PROC_FS */