1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see [sun.com URL with a
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lustre/fid/lproc_fid.c
38 * Lustre Sequence Manager
40 * Author: Yury Umanets <umka@clusterfs.com>
44 # define EXPORT_SYMTAB
46 #define DEBUG_SUBSYSTEM S_FID
49 # include <libcfs/libcfs.h>
50 # include <linux/module.h>
51 #else /* __KERNEL__ */
52 # include <liblustre.h>
56 #include <obd_class.h>
57 #include <dt_object.h>
58 #include <md_object.h>
59 #include <obd_support.h>
60 #include <lustre_req_layout.h>
61 #include <lustre_fid.h>
62 #include "fid_internal.h"
66 * Note: this function is only used for testing, it is no safe for production
70 seq_proc_write_common(struct file *file, const char *buffer,
71 unsigned long count, void *data,
72 struct lu_range *range)
78 LASSERT(range != NULL);
80 rc = sscanf(buffer, "[%Lx - %Lx]\n", &tmp.lr_start, &tmp.lr_end);
81 if (rc != 2 || !range_is_sane(&tmp) || range_is_zero(&tmp))
88 seq_proc_read_common(char *page, char **start, off_t off,
89 int count, int *eof, void *data,
90 struct lu_range *range)
96 rc = snprintf(page, count, "[%Lx - %Lx]\n",
102 * Server side procfs stuff.
105 seq_server_proc_write_space(struct file *file, const char *buffer,
106 unsigned long count, void *data)
108 struct lu_server_seq *seq = (struct lu_server_seq *)data;
112 LASSERT(seq != NULL);
115 rc = seq_proc_write_common(file, buffer, count,
116 data, &seq->lss_space);
118 CDEBUG(D_INFO, "%s: Space: "DRANGE"\n",
119 seq->lss_name, PRANGE(&seq->lss_space));
128 seq_server_proc_read_space(char *page, char **start, off_t off,
129 int count, int *eof, void *data)
131 struct lu_server_seq *seq = (struct lu_server_seq *)data;
135 LASSERT(seq != NULL);
138 rc = seq_proc_read_common(page, start, off, count, eof,
139 data, &seq->lss_space);
146 seq_server_proc_read_server(char *page, char **start, off_t off,
147 int count, int *eof, void *data)
149 struct lu_server_seq *seq = (struct lu_server_seq *)data;
150 struct client_obd *cli;
154 LASSERT(seq != NULL);
158 if (seq->lss_cli->lcs_exp != NULL) {
159 cli = &seq->lss_cli->lcs_exp->exp_obd->u.cli;
160 rc = snprintf(page, count, "%s\n",
161 cli->cl_target_uuid.uuid);
163 rc = snprintf(page, count, "%s\n",
164 seq->lss_cli->lcs_srv->lss_name);
167 rc = snprintf(page, count, "<none>\n");
174 seq_server_proc_write_width(struct file *file, const char *buffer,
175 unsigned long count, void *data)
177 struct lu_server_seq *seq = (struct lu_server_seq *)data;
181 LASSERT(seq != NULL);
185 rc = lprocfs_write_helper(buffer, count, &val);
189 seq->lss_width = val;
192 CDEBUG(D_INFO, "%s: Width: "LPU64"\n",
193 seq->lss_name, seq->lss_width);
202 seq_server_proc_read_width(char *page, char **start, off_t off,
203 int count, int *eof, void *data)
205 struct lu_server_seq *seq = (struct lu_server_seq *)data;
209 LASSERT(seq != NULL);
212 rc = snprintf(page, count, LPU64"\n", seq->lss_width);
218 /* Client side procfs stuff */
220 seq_client_proc_write_space(struct file *file, const char *buffer,
221 unsigned long count, void *data)
223 struct lu_client_seq *seq = (struct lu_client_seq *)data;
227 LASSERT(seq != NULL);
230 rc = seq_proc_write_common(file, buffer, count,
231 data, &seq->lcs_space);
234 CDEBUG(D_INFO, "%s: Space: "DRANGE"\n",
235 seq->lcs_name, PRANGE(&seq->lcs_space));
244 seq_client_proc_read_space(char *page, char **start, off_t off,
245 int count, int *eof, void *data)
247 struct lu_client_seq *seq = (struct lu_client_seq *)data;
251 LASSERT(seq != NULL);
254 rc = seq_proc_read_common(page, start, off, count, eof,
255 data, &seq->lcs_space);
262 seq_client_proc_write_width(struct file *file, const char *buffer,
263 unsigned long count, void *data)
265 struct lu_client_seq *seq = (struct lu_client_seq *)data;
269 LASSERT(seq != NULL);
273 rc = lprocfs_write_helper(buffer, count, &val);
277 if (val <= LUSTRE_SEQ_MAX_WIDTH && val > 0) {
278 seq->lcs_width = val;
281 CDEBUG(D_INFO, "%s: Sequence size: "LPU64"\n",
282 seq->lcs_name, seq->lcs_width);
292 seq_client_proc_read_width(char *page, char **start, off_t off,
293 int count, int *eof, void *data)
295 struct lu_client_seq *seq = (struct lu_client_seq *)data;
299 LASSERT(seq != NULL);
302 rc = snprintf(page, count, LPU64"\n", seq->lcs_width);
309 seq_client_proc_read_fid(char *page, char **start, off_t off,
310 int count, int *eof, void *data)
312 struct lu_client_seq *seq = (struct lu_client_seq *)data;
316 LASSERT(seq != NULL);
319 rc = snprintf(page, count, DFID"\n", PFID(&seq->lcs_fid));
326 seq_client_proc_read_server(char *page, char **start, off_t off,
327 int count, int *eof, void *data)
329 struct lu_client_seq *seq = (struct lu_client_seq *)data;
330 struct client_obd *cli;
334 LASSERT(seq != NULL);
336 if (seq->lcs_exp != NULL) {
337 cli = &seq->lcs_exp->exp_obd->u.cli;
338 rc = snprintf(page, count, "%s\n", cli->cl_target_uuid.uuid);
340 rc = snprintf(page, count, "%s\n", seq->lcs_srv->lss_name);
345 struct lprocfs_vars seq_server_proc_list[] = {
346 { "space", seq_server_proc_read_space, seq_server_proc_write_space, NULL },
347 { "width", seq_server_proc_read_width, seq_server_proc_write_width, NULL },
348 { "server", seq_server_proc_read_server, NULL, NULL },
351 struct lprocfs_vars seq_client_proc_list[] = {
352 { "space", seq_client_proc_read_space, seq_client_proc_write_space, NULL },
353 { "width", seq_client_proc_read_width, seq_client_proc_write_width, NULL },
354 { "server", seq_client_proc_read_server, NULL, NULL },
355 { "fid", seq_client_proc_read_fid, NULL, NULL },