Whamcloud - gitweb
- added proc interface to seq-mgr, it will be used for testing.
[fs/lustre-release.git] / lustre / fid / lproc_fid.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  lustre/fid/lproc_fid.c
5  *  Lustre Sequence Manager
6  *
7  *  Copyright (c) 2006 Cluster File Systems, Inc.
8  *   Author: Yury Umanets <umka@clusterfs.com>
9  *
10  *   This file is part of the Lustre file system, http://www.lustre.org
11  *   Lustre is a trademark of Cluster File Systems, Inc.
12  *
13  *   You may have signed or agreed to another license before downloading
14  *   this software.  If so, you are bound by the terms and conditions
15  *   of that agreement, and the following does not apply to you.  See the
16  *   LICENSE file included with this distribution for more information.
17  *
18  *   If you did not agree to a different license, then this copy of Lustre
19  *   is open source software; you can redistribute it and/or modify it
20  *   under the terms of version 2 of the GNU General Public License as
21  *   published by the Free Software Foundation.
22  *
23  *   In either case, Lustre is distributed in the hope that it will be
24  *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
25  *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26  *   license text for more details.
27  */
28
29 #ifndef EXPORT_SYMTAB
30 # define EXPORT_SYMTAB
31 #endif
32 #define DEBUG_SUBSYSTEM S_FID
33
34 #ifdef __KERNEL__
35 # include <libcfs/libcfs.h>
36 # include <linux/module.h>
37 #else /* __KERNEL__ */
38 # include <liblustre.h>
39 #endif
40
41 #include <obd.h>
42 #include <obd_class.h>
43 #include <dt_object.h>
44 #include <md_object.h>
45 #include <obd_support.h>
46 #include <lustre_req_layout.h>
47 #include <lustre_fid.h>
48 #include "fid_internal.h"
49
50 #ifdef LPROCFS
51 static int
52 seq_proc_write_range(struct file *file, const char *buffer,
53                      unsigned long count, void *data,
54                      struct lu_range *range)
55 {
56         struct lu_range tmp;
57         int rc;
58         ENTRY;
59
60         LASSERT(range != NULL);
61
62         rc = sscanf(buffer, "["LPU64"-"LPU64"]\n",
63                     &tmp.lr_start, &tmp.lr_end);
64
65         *range = tmp;
66         RETURN(count);
67 }
68
69 static int
70 seq_proc_read_range(char *page, char **start, off_t off,
71                     int count, int *eof, void *data,
72                     struct lu_range *range)
73 {
74         int rc;
75         ENTRY;
76
77         *eof = 1;
78         rc = snprintf(page, count, "["LPU64"-"LPU64"]\n",
79                       range->lr_start, range->lr_end);
80         RETURN(rc);
81 }
82
83 static int
84 seq_proc_write_space(struct file *file, const char *buffer,
85                      unsigned long count, void *data)
86 {
87         struct lu_server_seq *seq = (struct lu_server_seq *)data;
88         ENTRY;
89
90         LASSERT(seq != NULL);
91
92         down(&seq->seq_sem);
93         seq_proc_write_range(file, buffer, count,
94                              data, &seq->seq_space);
95
96         CDEBUG(D_WARNING, "sequences space range is changed "
97                "to ["LPU64"-"LPU64"]\n", seq->seq_space.lr_start,
98                seq->seq_space.lr_end);
99         
100         up(&seq->seq_sem);
101         
102         RETURN(count);
103 }
104
105 static int
106 seq_proc_read_space(char *page, char **start, off_t off,
107                     int count, int *eof, void *data)
108 {
109         struct lu_server_seq *seq = (struct lu_server_seq *)data;
110         int rc;
111         ENTRY;
112
113         LASSERT(seq != NULL);
114
115         down(&seq->seq_sem);
116         rc = seq_proc_read_range(page, start, off, count, eof,
117                                  data, &seq->seq_space);
118         up(&seq->seq_sem);
119         
120         RETURN(rc);
121 }
122
123 static int
124 seq_proc_write_super(struct file *file, const char *buffer,
125                      unsigned long count, void *data)
126 {
127         struct lu_server_seq *seq = (struct lu_server_seq *)data;
128         ENTRY;
129
130         LASSERT(seq != NULL);
131
132         down(&seq->seq_sem);
133         seq_proc_write_range(file, buffer, count,
134                              data, &seq->seq_super);
135
136         CDEBUG(D_WARNING, "super-sequence range is changed to "
137                "["LPU64"-"LPU64"]\n", seq->seq_super.lr_start,
138                seq->seq_super.lr_end);
139         
140         up(&seq->seq_sem);
141         
142         RETURN(count);
143 }
144
145 static int
146 seq_proc_read_super(char *page, char **start, off_t off,
147                     int count, int *eof, void *data)
148 {
149         struct lu_server_seq *seq = (struct lu_server_seq *)data;
150         int rc;
151         ENTRY;
152
153         LASSERT(seq != NULL);
154
155         down(&seq->seq_sem);
156         rc = seq_proc_read_range(page, start, off, count, eof,
157                                  data, &seq->seq_super);
158         up(&seq->seq_sem);
159         
160         RETURN(rc);
161 }
162
163 struct lprocfs_vars seq_proc_list[] = {
164         { "space", seq_proc_read_space, seq_proc_write_space, NULL },
165         { "super", seq_proc_read_super, seq_proc_write_super, NULL },
166         { NULL }};
167 #endif