staging: lustre: fid: remove ccflags from Makefile
[deliverable/linux.git] / drivers / staging / lustre / lustre / fid / lproc_fid.c
CommitLineData
d7e09d03
PT
1/*
2 * GPL HEADER START
3 *
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
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.
9 *
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).
15 *
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
19 *
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
22 * have any questions.
23 *
24 * GPL HEADER END
25 */
26/*
27 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
29 *
30 * Copyright (c) 2011, 2012, Intel Corporation.
31 */
32/*
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
35 *
36 * lustre/fid/lproc_fid.c
37 *
38 * Lustre Sequence Manager
39 *
40 * Author: Yury Umanets <umka@clusterfs.com>
41 */
42
43#define DEBUG_SUBSYSTEM S_FID
44
9fdaf8c0
GKH
45#include "../../include/linux/libcfs/libcfs.h"
46#include <linux/module.h>
d7e09d03 47
61566391
GKH
48#include "../include/obd.h"
49#include "../include/obd_class.h"
50#include "../include/dt_object.h"
51#include "../include/md_object.h"
52#include "../include/obd_support.h"
53#include "../include/lustre_req_layout.h"
54#include "../include/lustre_fid.h"
d7e09d03
PT
55#include "fid_internal.h"
56
a1e7e2d4
OD
57/* Format: [0x64BIT_INT - 0x64BIT_INT] + 32 bytes just in case */
58#define MAX_FID_RANGE_STRLEN (32 + 2 * 2 * sizeof(__u64))
d7e09d03
PT
59/*
60 * Note: this function is only used for testing, it is no safe for production
61 * use.
62 */
a1e7e2d4
OD
63static int lprocfs_fid_write_common(const char __user *buffer, size_t count,
64 struct lu_seq_range *range)
d7e09d03
PT
65{
66 struct lu_seq_range tmp;
67 int rc;
a1e7e2d4 68 char kernbuf[MAX_FID_RANGE_STRLEN];
d7e09d03
PT
69
70 LASSERT(range != NULL);
71
a1e7e2d4
OD
72 if (count >= sizeof(kernbuf))
73 return -EINVAL;
74
75 if (copy_from_user(kernbuf, buffer, count))
76 return -EFAULT;
77
78 kernbuf[count] = 0;
79
80 if (count == 5 && strcmp(kernbuf, "clear") == 0) {
81 memset(range, 0, sizeof(*range));
82 return count;
83 }
84
85 /* of the form "[0x0000000240000400 - 0x000000028000400]" */
86 rc = sscanf(kernbuf, "[%llx - %llx]\n",
d7e09d03
PT
87 (long long unsigned *)&tmp.lsr_start,
88 (long long unsigned *)&tmp.lsr_end);
a1e7e2d4
OD
89 if (!range_is_sane(&tmp) || range_is_zero(&tmp) ||
90 tmp.lsr_start < range->lsr_start || tmp.lsr_end > range->lsr_end)
0a3bdb00 91 return -EINVAL;
d7e09d03 92 *range = tmp;
a1e7e2d4 93 return count;
d7e09d03
PT
94}
95
d7e09d03 96/* Client side procfs stuff */
a1e7e2d4
OD
97static ssize_t lprocfs_fid_space_seq_write(struct file *file,
98 const char __user *buffer,
99 size_t count, loff_t *off)
d7e09d03 100{
d1acbe57 101 struct lu_client_seq *seq;
d7e09d03 102 int rc;
d7e09d03 103
d1acbe57 104 seq = ((struct seq_file *)file->private_data)->private;
d7e09d03
PT
105 LASSERT(seq != NULL);
106
107 mutex_lock(&seq->lcs_mutex);
73bb1da6 108 rc = lprocfs_fid_write_common(buffer, count, &seq->lcs_space);
d7e09d03
PT
109
110 if (rc == 0) {
111 CDEBUG(D_INFO, "%s: Space: "DRANGE"\n",
112 seq->lcs_name, PRANGE(&seq->lcs_space));
113 }
114
115 mutex_unlock(&seq->lcs_mutex);
116
0a3bdb00 117 return count;
d7e09d03
PT
118}
119
120static int
73bb1da6 121lprocfs_fid_space_seq_show(struct seq_file *m, void *unused)
d7e09d03 122{
73bb1da6 123 struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
d7e09d03 124 int rc;
d7e09d03
PT
125
126 LASSERT(seq != NULL);
127
128 mutex_lock(&seq->lcs_mutex);
73bb1da6 129 rc = seq_printf(m, "["LPX64" - "LPX64"]:%x:%s\n", PRANGE(&seq->lcs_space));
d7e09d03
PT
130 mutex_unlock(&seq->lcs_mutex);
131
0a3bdb00 132 return rc;
d7e09d03
PT
133}
134
a1e7e2d4
OD
135static ssize_t lprocfs_fid_width_seq_write(struct file *file,
136 const char __user *buffer,
137 size_t count, loff_t *off)
d7e09d03 138{
d1acbe57 139 struct lu_client_seq *seq;
d7e09d03
PT
140 __u64 max;
141 int rc, val;
d7e09d03 142
d1acbe57 143 seq = ((struct seq_file *)file->private_data)->private;
d7e09d03
PT
144 LASSERT(seq != NULL);
145
d7e09d03 146 rc = lprocfs_write_helper(buffer, count, &val);
73bb1da6 147 if (rc)
0a3bdb00 148 return rc;
d7e09d03 149
73bb1da6 150 mutex_lock(&seq->lcs_mutex);
d7e09d03
PT
151 if (seq->lcs_type == LUSTRE_SEQ_DATA)
152 max = LUSTRE_DATA_SEQ_MAX_WIDTH;
153 else
154 max = LUSTRE_METADATA_SEQ_MAX_WIDTH;
155
156 if (val <= max && val > 0) {
157 seq->lcs_width = val;
158
159 if (rc == 0) {
160 CDEBUG(D_INFO, "%s: Sequence size: "LPU64"\n",
161 seq->lcs_name, seq->lcs_width);
162 }
163 }
164
165 mutex_unlock(&seq->lcs_mutex);
166
0a3bdb00 167 return count;
d7e09d03
PT
168}
169
170static int
73bb1da6 171lprocfs_fid_width_seq_show(struct seq_file *m, void *unused)
d7e09d03 172{
73bb1da6 173 struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
d7e09d03 174 int rc;
d7e09d03
PT
175
176 LASSERT(seq != NULL);
177
178 mutex_lock(&seq->lcs_mutex);
73bb1da6 179 rc = seq_printf(m, LPU64"\n", seq->lcs_width);
d7e09d03
PT
180 mutex_unlock(&seq->lcs_mutex);
181
0a3bdb00 182 return rc;
d7e09d03
PT
183}
184
185static int
73bb1da6 186lprocfs_fid_fid_seq_show(struct seq_file *m, void *unused)
d7e09d03 187{
73bb1da6 188 struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
d7e09d03 189 int rc;
d7e09d03
PT
190
191 LASSERT(seq != NULL);
192
193 mutex_lock(&seq->lcs_mutex);
73bb1da6 194 rc = seq_printf(m, DFID"\n", PFID(&seq->lcs_fid));
d7e09d03
PT
195 mutex_unlock(&seq->lcs_mutex);
196
0a3bdb00 197 return rc;
d7e09d03
PT
198}
199
200static int
73bb1da6 201lprocfs_fid_server_seq_show(struct seq_file *m, void *unused)
d7e09d03 202{
73bb1da6 203 struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
d7e09d03
PT
204 struct client_obd *cli;
205 int rc;
d7e09d03
PT
206
207 LASSERT(seq != NULL);
208
209 if (seq->lcs_exp != NULL) {
210 cli = &seq->lcs_exp->exp_obd->u.cli;
73bb1da6 211 rc = seq_printf(m, "%s\n", cli->cl_target_uuid.uuid);
d7e09d03 212 } else {
73bb1da6 213 rc = seq_printf(m, "%s\n", seq->lcs_srv->lss_name);
d7e09d03 214 }
0a3bdb00 215 return rc;
d7e09d03
PT
216}
217
73bb1da6
PT
218LPROC_SEQ_FOPS(lprocfs_fid_space);
219LPROC_SEQ_FOPS(lprocfs_fid_width);
220LPROC_SEQ_FOPS_RO(lprocfs_fid_server);
221LPROC_SEQ_FOPS_RO(lprocfs_fid_fid);
d7e09d03
PT
222
223struct lprocfs_vars seq_client_proc_list[] = {
73bb1da6
PT
224 { "space", &lprocfs_fid_space_fops },
225 { "width", &lprocfs_fid_width_fops },
226 { "server", &lprocfs_fid_server_fops },
227 { "fid", &lprocfs_fid_fid_fops },
228 { NULL }
229};
This page took 0.309579 seconds and 5 git commands to generate.