Whamcloud - gitweb
LU-7991 quota: project quota against ZFS backend
[fs/lustre-release.git] / lustre / osd-zfs / osd_handler.c
index 44a0c99..5adcd1a 100644 (file)
@@ -166,8 +166,6 @@ static void osd_trans_commit_cb(void *cb_data, int error)
 
        lu_device_put(lud);
        th->th_dev = NULL;
-       lu_context_exit(&th->th_ctx);
-       lu_context_fini(&th->th_ctx);
        OBD_FREE_PTR(oh);
 
        EXIT;
@@ -225,8 +223,6 @@ static int osd_trans_start(const struct lu_env *env, struct dt_device *d,
                /* add commit callback */
                dmu_tx_callback_register(oh->ot_tx, osd_trans_commit_cb, oh);
                oh->ot_assigned = 1;
-               lu_context_init(&th->th_ctx, th->th_tags);
-               lu_context_enter(&th->th_ctx);
                lu_device_get(&d->dd_lu_dev);
        }
 
@@ -360,7 +356,6 @@ static struct thandle *osd_trans_create(const struct lu_env *env,
        th = &oh->ot_super;
        th->th_dev = dt;
        th->th_result = 0;
-       th->th_tags = LCT_TX_HANDLE;
        RETURN(th);
 }
 
@@ -783,6 +778,13 @@ static void osd_readonly_changed_cb(void *arg, uint64_t newval)
        osd->od_prop_rdonly = !!newval;
 }
 
+static void osd_dnodesize_changed_cb(void *arg, uint64_t newval)
+{
+       struct osd_device *osd = arg;
+
+       osd->od_dnsize = newval;
+}
+
 /*
  * This function unregisters all registered callbacks.  It's harmless to
  * unregister callbacks that were never registered so it is used to safely
@@ -798,6 +800,8 @@ static void osd_objset_unregister_callbacks(struct osd_device *o)
                                   osd_recordsize_changed_cb, o);
        (void) dsl_prop_unregister(ds, zfs_prop_to_name(ZFS_PROP_READONLY),
                                   osd_readonly_changed_cb, o);
+       (void) dsl_prop_unregister(ds, zfs_prop_to_name(ZFS_PROP_DNODESIZE),
+                                  osd_readonly_changed_cb, o);
 
        if (o->arc_prune_cb != NULL) {
                arc_remove_prune_callback(o->arc_prune_cb);
@@ -834,6 +838,11 @@ static int osd_objset_register_callbacks(struct osd_device *o)
        if (rc)
                GOTO(err, rc);
 
+       rc = -dsl_prop_register(ds, zfs_prop_to_name(ZFS_PROP_DNODESIZE),
+                               osd_dnodesize_changed_cb, o);
+       if (rc)
+               GOTO(err, rc);
+
        o->arc_prune_cb = arc_add_prune_callback(arc_prune_func, o);
 err:
        dsl_pool_config_exit(dp, FTAG);
@@ -850,9 +859,10 @@ static int osd_objset_open(struct osd_device *o)
        int             rc;
        ENTRY;
 
-       rc = -dmu_objset_own(o->od_mntdev, DMU_OST_ZFS,
+       rc = -osd_dmu_objset_own(o->od_mntdev, DMU_OST_ZFS,
                             o->od_dt_dev.dd_rdonly ? B_TRUE : B_FALSE,
-                            o, &o->od_os);
+                            B_FALSE, o, &o->od_os);
+
        if (rc) {
                CERROR("%s: can't open %s\n", o->od_svname, o->od_mntdev);
                o->od_os = NULL;
@@ -916,7 +926,7 @@ static int osd_objset_open(struct osd_device *o)
 
 out:
        if (rc != 0 && o->od_os != NULL) {
-               dmu_objset_disown(o->od_os, o);
+               osd_dmu_objset_disown(o->od_os, B_FALSE, o);
                o->od_os = NULL;
        }
 
@@ -1068,6 +1078,15 @@ static int osd_mount(const struct lu_env *env,
        if (rc)
                GOTO(err, rc);
 
+#ifdef ZFS_PROJINHERIT
+       if (dmu_objset_projectquota_enabled(o->od_os)) {
+               rc = __osd_obj2dnode(o->od_os, DMU_PROJECTUSED_OBJECT,
+                                    &o->od_projectused_dn);
+               if (rc && rc != -ENOENT)
+                       GOTO(err, rc);
+       }
+#endif
+
        /* 1. initialize oi before any file create or file open */
        rc = osd_oi_init(env, o);
        if (rc)
@@ -1099,6 +1118,13 @@ static int osd_mount(const struct lu_env *env,
                GOTO(err, rc);
        }
 
+#ifdef HAVE_DMU_USEROBJ_ACCOUNTING
+       if (!osd_dmu_userobj_accounting_available(o))
+               CWARN("%s: dnode accounting not enabled: "
+                     "enable feature@userobj_accounting in pool\n",
+                     o->od_mntdev);
+#endif
+
        /* parse mount option "noacl", and enable ACL by default */
        opts = lustre_cfg_string(cfg, 3);
        if (opts == NULL || strstr(opts, "noacl") == NULL)
@@ -1107,7 +1133,7 @@ static int osd_mount(const struct lu_env *env,
        osd_unlinked_drain(env, o);
 err:
        if (rc && o->od_os) {
-               dmu_objset_disown(o->od_os, o);
+               osd_dmu_objset_disown(o->od_os, B_FALSE, o);
                o->od_os = NULL;
        }
 
@@ -1141,14 +1167,20 @@ static void osd_umount(const struct lu_env *env, struct osd_device *o)
                o->od_groupused_dn = NULL;
        }
 
+#ifdef ZFS_PROJINHERIT
+       if (o->od_projectused_dn) {
+               osd_dnode_rele(o->od_projectused_dn);
+               o->od_projectused_dn = NULL;
+       }
+#endif
+
        if (o->od_os != NULL) {
                if (!o->od_dt_dev.dd_rdonly)
                        /* force a txg sync to get all commit callbacks */
                        txg_wait_synced(dmu_objset_pool(o->od_os), 0ULL);
 
                /* close the object set */
-               dmu_objset_disown(o->od_os, o);
-
+               osd_dmu_objset_disown(o->od_os, B_FALSE, o);
                o->od_os = NULL;
        }