1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2002 Cluster File Systems, Inc.
6 * This file is part of the Lustre file system, http://www.lustre.org
7 * Lustre is a trademark of Cluster File Systems, Inc.
9 * You may have signed or agreed to another license before downloading
10 * this software. If so, you are bound by the terms and conditions
11 * of that agreement, and the following does not apply to you. See the
12 * LICENSE file included with this distribution for more information.
14 * If you did not agree to a different license, then this copy of Lustre
15 * is open source software; you can redistribute it and/or modify it
16 * under the terms of version 2 of the GNU General Public License as
17 * published by the Free Software Foundation.
19 * In either case, Lustre is distributed in the hope that it will be
20 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
21 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * license text for more details.
25 #define DEBUG_SUBSYSTEM S_CLASS
27 #include <linux/version.h>
28 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
29 #include <asm/statfs.h>
31 #include <lprocfs_status.h>
32 #include <obd_class.h>
33 #include <linux/seq_file.h>
36 static int lov_rd_stripesize(char *page, char **start, off_t off, int count,
39 struct obd_device *dev = (struct obd_device *)data;
40 struct lov_desc *desc;
43 desc = &dev->u.lov.desc;
45 return snprintf(page, count, LPU64"\n", desc->ld_default_stripe_size);
48 static int lov_rd_stripeoffset(char *page, char **start, off_t off, int count,
51 struct obd_device *dev = (struct obd_device *)data;
52 struct lov_desc *desc;
55 desc = &dev->u.lov.desc;
57 return snprintf(page, count, LPU64"\n", desc->ld_default_stripe_offset);
60 static int lov_rd_stripetype(char *page, char **start, off_t off, int count,
63 struct obd_device* dev = (struct obd_device*)data;
64 struct lov_desc *desc;
67 desc = &dev->u.lov.desc;
69 return snprintf(page, count, "%u\n", desc->ld_pattern);
72 static int lov_rd_stripecount(char *page, char **start, off_t off, int count,
75 struct obd_device *dev = (struct obd_device *)data;
76 struct lov_desc *desc;
79 desc = &dev->u.lov.desc;
81 return snprintf(page, count, "%u\n", desc->ld_default_stripe_count);
84 static int lov_rd_numobd(char *page, char **start, off_t off, int count,
87 struct obd_device *dev = (struct obd_device*)data;
88 struct lov_desc *desc;
91 desc = &dev->u.lov.desc;
93 return snprintf(page, count, "%u\n", desc->ld_tgt_count);
97 static int lov_rd_activeobd(char *page, char **start, off_t off, int count,
100 struct obd_device* dev = (struct obd_device*)data;
101 struct lov_desc *desc;
103 LASSERT(dev != NULL);
104 desc = &dev->u.lov.desc;
106 return snprintf(page, count, "%u\n", desc->ld_active_tgt_count);
109 static int lov_rd_desc_uuid(char *page, char **start, off_t off, int count,
110 int *eof, void *data)
112 struct obd_device *dev = (struct obd_device*) data;
115 LASSERT(dev != NULL);
118 return snprintf(page, count, "%s\n", lov->desc.ld_uuid.uuid);
121 static int lov_rd_qos_threshold(char *page, char **start, off_t off, int count,
122 int *eof, void *data)
124 struct obd_device *dev = (struct obd_device*) data;
127 LASSERT(dev != NULL);
130 return snprintf(page, count, "%u MB\n", lov->desc.ld_qos_threshold);
133 static int lov_wr_qos_threshold(struct file *file, const char *buffer,
134 unsigned long count, void *data)
136 struct obd_device *dev = (struct obd_device *)data;
139 LASSERT(dev != NULL);
142 rc = lprocfs_write_helper(buffer, count, &val);
148 lov->desc.ld_qos_threshold = val;
152 static int lov_rd_qos_maxage(char *page, char **start, off_t off, int count,
153 int *eof, void *data)
155 struct obd_device *dev = (struct obd_device*) data;
158 LASSERT(dev != NULL);
161 return snprintf(page, count, "%u Sec\n", lov->desc.ld_qos_maxage);
164 static int lov_wr_qos_maxage(struct file *file, const char *buffer,
165 unsigned long count, void *data)
167 struct obd_device *dev = (struct obd_device *)data;
170 LASSERT(dev != NULL);
173 rc = lprocfs_write_helper(buffer, count, &val);
179 lov->desc.ld_qos_maxage = val;
183 static void *lov_tgt_seq_start(struct seq_file *p, loff_t *pos)
185 struct obd_device *dev = p->private;
186 struct lov_obd *lov = &dev->u.lov;
188 return (*pos >= lov->desc.ld_tgt_count) ? NULL : &(lov->tgts[*pos]);
192 static void lov_tgt_seq_stop(struct seq_file *p, void *v)
196 static void *lov_tgt_seq_next(struct seq_file *p, void *v, loff_t *pos)
198 struct obd_device *dev = p->private;
199 struct lov_obd *lov = &dev->u.lov;
202 return (*pos >=lov->desc.ld_tgt_count) ? NULL : &(lov->tgts[*pos]);
205 static int lov_tgt_seq_show(struct seq_file *p, void *v)
207 struct lov_tgt_desc *tgt = v;
208 struct obd_device *dev = p->private;
209 struct lov_obd *lov = &dev->u.lov;
210 int idx = tgt - &(lov->tgts[0]);
211 return seq_printf(p, "%d: %s %sACTIVE\n", idx, tgt->uuid.uuid,
212 tgt->active ? "" : "IN");
215 struct seq_operations lov_tgt_sops = {
216 .start = lov_tgt_seq_start,
217 .stop = lov_tgt_seq_stop,
218 .next = lov_tgt_seq_next,
219 .show = lov_tgt_seq_show,
222 static int lov_target_seq_open(struct inode *inode, struct file *file)
224 struct proc_dir_entry *dp = PDE(inode);
225 struct seq_file *seq;
226 int rc = seq_open(file, &lov_tgt_sops);
231 seq = file->private_data;
232 seq->private = dp->data;
237 struct lprocfs_vars lprocfs_obd_vars[] = {
238 { "uuid", lprocfs_rd_uuid, 0, 0 },
239 { "stripesize", lov_rd_stripesize, 0, 0 },
240 { "stripeoffset", lov_rd_stripeoffset, 0, 0 },
241 { "stripecount", lov_rd_stripecount, 0, 0 },
242 { "stripetype", lov_rd_stripetype, 0, 0 },
243 { "numobd", lov_rd_numobd, 0, 0 },
244 { "activeobd", lov_rd_activeobd, 0, 0 },
245 { "filestotal", lprocfs_rd_filestotal, 0, 0 },
246 { "filesfree", lprocfs_rd_filesfree, 0, 0 },
247 //{ "filegroups", lprocfs_rd_filegroups, 0, 0 },
248 { "blocksize", lprocfs_rd_blksize, 0, 0 },
249 { "kbytestotal", lprocfs_rd_kbytestotal, 0, 0 },
250 { "kbytesfree", lprocfs_rd_kbytesfree, 0, 0 },
251 { "kbytesavail", lprocfs_rd_kbytesavail, 0, 0 },
252 { "desc_uuid", lov_rd_desc_uuid, 0, 0 },
253 { "qos_threshold",lov_rd_qos_threshold, lov_wr_qos_threshold, 0 },
254 { "qos_maxage", lov_rd_qos_maxage, lov_wr_qos_maxage, 0 },
258 static struct lprocfs_vars lprocfs_module_vars[] = {
259 { "num_refs", lprocfs_rd_numrefs, 0, 0 },
263 struct file_operations lov_proc_target_fops = {
264 .owner = THIS_MODULE,
265 .open = lov_target_seq_open,
268 .release = seq_release,
271 LPROCFS_INIT_VARS(lov, lprocfs_module_vars, lprocfs_obd_vars)