X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fquota%2Fquota_check.c;h=c2238e20af3859ee93cd5e99ed3faf58a7c3b977;hb=41bb20fb65131223a6756f1bcd2794c635f81a9e;hp=e368a275839e641926f875385642ccace49b44cd;hpb=70e80ade90af09300396706b8910e196a7928520;p=fs%2Flustre-release.git diff --git a/lustre/quota/quota_check.c b/lustre/quota/quota_check.c index e368a27..c2238e2 100644 --- a/lustre/quota/quota_check.c +++ b/lustre/quota/quota_check.c @@ -16,8 +16,8 @@ * in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see [sun.com URL with a - * copy of GPLv2]. + * version 2 along with this program; If not, see + * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, * CA 95054 USA or visit www.sun.com if you need additional information or @@ -33,10 +33,12 @@ * This file is part of Lustre, http://www.lustre.org/ * Lustre is a trademark of Sun Microsystems, Inc. */ + + #ifndef EXPORT_SYMTAB # define EXPORT_SYMTAB #endif -#define DEBUG_SUBSYSTEM S_MDS +#define DEBUG_SUBSYSTEM S_LQUOTA #ifdef __KERNEL__ # include @@ -62,6 +64,7 @@ #include #include "quota_internal.h" +#ifdef HAVE_QUOTA_SUPPORT #ifdef __KERNEL__ static int target_quotacheck_callback(struct obd_export *exp, struct obd_quotactl *oqctl) @@ -71,7 +74,7 @@ static int target_quotacheck_callback(struct obd_export *exp, int rc; ENTRY; - req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_QC_CALLBACK, + req = ptlrpc_request_alloc_pack(exp->exp_imp_reverse, &RQF_QC_CALLBACK, LUSTRE_OBD_VERSION, OBD_QC_CALLBACK); if (req == NULL) RETURN(-ENOMEM); @@ -99,7 +102,7 @@ static int target_quotacheck_thread(void *data) ptlrpc_daemonize("quotacheck"); exp = qta->qta_exp; - obd = exp->exp_obd; + obd = qta->qta_obd; oqctl = &qta->qta_oqctl; push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); @@ -111,6 +114,7 @@ static int target_quotacheck_thread(void *data) pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); rc = target_quotacheck_callback(exp, oqctl); + class_export_put(exp); atomic_inc(qta->qta_sem); @@ -118,9 +122,9 @@ static int target_quotacheck_thread(void *data) return rc; } -int target_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl) +int target_quota_check(struct obd_device *obd, struct obd_export *exp, + struct obd_quotactl *oqctl) { - struct obd_device *obd = exp->exp_obd; struct obd_device_target *obt = &obd->u.obt; struct quotacheck_thread_args *qta; int rc = 0; @@ -136,7 +140,9 @@ int target_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl) GOTO(out, rc = -ENOMEM); qta->qta_exp = exp; + qta->qta_obd = obd; qta->qta_oqctl = *oqctl; + qta->qta_oqctl.qc_id = obt->obt_qfmt; /* override qfmt version */ qta->qta_sb = obt->obt_sb; qta->qta_sem = &obt->obt_quotachecking; @@ -150,6 +156,9 @@ int target_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl) } } + /* we get ref for exp because target_quotacheck_callback() will use this + * export later b=18126 */ + class_export_get(exp); rc = kernel_thread(target_quotacheck_thread, qta, CLONE_VM|CLONE_FILES); if (rc >= 0) { CDEBUG(D_INFO, "%s: target_quotacheck_thread: %d\n", @@ -157,6 +166,7 @@ int target_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl) RETURN(0); } + class_export_put(exp); CERROR("%s: error starting quotacheck_thread: %d\n", obd->obd_name, rc); OBD_FREE_PTR(qta); @@ -166,27 +176,31 @@ out: } #endif /* __KERNEL__ */ +#endif /* HAVE_QUOTA_SUPPORT */ -int client_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl) +int client_quota_check(struct obd_device *unused, struct obd_export *exp, + struct obd_quotactl *oqctl) { - struct client_obd *cli = &exp->exp_obd->u.cli; - struct ptlrpc_request *req; - struct obd_quotactl *body; - int ver, opc, rc; + struct client_obd *cli = &exp->exp_obd->u.cli; + struct ptlrpc_request *req; + struct obd_quotactl *body; + const struct req_format *rf; + int ver, opc, rc; ENTRY; if (!strcmp(exp->exp_obd->obd_type->typ_name, LUSTRE_MDC_NAME)) { + rf = &RQF_MDS_QUOTACHECK; ver = LUSTRE_MDS_VERSION; opc = MDS_QUOTACHECK; } else if (!strcmp(exp->exp_obd->obd_type->typ_name, LUSTRE_OSC_NAME)) { + rf = &RQF_OST_QUOTACHECK; ver = LUSTRE_OST_VERSION; opc = OST_QUOTACHECK; } else { RETURN(-EINVAL); } - req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), - &RQF_MDS_QUOTACHECK, ver, opc); + req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), rf, ver, opc); if (req == NULL) RETURN(-ENOMEM); @@ -220,34 +234,62 @@ int client_quota_poll_check(struct obd_export *exp, struct if_quotacheck *qchk) qchk->obd_uuid = cli->cl_target_uuid; /* FIXME change strncmp to strcmp and save the strlen op */ if (strncmp(exp->exp_obd->obd_type->typ_name, LUSTRE_OSC_NAME, - strlen(LUSTRE_OSC_NAME))) + strlen(LUSTRE_OSC_NAME)) == 0) memcpy(qchk->obd_type, LUSTRE_OST_NAME, strlen(LUSTRE_OST_NAME)); else if (strncmp(exp->exp_obd->obd_type->typ_name, LUSTRE_MDC_NAME, - strlen(LUSTRE_MDC_NAME))) + strlen(LUSTRE_MDC_NAME)) == 0) memcpy(qchk->obd_type, LUSTRE_MDS_NAME, strlen(LUSTRE_MDS_NAME)); RETURN(rc); } -int lov_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl) +int lmv_quota_check(struct obd_device *unused, struct obd_export *exp, + struct obd_quotactl *oqctl) { struct obd_device *obd = class_exp2obd(exp); - struct lov_obd *lov = &obd->u.lov; + struct lmv_obd *lmv = &obd->u.lmv; + struct lmv_tgt_desc *tgt; int i, rc = 0; ENTRY; - for (i = 0; i < lov->desc.ld_tgt_count; i++) { + for (i = 0, tgt = lmv->tgts; i < lmv->desc.ld_tgt_count; i++, tgt++) { int err; + if (!tgt->ltd_active) { + CERROR("lmv idx %d inactive\n", i); + RETURN(-EIO); + } + + err = obd_quotacheck(tgt->ltd_exp, oqctl); + if (err && !rc) + rc = err; + } + + RETURN(rc); +} + +int lov_quota_check(struct obd_device *unused, struct obd_export *exp, + struct obd_quotactl *oqctl) +{ + struct obd_device *obd = class_exp2obd(exp); + struct lov_obd *lov = &obd->u.lov; + int i, rc = 0; + ENTRY; + + for (i = 0; i < lov->desc.ld_tgt_count; i++) { if (!lov->lov_tgts[i] || !lov->lov_tgts[i]->ltd_active) { CERROR("lov idx %d inactive\n", i); RETURN(-EIO); } + } + + for (i = 0; i < lov->desc.ld_tgt_count; i++) { + int err; err = obd_quotacheck(lov->lov_tgts[i]->ltd_exp, oqctl); - if (err && lov->lov_tgts[i]->ltd_active && !rc) + if (err && !rc) rc = err; }