Whamcloud - gitweb
LU-1182 osd-zfs: add accounting support
authorJohann Lombardi <johann@whamcloud.com>
Wed, 27 Jun 2012 14:36:34 +0000 (16:36 +0200)
committerAndreas Dilger <adilger@whamcloud.com>
Sun, 1 Jul 2012 19:01:49 +0000 (15:01 -0400)
Create QSD instance in ZFS OSD so that space accounting data
are exported via procfs.

Signed-off-by: Johann Lombardi <johann@whamcloud.com>
Change-Id: Ie44a8032d437beadcd0cf337f6271247538946c4
Reviewed-on: http://review.whamcloud.com/3201
Tested-by: Hudson
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
lustre/osd-zfs/Makefile.in
lustre/osd-zfs/osd_handler.c
lustre/osd-zfs/osd_index.c
lustre/osd-zfs/osd_internal.h

index f4754e1..2d8e190 100644 (file)
@@ -1,5 +1,5 @@
 MODULES := osd_zfs
 MODULES := osd_zfs
-osd_zfs-objs := osd_handler.o osd_lproc.o udmu.o
+osd_zfs-objs := osd_handler.o osd_lproc.o udmu.o osd_quota.o
 osd_zfs-objs += osd_object.o osd_io.o osd_oi.o osd_xattr.o osd_index.o
 
 EXTRA_PRE_CFLAGS += -I@SPL_DIR@ -I@SPL_DIR@/include
 osd_zfs-objs += osd_object.o osd_io.o osd_oi.o osd_xattr.o osd_index.o
 
 EXTRA_PRE_CFLAGS += -I@SPL_DIR@ -I@SPL_DIR@/include
index c8757ee..67240f3 100644 (file)
@@ -486,6 +486,14 @@ struct lu_context_key osd_key = {
 
 static int osd_shutdown(const struct lu_env *env, struct osd_device *o)
 {
 
 static int osd_shutdown(const struct lu_env *env, struct osd_device *o)
 {
+       ENTRY;
+
+       /* shutdown quota slave instance associated with the device */
+       if (o->od_quota_slave != NULL) {
+               qsd_fini(env, o->od_quota_slave);
+               o->od_quota_slave = NULL;
+       }
+
        RETURN(0);
 }
 
        RETURN(0);
 }
 
@@ -715,7 +723,19 @@ static int osd_recovery_complete(const struct lu_env *env, struct lu_device *d)
 static int osd_prepare(const struct lu_env *env, struct lu_device *pdev,
                       struct lu_device *dev)
 {
 static int osd_prepare(const struct lu_env *env, struct lu_device *pdev,
                       struct lu_device *dev)
 {
-       return 0;
+       struct osd_device       *osd = osd_dev(dev);
+       int                      rc = 0;
+       ENTRY;
+
+       /* initialize quota slave instance */
+       osd->od_quota_slave = qsd_init(env, osd->od_svname, &osd->od_dt_dev,
+                                      osd->od_proc_entry);
+       if (IS_ERR(osd->od_quota_slave)) {
+               rc = PTR_ERR(osd->od_quota_slave);
+               osd->od_quota_slave = NULL;
+       }
+
+       RETURN(rc);
 }
 
 struct lu_device_operations osd_lu_ops = {
 }
 
 struct lu_device_operations osd_lu_ops = {
index e240a1c..0cb3bca 100644 (file)
@@ -916,11 +916,9 @@ int osd_index_try(const struct lu_env *env, struct dt_object *dt,
                        dt->do_index_ops = &osd_dir_ops;
                else
                        RETURN(-ENOTDIR);
                        dt->do_index_ops = &osd_dir_ops;
                else
                        RETURN(-ENOTDIR);
-#if 0
        } else if (unlikely(feat == &dt_acct_features)) {
                LASSERT(fid_is_acct(lu_object_fid(&dt->do_lu)));
                dt->do_index_ops = &osd_acct_index_ops;
        } else if (unlikely(feat == &dt_acct_features)) {
                LASSERT(fid_is_acct(lu_object_fid(&dt->do_lu)));
                dt->do_index_ops = &osd_acct_index_ops;
-#endif
        } else if (udmu_object_is_zap(obj->oo_db) &&
                   dt->do_index_ops == NULL) {
                /* For index file, we don't support variable key & record sizes
        } else if (udmu_object_is_zap(obj->oo_db) &&
                   dt->do_index_ops == NULL) {
                /* For index file, we don't support variable key & record sizes
index 45bac12..540f2ec 100644 (file)
@@ -47,6 +47,7 @@
 #define _OSD_INTERNAL_H
 
 #include <dt_object.h>
 #define _OSD_INTERNAL_H
 
 #include <dt_object.h>
+#include <lquota.h>
 #include <sys/arc.h>
 
 #include <sys/nvpair.h>
 #include <sys/arc.h>
 
 #include <sys/nvpair.h>
@@ -222,6 +223,9 @@ struct osd_device {
        uint64_t                 od_iusr_oid;
        uint64_t                 od_igrp_oid;
 
        uint64_t                 od_iusr_oid;
        uint64_t                 od_igrp_oid;
 
+       /* quota slave instance */
+       struct qsd_instance     *od_quota_slave;
+
        /* used to debug zerocopy logic: the fields track all
         * allocated, loaned and referenced buffers in use.
         * to be removed once the change is tested well. */
        /* used to debug zerocopy logic: the fields track all
         * allocated, loaned and referenced buffers in use.
         * to be removed once the change is tested well. */