1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * lustre/fid/lproc_fid.c
5 * Lustre Sequence Manager
7 * Copyright (c) 2006 Cluster File Systems, Inc.
8 * Author: Yury Umanets <umka@clusterfs.com>
10 * This file is part of the Lustre file system, http://www.lustre.org
11 * Lustre is a trademark of Cluster File Systems, Inc.
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.
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.
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.
30 # define EXPORT_SYMTAB
32 #define DEBUG_SUBSYSTEM S_FID
35 # include <libcfs/libcfs.h>
36 # include <linux/module.h>
37 #else /* __KERNEL__ */
38 # include <liblustre.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"
52 * Note: this function is only used for testing, it is no safe for production
56 seq_proc_write_common(struct file *file, const char *buffer,
57 unsigned long count, void *data,
58 struct lu_range *range)
64 LASSERT(range != NULL);
66 rc = sscanf(buffer, "[%Lx - %Lx]\n", &tmp.lr_start, &tmp.lr_end);
67 if (rc != 2 || !range_is_sane(&tmp) || range_is_zero(&tmp))
74 seq_proc_read_common(char *page, char **start, off_t off,
75 int count, int *eof, void *data,
76 struct lu_range *range)
82 rc = snprintf(page, count, "[%Lx - %Lx]\n",
88 * Server side procfs stuff.
91 seq_server_proc_write_space(struct file *file, const char *buffer,
92 unsigned long count, void *data)
94 struct lu_server_seq *seq = (struct lu_server_seq *)data;
101 rc = seq_proc_write_common(file, buffer, count,
102 data, &seq->lss_space);
104 CDEBUG(D_INFO, "%s: Space: "DRANGE"\n",
105 seq->lss_name, PRANGE(&seq->lss_space));
114 seq_server_proc_read_space(char *page, char **start, off_t off,
115 int count, int *eof, void *data)
117 struct lu_server_seq *seq = (struct lu_server_seq *)data;
121 LASSERT(seq != NULL);
124 rc = seq_proc_read_common(page, start, off, count, eof,
125 data, &seq->lss_space);
132 seq_server_proc_read_server(char *page, char **start, off_t off,
133 int count, int *eof, void *data)
135 struct lu_server_seq *seq = (struct lu_server_seq *)data;
136 struct client_obd *cli;
140 LASSERT(seq != NULL);
144 if (seq->lss_cli->lcs_exp != NULL) {
145 cli = &seq->lss_cli->lcs_exp->exp_obd->u.cli;
146 rc = snprintf(page, count, "%s\n",
147 cli->cl_target_uuid.uuid);
149 rc = snprintf(page, count, "%s\n",
150 seq->lss_cli->lcs_srv->lss_name);
153 rc = snprintf(page, count, "<none>\n");
160 seq_server_proc_write_width(struct file *file, const char *buffer,
161 unsigned long count, void *data)
163 struct lu_server_seq *seq = (struct lu_server_seq *)data;
167 LASSERT(seq != NULL);
171 rc = lprocfs_write_helper(buffer, count, &val);
175 seq->lss_width = val;
178 CDEBUG(D_INFO, "%s: Width: "LPU64"\n",
179 seq->lss_name, seq->lss_width);
188 seq_server_proc_read_width(char *page, char **start, off_t off,
189 int count, int *eof, void *data)
191 struct lu_server_seq *seq = (struct lu_server_seq *)data;
195 LASSERT(seq != NULL);
198 rc = snprintf(page, count, LPU64"\n", seq->lss_width);
204 /* Client side procfs stuff */
206 seq_client_proc_write_space(struct file *file, const char *buffer,
207 unsigned long count, void *data)
209 struct lu_client_seq *seq = (struct lu_client_seq *)data;
213 LASSERT(seq != NULL);
216 rc = seq_proc_write_common(file, buffer, count,
217 data, &seq->lcs_space);
220 CDEBUG(D_INFO, "%s: Space: "DRANGE"\n",
221 seq->lcs_name, PRANGE(&seq->lcs_space));
230 seq_client_proc_read_space(char *page, char **start, off_t off,
231 int count, int *eof, void *data)
233 struct lu_client_seq *seq = (struct lu_client_seq *)data;
237 LASSERT(seq != NULL);
240 rc = seq_proc_read_common(page, start, off, count, eof,
241 data, &seq->lcs_space);
248 seq_client_proc_write_width(struct file *file, const char *buffer,
249 unsigned long count, void *data)
251 struct lu_client_seq *seq = (struct lu_client_seq *)data;
255 LASSERT(seq != NULL);
259 rc = lprocfs_write_helper(buffer, count, &val);
263 if (val <= LUSTRE_SEQ_MAX_WIDTH && val > 0) {
264 seq->lcs_width = val;
267 CDEBUG(D_INFO, "%s: Sequence size: "LPU64"\n",
268 seq->lcs_name, seq->lcs_width);
278 seq_client_proc_read_width(char *page, char **start, off_t off,
279 int count, int *eof, void *data)
281 struct lu_client_seq *seq = (struct lu_client_seq *)data;
285 LASSERT(seq != NULL);
288 rc = snprintf(page, count, LPU64"\n", seq->lcs_width);
295 seq_client_proc_read_fid(char *page, char **start, off_t off,
296 int count, int *eof, void *data)
298 struct lu_client_seq *seq = (struct lu_client_seq *)data;
302 LASSERT(seq != NULL);
305 rc = snprintf(page, count, DFID"\n", PFID(&seq->lcs_fid));
312 seq_client_proc_read_server(char *page, char **start, off_t off,
313 int count, int *eof, void *data)
315 struct lu_client_seq *seq = (struct lu_client_seq *)data;
316 struct client_obd *cli;
320 LASSERT(seq != NULL);
322 if (seq->lcs_exp != NULL) {
323 cli = &seq->lcs_exp->exp_obd->u.cli;
324 rc = snprintf(page, count, "%s\n", cli->cl_target_uuid.uuid);
326 rc = snprintf(page, count, "%s\n", seq->lcs_srv->lss_name);
331 struct lprocfs_vars seq_server_proc_list[] = {
332 { "space", seq_server_proc_read_space, seq_server_proc_write_space, NULL },
333 { "width", seq_server_proc_read_width, seq_server_proc_write_width, NULL },
334 { "server", seq_server_proc_read_server, NULL, NULL },
337 struct lprocfs_vars seq_client_proc_list[] = {
338 { "space", seq_client_proc_read_space, seq_client_proc_write_space, NULL },
339 { "width", seq_client_proc_read_width, seq_client_proc_write_width, NULL },
340 { "server", seq_client_proc_read_server, NULL, NULL },
341 { "fid", seq_client_proc_read_fid, NULL, NULL },