Whamcloud - gitweb
Merge b_md into HEAD
[fs/lustre-release.git] / lustre / lov / lproc_lov.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2002 Cluster File Systems, Inc.
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
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.
11  *
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.
16  *
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.
20  *
21  */
22 #define DEBUG_SUBSYSTEM S_CLASS
23
24 #include <linux/lprocfs_status.h>
25 #include <linux/obd_class.h>
26
27 #ifndef LPROCFS
28 struct lprocfs_vars lprocfs_module_vars[] = { {0} };
29 struct lprocfs_vars lprocfs_obd_vars[] = { {0} };
30 #else
31
32 DEFINE_LPROCFS_STATFS_FCT(rd_blksize,     obd_self_statfs);
33 DEFINE_LPROCFS_STATFS_FCT(rd_kbytestotal, obd_self_statfs);
34 DEFINE_LPROCFS_STATFS_FCT(rd_kbytesfree,  obd_self_statfs);
35 DEFINE_LPROCFS_STATFS_FCT(rd_filestotal,  obd_self_statfs);
36 DEFINE_LPROCFS_STATFS_FCT(rd_filesfree,   obd_self_statfs);
37 DEFINE_LPROCFS_STATFS_FCT(rd_filegroups,  obd_self_statfs);
38
39 int rd_stripesize(char *page, char **start, off_t off, int count, int *eof,
40                   void *data)
41 {
42         struct obd_device *dev = (struct obd_device *)data;
43         struct lov_desc *desc = &dev->u.lov.desc;
44
45         *eof = 1;
46         return snprintf(page, count, LPU64"\n", desc->ld_default_stripe_size);
47 }
48
49 int rd_stripeoffset(char *page, char **start, off_t off, int count, int *eof,
50                     void *data)
51 {
52         struct obd_device *dev = (struct obd_device *)data;
53         struct lov_desc *desc = &dev->u.lov.desc;
54
55         *eof = 1;
56         return snprintf(page, count, LPU64"\n", desc->ld_default_stripe_offset);
57 }
58
59 int rd_stripetype(char *page, char **start, off_t off, int count, int *eof,
60                   void *data)
61 {
62         struct obd_device* dev = (struct obd_device*)data;
63         struct lov_desc *desc = &dev->u.lov.desc;
64
65         *eof = 1;
66         return snprintf(page, count, "%u\n", desc->ld_pattern);
67 }
68
69 int rd_stripecount(char *page, char **start, off_t off, int count, int *eof,
70                    void *data)
71 {
72         struct obd_device *dev = (struct obd_device *)data;
73         struct lov_desc *desc = &dev->u.lov.desc;
74
75         *eof = 1;
76         return snprintf(page, count, "%u\n", desc->ld_default_stripe_count);
77 }
78
79 int rd_numobd(char *page, char **start, off_t off, int count, int *eof,
80               void *data)
81 {
82         struct obd_device *dev = (struct obd_device*)data;
83         struct lov_desc *desc = &dev->u.lov.desc;
84
85         *eof = 1;
86         return snprintf(page, count, "%u\n", desc->ld_tgt_count);
87
88 }
89
90 int rd_activeobd(char *page, char **start, off_t off, int count, int *eof,
91                  void *data)
92 {
93         struct obd_device* dev = (struct obd_device*)data;
94         struct lov_desc *desc = &dev->u.lov.desc;
95
96         *eof = 1;
97         return snprintf(page, count, "%u\n", desc->ld_active_tgt_count);
98 }
99
100 int rd_target(char *page, char **start, off_t off, int count, int *eof,
101               void *data)
102 {
103         struct obd_device *dev = (struct obd_device*) data;
104         int len = 0, i;
105         struct lov_obd *lov = &dev->u.lov;
106         struct lov_tgt_desc *tgts = lov->tgts;
107
108         for (i = 0; i < lov->desc.ld_tgt_count; i++, tgts++) {
109                 int cur;
110                 cur = snprintf(&page[len], count, "%d: %s %sACTIVE\n",
111                                 i, tgts->uuid.uuid, tgts->active ? "" : "IN");
112                 len += cur;
113                 count -= cur;
114         }
115
116         *eof = 1;
117         return len;
118 }
119
120 int rd_mdc(char *page, char **start, off_t off, int count, int *eof, void *data)
121 {
122         struct obd_device *dev = (struct obd_device*) data;
123         struct lov_obd *lov = &dev->u.lov;
124
125         *eof = 1;
126         return snprintf(page, count, "%s\n", lov->mdcobd->obd_uuid.uuid);
127 }
128
129 struct lprocfs_vars lprocfs_obd_vars[] = {
130         { "uuid",         lprocfs_rd_uuid, 0, 0 },
131         { "stripesize",   rd_stripesize,   0, 0 },
132         { "stripeoffset", rd_stripeoffset, 0, 0 },
133         { "stripecount",  rd_stripecount,  0, 0 },
134         { "stripetype",   rd_stripetype,   0, 0 },
135         { "numobd",       rd_numobd,       0, 0 },
136         { "activeobd",    rd_activeobd,    0, 0 },
137         { "filestotal",   rd_filestotal,   0, 0 },
138         { "filesfree",    rd_filesfree,    0, 0 },
139         { "filegroups",   rd_filegroups,   0, 0 },
140         { "blocksize",    rd_blksize,      0, 0 },
141         { "kbytestotal",  rd_kbytestotal,  0, 0 },
142         { "kbytesfree",   rd_kbytesfree,   0, 0 },
143         { "target_obd",   rd_target,       0, 0 },
144         { "target_mdc",   rd_mdc,          0, 0 },
145         { 0 }
146 };
147
148 struct lprocfs_vars lprocfs_module_vars[] = {
149         { "num_refs",     lprocfs_rd_numrefs, 0, 0 },
150         { 0 }
151 };
152
153 #endif /* LPROCFS */
154 LPROCFS_INIT_VARS(lprocfs_module_vars, lprocfs_obd_vars)