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 * Server side procfs stuff.
77 seq_proc_read_common(char *page, char **start, off_t off,
78 int count, int *eof, void *data,
79 struct lu_range *range)
85 rc = snprintf(page, count, DRANGE"]\n",
91 seq_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_WARNING, "%s: Sequences space has "
105 "changed to "DRANGE"\n", seq->lss_name,
106 PRANGE(&seq->lss_space));
115 seq_proc_read_space(char *page, char **start, off_t off,
116 int count, int *eof, void *data)
118 struct lu_server_seq *seq = (struct lu_server_seq *)data;
122 LASSERT(seq != NULL);
125 rc = seq_proc_read_common(page, start, off, count, eof,
126 data, &seq->lss_space);
133 seq_proc_write_super(struct file *file, const char *buffer,
134 unsigned long count, void *data)
136 struct lu_server_seq *seq = (struct lu_server_seq *)data;
140 LASSERT(seq != NULL);
143 rc = seq_proc_write_common(file, buffer, count,
144 data, &seq->lss_super);
147 CDEBUG(D_WARNING, "%s: Super has changed to "
148 DRANGE"\n", seq->lss_name, PRANGE(&seq->lss_super));
157 seq_proc_read_super(char *page, char **start, off_t off,
158 int count, int *eof, void *data)
160 struct lu_server_seq *seq = (struct lu_server_seq *)data;
164 LASSERT(seq != NULL);
167 rc = seq_proc_read_common(page, start, off, count, eof,
168 data, &seq->lss_super);
175 seq_proc_read_controller(char *page, char **start, off_t off,
176 int count, int *eof, void *data)
178 struct lu_server_seq *seq = (struct lu_server_seq *)data;
182 LASSERT(seq != NULL);
186 struct obd_export *exp = seq->lss_cli->lcs_exp;
188 rc = snprintf(page, count, "%s\n",
189 exp->exp_client_uuid.uuid);
191 rc = snprintf(page, count, "<not assigned>\n");
198 seq_proc_write_super_width(struct file *file, const char *buffer,
199 unsigned long count, void *data)
201 struct lu_server_seq *seq = (struct lu_server_seq *)data;
205 LASSERT(seq != NULL);
209 rc = lprocfs_write_helper(buffer, count, &val);
213 seq->lss_super_width = val;
216 CDEBUG(D_WARNING, "%s: Super width has changed to "
217 LPU64"\n", seq->lss_name, seq->lss_super_width);
226 seq_proc_read_super_width(char *page, char **start, off_t off,
227 int count, int *eof, void *data)
229 struct lu_server_seq *seq = (struct lu_server_seq *)data;
233 LASSERT(seq != NULL);
236 rc = snprintf(page, count, LPU64"\n", seq->lss_super_width);
243 seq_proc_write_meta_width(struct file *file, const char *buffer,
244 unsigned long count, void *data)
246 struct lu_server_seq *seq = (struct lu_server_seq *)data;
250 LASSERT(seq != NULL);
254 rc = lprocfs_write_helper(buffer, count, &val);
258 if (val <= seq->lss_super_width) {
259 seq->lss_meta_width = val;
262 CDEBUG(D_WARNING, "%s: Meta width has changed to "
263 LPU64"\n", seq->lss_name, seq->lss_meta_width);
272 seq_proc_read_meta_width(char *page, char **start, off_t off,
273 int count, int *eof, void *data)
275 struct lu_server_seq *seq = (struct lu_server_seq *)data;
279 LASSERT(seq != NULL);
282 rc = snprintf(page, count, LPU64"\n", seq->lss_meta_width);
288 /* client side procfs stuff */
290 seq_proc_write_range(struct file *file, const char *buffer,
291 unsigned long count, void *data)
293 struct lu_client_seq *seq = (struct lu_client_seq *)data;
297 LASSERT(seq != NULL);
300 rc = seq_proc_write_common(file, buffer, count,
301 data, &seq->lcs_range);
304 CDEBUG(D_WARNING, "%s: Range has changed to "
305 DRANGE"\n", seq->lcs_name, PRANGE(&seq->lcs_range));
314 seq_proc_read_range(char *page, char **start, off_t off,
315 int count, int *eof, void *data)
317 struct lu_client_seq *seq = (struct lu_client_seq *)data;
321 LASSERT(seq != NULL);
324 rc = seq_proc_read_common(page, start, off, count, eof,
325 data, &seq->lcs_range);
332 seq_proc_write_seq_width(struct file *file, const char *buffer,
333 unsigned long count, void *data)
335 struct lu_client_seq *seq = (struct lu_client_seq *)data;
339 LASSERT(seq != NULL);
343 rc = lprocfs_write_helper(buffer, count, &val);
347 if (val <= LUSTRE_SEQ_MAX_WIDTH && val > 0) {
348 seq->lcs_width = val;
351 CDEBUG(D_WARNING, "%s: Sequence width "
352 "has changed to "LPU64"\n",
353 seq->lcs_name, seq->lcs_width);
363 seq_proc_read_seq_width(char *page, char **start, off_t off,
364 int count, int *eof, void *data)
366 struct lu_client_seq *seq = (struct lu_client_seq *)data;
370 LASSERT(seq != NULL);
373 rc = snprintf(page, count, LPU64"\n", seq->lcs_width);
380 seq_proc_read_next_fid(char *page, char **start, off_t off,
381 int count, int *eof, void *data)
383 struct lu_client_seq *seq = (struct lu_client_seq *)data;
387 LASSERT(seq != NULL);
390 rc = snprintf(page, count, DFID"\n", PFID(&seq->lcs_fid));
397 seq_proc_read_server(char *page, char **start, off_t off,
398 int count, int *eof, void *data)
400 struct lu_client_seq *seq = (struct lu_client_seq *)data;
401 struct client_obd *cli = &seq->lcs_exp->exp_obd->u.cli;
405 LASSERT(seq != NULL);
406 rc = snprintf(page, count, "%s\n",
407 cli->cl_target_uuid.uuid);
411 struct lprocfs_vars seq_server_proc_list[] = {
412 { "space", seq_proc_read_space, seq_proc_write_space, NULL },
413 { "super", seq_proc_read_super, seq_proc_write_super, NULL },
414 { "controller", seq_proc_read_controller, NULL, NULL },
415 { "super_width", seq_proc_read_super_width, seq_proc_write_super_width, NULL },
416 { "meta_width", seq_proc_read_meta_width, seq_proc_write_meta_width, NULL },
419 struct lprocfs_vars seq_client_proc_list[] = {
420 { "range", seq_proc_read_range, seq_proc_write_range, NULL },
421 { "server", seq_proc_read_server, NULL, NULL },
422 { "next_fid" , seq_proc_read_next_fid, NULL, NULL },
423 { "seq_width", seq_proc_read_seq_width, seq_proc_write_seq_width, NULL },