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, 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 <asm/statfs.h>
39 #include <lprocfs_status.h>
40 #include <obd_class.h>
41 #include <linux/seq_file.h>
42 #include "lov_internal.h"
44 static int lov_stripesize_seq_show(struct seq_file *m, void *v)
46 struct obd_device *dev = (struct obd_device *)m->private;
47 struct lov_desc *desc;
50 desc = &dev->u.lov.desc;
51 return seq_printf(m, LPU64"\n", desc->ld_default_stripe_size);
54 static ssize_t lov_stripesize_seq_write(struct file *file, const char *buffer,
55 size_t count, loff_t *off)
57 struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
58 struct lov_desc *desc;
63 desc = &dev->u.lov.desc;
64 rc = lprocfs_write_u64_helper(buffer, count, &val);
68 lov_fix_desc_stripe_size(&val);
69 desc->ld_default_stripe_size = val;
72 LPROC_SEQ_FOPS(lov_stripesize);
74 static int lov_stripeoffset_seq_show(struct seq_file *m, void *v)
76 struct obd_device *dev = (struct obd_device *)m->private;
77 struct lov_desc *desc;
80 desc = &dev->u.lov.desc;
81 return seq_printf(m, LPU64"\n", desc->ld_default_stripe_offset);
84 static ssize_t lov_stripeoffset_seq_write(struct file *file, const char *buffer,
85 size_t count, loff_t *off)
87 struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
88 struct lov_desc *desc;
93 desc = &dev->u.lov.desc;
94 rc = lprocfs_write_u64_helper(buffer, count, &val);
98 desc->ld_default_stripe_offset = val;
101 LPROC_SEQ_FOPS(lov_stripeoffset);
103 static int lov_stripetype_seq_show(struct seq_file *m, void *v)
105 struct obd_device *dev = (struct obd_device *)m->private;
106 struct lov_desc *desc;
108 LASSERT(dev != NULL);
109 desc = &dev->u.lov.desc;
110 return seq_printf(m, "%u\n", desc->ld_pattern);
113 static ssize_t lov_stripetype_seq_write(struct file *file, const char *buffer,
114 size_t count, loff_t *off)
116 struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
117 struct lov_desc *desc;
120 LASSERT(dev != NULL);
121 desc = &dev->u.lov.desc;
122 rc = lprocfs_write_helper(buffer, count, &val);
126 lov_fix_desc_pattern(&val);
127 desc->ld_pattern = val;
130 LPROC_SEQ_FOPS(lov_stripetype);
132 static int lov_stripecount_seq_show(struct seq_file *m, void *v)
134 struct obd_device *dev = (struct obd_device *)m->private;
135 struct lov_desc *desc;
137 LASSERT(dev != NULL);
138 desc = &dev->u.lov.desc;
139 return seq_printf(m, "%d\n",
140 (__s16)(desc->ld_default_stripe_count + 1) - 1);
143 static ssize_t lov_stripecount_seq_write(struct file *file, const char *buffer,
144 size_t count, loff_t *off)
146 struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
147 struct lov_desc *desc;
150 LASSERT(dev != NULL);
151 desc = &dev->u.lov.desc;
152 rc = lprocfs_write_helper(buffer, count, &val);
156 lov_fix_desc_stripe_count(&val);
157 desc->ld_default_stripe_count = val;
160 LPROC_SEQ_FOPS(lov_stripecount);
162 static int lov_numobd_seq_show(struct seq_file *m, void *v)
164 struct obd_device *dev = (struct obd_device *)m->private;
165 struct lov_desc *desc;
167 LASSERT(dev != NULL);
168 desc = &dev->u.lov.desc;
169 return seq_printf(m, "%u\n", desc->ld_tgt_count);
171 LPROC_SEQ_FOPS_RO(lov_numobd);
173 static int lov_activeobd_seq_show(struct seq_file *m, void *v)
175 struct obd_device *dev = (struct obd_device *)m->private;
176 struct lov_desc *desc;
178 LASSERT(dev != NULL);
179 desc = &dev->u.lov.desc;
180 return seq_printf(m, "%u\n", desc->ld_active_tgt_count);
182 LPROC_SEQ_FOPS_RO(lov_activeobd);
184 static int lov_desc_uuid_seq_show(struct seq_file *m, void *v)
186 struct obd_device *dev = (struct obd_device *)m->private;
189 LASSERT(dev != NULL);
191 return seq_printf(m, "%s\n", lov->desc.ld_uuid.uuid);
193 LPROC_SEQ_FOPS_RO(lov_desc_uuid);
195 static void *lov_tgt_seq_start(struct seq_file *p, loff_t *pos)
197 struct obd_device *dev = p->private;
198 struct lov_obd *lov = &dev->u.lov;
200 while (*pos < lov->desc.ld_tgt_count) {
201 if (lov->lov_tgts[*pos])
202 return lov->lov_tgts[*pos];
208 static void lov_tgt_seq_stop(struct seq_file *p, void *v)
212 static void *lov_tgt_seq_next(struct seq_file *p, void *v, loff_t *pos)
214 struct obd_device *dev = p->private;
215 struct lov_obd *lov = &dev->u.lov;
217 while (++*pos < lov->desc.ld_tgt_count) {
218 if (lov->lov_tgts[*pos])
219 return lov->lov_tgts[*pos];
224 static int lov_tgt_seq_show(struct seq_file *p, void *v)
226 struct lov_tgt_desc *tgt = v;
227 return seq_printf(p, "%d: %s %sACTIVE\n", tgt->ltd_index,
228 obd_uuid2str(&tgt->ltd_uuid),
229 tgt->ltd_active ? "" : "IN");
232 struct seq_operations lov_tgt_sops = {
233 .start = lov_tgt_seq_start,
234 .stop = lov_tgt_seq_stop,
235 .next = lov_tgt_seq_next,
236 .show = lov_tgt_seq_show,
239 static int lov_target_seq_open(struct inode *inode, struct file *file)
241 struct seq_file *seq;
244 rc = seq_open(file, &lov_tgt_sops);
248 seq = file->private_data;
249 seq->private = PDE_DATA(inode);
253 LPROC_SEQ_FOPS_RO_TYPE(lov, uuid);
254 LPROC_SEQ_FOPS_RO_TYPE(lov, filestotal);
255 LPROC_SEQ_FOPS_RO_TYPE(lov, filesfree);
256 LPROC_SEQ_FOPS_RO_TYPE(lov, blksize);
257 LPROC_SEQ_FOPS_RO_TYPE(lov, kbytestotal);
258 LPROC_SEQ_FOPS_RO_TYPE(lov, kbytesfree);
259 LPROC_SEQ_FOPS_RO_TYPE(lov, kbytesavail);
261 struct lprocfs_vars lprocfs_lov_obd_vars[] = {
262 { "uuid", &lov_uuid_fops, NULL, 0 },
263 { "stripesize", &lov_stripesize_fops, NULL },
264 { "stripeoffset", &lov_stripeoffset_fops, NULL },
265 { "stripecount", &lov_stripecount_fops, NULL },
266 { "stripetype", &lov_stripetype_fops, NULL },
267 { "numobd", &lov_numobd_fops, NULL, 0 },
268 { "activeobd", &lov_activeobd_fops, NULL, 0 },
269 { "filestotal", &lov_filestotal_fops, NULL, 0 },
270 { "filesfree", &lov_filesfree_fops, NULL, 0 },
271 /*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/
272 { "blocksize", &lov_blksize_fops, NULL, 0 },
273 { "kbytestotal", &lov_kbytestotal_fops, NULL, 0 },
274 { "kbytesfree", &lov_kbytesfree_fops, NULL, 0 },
275 { "kbytesavail", &lov_kbytesavail_fops, NULL, 0 },
276 { "desc_uuid", &lov_desc_uuid_fops, NULL, 0 },
280 LPROC_SEQ_FOPS_RO_TYPE(lov, numrefs);
282 static struct lprocfs_vars lprocfs_lov_module_vars[] = {
283 { "num_refs", &lov_numrefs_fops, NULL, 0 },
287 void lprocfs_lov_init_vars(struct lprocfs_static_vars *lvars)
289 lvars->module_vars = lprocfs_lov_module_vars;
290 lvars->obd_vars = lprocfs_lov_obd_vars;
293 const struct file_operations lov_proc_target_fops = {
294 .owner = THIS_MODULE,
295 .open = lov_target_seq_open,
298 .release = lprocfs_seq_release,