From 52c95d51f1906d4d838dec3419e39457a8e17824 Mon Sep 17 00:00:00 2001 From: Johann Lombardi Date: Tue, 26 Jun 2012 01:57:54 +0200 Subject: [PATCH] LU-1182 ofd: add space accounting support Add space accounting support to OFD. This is done by calling into the lquota library which looks up space usage via the accounting objects. Report success on quotacheck, quotaon & quotaoff for the time being, otherwise space accounting can't be tested with current MDT stack which requires quotacheck to be run for space accounting to be enabled. Signed-off-by: Johann Lombardi Change-Id: I442f3d1bcc9e7c95bb3f505f7a00665419d0f517 Reviewed-on: http://review.whamcloud.com/3186 Tested-by: Hudson Reviewed-by: Niu Yawei Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/ofd/lproc_ofd.c | 4 ++++ lustre/ofd/ofd_obd.c | 41 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/lustre/ofd/lproc_ofd.c b/lustre/ofd/lproc_ofd.c index 28f5ab4..64c046d 100644 --- a/lustre/ofd/lproc_ofd.c +++ b/lustre/ofd/lproc_ofd.c @@ -41,6 +41,7 @@ #include #include #include +#include #include "ofd_internal.h" @@ -463,6 +464,9 @@ static struct lprocfs_vars lprocfs_ofd_obd_vars[] = { { "capa", lprocfs_ofd_rd_capa, lprocfs_ofd_wr_capa, 0 }, { "capa_count", lprocfs_ofd_rd_capa_count, 0, 0 }, + /* we still register a fake quota type file for backward compatibility*/ + { "quota_type", lprocfs_quota_rd_type_dumb, + lprocfs_quota_wr_type_dumb, 0}, { 0 } }; diff --git a/lustre/ofd/ofd_obd.c b/lustre/ofd/ofd_obd.c index 415bfe8..a49b490 100644 --- a/lustre/ofd/ofd_obd.c +++ b/lustre/ofd/ofd_obd.c @@ -44,6 +44,7 @@ #include "ofd_internal.h" #include +#include static int ofd_export_stats_init(struct ofd_device *ofd, struct obd_export *exp, void *client_nid) @@ -1426,6 +1427,9 @@ static int ofd_obd_notify(struct obd_device *obd, struct obd_device *unused, /* * Handle quotacheck requests. + * Although in-kernel quotacheck isn't supported any more, we still emulate it + * in order to interoperate with current MDT stack which needs proper + * quotacheck support, even for space accounting. * * \param obd - is the obd device associated with the ofd * \param exp - is the client's export @@ -1434,7 +1438,23 @@ static int ofd_obd_notify(struct obd_device *obd, struct obd_device *unused, static int ofd_quotacheck(struct obd_device *obd, struct obd_export *exp, struct obd_quotactl *oqctl) { - return 0; + struct ptlrpc_request *req; + struct obd_quotactl *body; + ENTRY; + + req = ptlrpc_request_alloc_pack(exp->exp_imp_reverse, &RQF_QC_CALLBACK, + LUSTRE_OBD_VERSION, OBD_QC_CALLBACK); + if (req == NULL) + RETURN(-ENOMEM); + + body = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL); + oqctl->qc_stat = 0; + memcpy(body, oqctl, sizeof(*body)); + + ptlrpc_request_set_replen(req); + ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1); + + RETURN(0); } /* @@ -1448,7 +1468,24 @@ static int ofd_quotacheck(struct obd_device *obd, struct obd_export *exp, static int ofd_quotactl(struct obd_device *obd, struct obd_export *exp, struct obd_quotactl *oqctl) { - return 0; + struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev); + struct lu_env env; + int rc; + ENTRY; + + /* report success for quota on/off for interoperability with current MDT + * stack */ + if (oqctl->qc_cmd == Q_QUOTAON || oqctl->qc_cmd == Q_QUOTAOFF) + RETURN(0); + + rc = lu_env_init(&env, LCT_DT_THREAD); + if (rc) + RETURN(rc); + + rc = lquotactl_slv(&env, ofd->ofd_osd, oqctl); + lu_env_fini(&env); + + RETURN(rc); } struct obd_ops ofd_obd_ops = { -- 1.8.3.1