blob: edd72b926f811217fda4558024d43004eea034cc [file] [log] [blame]
Peng Taod7e09d02013-05-02 16:46:55 +08001/*
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
Oleg Drokin6a5b99a2016-06-14 23:33:40 -040018 * http://www.gnu.org/licenses/gpl-2.0.html
Peng Taod7e09d02013-05-02 16:46:55 +080019 *
Peng Taod7e09d02013-05-02 16:46:55 +080020 * GPL HEADER END
21 */
22/*
23 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
25 *
Andreas Dilger1dc563a2015-11-08 18:09:37 -050026 * Copyright (c) 2011, 2015, Intel Corporation.
Peng Taod7e09d02013-05-02 16:46:55 +080027 */
28/*
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
31 *
32 * lustre/fid/fid_request.c
33 *
34 * Lustre Sequence Manager
35 *
36 * Author: Yury Umanets <umka@clusterfs.com>
37 */
38
39#define DEBUG_SUBSYSTEM S_FID
40
Greg Kroah-Hartman9fdaf8c2014-07-11 20:51:16 -070041#include "../../include/linux/libcfs/libcfs.h"
Liu Xuezhao56f4c5a2013-07-23 00:06:44 +080042#include <linux/module.h>
Peng Taod7e09d02013-05-02 16:46:55 +080043
Greg Kroah-Hartman61566392014-07-11 21:50:29 -070044#include "../include/obd.h"
45#include "../include/obd_class.h"
46#include "../include/obd_support.h"
47#include "../include/lustre_fid.h"
Peng Taod7e09d02013-05-02 16:46:55 +080048/* mdc RPC locks */
Greg Kroah-Hartman61566392014-07-11 21:50:29 -070049#include "../include/lustre_mdc.h"
Peng Taod7e09d02013-05-02 16:46:55 +080050#include "fid_internal.h"
51
Dmitry Ereminf3aa79f2015-05-21 15:32:25 -040052static struct dentry *seq_debugfs_dir;
53
Peng Taod7e09d02013-05-02 16:46:55 +080054static int seq_client_rpc(struct lu_client_seq *seq,
55 struct lu_seq_range *output, __u32 opc,
56 const char *opcname)
57{
58 struct obd_export *exp = seq->lcs_exp;
59 struct ptlrpc_request *req;
60 struct lu_seq_range *out, *in;
Liu Xuezhao56f4c5a2013-07-23 00:06:44 +080061 __u32 *op;
62 unsigned int debug_mask;
63 int rc;
Peng Taod7e09d02013-05-02 16:46:55 +080064
wang dib78c2b9b2016-04-28 12:07:34 -040065 LASSERT(exp && !IS_ERR(exp));
Peng Taod7e09d02013-05-02 16:46:55 +080066 req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_SEQ_QUERY,
67 LUSTRE_MDS_VERSION, SEQ_QUERY);
Oleg Drokin6a9f7482016-02-16 00:46:49 -050068 if (!req)
Greg Kroah-Hartman0a3bdb02013-08-03 10:35:28 +080069 return -ENOMEM;
Peng Taod7e09d02013-05-02 16:46:55 +080070
71 /* Init operation code */
72 op = req_capsule_client_get(&req->rq_pill, &RMF_SEQ_OPC);
73 *op = opc;
74
75 /* Zero out input range, this is not recovery yet. */
76 in = req_capsule_client_get(&req->rq_pill, &RMF_SEQ_RANGE);
77 range_init(in);
78
79 ptlrpc_request_set_replen(req);
80
81 in->lsr_index = seq->lcs_space.lsr_index;
82 if (seq->lcs_type == LUSTRE_SEQ_METADATA)
83 fld_range_set_mdt(in);
84 else
85 fld_range_set_ost(in);
86
87 if (opc == SEQ_ALLOC_SUPER) {
88 req->rq_request_portal = SEQ_CONTROLLER_PORTAL;
89 req->rq_reply_portal = MDC_REPLY_PORTAL;
90 /* During allocating super sequence for data object,
91 * the current thread might hold the export of MDT0(MDT0
92 * precreating objects on this OST), and it will send the
93 * request to MDT0 here, so we can not keep resending the
94 * request here, otherwise if MDT0 is failed(umounted),
Oleg Drokindd28ea02016-02-24 22:00:27 -050095 * it can not release the export of MDT0
96 */
Nathaniel Clarka30dd802016-06-09 22:35:12 -040097 if (seq->lcs_type == LUSTRE_SEQ_DATA) {
98 req->rq_no_delay = 1;
99 req->rq_no_resend = 1;
100 }
Peng Taod7e09d02013-05-02 16:46:55 +0800101 debug_mask = D_CONSOLE;
102 } else {
wang diebde64c2016-05-04 10:28:59 -0400103 if (seq->lcs_type == LUSTRE_SEQ_METADATA) {
104 req->rq_reply_portal = MDC_REPLY_PORTAL;
Peng Taod7e09d02013-05-02 16:46:55 +0800105 req->rq_request_portal = SEQ_METADATA_PORTAL;
wang diebde64c2016-05-04 10:28:59 -0400106 } else {
107 req->rq_reply_portal = OSC_REPLY_PORTAL;
Peng Taod7e09d02013-05-02 16:46:55 +0800108 req->rq_request_portal = SEQ_DATA_PORTAL;
wang diebde64c2016-05-04 10:28:59 -0400109 }
Peng Taod7e09d02013-05-02 16:46:55 +0800110 debug_mask = D_INFO;
111 }
112
113 ptlrpc_at_set_req_timeout(req);
114
wang dib78c2b9b2016-04-28 12:07:34 -0400115 if (opc != SEQ_ALLOC_SUPER && seq->lcs_type == LUSTRE_SEQ_METADATA)
Peng Taod7e09d02013-05-02 16:46:55 +0800116 mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
117 rc = ptlrpc_queue_wait(req);
wang dib78c2b9b2016-04-28 12:07:34 -0400118 if (opc != SEQ_ALLOC_SUPER && seq->lcs_type == LUSTRE_SEQ_METADATA)
Peng Taod7e09d02013-05-02 16:46:55 +0800119 mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
120 if (rc)
Julia Lawall89180ca2014-08-30 16:41:23 +0200121 goto out_req;
Peng Taod7e09d02013-05-02 16:46:55 +0800122
123 out = req_capsule_server_get(&req->rq_pill, &RMF_SEQ_RANGE);
124 *output = *out;
125
126 if (!range_is_sane(output)) {
127 CERROR("%s: Invalid range received from server: "
Rehas Sachdevab9aabfc2016-09-15 18:20:31 +0530128 DRANGE "\n", seq->lcs_name, PRANGE(output));
Julia Lawall89180ca2014-08-30 16:41:23 +0200129 rc = -EINVAL;
130 goto out_req;
Peng Taod7e09d02013-05-02 16:46:55 +0800131 }
132
133 if (range_is_exhausted(output)) {
134 CERROR("%s: Range received from server is exhausted: "
Rehas Sachdevab9aabfc2016-09-15 18:20:31 +0530135 DRANGE "]\n", seq->lcs_name, PRANGE(output));
Julia Lawall89180ca2014-08-30 16:41:23 +0200136 rc = -EINVAL;
137 goto out_req;
Peng Taod7e09d02013-05-02 16:46:55 +0800138 }
139
Rehas Sachdevab9aabfc2016-09-15 18:20:31 +0530140 CDEBUG_LIMIT(debug_mask, "%s: Allocated %s-sequence " DRANGE "]\n",
Peng Taod7e09d02013-05-02 16:46:55 +0800141 seq->lcs_name, opcname, PRANGE(output));
142
Peng Taod7e09d02013-05-02 16:46:55 +0800143out_req:
144 ptlrpc_req_finished(req);
145 return rc;
146}
147
Peng Taod7e09d02013-05-02 16:46:55 +0800148/* Request sequence-controller node to allocate new meta-sequence. */
149static int seq_client_alloc_meta(const struct lu_env *env,
150 struct lu_client_seq *seq)
151{
152 int rc;
Peng Taod7e09d02013-05-02 16:46:55 +0800153
Oleg Drokinf4f84072015-09-28 23:44:06 -0400154 do {
155 /* If meta server return -EINPROGRESS or EAGAIN,
156 * it means meta server might not be ready to
157 * allocate super sequence from sequence controller
Oleg Drokindd28ea02016-02-24 22:00:27 -0500158 * (MDT0)yet
159 */
Oleg Drokinf4f84072015-09-28 23:44:06 -0400160 rc = seq_client_rpc(seq, &seq->lcs_space,
161 SEQ_ALLOC_META, "meta");
162 } while (rc == -EINPROGRESS || rc == -EAGAIN);
Liu Xuezhao56f4c5a2013-07-23 00:06:44 +0800163
Greg Kroah-Hartman0a3bdb02013-08-03 10:35:28 +0800164 return rc;
Peng Taod7e09d02013-05-02 16:46:55 +0800165}
166
167/* Allocate new sequence for client. */
168static int seq_client_alloc_seq(const struct lu_env *env,
Oleg Drokin114acca2014-08-15 12:55:55 -0400169 struct lu_client_seq *seq, u64 *seqnr)
Peng Taod7e09d02013-05-02 16:46:55 +0800170{
171 int rc;
Peng Taod7e09d02013-05-02 16:46:55 +0800172
173 LASSERT(range_is_sane(&seq->lcs_space));
174
175 if (range_is_exhausted(&seq->lcs_space)) {
176 rc = seq_client_alloc_meta(env, seq);
177 if (rc) {
Gary Rookard5cbcd112014-03-10 21:21:22 -0400178 CERROR("%s: Can't allocate new meta-sequence, rc %d\n",
Greg Kroah-Hartman913827e2014-07-12 01:09:15 -0700179 seq->lcs_name, rc);
Greg Kroah-Hartman0a3bdb02013-08-03 10:35:28 +0800180 return rc;
Peng Taod7e09d02013-05-02 16:46:55 +0800181 }
Rehas Sachdevab9aabfc2016-09-15 18:20:31 +0530182 CDEBUG(D_INFO, "%s: New range - " DRANGE "\n",
Antonio Murdaca71e8dd92015-06-08 21:48:41 +0200183 seq->lcs_name, PRANGE(&seq->lcs_space));
Peng Taod7e09d02013-05-02 16:46:55 +0800184 } else {
185 rc = 0;
186 }
187
188 LASSERT(!range_is_exhausted(&seq->lcs_space));
189 *seqnr = seq->lcs_space.lsr_start;
190 seq->lcs_space.lsr_start += 1;
191
Greg Kroah-Hartman55f5a822014-07-12 20:26:07 -0700192 CDEBUG(D_INFO, "%s: Allocated sequence [%#llx]\n", seq->lcs_name,
Peng Taod7e09d02013-05-02 16:46:55 +0800193 *seqnr);
194
Greg Kroah-Hartman0a3bdb02013-08-03 10:35:28 +0800195 return rc;
Peng Taod7e09d02013-05-02 16:46:55 +0800196}
197
198static int seq_fid_alloc_prep(struct lu_client_seq *seq,
199 wait_queue_t *link)
200{
201 if (seq->lcs_update) {
202 add_wait_queue(&seq->lcs_waitq, link);
203 set_current_state(TASK_UNINTERRUPTIBLE);
204 mutex_unlock(&seq->lcs_mutex);
205
Peng Taob3669a72014-03-18 21:05:53 +0800206 schedule();
Peng Taod7e09d02013-05-02 16:46:55 +0800207
208 mutex_lock(&seq->lcs_mutex);
209 remove_wait_queue(&seq->lcs_waitq, link);
210 set_current_state(TASK_RUNNING);
211 return -EAGAIN;
212 }
213 ++seq->lcs_update;
214 mutex_unlock(&seq->lcs_mutex);
215 return 0;
216}
217
218static void seq_fid_alloc_fini(struct lu_client_seq *seq)
219{
220 LASSERT(seq->lcs_update == 1);
221 mutex_lock(&seq->lcs_mutex);
222 --seq->lcs_update;
223 wake_up(&seq->lcs_waitq);
224}
225
Peng Taod7e09d02013-05-02 16:46:55 +0800226/* Allocate new fid on passed client @seq and save it to @fid. */
227int seq_client_alloc_fid(const struct lu_env *env,
228 struct lu_client_seq *seq, struct lu_fid *fid)
229{
230 wait_queue_t link;
231 int rc;
Peng Taod7e09d02013-05-02 16:46:55 +0800232
Oleg Drokin6a9f7482016-02-16 00:46:49 -0500233 LASSERT(seq);
234 LASSERT(fid);
Peng Taod7e09d02013-05-02 16:46:55 +0800235
Peng Tao9e795d32014-03-18 21:05:52 +0800236 init_waitqueue_entry(&link, current);
Peng Taod7e09d02013-05-02 16:46:55 +0800237 mutex_lock(&seq->lcs_mutex);
238
239 if (OBD_FAIL_CHECK(OBD_FAIL_SEQ_EXHAUST))
240 seq->lcs_fid.f_oid = seq->lcs_width;
241
242 while (1) {
Oleg Drokin114acca2014-08-15 12:55:55 -0400243 u64 seqnr;
Peng Taod7e09d02013-05-02 16:46:55 +0800244
245 if (!fid_is_zero(&seq->lcs_fid) &&
246 fid_oid(&seq->lcs_fid) < seq->lcs_width) {
247 /* Just bump last allocated fid and return to caller. */
248 seq->lcs_fid.f_oid += 1;
249 rc = 0;
250 break;
251 }
252
253 rc = seq_fid_alloc_prep(seq, &link);
254 if (rc)
255 continue;
256
257 rc = seq_client_alloc_seq(env, seq, &seqnr);
258 if (rc) {
Gary Rookard5cbcd112014-03-10 21:21:22 -0400259 CERROR("%s: Can't allocate new sequence, rc %d\n",
Greg Kroah-Hartman913827e2014-07-12 01:09:15 -0700260 seq->lcs_name, rc);
Peng Taod7e09d02013-05-02 16:46:55 +0800261 seq_fid_alloc_fini(seq);
262 mutex_unlock(&seq->lcs_mutex);
Greg Kroah-Hartman0a3bdb02013-08-03 10:35:28 +0800263 return rc;
Peng Taod7e09d02013-05-02 16:46:55 +0800264 }
265
Greg Kroah-Hartman143f3782014-07-12 18:23:18 -0700266 CDEBUG(D_INFO, "%s: Switch to sequence [0x%16.16Lx]\n",
Greg Kroah-Hartman913827e2014-07-12 01:09:15 -0700267 seq->lcs_name, seqnr);
Peng Taod7e09d02013-05-02 16:46:55 +0800268
269 seq->lcs_fid.f_oid = LUSTRE_FID_INIT_OID;
270 seq->lcs_fid.f_seq = seqnr;
271 seq->lcs_fid.f_ver = 0;
272
273 /*
274 * Inform caller that sequence switch is performed to allow it
275 * to setup FLD for it.
276 */
277 rc = 1;
278
279 seq_fid_alloc_fini(seq);
280 break;
281 }
282
283 *fid = seq->lcs_fid;
284 mutex_unlock(&seq->lcs_mutex);
285
286 CDEBUG(D_INFO, "%s: Allocated FID "DFID"\n", seq->lcs_name, PFID(fid));
Greg Kroah-Hartman0a3bdb02013-08-03 10:35:28 +0800287 return rc;
Peng Taod7e09d02013-05-02 16:46:55 +0800288}
289EXPORT_SYMBOL(seq_client_alloc_fid);
290
291/*
292 * Finish the current sequence due to disconnect.
293 * See mdc_import_event()
294 */
295void seq_client_flush(struct lu_client_seq *seq)
296{
297 wait_queue_t link;
298
Oleg Drokin6a9f7482016-02-16 00:46:49 -0500299 LASSERT(seq);
Peng Tao9e795d32014-03-18 21:05:52 +0800300 init_waitqueue_entry(&link, current);
Peng Taod7e09d02013-05-02 16:46:55 +0800301 mutex_lock(&seq->lcs_mutex);
302
303 while (seq->lcs_update) {
304 add_wait_queue(&seq->lcs_waitq, &link);
305 set_current_state(TASK_UNINTERRUPTIBLE);
306 mutex_unlock(&seq->lcs_mutex);
307
Peng Taob3669a72014-03-18 21:05:53 +0800308 schedule();
Peng Taod7e09d02013-05-02 16:46:55 +0800309
310 mutex_lock(&seq->lcs_mutex);
311 remove_wait_queue(&seq->lcs_waitq, &link);
312 set_current_state(TASK_RUNNING);
313 }
314
315 fid_zero(&seq->lcs_fid);
316 /**
317 * this id shld not be used for seq range allocation.
318 * set to -1 for dgb check.
319 */
320
321 seq->lcs_space.lsr_index = -1;
322
323 range_init(&seq->lcs_space);
324 mutex_unlock(&seq->lcs_mutex);
325}
326EXPORT_SYMBOL(seq_client_flush);
327
Dmitry Ereminf3aa79f2015-05-21 15:32:25 -0400328static void seq_client_debugfs_fini(struct lu_client_seq *seq)
Liu Xuezhao56f4c5a2013-07-23 00:06:44 +0800329{
Dmitry Ereminf3aa79f2015-05-21 15:32:25 -0400330 if (!IS_ERR_OR_NULL(seq->lcs_debugfs_entry))
331 ldebugfs_remove(&seq->lcs_debugfs_entry);
Liu Xuezhao56f4c5a2013-07-23 00:06:44 +0800332}
333
Dmitry Ereminf3aa79f2015-05-21 15:32:25 -0400334static int seq_client_debugfs_init(struct lu_client_seq *seq)
Peng Taod7e09d02013-05-02 16:46:55 +0800335{
336 int rc;
Peng Taod7e09d02013-05-02 16:46:55 +0800337
Dmitry Ereminf3aa79f2015-05-21 15:32:25 -0400338 seq->lcs_debugfs_entry = ldebugfs_register(seq->lcs_name,
339 seq_debugfs_dir,
340 NULL, NULL);
Peng Taod7e09d02013-05-02 16:46:55 +0800341
Dmitry Ereminf3aa79f2015-05-21 15:32:25 -0400342 if (IS_ERR_OR_NULL(seq->lcs_debugfs_entry)) {
343 CERROR("%s: LdebugFS failed in seq-init\n", seq->lcs_name);
344 rc = seq->lcs_debugfs_entry ? PTR_ERR(seq->lcs_debugfs_entry)
345 : -ENOMEM;
346 seq->lcs_debugfs_entry = NULL;
Greg Kroah-Hartman0a3bdb02013-08-03 10:35:28 +0800347 return rc;
Peng Taod7e09d02013-05-02 16:46:55 +0800348 }
349
Dmitry Ereminf3aa79f2015-05-21 15:32:25 -0400350 rc = ldebugfs_add_vars(seq->lcs_debugfs_entry,
351 seq_client_debugfs_list, seq);
Peng Taod7e09d02013-05-02 16:46:55 +0800352 if (rc) {
Dmitry Ereminf3aa79f2015-05-21 15:32:25 -0400353 CERROR("%s: Can't init sequence manager debugfs, rc %d\n",
Greg Kroah-Hartman913827e2014-07-12 01:09:15 -0700354 seq->lcs_name, rc);
Julia Lawall89180ca2014-08-30 16:41:23 +0200355 goto out_cleanup;
Peng Taod7e09d02013-05-02 16:46:55 +0800356 }
357
Greg Kroah-Hartman0a3bdb02013-08-03 10:35:28 +0800358 return 0;
Peng Taod7e09d02013-05-02 16:46:55 +0800359
360out_cleanup:
Dmitry Ereminf3aa79f2015-05-21 15:32:25 -0400361 seq_client_debugfs_fini(seq);
Peng Taod7e09d02013-05-02 16:46:55 +0800362 return rc;
Liu Xuezhao56f4c5a2013-07-23 00:06:44 +0800363}
Peng Taod7e09d02013-05-02 16:46:55 +0800364
Oleg Drokin065749e2015-09-28 23:44:04 -0400365static void seq_client_fini(struct lu_client_seq *seq)
366{
367 seq_client_debugfs_fini(seq);
368
369 if (seq->lcs_exp) {
370 class_export_put(seq->lcs_exp);
371 seq->lcs_exp = NULL;
372 }
Oleg Drokin065749e2015-09-28 23:44:04 -0400373}
374
375static int seq_client_init(struct lu_client_seq *seq,
376 struct obd_export *exp,
377 enum lu_cli_type type,
378 const char *prefix)
Peng Taod7e09d02013-05-02 16:46:55 +0800379{
380 int rc;
Peng Taod7e09d02013-05-02 16:46:55 +0800381
Oleg Drokin6a9f7482016-02-16 00:46:49 -0500382 LASSERT(seq);
383 LASSERT(prefix);
Peng Taod7e09d02013-05-02 16:46:55 +0800384
Peng Taod7e09d02013-05-02 16:46:55 +0800385 seq->lcs_type = type;
386
387 mutex_init(&seq->lcs_mutex);
388 if (type == LUSTRE_SEQ_METADATA)
389 seq->lcs_width = LUSTRE_METADATA_SEQ_MAX_WIDTH;
390 else
391 seq->lcs_width = LUSTRE_DATA_SEQ_MAX_WIDTH;
392
393 init_waitqueue_head(&seq->lcs_waitq);
394 /* Make sure that things are clear before work is started. */
395 seq_client_flush(seq);
396
Oleg Drokinf4f84072015-09-28 23:44:06 -0400397 seq->lcs_exp = class_export_get(exp);
Peng Taod7e09d02013-05-02 16:46:55 +0800398
399 snprintf(seq->lcs_name, sizeof(seq->lcs_name),
400 "cli-%s", prefix);
401
Dmitry Ereminf3aa79f2015-05-21 15:32:25 -0400402 rc = seq_client_debugfs_init(seq);
Peng Taod7e09d02013-05-02 16:46:55 +0800403 if (rc)
404 seq_client_fini(seq);
Greg Kroah-Hartman0a3bdb02013-08-03 10:35:28 +0800405 return rc;
Peng Taod7e09d02013-05-02 16:46:55 +0800406}
Liu Xuezhao56f4c5a2013-07-23 00:06:44 +0800407
408int client_fid_init(struct obd_device *obd,
409 struct obd_export *exp, enum lu_cli_type type)
410{
411 struct client_obd *cli = &obd->u.cli;
412 char *prefix;
413 int rc;
Liu Xuezhao56f4c5a2013-07-23 00:06:44 +0800414
Julia Lawall5a564742015-05-01 17:51:22 +0200415 cli->cl_seq = kzalloc(sizeof(*cli->cl_seq), GFP_NOFS);
Julia Lawall6c7c6552015-06-20 18:58:59 +0200416 if (!cli->cl_seq)
Greg Kroah-Hartman0a3bdb02013-08-03 10:35:28 +0800417 return -ENOMEM;
Liu Xuezhao56f4c5a2013-07-23 00:06:44 +0800418
Julia Lawall5a564742015-05-01 17:51:22 +0200419 prefix = kzalloc(MAX_OBD_NAME + 5, GFP_NOFS);
Julia Lawall6c7c6552015-06-20 18:58:59 +0200420 if (!prefix) {
Julia Lawall89180ca2014-08-30 16:41:23 +0200421 rc = -ENOMEM;
422 goto out_free_seq;
423 }
Liu Xuezhao56f4c5a2013-07-23 00:06:44 +0800424
425 snprintf(prefix, MAX_OBD_NAME + 5, "cli-%s", obd->obd_name);
426
427 /* Init client side sequence-manager */
Oleg Drokin065749e2015-09-28 23:44:04 -0400428 rc = seq_client_init(cli->cl_seq, exp, type, prefix);
Julia Lawall5a564742015-05-01 17:51:22 +0200429 kfree(prefix);
Liu Xuezhao56f4c5a2013-07-23 00:06:44 +0800430 if (rc)
Julia Lawall89180ca2014-08-30 16:41:23 +0200431 goto out_free_seq;
Liu Xuezhao56f4c5a2013-07-23 00:06:44 +0800432
Greg Kroah-Hartman0a3bdb02013-08-03 10:35:28 +0800433 return rc;
Liu Xuezhao56f4c5a2013-07-23 00:06:44 +0800434out_free_seq:
Julia Lawall5a564742015-05-01 17:51:22 +0200435 kfree(cli->cl_seq);
Liu Xuezhao56f4c5a2013-07-23 00:06:44 +0800436 cli->cl_seq = NULL;
437 return rc;
438}
439EXPORT_SYMBOL(client_fid_init);
440
441int client_fid_fini(struct obd_device *obd)
442{
443 struct client_obd *cli = &obd->u.cli;
Liu Xuezhao56f4c5a2013-07-23 00:06:44 +0800444
Oleg Drokin6a9f7482016-02-16 00:46:49 -0500445 if (cli->cl_seq) {
Liu Xuezhao56f4c5a2013-07-23 00:06:44 +0800446 seq_client_fini(cli->cl_seq);
Julia Lawall5a564742015-05-01 17:51:22 +0200447 kfree(cli->cl_seq);
Liu Xuezhao56f4c5a2013-07-23 00:06:44 +0800448 cli->cl_seq = NULL;
449 }
450
Greg Kroah-Hartman0a3bdb02013-08-03 10:35:28 +0800451 return 0;
Liu Xuezhao56f4c5a2013-07-23 00:06:44 +0800452}
453EXPORT_SYMBOL(client_fid_fini);
454
Andreas Dilgere0f94112016-02-26 11:36:05 -0500455static int __init fid_init(void)
Liu Xuezhao56f4c5a2013-07-23 00:06:44 +0800456{
Dmitry Ereminf3aa79f2015-05-21 15:32:25 -0400457 seq_debugfs_dir = ldebugfs_register(LUSTRE_SEQ_NAME,
458 debugfs_lustre_root,
459 NULL, NULL);
460 return PTR_ERR_OR_ZERO(seq_debugfs_dir);
Liu Xuezhao56f4c5a2013-07-23 00:06:44 +0800461}
462
Andreas Dilgere0f94112016-02-26 11:36:05 -0500463static void __exit fid_exit(void)
Liu Xuezhao56f4c5a2013-07-23 00:06:44 +0800464{
Dmitry Ereminf3aa79f2015-05-21 15:32:25 -0400465 if (!IS_ERR_OR_NULL(seq_debugfs_dir))
466 ldebugfs_remove(&seq_debugfs_dir);
Liu Xuezhao56f4c5a2013-07-23 00:06:44 +0800467}
468
James Simmonsa0455472015-11-04 13:40:02 -0500469MODULE_AUTHOR("OpenSFS, Inc. <http://www.lustre.org/>");
Andreas Dilger57878e12016-02-26 11:36:04 -0500470MODULE_DESCRIPTION("Lustre File IDentifier");
James Simmons5b0e50b2016-02-26 11:36:03 -0500471MODULE_VERSION(LUSTRE_VERSION_STRING);
Liu Xuezhao56f4c5a2013-07-23 00:06:44 +0800472MODULE_LICENSE("GPL");
473
Andreas Dilgere0f94112016-02-26 11:36:05 -0500474module_init(fid_init);
475module_exit(fid_exit);