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 Lustre, http://www.lustre.org.
8 * Lustre is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * Lustre is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #define DEBUG_SUBSYSTEM S_CLASS
24 #include <linux/version.h>
25 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
26 #include <asm/statfs.h>
28 #include <linux/lprocfs_status.h>
29 #include <linux/obd_class.h>
32 struct lprocfs_vars lprocfs_module_vars[] = { {0} };
33 struct lprocfs_vars lprocfs_obd_vars[] = { {0} };
36 DEFINE_LPROCFS_STATFS_FCT(rd_blksize, obd_self_statfs);
37 DEFINE_LPROCFS_STATFS_FCT(rd_kbytestotal, obd_self_statfs);
38 DEFINE_LPROCFS_STATFS_FCT(rd_kbytesfree, obd_self_statfs);
39 DEFINE_LPROCFS_STATFS_FCT(rd_filestotal, obd_self_statfs);
40 DEFINE_LPROCFS_STATFS_FCT(rd_filesfree, obd_self_statfs);
41 DEFINE_LPROCFS_STATFS_FCT(rd_filegroups, obd_self_statfs);
43 int rd_stripesize(char *page, char **start, off_t off, int count, int *eof,
46 struct obd_device *dev = (struct obd_device *)data;
47 struct lov_desc *desc;
50 desc = &dev->u.lov.desc;
52 return snprintf(page, count, LPU64"\n", desc->ld_default_stripe_size);
55 int rd_stripeoffset(char *page, char **start, off_t off, int count, int *eof,
58 struct obd_device *dev = (struct obd_device *)data;
59 struct lov_desc *desc;
62 desc = &dev->u.lov.desc;
64 return snprintf(page, count, LPU64"\n", desc->ld_default_stripe_offset);
67 int rd_stripetype(char *page, char **start, off_t off, int count, int *eof,
70 struct obd_device* dev = (struct obd_device*)data;
71 struct lov_desc *desc;
74 desc = &dev->u.lov.desc;
76 return snprintf(page, count, "%u\n", desc->ld_pattern);
79 int rd_stripecount(char *page, char **start, off_t off, int count, int *eof,
82 struct obd_device *dev = (struct obd_device *)data;
83 struct lov_desc *desc;
86 desc = &dev->u.lov.desc;
88 return snprintf(page, count, "%u\n", desc->ld_default_stripe_count);
91 int rd_numobd(char *page, char **start, off_t off, int count, int *eof,
94 struct obd_device *dev = (struct obd_device*)data;
95 struct lov_desc *desc;
98 desc = &dev->u.lov.desc;
100 return snprintf(page, count, "%u\n", desc->ld_tgt_count);
104 int rd_activeobd(char *page, char **start, off_t off, int count, int *eof,
107 struct obd_device* dev = (struct obd_device*)data;
108 struct lov_desc *desc;
110 LASSERT(dev != NULL);
111 desc = &dev->u.lov.desc;
113 return snprintf(page, count, "%u\n", desc->ld_active_tgt_count);
116 int rd_target(char *page, char **start, off_t off, int count, int *eof,
119 struct obd_device *dev = (struct obd_device*) data;
122 struct lov_tgt_desc *tgts;
124 LASSERT(dev != NULL);
127 LASSERT(tgts != NULL);
129 for (i = 0; i < lov->desc.ld_tgt_count; i++, tgts++) {
131 cur = snprintf(&page[len], count, "%d: %s %sACTIVE\n",
132 i, tgts->uuid.uuid, tgts->active ? "" : "IN");
141 int rd_mdc(char *page, char **start, off_t off, int count, int *eof, void *data)
143 struct obd_device *dev = (struct obd_device*) data;
146 LASSERT(dev != NULL);
149 return snprintf(page, count, "%s\n", lov->mdcobd->obd_uuid.uuid);
152 struct lprocfs_vars lprocfs_obd_vars[] = {
153 { "uuid", lprocfs_rd_uuid, 0, 0 },
154 { "stripesize", rd_stripesize, 0, 0 },
155 { "stripeoffset", rd_stripeoffset, 0, 0 },
156 { "stripecount", rd_stripecount, 0, 0 },
157 { "stripetype", rd_stripetype, 0, 0 },
158 { "numobd", rd_numobd, 0, 0 },
159 { "activeobd", rd_activeobd, 0, 0 },
160 { "filestotal", rd_filestotal, 0, 0 },
161 { "filesfree", rd_filesfree, 0, 0 },
162 { "filegroups", rd_filegroups, 0, 0 },
163 { "blocksize", rd_blksize, 0, 0 },
164 { "kbytestotal", rd_kbytestotal, 0, 0 },
165 { "kbytesfree", rd_kbytesfree, 0, 0 },
166 { "target_obd", rd_target, 0, 0 },
167 { "target_mdc", rd_mdc, 0, 0 },
171 struct lprocfs_vars lprocfs_module_vars[] = {
172 { "num_refs", lprocfs_rd_numrefs, 0, 0 },
177 LPROCFS_INIT_VARS(lprocfs_module_vars, lprocfs_obd_vars)