4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2011, 2012, Intel Corporation.
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>
43 #define DEBUG_SUBSYSTEM S_FID
45 # include <linux/libcfs/libcfs.h>
46 # include <linux/module.h>
49 #include <obd_class.h>
50 #include <dt_object.h>
51 #include <md_object.h>
52 #include <obd_support.h>
53 #include <lustre_req_layout.h>
54 #include <lustre_fid.h>
55 #include "fid_internal.h"
59 * Note: this function is only used for testing, it is no safe for production
63 lprocfs_fid_write_common(const char *buffer, unsigned long count,
64 struct lu_seq_range *range)
66 struct lu_seq_range tmp;
69 LASSERT(range != NULL);
71 rc = sscanf(buffer, "[%llx - %llx]\n",
72 (long long unsigned *)&tmp.lsr_start,
73 (long long unsigned *)&tmp.lsr_end);
74 if (rc != 2 || !range_is_sane(&tmp) || range_is_zero(&tmp))
80 /* Client side procfs stuff */
82 lprocfs_fid_space_seq_write(struct file *file, const char *buffer,
83 size_t count, loff_t *off)
85 struct lu_client_seq *seq = ((struct seq_file *)file->private_data)->private;
90 mutex_lock(&seq->lcs_mutex);
91 rc = lprocfs_fid_write_common(buffer, count, &seq->lcs_space);
94 CDEBUG(D_INFO, "%s: Space: "DRANGE"\n",
95 seq->lcs_name, PRANGE(&seq->lcs_space));
98 mutex_unlock(&seq->lcs_mutex);
104 lprocfs_fid_space_seq_show(struct seq_file *m, void *unused)
106 struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
109 LASSERT(seq != NULL);
111 mutex_lock(&seq->lcs_mutex);
112 rc = seq_printf(m, "["LPX64" - "LPX64"]:%x:%s\n", PRANGE(&seq->lcs_space));
113 mutex_unlock(&seq->lcs_mutex);
119 lprocfs_fid_width_seq_write(struct file *file, const char *buffer,
120 size_t count, loff_t *off)
122 struct lu_client_seq *seq = ((struct seq_file *)file->private_data)->private;
126 LASSERT(seq != NULL);
128 rc = lprocfs_write_helper(buffer, count, &val);
132 mutex_lock(&seq->lcs_mutex);
133 if (seq->lcs_type == LUSTRE_SEQ_DATA)
134 max = LUSTRE_DATA_SEQ_MAX_WIDTH;
136 max = LUSTRE_METADATA_SEQ_MAX_WIDTH;
138 if (val <= max && val > 0) {
139 seq->lcs_width = val;
142 CDEBUG(D_INFO, "%s: Sequence size: "LPU64"\n",
143 seq->lcs_name, seq->lcs_width);
147 mutex_unlock(&seq->lcs_mutex);
153 lprocfs_fid_width_seq_show(struct seq_file *m, void *unused)
155 struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
158 LASSERT(seq != NULL);
160 mutex_lock(&seq->lcs_mutex);
161 rc = seq_printf(m, LPU64"\n", seq->lcs_width);
162 mutex_unlock(&seq->lcs_mutex);
168 lprocfs_fid_fid_seq_show(struct seq_file *m, void *unused)
170 struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
173 LASSERT(seq != NULL);
175 mutex_lock(&seq->lcs_mutex);
176 rc = seq_printf(m, DFID"\n", PFID(&seq->lcs_fid));
177 mutex_unlock(&seq->lcs_mutex);
183 lprocfs_fid_server_seq_show(struct seq_file *m, void *unused)
185 struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
186 struct client_obd *cli;
189 LASSERT(seq != NULL);
191 if (seq->lcs_exp != NULL) {
192 cli = &seq->lcs_exp->exp_obd->u.cli;
193 rc = seq_printf(m, "%s\n", cli->cl_target_uuid.uuid);
195 rc = seq_printf(m, "%s\n", seq->lcs_srv->lss_name);
200 LPROC_SEQ_FOPS(lprocfs_fid_space);
201 LPROC_SEQ_FOPS(lprocfs_fid_width);
202 LPROC_SEQ_FOPS_RO(lprocfs_fid_server);
203 LPROC_SEQ_FOPS_RO(lprocfs_fid_fid);
205 struct lprocfs_vars seq_client_proc_list[] = {
206 { "space", &lprocfs_fid_space_fops },
207 { "width", &lprocfs_fid_width_fops },
208 { "server", &lprocfs_fid_server_fops },
209 { "fid", &lprocfs_fid_fid_fops },