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.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2012, 2015, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 #define DEBUG_SUBSYSTEM S_CLASS
38 #include <linux/version.h>
39 #include <asm/statfs.h>
40 #include <lprocfs_status.h>
41 #include <obd_class.h>
42 #include <lustre_param.h>
43 #include "lov_internal.h"
46 static int lov_stripesize_seq_show(struct seq_file *m, void *v)
48 struct obd_device *dev = (struct obd_device *)m->private;
49 struct lov_desc *desc;
52 desc = &dev->u.lov.desc;
54 seq_printf(m, LPU64"\n", desc->ld_default_stripe_size);
57 LPROC_SEQ_FOPS_RO(lov_stripesize);
59 static int lov_stripeoffset_seq_show(struct seq_file *m, void *v)
61 struct obd_device *dev = (struct obd_device *)m->private;
62 struct lov_desc *desc;
65 desc = &dev->u.lov.desc;
66 seq_printf(m, LPU64"\n", desc->ld_default_stripe_offset);
69 LPROC_SEQ_FOPS_RO(lov_stripeoffset);
71 static int lov_stripetype_seq_show(struct seq_file *m, void *v)
73 struct obd_device* dev = (struct obd_device*)m->private;
74 struct lov_desc *desc;
77 desc = &dev->u.lov.desc;
78 seq_printf(m, "%u\n", desc->ld_pattern);
81 LPROC_SEQ_FOPS_RO(lov_stripetype);
83 static int lov_stripecount_seq_show(struct seq_file *m, void *v)
85 struct obd_device *dev = (struct obd_device *)m->private;
86 struct lov_desc *desc;
89 desc = &dev->u.lov.desc;
91 (__s16)(desc->ld_default_stripe_count + 1) - 1);
94 LPROC_SEQ_FOPS_RO(lov_stripecount);
96 static int lov_numobd_seq_show(struct seq_file *m, void *v)
98 struct obd_device *dev = (struct obd_device*)m->private;
99 struct lov_desc *desc;
101 LASSERT(dev != NULL);
102 desc = &dev->u.lov.desc;
103 seq_printf(m, "%u\n", desc->ld_tgt_count);
106 LPROC_SEQ_FOPS_RO(lov_numobd);
108 static int lov_activeobd_seq_show(struct seq_file *m, void *v)
110 struct obd_device* dev = (struct obd_device*)m->private;
111 struct lov_desc *desc;
113 LASSERT(dev != NULL);
114 desc = &dev->u.lov.desc;
115 seq_printf(m, "%u\n", desc->ld_active_tgt_count);
118 LPROC_SEQ_FOPS_RO(lov_activeobd);
120 static int lov_desc_uuid_seq_show(struct seq_file *m, void *v)
122 struct obd_device *dev = m->private;
125 LASSERT(dev != NULL);
127 seq_printf(m, "%s\n", lov->desc.ld_uuid.uuid);
130 LPROC_SEQ_FOPS_RO(lov_desc_uuid);
132 static void *lov_tgt_seq_start(struct seq_file *p, loff_t *pos)
134 struct obd_device *dev = p->private;
135 struct lov_obd *lov = &dev->u.lov;
137 while (*pos < lov->desc.ld_tgt_count) {
138 if (lov->lov_tgts[*pos])
139 return lov->lov_tgts[*pos];
145 static void lov_tgt_seq_stop(struct seq_file *p, void *v)
149 static void *lov_tgt_seq_next(struct seq_file *p, void *v, loff_t *pos)
151 struct obd_device *dev = p->private;
152 struct lov_obd *lov = &dev->u.lov;
154 while (++*pos < lov->desc.ld_tgt_count) {
155 if (lov->lov_tgts[*pos])
156 return lov->lov_tgts[*pos];
161 static int lov_tgt_seq_show(struct seq_file *p, void *v)
163 struct lov_tgt_desc *tgt = v;
164 seq_printf(p, "%d: %s %sACTIVE\n", tgt->ltd_index,
165 obd_uuid2str(&tgt->ltd_uuid),
166 tgt->ltd_active ? "" : "IN");
170 static const struct seq_operations lov_tgt_sops = {
171 .start = lov_tgt_seq_start,
172 .stop = lov_tgt_seq_stop,
173 .next = lov_tgt_seq_next,
174 .show = lov_tgt_seq_show,
177 static int lov_target_seq_open(struct inode *inode, struct file *file)
179 struct seq_file *seq;
182 rc = LPROCFS_ENTRY_CHECK(inode);
186 rc = seq_open(file, &lov_tgt_sops);
190 seq = file->private_data;
191 seq->private = PDE_DATA(inode);
195 LPROC_SEQ_FOPS_RO_TYPE(lov, uuid);
196 LPROC_SEQ_FOPS_RO_TYPE(lov, filestotal);
197 LPROC_SEQ_FOPS_RO_TYPE(lov, filesfree);
198 LPROC_SEQ_FOPS_RO_TYPE(lov, blksize);
199 LPROC_SEQ_FOPS_RO_TYPE(lov, kbytestotal);
200 LPROC_SEQ_FOPS_RO_TYPE(lov, kbytesfree);
201 LPROC_SEQ_FOPS_RO_TYPE(lov, kbytesavail);
203 struct lprocfs_vars lprocfs_lov_obd_vars[] = {
205 .fops = &lov_uuid_fops },
206 { .name = "stripesize",
207 .fops = &lov_stripesize_fops },
208 { .name = "stripeoffset",
209 .fops = &lov_stripeoffset_fops },
210 { .name = "stripecount",
211 .fops = &lov_stripecount_fops },
212 { .name = "stripetype",
213 .fops = &lov_stripetype_fops },
215 .fops = &lov_numobd_fops },
216 { .name = "activeobd",
217 .fops = &lov_activeobd_fops },
218 { .name = "filestotal",
219 .fops = &lov_filestotal_fops },
220 { .name = "filesfree",
221 .fops = &lov_filesfree_fops },
222 { .name = "blocksize",
223 .fops = &lov_blksize_fops },
224 { .name = "kbytestotal",
225 .fops = &lov_kbytestotal_fops },
226 { .name = "kbytesfree",
227 .fops = &lov_kbytesfree_fops },
228 { .name = "kbytesavail",
229 .fops = &lov_kbytesavail_fops },
230 { .name = "desc_uuid",
231 .fops = &lov_desc_uuid_fops },
235 struct file_operations lov_proc_target_fops = {
236 .owner = THIS_MODULE,
237 .open = lov_target_seq_open,
240 .release = lprocfs_seq_release,
242 #endif /* CONFIG_PROC_FS */