Whamcloud - gitweb
land 0.5.20.3 b_devel onto HEAD (b_devel will remain)
[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/version.h>
25 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
26 #include <asm/statfs.h>
27 #endif
28 #include <linux/lprocfs_status.h>
29 #include <linux/obd_class.h>
30
31 #ifndef LPROCFS
32 struct lprocfs_vars lprocfs_module_vars[] = { {0} };
33 struct lprocfs_vars lprocfs_obd_vars[] = { {0} };
34 #else
35
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);
42
43 int rd_stripesize(char *page, char **start, off_t off, int count, int *eof,
44                   void *data)
45 {
46         struct obd_device *dev = (struct obd_device *)data;
47         struct lov_desc *desc;
48
49         LASSERT(dev != NULL);
50         desc = &dev->u.lov.desc;
51         *eof = 1;
52         return snprintf(page, count, LPU64"\n", desc->ld_default_stripe_size);
53 }
54
55 int rd_stripeoffset(char *page, char **start, off_t off, int count, int *eof,
56                     void *data)
57 {
58         struct obd_device *dev = (struct obd_device *)data;
59         struct lov_desc *desc;
60
61         LASSERT(dev != NULL);
62         desc = &dev->u.lov.desc;
63         *eof = 1;
64         return snprintf(page, count, LPU64"\n", desc->ld_default_stripe_offset);
65 }
66
67 int rd_stripetype(char *page, char **start, off_t off, int count, int *eof,
68                   void *data)
69 {
70         struct obd_device* dev = (struct obd_device*)data;
71         struct lov_desc *desc;
72
73         LASSERT(dev != NULL);
74         desc = &dev->u.lov.desc;
75         *eof = 1;
76         return snprintf(page, count, "%u\n", desc->ld_pattern);
77 }
78
79 int rd_stripecount(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;
84
85         LASSERT(dev != NULL);
86         desc = &dev->u.lov.desc;
87         *eof = 1;
88         return snprintf(page, count, "%u\n", desc->ld_default_stripe_count);
89 }
90
91 int rd_numobd(char *page, char **start, off_t off, int count, int *eof,
92               void *data)
93 {
94         struct obd_device *dev = (struct obd_device*)data;
95         struct lov_desc *desc;
96
97         LASSERT(dev != NULL);
98         desc = &dev->u.lov.desc;
99         *eof = 1;
100         return snprintf(page, count, "%u\n", desc->ld_tgt_count);
101
102 }
103
104 int rd_activeobd(char *page, char **start, off_t off, int count, int *eof,
105                  void *data)
106 {
107         struct obd_device* dev = (struct obd_device*)data;
108         struct lov_desc *desc;
109
110         LASSERT(dev != NULL);
111         desc = &dev->u.lov.desc;
112         *eof = 1;
113         return snprintf(page, count, "%u\n", desc->ld_active_tgt_count);
114 }
115
116 int rd_target(char *page, char **start, off_t off, int count, int *eof,
117               void *data)
118 {
119         struct obd_device *dev = (struct obd_device*) data;
120         int len = 0, i;
121         struct lov_obd *lov;
122         struct lov_tgt_desc *tgts;
123         
124         LASSERT(dev != NULL);
125         lov = &dev->u.lov;
126         tgts = lov->tgts;
127         LASSERT(tgts != NULL);
128
129         for (i = 0; i < lov->desc.ld_tgt_count; i++, tgts++) {
130                 int cur;
131                 cur = snprintf(&page[len], count, "%d: %s %sACTIVE\n",
132                                 i, tgts->uuid.uuid, tgts->active ? "" : "IN");
133                 len += cur;
134                 count -= cur;
135         }
136
137         *eof = 1;
138         return len;
139 }
140
141 int rd_mdc(char *page, char **start, off_t off, int count, int *eof, void *data)
142 {
143         struct obd_device *dev = (struct obd_device*) data;
144         struct lov_obd *lov;
145
146         LASSERT(dev != NULL);
147         lov = &dev->u.lov;
148         *eof = 1;
149         return snprintf(page, count, "%s\n", lov->mdcobd->obd_uuid.uuid);
150 }
151
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 },
168         { 0 }
169 };
170
171 struct lprocfs_vars lprocfs_module_vars[] = {
172         { "num_refs",     lprocfs_rd_numrefs, 0, 0 },
173         { 0 }
174 };
175
176 #endif /* LPROCFS */
177 LPROCFS_INIT_VARS(lprocfs_module_vars, lprocfs_obd_vars)