Whamcloud - gitweb
LU-1798 tests: add set_and_check to test-framework
[fs/lustre-release.git] / lustre / ofd / ofd_fs.c
index 31bca72..a21586d 100644 (file)
@@ -68,6 +68,17 @@ int ofd_record_write(const struct lu_env *env, struct ofd_device *ofd,
        RETURN(rc);
 }
 
+int ofd_precreate_batch(struct ofd_device *ofd, int batch)
+{
+       int count;
+
+       cfs_spin_lock(&ofd->ofd_objid_lock);
+       count = min(ofd->ofd_precreate_batch, batch);
+       cfs_spin_unlock(&ofd->ofd_objid_lock);
+
+       return count;
+}
+
 obd_id ofd_last_id(struct ofd_device *ofd, obd_seq group)
 {
        obd_id id;
@@ -221,6 +232,7 @@ int ofd_groups_init(const struct lu_env *env, struct ofd_device *ofd)
        if (rc)
                GOTO(cleanup, rc);
 
+       ofd->ofd_precreate_batch = OFD_PRECREATE_BATCH_DEFAULT;
        groups_size = (unsigned long)info->fti_attr.la_size;
 
        if (groups_size == sizeof(last_group)) {
@@ -324,7 +336,6 @@ int ofd_clients_data_init(const struct lu_env *env, struct ofd_device *ofd,
                fed = &exp->exp_filter_data;
                *fed->fed_ted.ted_lcd = *lcd;
 
-               ofd_export_stats_init(ofd, exp, NULL);
                rc = lut_client_add(env, exp, cl_idx);
                LASSERTF(rc == 0, "rc = %d\n", rc); /* can't fail existing */
                /* VBR: set export last committed version */
@@ -468,6 +479,16 @@ int ofd_fs_setup(const struct lu_env *env, struct ofd_device *ofd,
        if (OBD_FAIL_CHECK(OBD_FAIL_MDS_FS_SETUP))
                RETURN (-ENOENT);
 
+       /* prepare transactions callbacks */
+       ofd->ofd_txn_cb.dtc_txn_start = NULL;
+       ofd->ofd_txn_cb.dtc_txn_stop = ofd_txn_stop_cb;
+       ofd->ofd_txn_cb.dtc_txn_commit = NULL;
+       ofd->ofd_txn_cb.dtc_cookie = ofd;
+       ofd->ofd_txn_cb.dtc_tag = LCT_DT_THREAD;
+       CFS_INIT_LIST_HEAD(&ofd->ofd_txn_cb.dtc_linkage);
+
+       dt_txn_callback_add(ofd->ofd_osd, &ofd->ofd_txn_cb);
+
        rc = ofd_server_data_init(env, ofd);
        if (rc)
                GOTO(out, rc);
@@ -508,6 +529,7 @@ out_lg:
 out_hc:
        lu_object_put(env, &ofd->ofd_health_check_file->do_lu);
 out:
+       dt_txn_callback_del(ofd->ofd_osd, &ofd->ofd_txn_cb);
        return rc;
 }
 
@@ -530,6 +552,9 @@ void ofd_fs_cleanup(const struct lu_env *env, struct ofd_device *ofd)
        if (i)
                CERROR("can't sync: %d\n", i);
 
+       /* Remove transaction callback */
+       dt_txn_callback_del(ofd->ofd_osd, &ofd->ofd_txn_cb);
+
        if (ofd->ofd_last_group_file) {
                lu_object_put(env, &ofd->ofd_last_group_file->do_lu);
                ofd->ofd_last_group_file = NULL;