+struct ofd_soft_sync_callback {
+ struct dt_txn_commit_cb ossc_cb;
+ struct obd_export *ossc_exp;
+};
+
+static void ofd_cb_soft_sync(struct lu_env *env, struct thandle *th,
+ struct dt_txn_commit_cb *cb, int err)
+{
+ struct ofd_soft_sync_callback *ossc;
+
+ ossc = container_of(cb, struct ofd_soft_sync_callback, ossc_cb);
+
+ CDEBUG(D_INODE, "export %p soft sync count is reset\n", ossc->ossc_exp);
+ atomic_set(&ossc->ossc_exp->exp_filter_data.fed_soft_sync_count, 0);
+
+ class_export_cb_put(ossc->ossc_exp);
+ OBD_FREE_PTR(ossc);
+}
+
+static int ofd_soft_sync_cb_add(struct thandle *th, struct obd_export *exp)
+{
+ struct ofd_soft_sync_callback *ossc;
+ struct dt_txn_commit_cb *dcb;
+ int rc;
+
+ OBD_ALLOC_PTR(ossc);
+ if (ossc == NULL)
+ return -ENOMEM;
+
+ ossc->ossc_exp = class_export_cb_get(exp);
+
+ dcb = &ossc->ossc_cb;
+ dcb->dcb_func = ofd_cb_soft_sync;
+ CFS_INIT_LIST_HEAD(&dcb->dcb_linkage);
+ strncpy(dcb->dcb_name, "ofd_cb_soft_sync", MAX_COMMIT_CB_STR_LEN);
+ dcb->dcb_name[MAX_COMMIT_CB_STR_LEN - 1] = '\0';
+
+ rc = dt_trans_cb_add(th, dcb);
+ if (rc) {
+ class_export_cb_put(exp);
+ OBD_FREE_PTR(ossc);
+ }
+
+ return rc;
+}
+