if (IS_ERR(th))
return th;
- CFS_INIT_LIST_HEAD(&th->th_remote_update_list);
return th;
}
-static int lod_remote_sync(const struct lu_env *env, struct dt_device *dev,
- struct thandle *th)
-{
- struct update_request *update;
- int rc = 0;
- ENTRY;
-
- if (cfs_list_empty(&th->th_remote_update_list))
- RETURN(0);
-
- cfs_list_for_each_entry(update, &th->th_remote_update_list,
- ur_list) {
- /* In DNE phase I, there should be only one OSP
- * here, so we will do send/receive one by one,
- * instead of sending them parallel, will fix this
- * in Phase II */
- th->th_current_request = update;
- rc = dt_trans_start(env, update->ur_dt, th);
- if (rc != 0) {
- /* FIXME how to revert the partial results
- * once error happened? Resolved by 2 Phase commit */
- update->ur_rc = rc;
- break;
- }
- }
-
- RETURN(rc);
-}
-
static int lod_trans_start(const struct lu_env *env, struct dt_device *dev,
struct thandle *th)
{
struct lod_device *lod = dt2lod_dev((struct dt_device *) dev);
- int rc;
+ int rc = 0;
- rc = lod_remote_sync(env, dev, th);
- if (rc)
- return rc;
+ if (unlikely(th->th_update != NULL)) {
+ struct thandle_update *tu = th->th_update;
+ struct update_request *update;
+ list_for_each_entry(update, &tu->tu_remote_update_list,
+ ur_list) {
+ LASSERT(update->ur_dt != NULL);
+ rc = dt_trans_start(env, update->ur_dt, th);
+ if (rc != 0)
+ return rc;
+ }
+ }
return dt_trans_start(env, lod->lod_child, th);
}
-static int lod_trans_stop(const struct lu_env *env, struct thandle *th)
+static int lod_trans_stop(const struct lu_env *env, struct dt_device *dt,
+ struct thandle *th)
{
- struct update_request *update;
- struct update_request *tmp;
- int rc = 0;
- int rc2 = 0;
+ struct thandle_update *tu = th->th_update;
+ struct update_request *update;
+ struct update_request *tmp;
+ int rc2 = 0;
+ int rc;
+ ENTRY;
+
+ rc = dt_trans_stop(env, th->th_dev, th);
+ if (likely(tu == NULL))
+ RETURN(rc);
- cfs_list_for_each_entry_safe(update, tmp,
- &th->th_remote_update_list,
- ur_list) {
- th->th_current_request = update;
+ list_for_each_entry_safe(update, tmp, &tu->tu_remote_update_list,
+ ur_list) {
+ /* update will be freed inside dt_trans_stop */
rc2 = dt_trans_stop(env, update->ur_dt, th);
if (unlikely(rc2 != 0 && rc == 0))
rc = rc2;
}
- rc2 = dt_trans_stop(env, th->th_dev, th);
-
- return rc2 != 0 ? rc2 : rc;
+ RETURN(rc);
}
static void lod_conf_get(const struct lu_env *env,