X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fquota%2Fqsd_entry.c;h=c3a434f58dcd9fde3e6a32a27f5310fd570f10dd;hb=a71382df0204fe2cd465eba3873574118f46622b;hp=5ebdfebcb91bc5c3c83c933e98b37ab848880018;hpb=11db1a551172f596d1d284e8496530f9ce24ac81;p=fs%2Flustre-release.git diff --git a/lustre/quota/qsd_entry.c b/lustre/quota/qsd_entry.c index 5ebdfeb..c3a434f 100644 --- a/lustre/quota/qsd_entry.c +++ b/lustre/quota/qsd_entry.c @@ -21,7 +21,7 @@ * GPL HEADER END */ /* - * Copyright (c) 2012, Intel Corporation. + * Copyright (c) 2012, 2017, Intel Corporation. * Use is subject to license terms. * * Author: Johann Lombardi @@ -47,7 +47,7 @@ static void qsd_lqe_init(struct lquota_entry *lqe, void *arg) memset(&lqe->lqe_lockh, 0, sizeof(lqe->lqe_lockh)); lqe->lqe_pending_write = 0; lqe->lqe_pending_req = 0; - cfs_waitq_init(&lqe->lqe_waiters); + init_waitqueue_head(&lqe->lqe_waiters); lqe->lqe_usage = 0; lqe->lqe_nopreacq = false; } @@ -60,9 +60,10 @@ static void qsd_lqe_init(struct lquota_entry *lqe, void *arg) * \param env - the environment passed by the caller * \param lqe - is the quota entry to refresh * \param arg - is the pointer to the qsd_qtype_info structure + * \param need_crt - needed to be compat with qmt_lqe_read */ static int qsd_lqe_read(const struct lu_env *env, struct lquota_entry *lqe, - void *arg) + void *arg, bool need_crt) { struct qsd_thread_info *qti = qsd_info(env); struct qsd_qtype_info *qqi = (struct qsd_qtype_info *)arg; @@ -81,12 +82,21 @@ static int qsd_lqe_read(const struct lu_env *env, struct lquota_entry *lqe, lqe->lqe_enforced = false; break; case 0: - if (qti->qti_glb_rec.qbr_hardlimit == 0 && - qti->qti_glb_rec.qbr_softlimit == 0) - /* quota isn't enforced for this use */ - lqe->lqe_enforced = false; - else + if (lqe->lqe_id.qid_uid == 0) { + qqi->qqi_default_hardlimit = + qti->qti_glb_rec.qbr_hardlimit; + qqi->qqi_default_softlimit = + qti->qti_glb_rec.qbr_softlimit; + qqi->qqi_default_gracetime = + qti->qti_glb_rec.qbr_granted; + } + + if (lqe->lqe_id.qid_uid != 0 && + (qti->qti_glb_rec.qbr_hardlimit != 0 || + qti->qti_glb_rec.qbr_softlimit != 0)) lqe->lqe_enforced = true; + else + lqe->lqe_enforced = false; break; default: LQUOTA_ERROR(lqe, "failed to read quota entry from global " @@ -94,6 +104,29 @@ static int qsd_lqe_read(const struct lu_env *env, struct lquota_entry *lqe, return rc; } + if (lqe->lqe_id.qid_uid != 0 && + (rc == -ENOENT || + (LQUOTA_FLAG(qti->qti_glb_rec.qbr_time) & LQUOTA_FLAG_DEFAULT && + qti->qti_glb_rec.qbr_hardlimit == 0 && + qti->qti_glb_rec.qbr_softlimit == 0))) { + struct lquota_entry *lqe_def; + union lquota_id qid = { {0} }; + + /* ensure the lqe storing the default quota setting loaded */ + lqe_def = lqe_locate(env, qqi->qqi_site, &qid); + + lqe->lqe_is_default = true; + + if (qqi->qqi_default_hardlimit != 0 || + qqi->qqi_default_softlimit != 0) { + LQUOTA_DEBUG(lqe, "enforced by default quota"); + lqe->lqe_enforced = true; + } + + if (!IS_ERR(lqe_def)) + lqe_putref(lqe_def); + } + /* read record from slave index copy to find out how much space is * currently owned by this slave */ rc = lquota_disk_read(env, qqi->qqi_slv_obj, &lqe->lqe_id, @@ -133,26 +166,25 @@ static int qsd_lqe_read(const struct lu_env *env, struct lquota_entry *lqe, */ static void qsd_lqe_debug(struct lquota_entry *lqe, void *arg, struct libcfs_debug_msg_data *msgdata, - const char *fmt, va_list args) + struct va_format *vaf) { struct qsd_qtype_info *qqi = (struct qsd_qtype_info *)arg; - libcfs_debug_vmsg2(msgdata, fmt, args, - "qsd:%s qtype:%s id:"LPU64" enforced:%d granted:" - LPU64" pending:"LPU64" waiting:"LPU64" req:%d usage:" - LPU64" qunit:"LPU64" qtune:"LPU64" edquot:%d\n", - qqi->qqi_qsd->qsd_svname, QTYPE_NAME(qqi->qqi_qtype), - lqe->lqe_id.qid_uid, lqe->lqe_enforced, - lqe->lqe_granted, lqe->lqe_pending_write, - lqe->lqe_waiting_write, lqe->lqe_pending_req, - lqe->lqe_usage, lqe->lqe_qunit, lqe->lqe_qtune, - lqe->lqe_edquot); + libcfs_debug_msg(msgdata, + "%pV qsd:%s qtype:%s id:%llu enforced:%d granted: %llu pending:%llu waiting:%llu req:%d usage: %llu qunit:%llu qtune:%llu edquot:%d default:%s\n", + vaf, + qqi->qqi_qsd->qsd_svname, qtype_name(qqi->qqi_qtype), + lqe->lqe_id.qid_uid, lqe->lqe_enforced, + lqe->lqe_granted, lqe->lqe_pending_write, + lqe->lqe_waiting_write, lqe->lqe_pending_req, + lqe->lqe_usage, lqe->lqe_qunit, lqe->lqe_qtune, + lqe->lqe_edquot, lqe->lqe_is_default ? "yes" : "no"); } /* * Vector of quota entry operations supported on the slave */ -struct lquota_entry_operations qsd_lqe_ops = { +const struct lquota_entry_operations qsd_lqe_ops = { .lqe_init = qsd_lqe_init, .lqe_read = qsd_lqe_read, .lqe_debug = qsd_lqe_debug, @@ -212,7 +244,7 @@ int qsd_refresh_usage(const struct lu_env *env, struct lquota_entry *lqe) RETURN(rc); } - LQUOTA_DEBUG(lqe, "disk usage: "LPU64, lqe->lqe_usage); + LQUOTA_DEBUG(lqe, "disk usage: %llu", lqe->lqe_usage); RETURN(0); } @@ -261,15 +293,15 @@ int qsd_update_index(const struct lu_env *env, struct qsd_qtype_info *qqi, /* Update record in global index copy */ struct lquota_glb_rec *glb_rec = (struct lquota_glb_rec *)rec; - CDEBUG(D_QUOTA, "%s: updating global index hardlimit: "LPU64", " - "softlimit: "LPU64" for id "LPU64"\n", + CDEBUG(D_QUOTA, "%s: updating global index hardlimit: %llu, " + "softlimit: %llu for id %llu\n", qqi->qqi_qsd->qsd_svname, glb_rec->qbr_hardlimit, glb_rec->qbr_softlimit, qid->qid_uid); } else { /* Update record in slave index copy */ struct lquota_slv_rec *slv_rec = (struct lquota_slv_rec *)rec; - CDEBUG(D_QUOTA, "%s: update granted to "LPU64" for id "LPU64 + CDEBUG(D_QUOTA, "%s: update granted to %llu for id %llu" "\n", qqi->qqi_qsd->qsd_svname, slv_rec->qsr_granted, qid->qid_uid); } @@ -286,8 +318,8 @@ int qsd_update_index(const struct lu_env *env, struct qsd_qtype_info *qqi, out: dt_trans_stop(env, qqi->qqi_qsd->qsd_dev, th); if (rc) - CERROR("%s: failed to update %s index copy for id "LPU64", rc:" - "%d\n", qqi->qqi_qsd->qsd_svname, + CERROR("%s: failed to update %s index copy for id %llu, : rc = %d\n", + qqi->qqi_qsd->qsd_svname, global ? "global" : "slave", qid->qid_uid, rc); else if (flags == LQUOTA_SET_VER) qsd_bump_version(qqi, ver, global); @@ -318,19 +350,32 @@ int qsd_update_lqe(const struct lu_env *env, struct lquota_entry *lqe, if (global) { struct lquota_glb_rec *glb_rec = (struct lquota_glb_rec *)rec; + /* doesn't change quota enforcement if the quota entry is still + * using default quota. */ + if (LQUOTA_FLAG(glb_rec->qbr_time) & LQUOTA_FLAG_DEFAULT && + glb_rec->qbr_hardlimit == 0 && glb_rec->qbr_softlimit == 0) + RETURN(0); + + LQUOTA_DEBUG(lqe, "the ID has been set quota, so clear the" + " default quota flag"); + lqe->lqe_is_default = false; + /* change enforcement status based on new hard/soft limit */ - lqe->lqe_enforced = (glb_rec->qbr_hardlimit || - glb_rec->qbr_softlimit) ? true : false; + if (lqe->lqe_id.qid_uid != 0 && (glb_rec->qbr_hardlimit != 0 || + glb_rec->qbr_softlimit != 0)) + lqe->lqe_enforced = true; + else + lqe->lqe_enforced = false; - LQUOTA_DEBUG(lqe, "updating global index hardlimit: "LPU64", " - "softlimit: "LPU64, glb_rec->qbr_hardlimit, + LQUOTA_DEBUG(lqe, "updating global index hardlimit: %llu, " + "softlimit: %llu", glb_rec->qbr_hardlimit, glb_rec->qbr_softlimit); } else { struct lquota_slv_rec *slv_rec = (struct lquota_slv_rec *)rec; lqe->lqe_granted = slv_rec->qsr_granted; - LQUOTA_DEBUG(lqe, "updating slave index, granted:"LPU64"", + LQUOTA_DEBUG(lqe, "updating slave index, granted:%llu", slv_rec->qsr_granted); }