Whamcloud - gitweb
LU-12871 mdd: enable Changelog garbage collection
[fs/lustre-release.git] / lustre / mdd / mdd_device.c
index 7c88545..a00a240 100644 (file)
@@ -145,7 +145,7 @@ static int mdd_init0(const struct lu_env *env, struct mdd_device *mdd,
        /* sync permission changes */
        mdd->mdd_sync_permission = 1;
        /* enable changelog garbage collection */
-       mdd->mdd_changelog_gc = 0;
+       mdd->mdd_changelog_gc = 1;
        /* with a significant amount of idle time */
        mdd->mdd_changelog_max_idle_time = CHLOG_MAX_IDLE_TIME;
        /* or a significant amount of late indexes */
@@ -154,6 +154,9 @@ static int mdd_init0(const struct lu_env *env, struct mdd_device *mdd,
        mdd->mdd_changelog_min_gc_interval = CHLOG_MIN_GC_INTERVAL;
        /* with a very few number of free catalog entries */
        mdd->mdd_changelog_min_free_cat_entries = CHLOG_MIN_FREE_CAT_ENTRIES;
+       /* special default striping for files created with O_APPEND */
+       mdd->mdd_append_stripe_count = 1;
+       mdd->mdd_append_pool[0] = '\0';
 
        dt_conf_get(env, mdd->mdd_child, &mdd->mdd_dt_conf);
 
@@ -373,6 +376,8 @@ static int llog_changelog_cancel(const struct lu_env *env,
        RETURN(rc);
 }
 
+static struct llog_operations changelog_orig_logops;
+
 static int
 mdd_changelog_write_header(const struct lu_env *env, struct mdd_device *mdd,
                           int markerflags);
@@ -437,7 +442,7 @@ static int mdd_changelog_llog_init(const struct lu_env *env,
        OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt);
        obd->obd_lvfs_ctxt.dt = mdd->mdd_bottom;
        rc = llog_setup(env, obd, &obd->obd_olg, LLOG_CHANGELOG_ORIG_CTXT,
-                       obd, &llog_common_cat_ops);
+                       obd, &changelog_orig_logops);
        if (rc) {
                CERROR("%s: changelog llog setup failed: rc = %d\n",
                       obd->obd_name, rc);
@@ -470,7 +475,7 @@ static int mdd_changelog_llog_init(const struct lu_env *env,
 
        /* setup user changelog */
        rc = llog_setup(env, obd, &obd->obd_olg, LLOG_CHANGELOG_USER_ORIG_CTXT,
-                       obd, &llog_common_cat_ops);
+                       obd, &changelog_orig_logops);
        if (rc) {
                CERROR("%s: changelog users llog setup failed: rc = %d\n",
                       obd->obd_name, rc);
@@ -732,9 +737,6 @@ int mdd_changelog_write_header(const struct lu_env *env,
                                            rec->cr.cr_namelen);
        rec->cr_hdr.lrh_type = CHANGELOG_REC;
        rec->cr.cr_time = cl_time();
-       spin_lock(&mdd->mdd_cl.mc_lock);
-       rec->cr.cr_index = ++mdd->mdd_cl.mc_index;
-       spin_unlock(&mdd->mdd_cl.mc_lock);
 
        ctxt = llog_get_context(obd, LLOG_CHANGELOG_ORIG_CTXT);
        LASSERT(ctxt);
@@ -839,9 +841,21 @@ static int mdd_dummy_unlink(const struct lu_env *env,
        return -EPERM;
 }
 
+int mdd_create(const struct lu_env *env, struct md_object *pobj,
+                     const struct lu_name *lname, struct md_object *child,
+                     struct md_op_spec *spec, struct md_attr *ma);
+static int mdd_obf_create(const struct lu_env *env, struct md_object *pobj,
+                     const struct lu_name *lname, struct md_object *child,
+                     struct md_op_spec *spec, struct md_attr *ma)
+{
+       if (spec->sp_cr_flags & MDS_OPEN_VOLATILE)
+               return mdd_create(env, pobj, lname, child, spec, ma);
+       RETURN(-EPERM);
+}
+
 static struct md_dir_operations mdd_obf_dir_ops = {
        .mdo_lookup = obf_lookup,
-       .mdo_create = mdd_dummy_create,
+       .mdo_create = mdd_obf_create,
        .mdo_rename = mdd_dummy_rename,
        .mdo_link   = mdd_dummy_link,
        .mdo_unlink = mdd_dummy_unlink
@@ -1483,7 +1497,7 @@ static int mdd_obd_set_info_async(const struct lu_env *env,
        RETURN(rc);
 }
 
-static struct obd_ops mdd_obd_device_ops = {
+static const struct obd_ops mdd_obd_device_ops = {
        .o_owner        = THIS_MODULE,
        .o_connect      = mdd_obd_connect,
        .o_disconnect   = mdd_obd_disconnect,
@@ -1993,6 +2007,9 @@ static int __init mdd_init(void)
        if (rc)
                return rc;
 
+       changelog_orig_logops = llog_common_cat_ops;
+       changelog_orig_logops.lop_write_rec = mdd_changelog_write_rec;
+
        rc = class_register_type(&mdd_obd_device_ops, NULL, false, NULL,
                                 LUSTRE_MDD_NAME, &mdd_device_type);
        if (rc)