Whamcloud - gitweb
LU-1182 ofd: add space accounting support
authorJohann Lombardi <johann@whamcloud.com>
Mon, 25 Jun 2012 23:57:54 +0000 (01:57 +0200)
committerAndreas Dilger <adilger@whamcloud.com>
Fri, 29 Jun 2012 22:00:09 +0000 (18:00 -0400)
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 <johann@whamcloud.com>
Change-Id: I442f3d1bcc9e7c95bb3f505f7a00665419d0f517
Reviewed-on: http://review.whamcloud.com/3186
Tested-by: Hudson
Reviewed-by: Niu Yawei <niu@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/ofd/lproc_ofd.c
lustre/ofd/ofd_obd.c

index 28f5ab4..64c046d 100644 (file)
@@ -41,6 +41,7 @@
 #include <obd.h>
 #include <lprocfs_status.h>
 #include <linux/seq_file.h>
+#include <lquota.h>
 
 #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 }
 };
 
index 415bfe8..a49b490 100644 (file)
@@ -44,6 +44,7 @@
 
 #include "ofd_internal.h"
 #include <obd_cksum.h>
+#include <lquota.h>
 
 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 = {