static inline int obd_precleanup(struct obd_device *obd)
{
- int rc;
struct lu_device_type *ldt = obd->obd_type->typ_lu;
struct lu_device *d = obd->obd_lu_dev;
+ int rc = -ENOMEM;
ENTRY;
struct lu_env *env = lu_env_find();
struct lu_env _env;
- if (!env) {
+ if (!env && lu_env_init(&_env, ldt->ldt_ctx_tags) == 0) {
env = &_env;
- rc = lu_env_init(env, ldt->ldt_ctx_tags);
- LASSERT(rc == 0);
- lu_env_add(env);
+ rc = lu_env_add(env);
}
ldt->ldt_ops->ldto_device_fini(env, d);
if (env == &_env) {
- lu_env_remove(env);
+ if (rc == 0)
+ lu_env_remove(env);
lu_env_fini(env);
}
}
ENTRY;
+ rc = lu_env_init(&env, LCT_DT_THREAD | LCT_MD_THREAD);
+ if (rc)
+ RETURN(rc);
+ rc = lu_env_add(&env);
+ if (unlikely(rc))
+ GOTO(out_fini, rc);
+
expired_lock_thread_state = ELT_READY;
wake_up(&expired_lock_wait_queue);
have_expired_locks() ||
expired_lock_thread_state == ELT_TERMINATE);
- rc = lu_env_init(&env, LCT_DT_THREAD | LCT_MD_THREAD);
- if (rc) {
- CERROR("can't init env: rc=%d\n", rc);
+ rc = lu_env_refill(&env);
+ if (unlikely(rc)) {
+ CERROR("can't refill env context: rc=%d\n", rc);
schedule_timeout(HZ * 3);
continue;
}
- rc = lu_env_add(&env);
- LASSERT(rc == 0);
spin_lock_bh(&waiting_locks_spinlock);
}
spin_unlock_bh(&waiting_locks_spinlock);
- lu_env_remove(&env);
- lu_env_fini(&env);
-
if (do_dump) {
CERROR("dump the log upon eviction\n");
libcfs_debug_dumplog();
expired_lock_thread_state = ELT_STOPPED;
wake_up(&expired_lock_wait_queue);
- RETURN(0);
+ rc = 0;
+
+ lu_env_remove(&env);
+out_fini:
+ lu_env_fini(&env);
+
+ RETURN(rc);
}
/**
if (rc)
RETURN(rc);
rc = lu_env_add(&env);
- LASSERT(rc == 0);
+ if (unlikely(rc))
+ GOTO(out_fini, rc);
rc = -EINVAL;
switch (cmd) {
}
out:
lu_env_remove(&env);
+out_fini:
lu_env_fini(&env);
RETURN(rc);
}
struct obd_export *doomed_exp;
int exports_evicted = 0;
struct lu_env *env = NULL, _env;
- int rc;
libcfs_strnid(&nid_key, nid);
*/
if (obd->obd_stopping) {
spin_unlock(&obd->obd_dev_lock);
- return exports_evicted;
+ return 0;
}
spin_unlock(&obd->obd_dev_lock);
/* can be called via procfs and from ptlrpc */
env = lu_env_find();
if (env == NULL) {
- rc = lu_env_init(&_env, LCT_DT_THREAD | LCT_MD_THREAD);
+ int rc = lu_env_init(&_env, LCT_DT_THREAD | LCT_MD_THREAD);
+
if (rc)
return rc;
- rc = lu_env_add(&_env);
- LASSERT(rc == 0);
env = &_env;
+ rc = lu_env_add(env);
+ if (unlikely(rc))
+ GOTO(out_fini, exports_evicted = rc);
}
doomed_exp = NULL;
doomed_exp = NULL;
}
+ if (!exports_evicted)
+ CDEBUG(D_HA,
+ "%s: can't disconnect NID '%s': no exports found\n",
+ obd->obd_name, nid);
+
if (env == &_env) {
lu_env_remove(&_env);
+out_fini:
lu_env_fini(&_env);
}
- if (!exports_evicted)
- CDEBUG(D_HA,
- "%s: can't disconnect NID '%s': no exports found\n",
- obd->obd_name, nid);
return exports_evicted;
}
EXPORT_SYMBOL(obd_export_evict_by_nid);
{
struct obd_export *doomed_exp = NULL;
struct obd_uuid doomed_uuid;
- int exports_evicted = 0;
struct lu_env env;
- int rc;
+ int rc = 0;
spin_lock(&obd->obd_dev_lock);
if (obd->obd_stopping) {
spin_unlock(&obd->obd_dev_lock);
- return exports_evicted;
+ return 0;
}
spin_unlock(&obd->obd_dev_lock);
obd_str2uuid(&doomed_uuid, uuid);
if (obd_uuid_equals(&doomed_uuid, &obd->obd_uuid)) {
CERROR("%s: can't evict myself\n", obd->obd_name);
- return exports_evicted;
+ return 0;
}
rc = lu_env_init(&env, LCT_DT_THREAD | LCT_MD_THREAD);
if (rc)
return rc;
rc = lu_env_add(&env);
- LASSERT(rc == 0);
+ if (unlikely(rc))
+ goto out_fini;
doomed_exp = obd_uuid_lookup(obd, &doomed_uuid);
class_fail_export(doomed_exp);
class_export_put(doomed_exp);
obd_uuid_del(obd, doomed_exp);
- exports_evicted++;
+ rc = 1;
}
lu_env_remove(&env);
+out_fini:
lu_env_fini(&env);
- return exports_evicted;
+ return rc;
}
#endif /* HAVE_SERVER_SUPPORT */
rc = lu_env_init(&_env, LCT_DT_THREAD | LCT_MD_THREAD);
if (rc)
RETURN(rc);
+ env = &_env;
rc = lu_env_add(&_env);
if (unlikely(rc))
- RETURN(rc);
- env = &_env;
+ GOTO(out_fini, rc);
}
lti = llog_info(env);
out_env:
if (env == &_env) {
lu_env_remove(&_env);
+out_fini:
lu_env_fini(&_env);
}
if (IS_ERR(env))
RETURN(PTR_ERR(env));
- lu_env_add(env);
+ rc = lu_env_add(env);
+ if (rc)
+ GOTO(out_put, rc);
#ifdef HAVE_SERVER_SUPPORT
if (cmd == OBD_IOC_ECHO_MD || cmd == OBD_IOC_ECHO_ALLOC_SEQ)
EXIT;
out:
lu_env_remove(env);
+out_put:
cl_env_put(env, &refcheck);
return rc;
RETURN(rc);
}
rc = lu_env_add(&env);
- LASSERT(rc == 0);
+ if (unlikely(rc))
+ GOTO(out_fini, rc);
again:
ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT);
atomic_read(&d->opd_sync_rpcs_in_flight),
list_empty(&d->opd_sync_committed_there) ? "" : "!");
- lu_env_remove(&env);
- lu_env_fini(&env);
-
if (xchg(&d->opd_sync_task, NULL) == NULL)
/* already being waited for */
wait_event_interruptible(d->opd_sync_waitq,
kthread_should_stop());
+
+ /* caller will delete args when non-zero is returned here */
OBD_FREE_PTR(args);
+ rc = 0;
- RETURN(0);
+ lu_env_remove(&env);
+out_fini:
+ lu_env_fini(&env);
+
+ RETURN(rc);
}
/**
int rc;
ENTRY;
+
+ rc = lu_env_init(&env, LCT_DT_THREAD | LCT_MD_THREAD);
+ if (rc) {
+ CERROR("can't init env: rc=%d\n", rc);
+ RETURN(rc);
+ }
+ rc = lu_env_add(&env);
+ if (unlikely(rc))
+ GOTO(out_fini, rc);
+
unshare_fs_struct();
CDEBUG(D_HA, "Starting Ping Evictor\n");
pet_state = PET_READY;
if ((pet_state == PET_TERMINATE) && list_empty(&pet_list))
break;
- rc = lu_env_init(&env, LCT_DT_THREAD | LCT_MD_THREAD);
- if (rc) {
- CERROR("can't init env: rc=%d\n", rc);
+ rc = lu_env_refill(&env);
+ if (unlikely(rc)) {
+ CERROR("can't refill env context: rc=%d\n", rc);
schedule_timeout(HZ * 3);
continue;
}
- rc = lu_env_add(&env);
- LASSERT(rc == 0);
/*
* we only get here if pet_exp != NULL, and the end of this
}
spin_unlock(&obd->obd_dev_lock);
- lu_env_remove(&env);
- lu_env_fini(&env);
-
spin_lock(&pet_lock);
list_del_init(&obd->obd_evict_list);
spin_unlock(&pet_lock);
}
CDEBUG(D_HA, "Exiting Ping Evictor\n");
- RETURN(0);
+ lu_env_remove(&env);
+out_fini:
+ lu_env_fini(&env);
+
+ RETURN(rc);
}
void ping_evictor_start(void)
GOTO(out, rc);
}
rc = lu_env_add(&env);
- LASSERT(rc == 0);
+ if (unlikely(rc))
+ GOTO(out_fini, rc);
/* Stop the target */
if (!test_bit(LMD_FLG_NOSVC, lsi->lsi_lmd->lmd_flags) &&
}
lu_env_remove(&env);
+out_fini:
lu_env_fini(&env);
out: