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.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2011, 2015, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
32 * lustre/fid/lproc_fid.c
34 * Lustre Sequence Manager
36 * Author: Yury Umanets <umka@clusterfs.com>
39 #define DEBUG_SUBSYSTEM S_FID
41 #include <linux/libcfs/libcfs.h>
42 #include <linux/module.h>
45 #include <obd_class.h>
46 #include <obd_support.h>
47 #include <lustre_req_layout.h>
48 #include <lustre_fid.h>
49 #include "fid_internal.h"
51 /* Format: [0x64BIT_INT - 0x64BIT_INT] + 32 bytes just in case */
52 #define MAX_FID_RANGE_STRLEN (32 + 2 * 2 * sizeof(__u64))
54 * Note: this function is only used for testing, it is no safe for production
58 ldebugfs_fid_write_common(const char __user *buffer, size_t count,
59 struct lu_seq_range *range)
61 struct lu_seq_range tmp;
63 char kernbuf[MAX_FID_RANGE_STRLEN];
67 if (count >= sizeof(kernbuf))
70 if (copy_from_user(kernbuf, buffer, count))
75 if (count == 5 && strcmp(kernbuf, "clear") == 0) {
76 memset(range, 0, sizeof(*range));
80 /* of the form "[0x0000000240000400 - 0x000000028000400]" */
81 rc = sscanf(kernbuf, "[%llx - %llx]\n",
82 (unsigned long long *)&tmp.lsr_start,
83 (unsigned long long *)&tmp.lsr_end);
86 if (!lu_seq_range_is_sane(&tmp) || lu_seq_range_is_zero(&tmp) ||
87 tmp.lsr_start < range->lsr_start || tmp.lsr_end > range->lsr_end)
93 /* Client side debugfs stuff */
95 ldebugfs_fid_space_seq_write(struct file *file,
96 const char __user *buffer,
97 size_t count, loff_t *off)
99 struct lu_client_seq *seq;
102 seq = ((struct seq_file *)file->private_data)->private;
104 mutex_lock(&seq->lcs_mutex);
105 rc = ldebugfs_fid_write_common(buffer, count, &seq->lcs_space);
108 CDEBUG(D_INFO, "%s: Space: " DRANGE "\n",
109 seq->lcs_name, PRANGE(&seq->lcs_space));
112 mutex_unlock(&seq->lcs_mutex);
118 ldebugfs_fid_space_seq_show(struct seq_file *m, void *unused)
120 struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
122 mutex_lock(&seq->lcs_mutex);
123 seq_printf(m, "[%#llx - %#llx]:%x:%s\n", PRANGE(&seq->lcs_space));
124 mutex_unlock(&seq->lcs_mutex);
130 ldebugfs_fid_width_seq_write(struct file *file,
131 const char __user *buffer,
132 size_t count, loff_t *off)
134 struct lu_client_seq *seq;
138 seq = ((struct seq_file *)file->private_data)->private;
140 rc = lprocfs_write_helper(buffer, count, &val);
144 mutex_lock(&seq->lcs_mutex);
145 if (seq->lcs_type == LUSTRE_SEQ_DATA)
146 max = LUSTRE_DATA_SEQ_MAX_WIDTH;
148 max = LUSTRE_METADATA_SEQ_MAX_WIDTH;
150 if (val <= max && val > 0) {
151 seq->lcs_width = val;
153 CDEBUG(D_INFO, "%s: Sequence size: %llu\n", seq->lcs_name,
157 mutex_unlock(&seq->lcs_mutex);
163 ldebugfs_fid_width_seq_show(struct seq_file *m, void *unused)
165 struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
167 mutex_lock(&seq->lcs_mutex);
168 seq_printf(m, "%llu\n", seq->lcs_width);
169 mutex_unlock(&seq->lcs_mutex);
175 ldebugfs_fid_fid_seq_show(struct seq_file *m, void *unused)
177 struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
179 mutex_lock(&seq->lcs_mutex);
180 seq_printf(m, DFID "\n", PFID(&seq->lcs_fid));
181 mutex_unlock(&seq->lcs_mutex);
187 ldebugfs_fid_server_seq_show(struct seq_file *m, void *unused)
189 struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
190 struct client_obd *cli;
193 cli = &seq->lcs_exp->exp_obd->u.cli;
194 seq_printf(m, "%s\n", cli->cl_target_uuid.uuid);
200 LPROC_SEQ_FOPS(ldebugfs_fid_space);
201 LPROC_SEQ_FOPS(ldebugfs_fid_width);
202 LPROC_SEQ_FOPS_RO(ldebugfs_fid_server);
203 LPROC_SEQ_FOPS_RO(ldebugfs_fid_fid);
205 struct lprocfs_vars seq_client_debugfs_list[] = {
207 .fops = &ldebugfs_fid_space_fops },
209 .fops = &ldebugfs_fid_width_fops },
211 .fops = &ldebugfs_fid_server_fops },
213 .fops = &ldebugfs_fid_fid_fops },