Whamcloud - gitweb
LU-1842 quota: add per-filesystem information
[fs/lustre-release.git] / lustre / osd-zfs / osd_handler.c
index c7cb402..6da92fa 100644 (file)
@@ -505,9 +505,17 @@ static int osd_shutdown(const struct lu_env *env, struct osd_device *o)
        RETURN(0);
 }
 
+static void osd_xattr_changed_cb(void *arg, uint64_t newval)
+{
+       struct osd_device *osd = arg;
+
+       osd->od_xattr_in_sa = (newval == ZFS_XATTR_SA);
+}
+
 static int osd_mount(const struct lu_env *env,
                     struct osd_device *o, struct lustre_cfg *cfg)
 {
+       struct dsl_dataset *ds;
        char      *dev  = lustre_cfg_string(cfg, 1);
        dmu_buf_t *rootdb;
        int        rc;
@@ -529,6 +537,13 @@ static int osd_mount(const struct lu_env *env,
                RETURN(rc);
        }
 
+       ds = dmu_objset_ds(o->od_objset.os);
+       LASSERT(ds);
+       rc = dsl_prop_register(ds, "xattr", osd_xattr_changed_cb, o);
+       if (rc)
+               CERROR("%s: cat not register xattr callback, ignore: %d\n",
+                      o->od_svname, rc);
+
        rc = __osd_obj2dbuf(env, o->od_objset.os, o->od_objset.root,
                                &rootdb, root_tag);
        if (rc) {
@@ -564,6 +579,14 @@ static int osd_mount(const struct lu_env *env,
 
        o->arc_prune_cb = arc_add_prune_callback(arc_prune_func, o);
 
+       /* initialize quota slave instance */
+       o->od_quota_slave = qsd_init(env, o->od_svname, &o->od_dt_dev,
+                                    o->od_proc_entry);
+       if (IS_ERR(o->od_quota_slave)) {
+               rc = PTR_ERR(o->od_quota_slave);
+               o->od_quota_slave = NULL;
+               GOTO(err, rc);
+       }
 err:
        RETURN(rc);
 }
@@ -668,6 +691,7 @@ static struct lu_device *osd_device_fini(const struct lu_env *env,
                                         struct lu_device *d)
 {
        struct osd_device *o = osd_dev(d);
+       struct dsl_dataset *ds;
        int                rc;
        ENTRY;
 
@@ -675,6 +699,11 @@ static struct lu_device *osd_device_fini(const struct lu_env *env,
        osd_oi_fini(env, o);
 
        if (o->od_objset.os) {
+               ds = dmu_objset_ds(o->od_objset.os);
+               rc = dsl_prop_unregister(ds, "xattr", osd_xattr_changed_cb, o);
+               if (rc)
+                       CERROR("%s: dsl_prop_unregister xattr error %d\n",
+                               o->od_svname, rc);
                arc_remove_prune_callback(o->arc_prune_cb);
                o->arc_prune_cb = NULL;
                osd_sync(env, lu2dt_dev(d));
@@ -789,14 +818,19 @@ static int osd_prepare(const struct lu_env *env, struct lu_device *pdev,
        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;
+       if (dev->ld_site && lu_device_is_md(dev->ld_site->ls_top_dev)) {
+               /* MDT/MDD still use old infrastructure to create
+                * special files */
+               rc = llo_local_objects_setup(env, lu2md_dev(pdev),
+                                            lu2dt_dev(dev));
+               if (rc)
+                       RETURN(rc);
        }
 
+       if (osd->od_quota_slave != NULL)
+               /* set up quota slave objects */
+               rc = qsd_prepare(env, osd->od_quota_slave);
+
        RETURN(rc);
 }