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 "../../include/linux/libcfs/libcfs.h"
46 #include <linux/module.h>
48 #include "../include/obd.h"
49 #include "../include/obd_class.h"
50 #include "../include/dt_object.h"
51 #include "../include/obd_support.h"
52 #include "../include/lustre_req_layout.h"
53 #include "../include/lustre_fid.h"
54 #include "fid_internal.h"
56 /* Format: [0x64BIT_INT - 0x64BIT_INT] + 32 bytes just in case */
57 #define MAX_FID_RANGE_STRLEN (32 + 2 * 2 * sizeof(__u64))
59 * Note: this function is only used for testing, it is no safe for production
63 ldebugfs_fid_write_common(const char __user *buffer, size_t count,
64 struct lu_seq_range *range)
66 struct lu_seq_range tmp;
68 char kernbuf[MAX_FID_RANGE_STRLEN];
70 LASSERT(range != NULL);
72 if (count >= sizeof(kernbuf))
75 if (copy_from_user(kernbuf, buffer, count))
80 if (count == 5 && strcmp(kernbuf, "clear") == 0) {
81 memset(range, 0, sizeof(*range));
85 /* of the form "[0x0000000240000400 - 0x000000028000400]" */
86 rc = sscanf(kernbuf, "[%llx - %llx]\n",
87 (unsigned long long *)&tmp.lsr_start,
88 (unsigned long long *)&tmp.lsr_end);
89 if (!range_is_sane(&tmp) || range_is_zero(&tmp) ||
90 tmp.lsr_start < range->lsr_start || tmp.lsr_end > range->lsr_end)
96 /* Client side debugfs stuff */
98 ldebugfs_fid_space_seq_write(struct file *file,
99 const char __user *buffer,
100 size_t count, loff_t *off)
102 struct lu_client_seq *seq;
105 seq = ((struct seq_file *)file->private_data)->private;
106 LASSERT(seq != NULL);
108 mutex_lock(&seq->lcs_mutex);
109 rc = ldebugfs_fid_write_common(buffer, count, &seq->lcs_space);
112 CDEBUG(D_INFO, "%s: Space: "DRANGE"\n",
113 seq->lcs_name, PRANGE(&seq->lcs_space));
116 mutex_unlock(&seq->lcs_mutex);
122 ldebugfs_fid_space_seq_show(struct seq_file *m, void *unused)
124 struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
126 LASSERT(seq != NULL);
128 mutex_lock(&seq->lcs_mutex);
129 seq_printf(m, "[%#llx - %#llx]:%x:%s\n", PRANGE(&seq->lcs_space));
130 mutex_unlock(&seq->lcs_mutex);
136 ldebugfs_fid_width_seq_write(struct file *file,
137 const char __user *buffer,
138 size_t count, loff_t *off)
140 struct lu_client_seq *seq;
144 seq = ((struct seq_file *)file->private_data)->private;
145 LASSERT(seq != NULL);
147 rc = lprocfs_write_helper(buffer, count, &val);
151 mutex_lock(&seq->lcs_mutex);
152 if (seq->lcs_type == LUSTRE_SEQ_DATA)
153 max = LUSTRE_DATA_SEQ_MAX_WIDTH;
155 max = LUSTRE_METADATA_SEQ_MAX_WIDTH;
157 if (val <= max && val > 0) {
158 seq->lcs_width = val;
160 CDEBUG(D_INFO, "%s: Sequence size: %llu\n", seq->lcs_name,
164 mutex_unlock(&seq->lcs_mutex);
170 ldebugfs_fid_width_seq_show(struct seq_file *m, void *unused)
172 struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
174 LASSERT(seq != NULL);
176 mutex_lock(&seq->lcs_mutex);
177 seq_printf(m, "%llu\n", seq->lcs_width);
178 mutex_unlock(&seq->lcs_mutex);
184 ldebugfs_fid_fid_seq_show(struct seq_file *m, void *unused)
186 struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
188 LASSERT(seq != NULL);
190 mutex_lock(&seq->lcs_mutex);
191 seq_printf(m, DFID "\n", PFID(&seq->lcs_fid));
192 mutex_unlock(&seq->lcs_mutex);
198 ldebugfs_fid_server_seq_show(struct seq_file *m, void *unused)
200 struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
201 struct client_obd *cli;
203 LASSERT(seq != NULL);
205 if (seq->lcs_exp != NULL) {
206 cli = &seq->lcs_exp->exp_obd->u.cli;
207 seq_printf(m, "%s\n", cli->cl_target_uuid.uuid);
209 seq_printf(m, "%s\n", seq->lcs_srv->lss_name);
215 LPROC_SEQ_FOPS(ldebugfs_fid_space);
216 LPROC_SEQ_FOPS(ldebugfs_fid_width);
217 LPROC_SEQ_FOPS_RO(ldebugfs_fid_server);
218 LPROC_SEQ_FOPS_RO(ldebugfs_fid_fid);
220 struct lprocfs_vars seq_client_debugfs_list[] = {
221 { "space", &ldebugfs_fid_space_fops },
222 { "width", &ldebugfs_fid_width_fops },
223 { "server", &ldebugfs_fid_server_fops },
224 { "fid", &ldebugfs_fid_fid_fops },