/* on success, pack lvb in reply */
lvb = req_capsule_server_get(&req->rq_pill, &RMF_DLM_LVB);
lvb_len = ldlm_lvbo_size(*lockp);
- lvb_len = ldlm_lvbo_fill(*lockp, lvb, lvb_len);
+ lvb_len = ldlm_lvbo_fill(*lockp, lvb, &lvb_len);
if (lvb_len < 0)
GOTO(out, rc = lvb_len);
struct lu_env *env;
struct qmt_thread_info *qti;
struct qmt_device *qmt = lu2qmt_dev(ld);
- int pool_id, pool_type, qtype;
+ int pool_type, qtype;
int rc;
ENTRY;
res->lr_name.name[LUSTRE_RES_ID_SEQ_OFF] != FID_SEQ_QUOTA_GLB)
RETURN(0);
- OBD_ALLOC_PTR(env);
- if (env == NULL)
- RETURN(-ENOMEM);
-
- /* initialize environment */
- rc = lu_env_init(env, LCT_MD_THREAD);
- if (rc != 0)
- GOTO(out_free, rc);
+ env = lu_env_find();
+ LASSERT(env);
qti = qmt_info(env);
/* extract global index FID and quota identifier */
fid_extract_from_quota_res(&qti->qti_fid, &qti->qti_id, &res->lr_name);
/* sanity check the global index FID */
- rc = lquota_extract_fid(&qti->qti_fid, &pool_id, &pool_type, &qtype);
+ rc = lquota_extract_fid(&qti->qti_fid, &pool_type, &qtype);
if (rc) {
- CERROR("can't extract pool information from FID "DFID"\n",
+ CERROR("can't extract glb index information from FID "DFID"\n",
PFID(&qti->qti_fid));
GOTO(out, rc);
}
struct lquota_entry *lqe;
/* Find the quota entry associated with the quota id */
- lqe = qmt_pool_lqe_lookup(env, qmt, pool_id, pool_type, qtype,
+ lqe = qmt_pool_lqe_lookup(env, qmt, pool_type, qtype,
&qti->qti_id);
if (IS_ERR(lqe))
GOTO(out, rc = PTR_ERR(lqe));
res->lr_lvb_len = sizeof(struct lquota_lvb);
EXIT;
out:
- lu_env_fini(env);
-out_free:
- OBD_FREE_PTR(env);
return rc;
}
if (lvb->lvb_id_may_rel != 0)
/* but might still release later ... */
lqe->lqe_may_rel += lvb->lvb_id_may_rel;
- GOTO(out_lqe, rc = 0);
+ GOTO(out, rc = 0);
}
/* allocate environement */
- OBD_ALLOC_PTR(env);
- if (env == NULL)
- GOTO(out_lqe, rc = -ENOMEM);
-
- /* initialize environment */
- rc = lu_env_init(env, LCT_MD_THREAD);
- if (rc)
- GOTO(out_env, rc);
+ env = lu_env_find();
+ LASSERT(env);
qti = qmt_info(env);
/* The request is a glimpse callback which was sent via the
if (IS_ERR(lock)) {
CERROR("%s: failed to get lock from request!\n",
qmt->qmt_svname);
- GOTO(out_env_init, rc = PTR_ERR(lock));
+ GOTO(out, rc = PTR_ERR(lock));
}
exp = class_export_get(lock->l_export);
if (exp == NULL) {
CERROR("%s: failed to get export from lock!\n",
qmt->qmt_svname);
- GOTO(out_env_init, rc = -EFAULT);
+ GOTO(out, rc = -EFAULT);
}
/* release quota space */
lvb->lvb_id_rel, rc);
class_export_put(exp);
if (rc)
- GOTO(out_env_init, rc);
+ GOTO(out, rc);
EXIT;
-out_env_init:
- lu_env_fini(env);
-out_env:
- OBD_FREE_PTR(env);
-out_lqe:
+out:
lqe_putref(lqe);
return rc;
}
lqe_putref(lqe);
} else {
/* global quota lock */
- struct lu_env *env;
- int rc;
- struct dt_object *obj = res->lr_lvb_data;
-
- OBD_ALLOC_PTR(env);
- if (env == NULL)
- RETURN(-ENOMEM);
-
- /* initialize environment */
- rc = lu_env_init(env, LCT_LOCAL);
- if (rc) {
- OBD_FREE_PTR(env);
- RETURN(rc);
- }
+ struct dt_object *obj = res->lr_lvb_data;
/* return current version of global index */
- qlvb->lvb_glb_ver = dt_version_get(env, obj);
-
- lu_env_fini(env);
- OBD_FREE_PTR(env);
+ qlvb->lvb_glb_ver = dt_version_get(lu_env_find(), obj);
}
RETURN(sizeof(struct lquota_lvb));
/* release lqe reference */
lqe_putref(lqe);
} else {
- struct dt_object *obj = res->lr_lvb_data;
- struct lu_env *env;
- int rc;
-
- OBD_ALLOC_PTR(env);
- if (env == NULL)
- RETURN(-ENOMEM);
-
- /* initialize environment */
- rc = lu_env_init(env, LCT_LOCAL);
- if (rc) {
- OBD_FREE_PTR(env);
- RETURN(rc);
- }
-
+ struct dt_object *obj = res->lr_lvb_data;
/* release object reference */
- dt_object_put(env, obj);
- lu_env_fini(env);
- OBD_FREE_PTR(env);
+ dt_object_put(lu_env_find(), obj);
}
res->lr_lvb_data = NULL;
qmt_glimpse_cb_t cb, void *arg)
{
struct list_head *tmp, *pos;
- struct list_head gl_list = LIST_HEAD_INIT(gl_list);
+ LIST_HEAD(gl_list);
struct qmt_gl_lock_array locks;
unsigned long i;
int rc = 0;
struct ldlm_resource *res = NULL;
ENTRY;
- lquota_generate_fid(&qti->qti_fid, pool->qpi_key & 0x0000ffff,
- pool->qpi_key >> 16, lqe->lqe_site->lqs_qtype);
+ lquota_generate_fid(&qti->qti_fid, pool->qpi_rtype,
+ lqe->lqe_site->lqs_qtype);
/* send glimpse callback to notify slaves of new quota settings */
qti->qti_gl_desc.lquota_desc.gl_id = lqe->lqe_id;
qti->qti_gl_desc.lquota_desc.gl_flags = 0;
- qti->qti_gl_desc.lquota_desc.gl_hardlimit = lqe->lqe_hardlimit;
- qti->qti_gl_desc.lquota_desc.gl_softlimit = lqe->lqe_softlimit;
- qti->qti_gl_desc.lquota_desc.gl_time = lqe->lqe_gracetime;
+ if (lqe->lqe_is_default) {
+ qti->qti_gl_desc.lquota_desc.gl_hardlimit = 0;
+ qti->qti_gl_desc.lquota_desc.gl_softlimit = 0;
+ qti->qti_gl_desc.lquota_desc.gl_time = LQUOTA_GRACE_FLAG(0,
+ LQUOTA_FLAG_DEFAULT);
+
+ } else {
+ qti->qti_gl_desc.lquota_desc.gl_hardlimit = lqe->lqe_hardlimit;
+ qti->qti_gl_desc.lquota_desc.gl_softlimit = lqe->lqe_softlimit;
+ qti->qti_gl_desc.lquota_desc.gl_time = lqe->lqe_gracetime;
+ }
qti->qti_gl_desc.lquota_desc.gl_ver = ver;
/* look up ldlm resource associated with global index */
if (!lqe->lqe_enforced)
RETURN_EXIT;
- lquota_generate_fid(&qti->qti_fid, pool->qpi_key & 0x0000ffff,
- pool->qpi_key >> 16, lqe->lqe_site->lqs_qtype);
+ lquota_generate_fid(&qti->qti_fid, pool->qpi_rtype,
+ lqe->lqe_site->lqs_qtype);
fid_build_quota_res_name(&qti->qti_fid, &lqe->lqe_id, &qti->qti_resid);
res = ldlm_resource_get(qmt->qmt_ns, NULL, &qti->qti_resid, LDLM_PLAIN,
0);
{
struct qmt_device *qmt = (struct qmt_device *)arg;
struct ptlrpc_thread *thread = &qmt->qmt_reba_thread;
- struct l_wait_info lwi = { 0 };
struct lu_env *env;
struct lquota_entry *lqe, *tmp;
int rc;
ENTRY;
OBD_ALLOC_PTR(env);
- if (env == NULL)
+ if (env == NULL) {
+ thread_set_flags(thread, SVC_STOPPED);
RETURN(-ENOMEM);
+ }
rc = lu_env_init(env, LCT_MD_THREAD);
if (rc) {
CERROR("%s: failed to init env.", qmt->qmt_svname);
- OBD_FREE_PTR(env);
- RETURN(rc);
+ GOTO(out_env, rc);
}
+ rc = lu_env_add(env);
+ if (rc)
+ GOTO(out_env_fini, rc);
thread_set_flags(thread, SVC_RUNNING);
wake_up(&thread->t_ctl_waitq);
while (1) {
- l_wait_event(thread->t_ctl_waitq,
- !list_empty(&qmt->qmt_reba_list) ||
- !thread_is_running(thread), &lwi);
+ wait_event_idle(thread->t_ctl_waitq,
+ !list_empty(&qmt->qmt_reba_list) ||
+ !thread_is_running(thread));
spin_lock(&qmt->qmt_reba_lock);
list_for_each_entry_safe(lqe, tmp, &qmt->qmt_reba_list,
if (!thread_is_running(thread))
break;
}
+ lu_env_remove(env);
+out_env_fini:
lu_env_fini(env);
+out_env:
OBD_FREE_PTR(env);
thread_set_flags(thread, SVC_STOPPED);
wake_up(&thread->t_ctl_waitq);
int qmt_start_reba_thread(struct qmt_device *qmt)
{
struct ptlrpc_thread *thread = &qmt->qmt_reba_thread;
- struct l_wait_info lwi = { 0 };
struct task_struct *task;
ENTRY;
RETURN(PTR_ERR(task));
}
- l_wait_event(thread->t_ctl_waitq,
- thread_is_running(thread) || thread_is_stopped(thread),
- &lwi);
+ wait_event_idle(thread->t_ctl_waitq,
+ thread_is_running(thread) || thread_is_stopped(thread));
RETURN(0);
}
struct ptlrpc_thread *thread = &qmt->qmt_reba_thread;
if (!thread_is_stopped(thread)) {
- struct l_wait_info lwi = { 0 };
thread_set_flags(thread, SVC_STOPPING);
wake_up(&thread->t_ctl_waitq);
- l_wait_event(thread->t_ctl_waitq, thread_is_stopped(thread),
- &lwi);
+ wait_event_idle(thread->t_ctl_waitq, thread_is_stopped(thread));
}
LASSERT(list_empty(&qmt->qmt_reba_list));
}