Whamcloud - gitweb
* 1st attempt to prevent duplicate devices being started.
[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 #include <linux/obd_support.h>
24 #include <linux/obd_class.h>
25 #include <linux/lprocfs.h>
26 #include <linux/string.h>
27 #include <linux/lustre_lib.h>
28
29
30 /*
31  * Common SNMP namespace
32  */
33
34 int rd_uuid(char* page, char **start, off_t off,
35                int count, int *eof, void *data)
36 {
37         int len=0;
38         struct obd_device* dev=(struct obd_device*)data;
39         len+=snprintf(page, count, "%s\n", dev->obd_uuid);
40         return len;
41         
42
43 }
44 int rd_stripesize(char* page, char **start, off_t off,
45                int count, int *eof, void *data)
46 {
47         struct obd_device* dev=(struct obd_device*)data;
48         int len=0;
49         struct lov_obd* lov=&dev->u.lov;
50         len+=snprintf(page, count, LPU64"\n", \
51                       (__u64)(lov->desc.ld_default_stripe_count));
52         
53         return len;
54 }
55
56 int rd_stripedepth(char* page, char **start, off_t off,
57                int count, int *eof, void *data)
58 {
59         struct obd_device* dev=(struct obd_device*)data;
60         int len=0;
61         struct lov_obd* lov=&dev->u.lov;
62         len+=snprintf(page, count, LPU64"\n", \
63                       lov->desc.ld_default_stripe_size);
64         return len;
65
66 }
67 int rd_stripefactor(char* page, char **start, off_t off,
68                int count, int *eof, void *data)
69 {
70         struct obd_device* dev=(struct obd_device*)data;
71         int len=0;
72         struct lov_obd* lov=&dev->u.lov;
73         len+=snprintf(page, count, LPU64"\n", \
74                       lov->desc.ld_default_stripe_offset);
75         return len;
76
77 }
78
79 int rd_stripetype(char* page, char **start, off_t off,
80                int count, int *eof, void *data)
81 {       
82         struct obd_device* dev=(struct obd_device*)data;
83         int len=0;
84         struct lov_obd* lov=&dev->u.lov;
85         len+=snprintf(page, count, LPU64"\n", \
86                       (__u64)(lov->desc.ld_pattern));
87         return len;
88
89 }
90
91 int rd_blksize(char* page, char **start, off_t off,
92                 int count, int *eof, void *data)
93 {
94         return 0;
95 }
96
97
98 int rd_blktotal(char* page, char **start, off_t off,
99                 int count, int *eof, void *data)
100 {
101         return 0;
102 }
103
104 int rd_blkfree(char* page, char **start, off_t off,
105                int count, int *eof, void *data)
106 {
107         return 0;
108 }
109
110 int rd_kbfree(char* page, char **start, off_t off,
111               int count, int *eof, void *data)
112 {
113         return 0;
114 }
115
116 int rd_numobjects(char* page, char **start, off_t off,
117                   int count, int *eof, void *data)
118 {
119         return 0;
120 }
121
122 int rd_objfree(char* page, char **start, off_t off,
123                int count, int *eof, void *data)
124 {
125         return 0;
126 }
127
128 int rd_objgroups(char* page, char **start, off_t off,
129                  int count, int *eof, void *data)
130 {
131         return 0;
132 }
133
134 int rd_target(char* page, char **start, off_t off,
135                  int count, int *eof, void *data)
136 {
137         struct obd_device* dev=(struct obd_device*)data;
138         int len=0, i=0;
139         struct lov_obd* lov=&dev->u.lov;
140         struct lov_tgt_desc* tgts=lov->tgts;
141         while(i<lov->desc.ld_tgt_count){
142                 len+=snprintf(page, count, \
143                               "OBD Device [%d] UUID: %s\n", \
144                               i, tgts->uuid);
145
146                 i++;
147                 tgts++;
148         }
149         
150         return len;
151 }
152 int rd_mdc(char* page, char **start, off_t off,
153                  int count, int *eof, void *data)
154 {
155         struct obd_device* dev=(struct obd_device*)data;
156         int len=0;
157         struct lov_obd* lov=&dev->u.lov;
158         len+=snprintf(page, count, \
159                               "%s\n", \
160                               lov->mdcobd->obd_uuid);
161         return len;
162 }
163
164 lprocfs_vars_t snmp_var_nm_1[]={
165         {"snmp/uuid", rd_uuid, 0},
166         {"snmp/lov_stripesize",rd_stripesize, 0},
167         {"snmp/lov_stripedepth",rd_stripedepth, 0},
168         {"snmp/lov_stripefactor",rd_stripefactor, 0},
169         {"snmp/lov_stripetype", rd_stripetype, 0},
170         {"snmp/f_objects", rd_numobjects, 0},
171         {"snmp/f_objectsfree", rd_objfree, 0},
172         {"snmp/f_objectgroups", rd_objgroups, 0},
173         {"snmp/f_blocksize", rd_blksize, 0},
174         {"snmp/f_blockstotal", rd_blktotal, 0},
175         {"snmp/f_kbytesfree", rd_kbfree, 0},
176         {"snmp/f_blocksfree", rd_blkfree, 0},
177         {"snmp/target_obd", rd_target, 0},
178         {"snmp/target_mdc", rd_mdc, 0},
179         {0}
180 };