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) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2012, 2015, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
32 #define DEBUG_SUBSYSTEM S_CLASS
34 #include <linux/version.h>
35 #include <asm/statfs.h>
36 #include <lprocfs_status.h>
37 #include <obd_class.h>
38 #include <lustre_param.h>
39 #include "lov_internal.h"
42 static int lov_stripesize_seq_show(struct seq_file *m, void *v)
44 struct obd_device *dev = (struct obd_device *)m->private;
45 struct lov_desc *desc;
48 desc = &dev->u.lov.desc;
50 seq_printf(m, "%llu\n", desc->ld_default_stripe_size);
54 static ssize_t lov_stripesize_seq_write(struct file *file,
55 const char __user *buffer,
56 size_t count, loff_t *off)
58 struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
59 struct lov_desc *desc;
64 desc = &dev->u.lov.desc;
65 rc = lprocfs_str_to_s64(buffer, count, &val);
71 lov_fix_desc_stripe_size(&val);
72 desc->ld_default_stripe_size = val;
76 LPROC_SEQ_FOPS(lov_stripesize);
78 static int lov_stripeoffset_seq_show(struct seq_file *m, void *v)
80 struct obd_device *dev = (struct obd_device *)m->private;
81 struct lov_desc *desc;
84 desc = &dev->u.lov.desc;
85 seq_printf(m, "%llu\n", desc->ld_default_stripe_offset);
89 static ssize_t lov_stripeoffset_seq_write(struct file *file,
90 const char __user *buffer,
91 size_t count, loff_t *off)
93 struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
94 struct lov_desc *desc;
99 desc = &dev->u.lov.desc;
100 rc = lprocfs_str_to_s64(buffer, count, &val);
106 desc->ld_default_stripe_offset = val;
110 LPROC_SEQ_FOPS(lov_stripeoffset);
112 static int lov_stripetype_seq_show(struct seq_file *m, void *v)
114 struct obd_device* dev = (struct obd_device*)m->private;
115 struct lov_desc *desc;
117 LASSERT(dev != NULL);
118 desc = &dev->u.lov.desc;
119 seq_printf(m, "%u\n", desc->ld_pattern);
123 static ssize_t lov_stripetype_seq_write(struct file *file,
124 const char __user *buffer,
125 size_t count, loff_t *off)
127 struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
128 struct lov_desc *desc;
132 LASSERT(dev != NULL);
133 desc = &dev->u.lov.desc;
134 rc = lprocfs_str_to_s64(buffer, count, &val);
137 if (val < INT_MIN || val > INT_MAX)
141 lov_fix_desc_pattern(&pattern);
142 desc->ld_pattern = pattern;
146 LPROC_SEQ_FOPS(lov_stripetype);
148 static int lov_stripecount_seq_show(struct seq_file *m, void *v)
150 struct obd_device *dev = (struct obd_device *)m->private;
151 struct lov_desc *desc;
153 LASSERT(dev != NULL);
154 desc = &dev->u.lov.desc;
155 seq_printf(m, "%d\n",
156 (__s16)(desc->ld_default_stripe_count + 1) - 1);
160 static ssize_t lov_stripecount_seq_write(struct file *file,
161 const char __user *buffer,
162 size_t count, loff_t *off)
164 struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
165 struct lov_desc *desc;
170 LASSERT(dev != NULL);
171 desc = &dev->u.lov.desc;
172 rc = lprocfs_str_to_s64(buffer, count, &val);
179 lov_fix_desc_stripe_count(&stripe_count);
180 desc->ld_default_stripe_count = stripe_count;
184 LPROC_SEQ_FOPS(lov_stripecount);
186 static int lov_numobd_seq_show(struct seq_file *m, void *v)
188 struct obd_device *dev = (struct obd_device*)m->private;
189 struct lov_desc *desc;
191 LASSERT(dev != NULL);
192 desc = &dev->u.lov.desc;
193 seq_printf(m, "%u\n", desc->ld_tgt_count);
196 LPROC_SEQ_FOPS_RO(lov_numobd);
198 static int lov_activeobd_seq_show(struct seq_file *m, void *v)
200 struct obd_device* dev = (struct obd_device*)m->private;
201 struct lov_desc *desc;
203 LASSERT(dev != NULL);
204 desc = &dev->u.lov.desc;
205 seq_printf(m, "%u\n", desc->ld_active_tgt_count);
208 LPROC_SEQ_FOPS_RO(lov_activeobd);
210 static int lov_desc_uuid_seq_show(struct seq_file *m, void *v)
212 struct obd_device *dev = m->private;
215 LASSERT(dev != NULL);
217 seq_printf(m, "%s\n", lov->desc.ld_uuid.uuid);
220 LPROC_SEQ_FOPS_RO(lov_desc_uuid);
222 static void *lov_tgt_seq_start(struct seq_file *p, loff_t *pos)
224 struct obd_device *dev = p->private;
225 struct lov_obd *lov = &dev->u.lov;
227 while (*pos < lov->desc.ld_tgt_count) {
228 if (lov->lov_tgts[*pos])
229 return lov->lov_tgts[*pos];
235 static void lov_tgt_seq_stop(struct seq_file *p, void *v)
239 static void *lov_tgt_seq_next(struct seq_file *p, void *v, loff_t *pos)
241 struct obd_device *dev = p->private;
242 struct lov_obd *lov = &dev->u.lov;
244 while (++*pos < lov->desc.ld_tgt_count) {
245 if (lov->lov_tgts[*pos])
246 return lov->lov_tgts[*pos];
251 static int lov_tgt_seq_show(struct seq_file *p, void *v)
253 struct lov_tgt_desc *tgt = v;
254 seq_printf(p, "%d: %s %sACTIVE\n", tgt->ltd_index,
255 obd_uuid2str(&tgt->ltd_uuid),
256 tgt->ltd_active ? "" : "IN");
260 static const struct seq_operations lov_tgt_sops = {
261 .start = lov_tgt_seq_start,
262 .stop = lov_tgt_seq_stop,
263 .next = lov_tgt_seq_next,
264 .show = lov_tgt_seq_show,
267 static int lov_target_seq_open(struct inode *inode, struct file *file)
269 struct seq_file *seq;
272 rc = LPROCFS_ENTRY_CHECK(inode);
276 rc = seq_open(file, &lov_tgt_sops);
280 seq = file->private_data;
281 seq->private = PDE_DATA(inode);
285 LPROC_SEQ_FOPS_RO_TYPE(lov, uuid);
286 LPROC_SEQ_FOPS_RO_TYPE(lov, filestotal);
287 LPROC_SEQ_FOPS_RO_TYPE(lov, filesfree);
288 LPROC_SEQ_FOPS_RO_TYPE(lov, blksize);
289 LPROC_SEQ_FOPS_RO_TYPE(lov, kbytestotal);
290 LPROC_SEQ_FOPS_RO_TYPE(lov, kbytesfree);
291 LPROC_SEQ_FOPS_RO_TYPE(lov, kbytesavail);
293 struct lprocfs_vars lprocfs_lov_obd_vars[] = {
295 .fops = &lov_uuid_fops },
296 { .name = "stripesize",
297 .fops = &lov_stripesize_fops },
298 { .name = "stripeoffset",
299 .fops = &lov_stripeoffset_fops },
300 { .name = "stripecount",
301 .fops = &lov_stripecount_fops },
302 { .name = "stripetype",
303 .fops = &lov_stripetype_fops },
305 .fops = &lov_numobd_fops },
306 { .name = "activeobd",
307 .fops = &lov_activeobd_fops },
308 { .name = "filestotal",
309 .fops = &lov_filestotal_fops },
310 { .name = "filesfree",
311 .fops = &lov_filesfree_fops },
312 { .name = "blocksize",
313 .fops = &lov_blksize_fops },
314 { .name = "kbytestotal",
315 .fops = &lov_kbytestotal_fops },
316 { .name = "kbytesfree",
317 .fops = &lov_kbytesfree_fops },
318 { .name = "kbytesavail",
319 .fops = &lov_kbytesavail_fops },
320 { .name = "desc_uuid",
321 .fops = &lov_desc_uuid_fops },
325 struct file_operations lov_proc_target_fops = {
326 .owner = THIS_MODULE,
327 .open = lov_target_seq_open,
330 .release = lprocfs_seq_release,
332 #endif /* CONFIG_PROC_FS */