Whamcloud - gitweb
git://git.whamcloud.com
/
fs
/
lustre-release.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
LU-5458: libcfs: protect kkuc_groups from write access
[fs/lustre-release.git]
/
lustre
/
quota
/
qmt_lock.c
diff --git
a/lustre/quota/qmt_lock.c
b/lustre/quota/qmt_lock.c
index
3067ce7
..
9500611
100644
(file)
--- a/
lustre/quota/qmt_lock.c
+++ b/
lustre/quota/qmt_lock.c
@@
-21,17
+21,13
@@
* GPL HEADER END
*/
/*
* GPL HEADER END
*/
/*
- * Copyright (c) 2012
Intel, Inc
.
+ * Copyright (c) 2012
, 2013, Intel Corporation
.
* Use is subject to license terms.
*
* Author: Johann Lombardi <johann.lombardi@intel.com>
* Author: Niu Yawei <yawei.niu@intel.com>
*/
* Use is subject to license terms.
*
* Author: Johann Lombardi <johann.lombardi@intel.com>
* Author: Niu Yawei <yawei.niu@intel.com>
*/
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
-
#define DEBUG_SUBSYSTEM S_LQUOTA
#include <lustre_dlm.h>
#define DEBUG_SUBSYSTEM S_LQUOTA
#include <lustre_dlm.h>
@@
-52,10
+48,12
@@
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;
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);
ENTRY;
req_capsule_extend(&req->rq_pill, &RQF_LDLM_INTENT_QUOTA);
+ req_capsule_set_size(&req->rq_pill, &RMF_DLM_LVB, RCL_SERVER,
+ ldlm_lvbo_size(*lockp));
/* extract quota body and intent opc */
it = req_capsule_client_get(&req->rq_pill, &RMF_LDLM_INTENT);
/* extract quota body and intent opc */
it = req_capsule_client_get(&req->rq_pill, &RMF_LDLM_INTENT);
@@
-132,10
+130,13
@@
int qmt_intent_policy(const struct lu_env *env, struct lu_device *ld,
}
/* on success, pack lvb in reply */
}
/* on success, pack lvb in reply */
- req_capsule_set_size(&req->rq_pill, &RMF_DLM_LVB, RCL_SERVER,
- ldlm_lvbo_size(*lockp));
lvb = req_capsule_server_get(&req->rq_pill, &RMF_DLM_LVB);
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;
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);
/* 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 */
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);
/* 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));
}
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);
EXIT;
out:
lu_env_fini(env);
+out_free:
OBD_FREE_PTR(env);
return rc;
}
OBD_FREE_PTR(env);
return rc;
}
@@
-252,7
+252,8
@@
int qmt_lvbo_update(struct lu_device *ld, struct ldlm_resource *res,
/* no need to update lvb for global quota locks */
RETURN(0);
/* no need to update lvb for global quota locks */
RETURN(0);
- lvb = req_capsule_server_get(&req->rq_pill, &RMF_DLM_LVB);
+ lvb = req_capsule_server_swab_get(&req->rq_pill, &RMF_DLM_LVB,
+ lustre_swab_lquota_lvb);
if (lvb == NULL) {
CERROR("%s: failed to extract lvb from request\n",
qmt->qmt_svname);
if (lvb == NULL) {
CERROR("%s: failed to extract lvb from request\n",
qmt->qmt_svname);
@@
-456,19
+457,19
@@
static int qmt_glimpse_lock(const struct lu_env *env, struct qmt_device *qmt,
struct ldlm_resource *res, union ldlm_gl_desc *desc,
qmt_glimpse_cb_t cb, void *arg)
{
struct ldlm_resource *res, union ldlm_gl_desc *desc,
qmt_glimpse_cb_t cb, void *arg)
{
-
cfs_list_t
*tmp, *pos;
-
CFS_LIST_HEAD
(gl_list);
+
struct list_head
*tmp, *pos;
+
struct list_head gl_list = LIST_HEAD_INIT
(gl_list);
int rc = 0;
ENTRY;
lock_res(res);
/* scan list of granted locks */
int rc = 0;
ENTRY;
lock_res(res);
/* scan list of granted locks */
-
cfs_
list_for_each(pos, &res->lr_granted) {
+ list_for_each(pos, &res->lr_granted) {
struct ldlm_glimpse_work *work;
struct ldlm_lock *lock;
struct obd_uuid *uuid;
struct ldlm_glimpse_work *work;
struct ldlm_lock *lock;
struct obd_uuid *uuid;
- lock =
cfs_
list_entry(pos, struct ldlm_lock, l_res_link);
+ lock = list_entry(pos, struct ldlm_lock, l_res_link);
LASSERT(lock->l_export);
uuid = &lock->l_export->exp_client_uuid;
LASSERT(lock->l_export);
uuid = &lock->l_export->exp_client_uuid;
@@
-492,7
+493,7
@@
static int qmt_glimpse_lock(const struct lu_env *env, struct qmt_device *qmt,
continue;
}
continue;
}
-
cfs_
list_add_tail(&work->gl_list, &gl_list);
+ list_add_tail(&work->gl_list, &gl_list);
work->gl_lock = LDLM_LOCK_GET(lock);
work->gl_flags = 0;
work->gl_desc = desc;
work->gl_lock = LDLM_LOCK_GET(lock);
work->gl_flags = 0;
work->gl_desc = desc;
@@
-500,7
+501,7
@@
static int qmt_glimpse_lock(const struct lu_env *env, struct qmt_device *qmt,
}
unlock_res(res);
}
unlock_res(res);
- if (
cfs_
list_empty(&gl_list)) {
+ if (list_empty(&gl_list)) {
CDEBUG(D_QUOTA, "%s: nobody to notify\n", qmt->qmt_svname);
RETURN(0);
}
CDEBUG(D_QUOTA, "%s: nobody to notify\n", qmt->qmt_svname);
RETURN(0);
}
@@
-508,12
+509,12
@@
static int qmt_glimpse_lock(const struct lu_env *env, struct qmt_device *qmt,
/* issue glimpse callbacks to all connected slaves */
rc = ldlm_glimpse_locks(res, &gl_list);
/* issue glimpse callbacks to all connected slaves */
rc = ldlm_glimpse_locks(res, &gl_list);
-
cfs_
list_for_each_safe(pos, tmp, &gl_list) {
+ list_for_each_safe(pos, tmp, &gl_list) {
struct ldlm_glimpse_work *work;
struct ldlm_glimpse_work *work;
- work =
cfs_
list_entry(pos, struct ldlm_glimpse_work, gl_list);
+ work = list_entry(pos, struct ldlm_glimpse_work, gl_list);
-
cfs_
list_del(&work->gl_list);
+ list_del(&work->gl_list);
CERROR("%s: failed to notify %s of new quota settings\n",
qmt->qmt_svname,
obd_uuid2str(&work->gl_lock->l_export->exp_client_uuid));
CERROR("%s: failed to notify %s of new quota settings\n",
qmt->qmt_svname,
obd_uuid2str(&work->gl_lock->l_export->exp_client_uuid));
@@
-549,13
+550,14
@@
void qmt_glb_lock_notify(const struct lu_env *env, struct lquota_entry *lqe,
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_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;
qti->qti_gl_desc.lquota_desc.gl_ver = ver;
/* look up ldlm resource associated with global index */
fid_build_reg_res_name(&qti->qti_fid, &qti->qti_resid);
res = ldlm_resource_get(pool->qpi_qmt->qmt_ns, NULL, &qti->qti_resid,
LDLM_PLAIN, 0);
qti->qti_gl_desc.lquota_desc.gl_ver = ver;
/* look up ldlm resource associated with global index */
fid_build_reg_res_name(&qti->qti_fid, &qti->qti_resid);
res = ldlm_resource_get(pool->qpi_qmt->qmt_ns, NULL, &qti->qti_resid,
LDLM_PLAIN, 0);
- if (
res == NULL
) {
+ if (
IS_ERR(res)
) {
/* this might happen if no slaves have enqueued global quota
* locks yet */
LQUOTA_DEBUG(lqe, "failed to lookup ldlm resource associated "
/* this might happen if no slaves have enqueued global quota
* locks yet */
LQUOTA_DEBUG(lqe, "failed to lookup ldlm resource associated "
@@
-605,10
+607,10
@@
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);
lquota_generate_fid(&qti->qti_fid, pool->qpi_key & 0x0000ffff,
pool->qpi_key >> 16, lqe->lqe_site->lqs_qtype);
- fid_build_quota_res
id
(&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);
res = ldlm_resource_get(qmt->qmt_ns, NULL, &qti->qti_resid, LDLM_PLAIN,
0);
- if (
res == NULL
) {
+ if (
IS_ERR(res)
) {
/* this might legitimately happens if slaves haven't had the
* opportunity to enqueue quota lock yet. */
LQUOTA_DEBUG(lqe, "failed to lookup ldlm resource for per-ID "
/* this might legitimately happens if slaves haven't had the
* opportunity to enqueue quota lock yet. */
LQUOTA_DEBUG(lqe, "failed to lookup ldlm resource for per-ID "
@@
-678,15
+680,15
@@
void qmt_id_lock_notify(struct qmt_device *qmt, struct lquota_entry *lqe)
ENTRY;
lqe_getref(lqe);
ENTRY;
lqe_getref(lqe);
-
cfs_
spin_lock(&qmt->qmt_reba_lock);
- if (!qmt->qmt_stopping &&
cfs_
list_empty(&lqe->lqe_link)) {
-
cfs_
list_add_tail(&lqe->lqe_link, &qmt->qmt_reba_list);
+ spin_lock(&qmt->qmt_reba_lock);
+ if (!qmt->qmt_stopping && list_empty(&lqe->lqe_link)) {
+ list_add_tail(&lqe->lqe_link, &qmt->qmt_reba_list);
added = true;
}
added = true;
}
-
cfs_
spin_unlock(&qmt->qmt_reba_lock);
+ spin_unlock(&qmt->qmt_reba_lock);
if (added)
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;
else
lqe_putref(lqe);
EXIT;
@@
-709,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;
struct l_wait_info lwi = { 0 };
struct lu_env *env;
struct lquota_entry *lqe, *tmp;
- char pname[MTI_NAME_MAXLEN];
int rc;
ENTRY;
int rc;
ENTRY;
@@
-724,30
+725,27
@@
static int qmt_reba_thread(void *arg)
RETURN(rc);
}
RETURN(rc);
}
- snprintf(pname, MTI_NAME_MAXLEN, "qmt_reba_%s", qmt->qmt_svname);
- cfs_daemonize(pname);
-
thread_set_flags(thread, SVC_RUNNING);
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,
while (1) {
l_wait_event(thread->t_ctl_waitq,
- !
cfs_
list_empty(&qmt->qmt_reba_list) ||
+ !list_empty(&qmt->qmt_reba_list) ||
!thread_is_running(thread), &lwi);
!thread_is_running(thread), &lwi);
-
cfs_
spin_lock(&qmt->qmt_reba_lock);
-
cfs_
list_for_each_entry_safe(lqe, tmp, &qmt->qmt_reba_list,
-
lqe_link) {
-
cfs_
list_del_init(&lqe->lqe_link);
-
cfs_
spin_unlock(&qmt->qmt_reba_lock);
+ spin_lock(&qmt->qmt_reba_lock);
+ list_for_each_entry_safe(lqe, tmp, &qmt->qmt_reba_list,
+ lqe_link) {
+ list_del_init(&lqe->lqe_link);
+ spin_unlock(&qmt->qmt_reba_lock);
if (thread_is_running(thread))
qmt_id_lock_glimpse(env, qmt, lqe, NULL);
lqe_putref(lqe);
if (thread_is_running(thread))
qmt_id_lock_glimpse(env, qmt, lqe, NULL);
lqe_putref(lqe);
-
cfs_
spin_lock(&qmt->qmt_reba_lock);
+ spin_lock(&qmt->qmt_reba_lock);
}
}
-
cfs_
spin_unlock(&qmt->qmt_reba_lock);
+ spin_unlock(&qmt->qmt_reba_lock);
if (!thread_is_running(thread))
break;
if (!thread_is_running(thread))
break;
@@
-755,7
+753,7
@@
static int qmt_reba_thread(void *arg)
lu_env_fini(env);
OBD_FREE_PTR(env);
thread_set_flags(thread, SVC_STOPPED);
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);
}
RETURN(rc);
}
@@
-766,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 };
{
struct ptlrpc_thread *thread = &qmt->qmt_reba_thread;
struct l_wait_info lwi = { 0 };
-
int rc
;
+
struct task_struct *task
;
ENTRY;
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);
thread_set_flags(thread, SVC_STOPPED);
- RETURN(
rc
);
+ RETURN(
PTR_ERR(task)
);
}
l_wait_event(thread->t_ctl_waitq,
}
l_wait_event(thread->t_ctl_waitq,
@@
-795,10
+794,10
@@
void qmt_stop_reba_thread(struct qmt_device *qmt)
struct l_wait_info lwi = { 0 };
thread_set_flags(thread, SVC_STOPPING);
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);
}
l_wait_event(thread->t_ctl_waitq, thread_is_stopped(thread),
&lwi);
}
- LASSERT(
cfs_
list_empty(&qmt->qmt_reba_list));
+ LASSERT(list_empty(&qmt->qmt_reba_list));
}
}