X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fquota%2Fqmt_lock.c;h=f7226172a3034ee2b76fe68cb91e90faf5b25fc1;hb=e0d2bfe3b93d5179c9aee4a65e1695fa4c7779ed;hp=a4086f6b52bcf1aff8b04ee70ebde50071ab688d;hpb=08aa217ce49aba1ded52e0f7adb8a607035123fd;p=fs%2Flustre-release.git diff --git a/lustre/quota/qmt_lock.c b/lustre/quota/qmt_lock.c index a4086f6..f722617 100644 --- a/lustre/quota/qmt_lock.c +++ b/lustre/quota/qmt_lock.c @@ -21,17 +21,13 @@ * GPL HEADER END */ /* - * Copyright (c) 2012, Intel Corporation. + * Copyright (c) 2012, 2013, Intel Corporation. * Use is subject to license terms. * * Author: Johann Lombardi * Author: Niu Yawei */ -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif - #define DEBUG_SUBSYSTEM S_LQUOTA #include @@ -52,7 +48,7 @@ int qmt_intent_policy(const struct lu_env *env, struct lu_device *ld, struct obd_uuid *uuid; struct lquota_lvb *lvb; struct ldlm_resource *res = (*lockp)->l_resource; - int rc; + int rc, lvb_len; ENTRY; req_capsule_extend(&req->rq_pill, &RQF_LDLM_INTENT_QUOTA); @@ -135,7 +131,12 @@ int qmt_intent_policy(const struct lu_env *env, struct lu_device *ld, /* on success, pack lvb in reply */ lvb = req_capsule_server_get(&req->rq_pill, &RMF_DLM_LVB); - ldlm_lvbo_fill(*lockp, lvb, ldlm_lvbo_size(*lockp)); + lvb_len = ldlm_lvbo_size(*lockp); + lvb_len = ldlm_lvbo_fill(*lockp, lvb, lvb_len); + if (lvb_len < 0) + GOTO(out, rc = lvb_len); + + req_capsule_shrink(&req->rq_pill, &RMF_DLM_LVB, lvb_len, RCL_SERVER); EXIT; out: return rc; @@ -169,14 +170,12 @@ int qmt_lvbo_init(struct lu_device *ld, struct ldlm_resource *res) /* initialize environment */ rc = lu_env_init(env, LCT_MD_THREAD); - if (rc) { - OBD_FREE_PTR(env); - RETURN(rc); - } + if (rc != 0) + GOTO(out_free, rc); qti = qmt_info(env); /* extract global index FID and quota identifier */ - fid_extract_quota_resid(&res->lr_name, &qti->qti_fid, &qti->qti_id); + 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); @@ -217,10 +216,11 @@ int qmt_lvbo_init(struct lu_device *ld, struct ldlm_resource *res) CDEBUG(D_QUOTA, DFID" initialized lvb\n", PFID(&qti->qti_fid)); } - res->lr_lvb_len = sizeof(struct lquota_lvb); + res->lr_lvb_len = sizeof(struct lquota_lvb); EXIT; out: lu_env_fini(env); +out_free: OBD_FREE_PTR(env); return rc; } @@ -607,7 +607,7 @@ static void qmt_id_lock_glimpse(const struct lu_env *env, lquota_generate_fid(&qti->qti_fid, pool->qpi_key & 0x0000ffff, pool->qpi_key >> 16, lqe->lqe_site->lqs_qtype); - fid_build_quota_resid(&qti->qti_fid, &lqe->lqe_id, &qti->qti_resid); + 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); if (res == NULL) { @@ -688,7 +688,7 @@ void qmt_id_lock_notify(struct qmt_device *qmt, struct lquota_entry *lqe) spin_unlock(&qmt->qmt_reba_lock); if (added) - cfs_waitq_signal(&qmt->qmt_reba_thread.t_ctl_waitq); + wake_up(&qmt->qmt_reba_thread.t_ctl_waitq); else lqe_putref(lqe); EXIT; @@ -711,7 +711,6 @@ static int qmt_reba_thread(void *arg) struct l_wait_info lwi = { 0 }; struct lu_env *env; struct lquota_entry *lqe, *tmp; - char pname[MTI_NAME_MAXLEN]; int rc; ENTRY; @@ -726,11 +725,8 @@ static int qmt_reba_thread(void *arg) RETURN(rc); } - snprintf(pname, MTI_NAME_MAXLEN, "qmt_reba_%s", qmt->qmt_svname); - cfs_daemonize(pname); - thread_set_flags(thread, SVC_RUNNING); - cfs_waitq_signal(&thread->t_ctl_waitq); + wake_up(&thread->t_ctl_waitq); while (1) { l_wait_event(thread->t_ctl_waitq, @@ -757,7 +753,7 @@ static int qmt_reba_thread(void *arg) lu_env_fini(env); OBD_FREE_PTR(env); thread_set_flags(thread, SVC_STOPPED); - cfs_waitq_signal(&thread->t_ctl_waitq); + wake_up(&thread->t_ctl_waitq); RETURN(rc); } @@ -768,15 +764,16 @@ int qmt_start_reba_thread(struct qmt_device *qmt) { struct ptlrpc_thread *thread = &qmt->qmt_reba_thread; struct l_wait_info lwi = { 0 }; - int rc; + struct task_struct *task; ENTRY; - rc = cfs_create_thread(qmt_reba_thread, (void *)qmt, 0); - if (rc < 0) { - CERROR("%s: failed to start rebalance thread (%d)\n", - qmt->qmt_svname, rc); + task = kthread_run(qmt_reba_thread, (void *)qmt, + "qmt_reba_%s", qmt->qmt_svname); + if (IS_ERR(task)) { + CERROR("%s: failed to start rebalance thread (%ld)\n", + qmt->qmt_svname, PTR_ERR(task)); thread_set_flags(thread, SVC_STOPPED); - RETURN(rc); + RETURN(PTR_ERR(task)); } l_wait_event(thread->t_ctl_waitq, @@ -797,7 +794,7 @@ void qmt_stop_reba_thread(struct qmt_device *qmt) struct l_wait_info lwi = { 0 }; thread_set_flags(thread, SVC_STOPPING); - cfs_waitq_signal(&thread->t_ctl_waitq); + wake_up(&thread->t_ctl_waitq); l_wait_event(thread->t_ctl_waitq, thread_is_stopped(thread), &lwi);