+struct tgt_new_client_callback {
+ struct dt_txn_commit_cb lncc_cb;
+ struct obd_export *lncc_exp;
+};
+
+static void tgt_cb_new_client(struct lu_env *env, struct thandle *th,
+ struct dt_txn_commit_cb *cb, int err)
+{
+ struct tgt_new_client_callback *ccb;
+
+ ccb = container_of0(cb, struct tgt_new_client_callback, lncc_cb);
+
+ LASSERT(ccb->lncc_exp->exp_obd);
+
+ CDEBUG(D_RPCTRACE, "%s: committing for initial connect of %s\n",
+ ccb->lncc_exp->exp_obd->obd_name,
+ ccb->lncc_exp->exp_client_uuid.uuid);
+
+ spin_lock(&ccb->lncc_exp->exp_lock);
+
+ ccb->lncc_exp->exp_need_sync = 0;
+
+ spin_unlock(&ccb->lncc_exp->exp_lock);
+ class_export_cb_put(ccb->lncc_exp);
+
+ OBD_FREE_PTR(ccb);
+}
+
+int tgt_new_client_cb_add(struct thandle *th, struct obd_export *exp)
+{
+ struct tgt_new_client_callback *ccb;
+ struct dt_txn_commit_cb *dcb;
+ int rc;
+
+ OBD_ALLOC_PTR(ccb);
+ if (ccb == NULL)
+ return -ENOMEM;
+
+ ccb->lncc_exp = class_export_cb_get(exp);
+
+ dcb = &ccb->lncc_cb;
+ dcb->dcb_func = tgt_cb_new_client;
+ INIT_LIST_HEAD(&dcb->dcb_linkage);
+ strlcpy(dcb->dcb_name, "tgt_cb_new_client", sizeof(dcb->dcb_name));
+
+ rc = dt_trans_cb_add(th, dcb);
+ if (rc) {
+ class_export_cb_put(exp);
+ OBD_FREE_PTR(ccb);
+ }
+ return rc;
+}
+