- * In DNE phase I, all remote updates will be packed into RPC (the format
- * description is in lustre_idl.h) during declare phase, all of updates
- * are attached to the transaction, one entry per OSP. Then in trans start,
- * LOD will walk through these entries and send these UPDATEs to the remote
- * MDT to be executed synchronously.
- */
-int osp_trans_start(const struct lu_env *env, struct dt_device *dt,
- struct thandle *th)
-{
- struct update_request *update;
- int rc = 0;
-
- /* In phase I, if the transaction includes remote updates, the local
- * update should be synchronized, so it will set th_sync = 1 */
- update = th->th_current_request;
- LASSERT(update != NULL && update->ur_dt == dt);
- if (update->ur_buf->ub_count > 0) {
- rc = osp_remote_sync(env, dt, update, NULL);
- th->th_sync = 1;
- }
-
- RETURN(rc);
-}
-
-/**
- * Insert the update into the th_bufs for the device.
- */
-static int osp_insert_update(const struct lu_env *env,
- struct update_request *update, int op,
- struct lu_fid *fid, int count,
- int *lens, char **bufs)
-{
- struct update_buf *ubuf = update->ur_buf;
- struct update *obj_update;
- char *ptr;
- int i;
- int update_length;
- int rc = 0;
- ENTRY;
-
- obj_update = (struct update *)((char *)ubuf +
- cfs_size_round(update_buf_size(ubuf)));
-
- /* Check update size to make sure it can fit into the buffer */
- update_length = cfs_size_round(offsetof(struct update,
- u_bufs[0]));
- for (i = 0; i < count; i++)
- update_length += cfs_size_round(lens[i]);
-
- if (cfs_size_round(update_buf_size(ubuf)) + update_length >
- UPDATE_BUFFER_SIZE || ubuf->ub_count >= UPDATE_MAX_OPS) {
- CERROR("%s: insert up %p, idx %d cnt %d len %lu: rc = %d\n",
- update->ur_dt->dd_lu_dev.ld_obd->obd_name, ubuf,
- update_length, ubuf->ub_count, update_buf_size(ubuf),
- -E2BIG);
- RETURN(-E2BIG);
- }
-
- if (count > UPDATE_BUF_COUNT) {
- CERROR("%s: Insert too much params %d "DFID" op %d: rc = %d\n",
- update->ur_dt->dd_lu_dev.ld_obd->obd_name, count,
- PFID(fid), op, -E2BIG);
- RETURN(-E2BIG);
- }
-
- /* fill the update into the update buffer */
- fid_cpu_to_le(&obj_update->u_fid, fid);
- obj_update->u_type = cpu_to_le32(op);
- obj_update->u_batchid = update->ur_batchid;
- for (i = 0; i < count; i++)
- obj_update->u_lens[i] = cpu_to_le32(lens[i]);
-
- ptr = (char *)obj_update +
- cfs_size_round(offsetof(struct update, u_bufs[0]));
- for (i = 0; i < count; i++)
- LOGL(bufs[i], lens[i], ptr);
-
- ubuf->ub_count++;
-
- CDEBUG(D_INFO, "%s: %p "DFID" idx %d: op %d params %d:%lu\n",
- update->ur_dt->dd_lu_dev.ld_obd->obd_name, ubuf, PFID(fid),
- ubuf->ub_count, op, count, update_buf_size(ubuf));
-
- RETURN(rc);
-}
-
-static struct update_request
-*osp_find_update(struct thandle *th, struct dt_device *dt_dev)
-{
- struct update_request *update;
-
- /* Because transaction api does not proivde the interface
- * to transfer the update from LOD to OSP, we need walk
- * remote update list to find the update, this probably
- * should move to LOD layer, when update can be part of
- * the trancation api parameter. XXX */
- cfs_list_for_each_entry(update, &th->th_remote_update_list, ur_list) {
- if (update->ur_dt == dt_dev)
- return update;
- }
- return NULL;
-}
-
-static inline void osp_md_add_update_batchid(struct update_request *update)
-{
- update->ur_batchid++;
-}
-
-/**
- * Find one loc in th_dev/dev_obj_update for the update,
- * Because only one thread can access this thandle, no need
- * lock now.