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) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2011, Whamcloud, Inc.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lustre/osc/osc_create.c
37 * For testing and management it is treated as an obd_device,
38 * although * it does not export a full OBD method table (the
39 * requests are coming * in over the wire, so object target modules
40 * do not have a full * method table.)
42 * Author: Peter Braam <braam@clusterfs.com>
46 # define EXPORT_SYMTAB
48 #define DEBUG_SUBSYSTEM S_OSC
51 # include <libcfs/libcfs.h>
52 #else /* __KERNEL__ */
53 # include <liblustre.h>
60 #include <lustre_dlm.h>
61 #include <obd_class.h>
62 #include "osc_internal.h"
64 /* XXX need AT adjust ? */
65 #define osc_create_timeout (obd_timeout / 2)
67 struct osc_create_async_args {
68 struct osc_creator *rq_oscc;
69 struct lov_stripe_md *rq_lsm;
70 struct obd_info *rq_oinfo;
74 static int oscc_internal_create(struct osc_creator *oscc);
75 static int handle_async_create(struct ptlrpc_request *req, int rc);
77 static int osc_interpret_create(const struct lu_env *env,
78 struct ptlrpc_request *req, void *data, int rc)
80 struct osc_create_async_args *args = ptlrpc_req_async_args(req);
81 struct osc_creator *oscc = args->rq_oscc;
82 struct ost_body *body = NULL;
83 struct ptlrpc_request *fake_req, *pos;
87 body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
88 if (body == NULL && rc == 0)
92 LASSERT(oscc && (oscc->oscc_obd != LP_POISON));
94 cfs_spin_lock(&oscc->oscc_lock);
95 oscc->oscc_flags &= ~OSCC_FLAG_CREATING;
99 int diff =ostid_id(&body->oa.o_oi)- oscc->oscc_last_id;
101 /* oscc_internal_create() stores the original value of
102 * grow_count in osc_create_async_args::rq_grow_count.
103 * We can't compare against oscc_grow_count directly,
104 * because it may have been increased while the RPC
105 * is in flight, so we would always find ourselves
106 * having created fewer objects and decreasing the
107 * precreate request size. b=18577 */
108 if (diff < args->rq_grow_count) {
109 /* the OST has not managed to create all the
110 * objects we asked for */
111 oscc->oscc_grow_count = max(diff,
113 /* don't bump grow_count next time */
114 oscc->oscc_flags |= OSCC_FLAG_LOW;
116 /* the OST is able to keep up with the work,
117 * we could consider increasing grow_count
118 * next time if needed */
119 oscc->oscc_flags &= ~OSCC_FLAG_LOW;
121 oscc->oscc_last_id = ostid_id(&body->oa.o_oi);
123 cfs_spin_unlock(&oscc->oscc_lock);
127 oscc->oscc_flags |= OSCC_FLAG_RDONLY;
131 oscc->oscc_flags |= OSCC_FLAG_NOSPC;
132 if (body && rc == -ENOSPC) {
133 oscc->oscc_last_id = body->oa.o_id;
134 oscc->oscc_grow_count = OST_MIN_PRECREATE;
136 if ((body->oa.o_valid & OBD_MD_FLFLAGS) &&
137 (body->oa.o_flags & OBD_FL_NOSPC_BLK))
138 oscc->oscc_flags |= OSCC_FLAG_NOSPC_BLK;
143 cfs_spin_unlock(&oscc->oscc_lock);
144 DEBUG_REQ(D_INODE, req, "OST out of space, flagging");
147 /* filter always set body->oa.o_id as the last_id
148 * of filter (see filter_handle_precreate for detail)*/
149 if (body && body->oa.o_id > oscc->oscc_last_id)
150 oscc->oscc_last_id = body->oa.o_id;
151 cfs_spin_unlock(&oscc->oscc_lock);
156 /* aka EAGAIN we should not delay create if import failed -
157 * this avoid client stick in create and avoid race with
159 /* EINTR say - old create request is killed due mds<>ost
160 * eviction - OSCC_FLAG_RECOVERING can already set due
161 * IMP_DISCONN event */
162 oscc->oscc_flags |= OSCC_FLAG_RECOVERING;
163 /* oscc->oscc_grow_count = OST_MIN_PRECREATE; */
164 cfs_spin_unlock(&oscc->oscc_lock);
168 oscc->oscc_flags |= OSCC_FLAG_RECOVERING;
169 oscc->oscc_grow_count = OST_MIN_PRECREATE;
170 cfs_spin_unlock(&oscc->oscc_lock);
171 DEBUG_REQ(D_ERROR, req,
172 "Unknown rc %d from async create: failing oscc", rc);
173 ptlrpc_fail_import(req->rq_import,
174 lustre_msg_get_conn_cnt(req->rq_reqmsg));
178 CDEBUG(D_HA, "preallocated through id "LPU64" (next to use "LPU64")\n",
179 oscc->oscc_last_id, oscc->oscc_next_id);
181 cfs_spin_lock(&oscc->oscc_lock);
182 cfs_list_for_each_entry_safe(fake_req, pos,
183 &oscc->oscc_wait_create_list, rq_list) {
184 if (handle_async_create(fake_req, rc) == -EAGAIN) {
185 oscc_internal_create(oscc);
186 /* sending request should be never fail because
187 * osc use preallocated requests pool */
188 GOTO(exit_wakeup, rc);
191 cfs_spin_unlock(&oscc->oscc_lock);
194 cfs_waitq_signal(&oscc->oscc_waitq);
198 static int oscc_internal_create(struct osc_creator *oscc)
200 struct osc_create_async_args *args;
201 struct ptlrpc_request *request;
202 struct ost_body *body;
205 LASSERT_SPIN_LOCKED(&oscc->oscc_lock);
207 /* Do not check for a degraded OST here - bug21563/bug18539 */
208 if (oscc->oscc_flags & OSCC_FLAG_RECOVERING) {
209 cfs_spin_unlock(&oscc->oscc_lock);
213 /* we need check it before OSCC_FLAG_CREATING - because need
214 * see lower number of precreate objects */
215 if (oscc->oscc_grow_count < oscc->oscc_max_grow_count &&
216 ((oscc->oscc_flags & OSCC_FLAG_LOW) == 0) &&
217 (__s64)(oscc->oscc_last_id - oscc->oscc_next_id) <=
218 (oscc->oscc_grow_count / 4 + 1)) {
219 oscc->oscc_flags |= OSCC_FLAG_LOW;
220 oscc->oscc_grow_count *= 2;
223 if (oscc->oscc_flags & OSCC_FLAG_CREATING) {
224 cfs_spin_unlock(&oscc->oscc_lock);
228 if (oscc->oscc_grow_count > oscc->oscc_max_grow_count / 2)
229 oscc->oscc_grow_count = oscc->oscc_max_grow_count / 2;
231 oscc->oscc_flags |= OSCC_FLAG_CREATING;
232 cfs_spin_unlock(&oscc->oscc_lock);
234 request = ptlrpc_request_alloc_pack(oscc->oscc_obd->u.cli.cl_import,
236 LUSTRE_OST_VERSION, OST_CREATE);
237 if (request == NULL) {
238 cfs_spin_lock(&oscc->oscc_lock);
239 oscc->oscc_flags &= ~OSCC_FLAG_CREATING;
240 cfs_spin_unlock(&oscc->oscc_lock);
244 request->rq_request_portal = OST_CREATE_PORTAL;
245 ptlrpc_at_set_req_timeout(request);
246 body = req_capsule_client_get(&request->rq_pill, &RMF_OST_BODY);
247 args = ptlrpc_req_async_args(request);
248 args->rq_oscc = oscc;
250 cfs_spin_lock(&oscc->oscc_lock);
251 args->rq_grow_count = oscc->oscc_grow_count;
253 if (likely(fid_seq_is_mdt(oscc->oscc_oa.o_seq))) {
254 body->oa.o_oi.oi_seq = oscc->oscc_oa.o_seq;
255 body->oa.o_oi.oi_id = oscc->oscc_last_id +
256 oscc->oscc_grow_count;
258 /*Just warning here currently, since not sure how fid-on-ost
259 *will be implemented here */
260 CWARN("o_seq: "LPU64" is not indicate any MDTs.\n",
261 oscc->oscc_oa.o_seq);
263 cfs_spin_unlock(&oscc->oscc_lock);
265 body->oa.o_valid |= OBD_MD_FLID | OBD_MD_FLGROUP;
266 CDEBUG(D_RPCTRACE, "prealloc through id "LPU64" (last seen "LPU64")\n",
267 body->oa.o_id, oscc->oscc_last_id);
269 /* we should not resend create request - anyway we will have delorphan
270 * and kill these objects */
271 request->rq_no_delay = request->rq_no_resend = 1;
272 ptlrpc_request_set_replen(request);
274 request->rq_interpret_reply = osc_interpret_create;
275 ptlrpcd_add_req(request, PDL_POLICY_ROUND, -1);
280 static int oscc_has_objects_nolock(struct osc_creator *oscc, int count)
282 return ((__s64)(oscc->oscc_last_id - oscc->oscc_next_id) >= count);
285 static int oscc_has_objects(struct osc_creator *oscc, int count)
289 cfs_spin_lock(&oscc->oscc_lock);
290 have_objs = oscc_has_objects_nolock(oscc, count);
291 cfs_spin_unlock(&oscc->oscc_lock);
296 static int oscc_wait_for_objects(struct osc_creator *oscc, int count)
301 ost_unusable = oscc->oscc_obd->u.cli.cl_import->imp_invalid;
303 cfs_spin_lock(&oscc->oscc_lock);
304 ost_unusable |= (OSCC_FLAG_NOSPC | OSCC_FLAG_RDONLY |
305 OSCC_FLAG_EXITING) & oscc->oscc_flags;
306 have_objs = oscc_has_objects_nolock(oscc, count);
308 if (!ost_unusable && !have_objs)
309 /* they release lock himself */
310 have_objs = oscc_internal_create(oscc);
312 cfs_spin_unlock(&oscc->oscc_lock);
314 return have_objs || ost_unusable;
317 static int oscc_precreate(struct osc_creator *oscc)
319 struct l_wait_info lwi;
323 if (oscc_has_objects(oscc, oscc->oscc_grow_count / 2))
326 /* we should be not block forever - because client's create rpc can
327 * stick in mds for long time and forbid client reconnect */
328 lwi = LWI_TIMEOUT(cfs_timeout_cap(cfs_time_seconds(osc_create_timeout)),
331 rc = l_wait_event(oscc->oscc_waitq, oscc_wait_for_objects(oscc, 1), &lwi);
335 static int oscc_in_sync(struct osc_creator *oscc)
339 cfs_spin_lock(&oscc->oscc_lock);
340 sync = oscc->oscc_flags & OSCC_FLAG_SYNC_IN_PROGRESS;
341 cfs_spin_unlock(&oscc->oscc_lock);
346 /* decide if the OST has remaining object, return value :
347 0 : the OST has remaining objects, may or may not send precreation RPC.
348 1 : the OST has no remaining object, and the sent precreation RPC
349 has not been completed yet.
350 2 : the OST has no remaining object, and will not get any for
351 a potentially very long time
354 int osc_precreate(struct obd_export *exp)
356 struct osc_creator *oscc = &exp->exp_obd->u.cli.cl_oscc;
357 struct obd_import *imp = exp->exp_imp_reverse;
361 LASSERT(oscc != NULL);
362 if (imp != NULL && imp->imp_deactive)
363 GOTO(out_nolock, rc = 1000);
365 /* Handle critical states first */
366 cfs_spin_lock(&oscc->oscc_lock);
367 if (oscc->oscc_flags & OSCC_FLAG_NOSPC_BLK ||
368 oscc->oscc_flags & OSCC_FLAG_RDONLY ||
369 oscc->oscc_flags & OSCC_FLAG_EXITING)
370 GOTO(out, rc = 1000);
372 if ((oscc->oscc_flags & OSCC_FLAG_RECOVERING) ||
373 (oscc->oscc_flags & OSCC_FLAG_DEGRADED))
376 if (oscc_has_objects_nolock(oscc, oscc->oscc_grow_count / 2))
379 /* Return 0, if we have at least one object - bug 22884 */
380 rc = oscc_has_objects_nolock(oscc, 1) ? 0 : 1;
382 if (oscc->oscc_flags & OSCC_FLAG_NOSPC)
383 GOTO(out, (rc == 0) ? 0 : 1000);
385 /* Do not check for OSCC_FLAG_CREATING flag here, let
386 * osc_precreate() call oscc_internal_create() and
387 * adjust oscc_grow_count bug21563 */
388 if (oscc->oscc_flags & OSCC_FLAG_SYNC_IN_PROGRESS)
391 if (oscc_internal_create(oscc))
392 GOTO(out_nolock, rc = 1000);
396 cfs_spin_unlock(&oscc->oscc_lock);
401 static int handle_async_create(struct ptlrpc_request *req, int rc)
403 struct osc_create_async_args *args = ptlrpc_req_async_args(req);
404 struct osc_creator *oscc = args->rq_oscc;
405 struct lov_stripe_md *lsm = args->rq_lsm;
406 struct obd_info *oinfo = args->rq_oinfo;
407 struct obdo *oa = oinfo->oi_oa;
409 LASSERT_SPIN_LOCKED(&oscc->oscc_lock);
414 /* Handle the critical type errors first.
415 * Should we also test cl_import state as well ? */
416 if (oscc->oscc_flags & OSCC_FLAG_EXITING)
417 GOTO(out_wake, rc = -EIO);
419 if (oscc->oscc_flags & OSCC_FLAG_NOSPC_BLK)
420 GOTO(out_wake, rc = -ENOSPC);
422 if (oscc->oscc_flags & OSCC_FLAG_RDONLY)
423 GOTO(out_wake, rc = -EROFS);
425 /* should be try wait until recovery finished */
426 if((oscc->oscc_flags & OSCC_FLAG_RECOVERING) ||
427 (oscc->oscc_flags & OSCC_FLAG_DEGRADED))
430 if (oscc_has_objects_nolock(oscc, 1)) {
431 memcpy(oa, &oscc->oscc_oa, sizeof(*oa));
432 oa->o_id = oscc->oscc_next_id;
433 lsm->lsm_object_id = oscc->oscc_next_id;
434 oscc->oscc_next_id++;
436 CDEBUG(D_RPCTRACE, " set oscc_next_id = "LPU64"\n",
438 GOTO(out_wake, rc = 0);
441 /* we don't have objects now - continue wait */
446 rc = oinfo->oi_cb_up(oinfo, rc);
447 ptlrpc_fakereq_finished(req);
452 static int async_create_interpret(const struct lu_env *env,
453 struct ptlrpc_request *req, void *data,
456 struct osc_create_async_args *args = ptlrpc_req_async_args(req);
457 struct osc_creator *oscc = args->rq_oscc;
460 cfs_spin_lock(&oscc->oscc_lock);
461 ret = handle_async_create(req, rc);
462 cfs_spin_unlock(&oscc->oscc_lock);
467 int osc_create_async(struct obd_export *exp, struct obd_info *oinfo,
468 struct lov_stripe_md **ea, struct obd_trans_info *oti)
471 struct ptlrpc_request *fake_req;
472 struct osc_create_async_args *args;
473 struct osc_creator *oscc = &exp->exp_obd->u.cli.cl_oscc;
474 struct obdo *oa = oinfo->oi_oa;
477 if ((oa->o_valid & OBD_MD_FLGROUP) && !fid_seq_is_mdt(oa->o_seq)) {
478 rc = osc_real_create(exp, oinfo->oi_oa, ea, oti);
479 rc = oinfo->oi_cb_up(oinfo, rc);
483 if ((oa->o_valid & OBD_MD_FLFLAGS) &&
484 oa->o_flags == OBD_FL_RECREATE_OBJS) {
485 rc = osc_real_create(exp, oinfo->oi_oa, ea, oti);
486 rc = oinfo->oi_cb_up(oinfo, rc);
490 LASSERT((*ea) != NULL);
492 fake_req = ptlrpc_prep_fakereq(oscc->oscc_obd->u.cli.cl_import,
494 async_create_interpret);
495 if (fake_req == NULL) {
496 rc = oinfo->oi_cb_up(oinfo, -ENOMEM);
500 args = ptlrpc_req_async_args(fake_req);
501 CLASSERT(sizeof(*args) <= sizeof(fake_req->rq_async_args));
503 args->rq_oscc = oscc;
505 args->rq_oinfo = oinfo;
507 cfs_spin_lock(&oscc->oscc_lock);
509 rc = handle_async_create(fake_req, 0);
511 /* We don't have any objects, wait until we get a reply. */
512 ptlrpcd_add_req(fake_req, PDL_POLICY_ROUND, -1);
513 cfs_list_add(&fake_req->rq_list,
514 &oscc->oscc_wait_create_list);
515 cfs_spin_unlock(&oscc->oscc_lock);
516 /* EAGAIN mean - request is delayed */
519 cfs_spin_unlock(&oscc->oscc_lock);
520 /* need free request if was error hit or
521 * objects already allocated */
522 ptlrpc_req_finished(fake_req);
528 int osc_create(const struct lu_env *env, struct obd_export *exp,
529 struct obdo *oa, struct lov_stripe_md **ea,
530 struct obd_trans_info *oti)
532 struct osc_creator *oscc = &exp->exp_obd->u.cli.cl_oscc;
533 struct obd_import *imp = exp->exp_obd->u.cli.cl_import;
534 struct lov_stripe_md *lsm;
535 int del_orphan = 0, rc = 0;
540 LASSERT(oa->o_valid & OBD_MD_FLGROUP);
542 if ((oa->o_valid & OBD_MD_FLFLAGS) &&
543 oa->o_flags == OBD_FL_RECREATE_OBJS) {
544 RETURN(osc_real_create(exp, oa, ea, oti));
547 if (!fid_seq_is_mdt(oa->o_seq))
548 RETURN(osc_real_create(exp, oa, ea, oti));
550 /* this is the special case where create removes orphans */
551 if (oa->o_valid & OBD_MD_FLFLAGS &&
552 oa->o_flags == OBD_FL_DELORPHAN) {
553 cfs_spin_lock(&oscc->oscc_lock);
554 if (oscc->oscc_flags & OSCC_FLAG_SYNC_IN_PROGRESS) {
555 cfs_spin_unlock(&oscc->oscc_lock);
558 if (!(oscc->oscc_flags & OSCC_FLAG_RECOVERING)) {
559 cfs_spin_unlock(&oscc->oscc_lock);
563 oscc->oscc_flags |= OSCC_FLAG_SYNC_IN_PROGRESS;
564 /* seting flag LOW we prevent extra grow precreate size
565 * and enforce use last assigned size */
566 oscc->oscc_flags |= OSCC_FLAG_LOW;
567 cfs_spin_unlock(&oscc->oscc_lock);
568 CDEBUG(D_HA, "%s: oscc recovery started - delete to "LPU64"\n",
569 oscc->oscc_obd->obd_name, oscc->oscc_next_id - 1);
573 /* delete from next_id on up */
574 oa->o_valid |= OBD_MD_FLID;
575 oa->o_id = oscc->oscc_next_id - 1;
577 rc = osc_real_create(exp, oa, ea, NULL);
579 cfs_spin_lock(&oscc->oscc_lock);
580 oscc->oscc_flags &= ~OSCC_FLAG_SYNC_IN_PROGRESS;
581 if (rc == 0 || rc == -ENOSPC) {
582 struct obd_connect_data *ocd;
585 oscc->oscc_flags |= OSCC_FLAG_NOSPC;
586 if ((oa->o_valid & OBD_MD_FLFLAGS) &&
587 (oa->o_flags & OBD_FL_NOSPC_BLK))
588 oscc->oscc_flags |= OSCC_FLAG_NOSPC_BLK;
590 oscc->oscc_flags &= ~OSCC_FLAG_RECOVERING;
592 oscc->oscc_last_id = oa->o_id;
593 ocd = &imp->imp_connect_data;
594 if (ocd->ocd_connect_flags & OBD_CONNECT_SKIP_ORPHAN) {
596 * The OST reports back in oa->o_id from where
597 * we should restart in order to skip orphan
600 CDEBUG(D_HA, "%s: Skip orphan set, reset last "
601 "objid\n", oscc->oscc_obd->obd_name);
602 oscc->oscc_next_id = oa->o_id + 1;
605 /* sanity check for next objid. see bug 17025 */
606 LASSERT(oscc->oscc_next_id == oa->o_id + 1);
608 CDEBUG(D_HA, "%s: oscc recovery finished, last_id: "
609 LPU64", rc: %d\n", oscc->oscc_obd->obd_name,
610 oscc->oscc_last_id, rc);
612 CDEBUG(D_ERROR, "%s: oscc recovery failed: %d\n",
613 oscc->oscc_obd->obd_name, rc);
616 cfs_waitq_signal(&oscc->oscc_waitq);
617 cfs_spin_unlock(&oscc->oscc_lock);
625 rc = obd_alloc_memmd(exp, &lsm);
631 if (oscc_in_sync(oscc))
632 CDEBUG(D_HA,"%s: oscc recovery in progress, waiting\n",
633 oscc->oscc_obd->obd_name);
635 rc = oscc_precreate(oscc);
637 CDEBUG(D_HA,"%s: error create %d\n",
638 oscc->oscc_obd->obd_name, rc);
640 cfs_spin_lock(&oscc->oscc_lock);
642 /* wakeup but recovery did not finished */
643 if ((oscc->oscc_obd->u.cli.cl_import->imp_invalid) ||
644 (oscc->oscc_flags & OSCC_FLAG_RECOVERING)) {
646 cfs_spin_unlock(&oscc->oscc_lock);
650 if (oscc->oscc_flags & OSCC_FLAG_NOSPC_BLK) {
652 cfs_spin_unlock(&oscc->oscc_lock);
656 if (oscc->oscc_flags & OSCC_FLAG_RDONLY) {
658 cfs_spin_unlock(&oscc->oscc_lock);
662 // Should we report -EIO error ?
663 if (oscc->oscc_flags & OSCC_FLAG_EXITING) {
664 cfs_spin_unlock(&oscc->oscc_lock);
669 * If this is DELORPHAN process, no need create object here,
670 * otherwise this will create a gap of object id, and MDS
671 * might create some orphan log (mds_lov_update_objids), then
672 * remove objects wrongly on OST. Bug 21379.
674 if (oa->o_valid & OBD_MD_FLFLAGS &&
675 oa->o_flags == OBD_FL_DELORPHAN) {
676 cfs_spin_unlock(&oscc->oscc_lock);
680 if (oscc_has_objects_nolock(oscc, 1)) {
681 memcpy(oa, &oscc->oscc_oa, sizeof(*oa));
682 oa->o_id = oscc->oscc_next_id;
683 lsm->lsm_object_id = oscc->oscc_next_id;
685 oscc->oscc_next_id++;
686 cfs_spin_unlock(&oscc->oscc_lock);
688 CDEBUG(D_RPCTRACE, "%s: set oscc_next_id = "LPU64"\n",
689 exp->exp_obd->obd_name, oscc->oscc_next_id);
693 if (oscc->oscc_flags & OSCC_FLAG_NOSPC) {
695 cfs_spin_unlock(&oscc->oscc_lock);
699 cfs_spin_unlock(&oscc->oscc_lock);
703 CDEBUG(D_INFO, "%s: returning objid "LPU64"\n",
704 obd2cli_tgt(oscc->oscc_obd), lsm->lsm_object_id);
707 obd_free_memmd(exp, &lsm);
708 if (del_orphan != 0 && rc != -EIO)
709 /* Ignore non-IO precreate error for clear orphan */
715 void oscc_init(struct obd_device *obd)
717 struct osc_creator *oscc;
722 oscc = &obd->u.cli.cl_oscc;
724 memset(oscc, 0, sizeof(*oscc));
726 cfs_waitq_init(&oscc->oscc_waitq);
727 cfs_spin_lock_init(&oscc->oscc_lock);
728 oscc->oscc_obd = obd;
729 oscc->oscc_grow_count = OST_MIN_PRECREATE;
730 oscc->oscc_max_grow_count = OST_MAX_PRECREATE;
732 oscc->oscc_next_id = 2;
733 oscc->oscc_last_id = 1;
734 oscc->oscc_flags |= OSCC_FLAG_RECOVERING;
736 CFS_INIT_LIST_HEAD(&oscc->oscc_wait_create_list);
738 /* XXX the export handle should give the oscc the last object */
739 /* oed->oed_oscc.oscc_last_id = exph->....; */
742 void oscc_fini(struct obd_device *obd)
744 struct osc_creator *oscc = &obd->u.cli.cl_oscc;
748 cfs_spin_lock(&oscc->oscc_lock);
749 oscc->oscc_flags &= ~OSCC_FLAG_RECOVERING;
750 oscc->oscc_flags |= OSCC_FLAG_EXITING;
751 cfs_spin_unlock(&oscc->oscc_lock);