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
;
70 LASSERT(range
!= NULL
);
72 rc
= sscanf(buffer
, "[%llx - %llx]\n",
73 (long long unsigned *)&tmp
.lsr_start
,
74 (long long unsigned *)&tmp
.lsr_end
);
75 if (rc
!= 2 || !range_is_sane(&tmp
) || range_is_zero(&tmp
))
81 /* Client side procfs stuff */
83 lprocfs_fid_space_seq_write(struct file
*file
, const char *buffer
,
84 size_t count
, loff_t
*off
)
86 struct lu_client_seq
*seq
= ((struct seq_file
*)file
->private_data
)->private;
92 mutex_lock(&seq
->lcs_mutex
);
93 rc
= lprocfs_fid_write_common(buffer
, count
, &seq
->lcs_space
);
96 CDEBUG(D_INFO
, "%s: Space: "DRANGE
"\n",
97 seq
->lcs_name
, PRANGE(&seq
->lcs_space
));
100 mutex_unlock(&seq
->lcs_mutex
);
106 lprocfs_fid_space_seq_show(struct seq_file
*m
, void *unused
)
108 struct lu_client_seq
*seq
= (struct lu_client_seq
*)m
->private;
112 LASSERT(seq
!= NULL
);
114 mutex_lock(&seq
->lcs_mutex
);
115 rc
= seq_printf(m
, "["LPX64
" - "LPX64
"]:%x:%s\n", PRANGE(&seq
->lcs_space
));
116 mutex_unlock(&seq
->lcs_mutex
);
122 lprocfs_fid_width_seq_write(struct file
*file
, const char *buffer
,
123 size_t count
, loff_t
*off
)
125 struct lu_client_seq
*seq
= ((struct seq_file
*)file
->private_data
)->private;
130 LASSERT(seq
!= NULL
);
132 rc
= lprocfs_write_helper(buffer
, count
, &val
);
136 mutex_lock(&seq
->lcs_mutex
);
137 if (seq
->lcs_type
== LUSTRE_SEQ_DATA
)
138 max
= LUSTRE_DATA_SEQ_MAX_WIDTH
;
140 max
= LUSTRE_METADATA_SEQ_MAX_WIDTH
;
142 if (val
<= max
&& val
> 0) {
143 seq
->lcs_width
= val
;
146 CDEBUG(D_INFO
, "%s: Sequence size: "LPU64
"\n",
147 seq
->lcs_name
, seq
->lcs_width
);
151 mutex_unlock(&seq
->lcs_mutex
);
157 lprocfs_fid_width_seq_show(struct seq_file
*m
, void *unused
)
159 struct lu_client_seq
*seq
= (struct lu_client_seq
*)m
->private;
163 LASSERT(seq
!= NULL
);
165 mutex_lock(&seq
->lcs_mutex
);
166 rc
= seq_printf(m
, LPU64
"\n", seq
->lcs_width
);
167 mutex_unlock(&seq
->lcs_mutex
);
173 lprocfs_fid_fid_seq_show(struct seq_file
*m
, void *unused
)
175 struct lu_client_seq
*seq
= (struct lu_client_seq
*)m
->private;
179 LASSERT(seq
!= NULL
);
181 mutex_lock(&seq
->lcs_mutex
);
182 rc
= seq_printf(m
, DFID
"\n", PFID(&seq
->lcs_fid
));
183 mutex_unlock(&seq
->lcs_mutex
);
189 lprocfs_fid_server_seq_show(struct seq_file
*m
, void *unused
)
191 struct lu_client_seq
*seq
= (struct lu_client_seq
*)m
->private;
192 struct client_obd
*cli
;
196 LASSERT(seq
!= NULL
);
198 if (seq
->lcs_exp
!= NULL
) {
199 cli
= &seq
->lcs_exp
->exp_obd
->u
.cli
;
200 rc
= seq_printf(m
, "%s\n", cli
->cl_target_uuid
.uuid
);
202 rc
= seq_printf(m
, "%s\n", seq
->lcs_srv
->lss_name
);
207 struct lprocfs_vars seq_server_proc_list
[] = {
210 LPROC_SEQ_FOPS(lprocfs_fid_space
);
211 LPROC_SEQ_FOPS(lprocfs_fid_width
);
212 LPROC_SEQ_FOPS_RO(lprocfs_fid_server
);
213 LPROC_SEQ_FOPS_RO(lprocfs_fid_fid
);
215 struct lprocfs_vars seq_client_proc_list
[] = {
216 { "space", &lprocfs_fid_space_fops
},
217 { "width", &lprocfs_fid_width_fops
},
218 { "server", &lprocfs_fid_server_fops
},
219 { "fid", &lprocfs_fid_fid_fops
},