From f1c56a55d453855f8fa57d5aded8800dfb53f060 Mon Sep 17 00:00:00 2001 From: Johann Lombardi Date: Wed, 27 Jun 2012 16:36:34 +0200 Subject: [PATCH] LU-1182 osd-zfs: add accounting support Create QSD instance in ZFS OSD so that space accounting data are exported via procfs. Signed-off-by: Johann Lombardi Change-Id: Ie44a8032d437beadcd0cf337f6271247538946c4 Reviewed-on: http://review.whamcloud.com/3201 Tested-by: Hudson Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Alex Zhuravlev --- lustre/osd-zfs/Makefile.in | 2 +- lustre/osd-zfs/osd_handler.c | 22 +++++++++++++++++++++- lustre/osd-zfs/osd_index.c | 2 -- lustre/osd-zfs/osd_internal.h | 4 ++++ 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/lustre/osd-zfs/Makefile.in b/lustre/osd-zfs/Makefile.in index f4754e1..2d8e190 100644 --- a/lustre/osd-zfs/Makefile.in +++ b/lustre/osd-zfs/Makefile.in @@ -1,5 +1,5 @@ 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 diff --git a/lustre/osd-zfs/osd_handler.c b/lustre/osd-zfs/osd_handler.c index c8757ee..67240f3 100644 --- a/lustre/osd-zfs/osd_handler.c +++ b/lustre/osd-zfs/osd_handler.c @@ -486,6 +486,14 @@ struct lu_context_key osd_key = { 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); } @@ -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) { - 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 = { diff --git a/lustre/osd-zfs/osd_index.c b/lustre/osd-zfs/osd_index.c index e240a1c..0cb3bca 100644 --- a/lustre/osd-zfs/osd_index.c +++ b/lustre/osd-zfs/osd_index.c @@ -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); -#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; -#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 diff --git a/lustre/osd-zfs/osd_internal.h b/lustre/osd-zfs/osd_internal.h index 45bac12..540f2ec 100644 --- a/lustre/osd-zfs/osd_internal.h +++ b/lustre/osd-zfs/osd_internal.h @@ -47,6 +47,7 @@ #define _OSD_INTERNAL_H #include +#include #include #include @@ -222,6 +223,9 @@ struct osd_device { 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. */ -- 1.8.3.1