X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fquota%2Fquota_ctl.c;h=99d30f4827f33fb7f104eb8b5820764146358c31;hb=801469af8c31afad1bd8aaa23b01bfc42abe45eb;hp=3c761f40741706ff314ea24a647f6ddf45fc559a;hpb=408c61bd36c1cf41a432e152de9891bcd0c3e49f;p=fs%2Flustre-release.git diff --git a/lustre/quota/quota_ctl.c b/lustre/quota/quota_ctl.c index 3c761f4..99d30f4 100644 --- a/lustre/quota/quota_ctl.c +++ b/lustre/quota/quota_ctl.c @@ -1,6 +1,4 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * +/* * GPL HEADER START * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,14 +26,14 @@ /* * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. + * + * Copyright (c) 2011, 2012, Whamcloud, Inc. */ /* * 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_LQUOTA #ifdef __KERNEL__ @@ -45,7 +43,6 @@ # include # include # include -# include # include # include # include @@ -62,7 +59,6 @@ #include #include "quota_internal.h" -#ifdef HAVE_QUOTA_SUPPORT #ifdef __KERNEL__ int mds_quota_ctl(struct obd_device *obd, struct obd_export *unused, @@ -289,135 +285,3 @@ adjust: RETURN(rc); } #endif /* __KERNEL__ */ -#endif - -int client_quota_ctl(struct obd_device *unused, struct obd_export *exp, - struct obd_quotactl *oqctl) -{ - struct ptlrpc_request *req; - struct obd_quotactl *oqc; - 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_QUOTACTL; - ver = LUSTRE_MDS_VERSION, - opc = MDS_QUOTACTL; - } else if (!strcmp(exp->exp_obd->obd_type->typ_name, LUSTRE_OSC_NAME)) { - rf = &RQF_OST_QUOTACTL; - ver = LUSTRE_OST_VERSION, - opc = OST_QUOTACTL; - } else { - RETURN(-EINVAL); - } - - req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), rf, ver, opc); - if (req == NULL) - RETURN(-ENOMEM); - - oqc = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL); - *oqc = *oqctl; - - ptlrpc_request_set_replen(req); - ptlrpc_at_set_req_timeout(req); - req->rq_no_resend = 1; - - rc = ptlrpc_queue_wait(req); - if (rc) - CERROR("ptlrpc_queue_wait failed, rc: %d\n", rc); - - if (req->rq_repmsg && - (oqc = req_capsule_server_get(&req->rq_pill, &RMF_OBD_QUOTACTL))) { - *oqctl = *oqc; - } else if (!rc) { - CERROR ("Can't unpack obd_quotactl\n"); - rc = -EPROTO; - } - - EXIT; - - ptlrpc_req_finished(req); - - return rc; -} - -/** - * For lmv, only need to send request to master MDT, and the master MDT will - * process with other slave MDTs. - */ -int lmv_quota_ctl(struct obd_device *unused, struct obd_export *exp, - struct obd_quotactl *oqctl) -{ - struct obd_device *obd = class_exp2obd(exp); - struct lmv_obd *lmv = &obd->u.lmv; - struct lmv_tgt_desc *tgt = &lmv->tgts[0]; - int rc; - ENTRY; - - if (!lmv->desc.ld_tgt_count || !tgt->ltd_active) { - CERROR("master lmv inactive\n"); - RETURN(-EIO); - } - - rc = obd_quotactl(tgt->ltd_exp, oqctl); - RETURN(rc); -} - -int lov_quota_ctl(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 lov_tgt_desc *tgt; - __u64 curspace = 0; - __u64 bhardlimit = 0; - int i, rc = 0; - ENTRY; - - if (oqctl->qc_cmd != LUSTRE_Q_QUOTAON && - oqctl->qc_cmd != LUSTRE_Q_QUOTAOFF && - oqctl->qc_cmd != Q_GETOQUOTA && - oqctl->qc_cmd != Q_INITQUOTA && - oqctl->qc_cmd != LUSTRE_Q_SETQUOTA && - oqctl->qc_cmd != Q_FINVALIDATE) { - CERROR("bad quota opc %x for lov obd", oqctl->qc_cmd); - RETURN(-EFAULT); - } - - /* for lov tgt */ - obd_getref(obd); - for (i = 0; i < lov->desc.ld_tgt_count; i++) { - int err; - - tgt = lov->lov_tgts[i]; - if (!tgt || !tgt->ltd_active || tgt->ltd_reap) { - if (oqctl->qc_cmd == Q_GETOQUOTA) { - rc = -EREMOTEIO; - CERROR("ost %d is inactive\n", i); - } else { - CDEBUG(D_HA, "ost %d is inactive\n", i); - } - continue; - } - - err = obd_quotactl(tgt->ltd_exp, oqctl); - if (err) { - if (tgt->ltd_active && !rc) - rc = err; - continue; - } - - if (oqctl->qc_cmd == Q_GETOQUOTA) { - curspace += oqctl->qc_dqblk.dqb_curspace; - bhardlimit += oqctl->qc_dqblk.dqb_bhardlimit; - } - } - obd_putref(obd); - - if (oqctl->qc_cmd == Q_GETOQUOTA) { - oqctl->qc_dqblk.dqb_curspace = curspace; - oqctl->qc_dqblk.dqb_bhardlimit = bhardlimit; - } - RETURN(rc); -}