#endif
}
+enum scst_sg_copy_dir {
+ SCST_SG_COPY_FROM_TARGET,
+ SCST_SG_COPY_TO_TARGET
+};
+
+/*
+ * Copies data between cmd->tgt_sg and cmd->sg in direction defined by
+ * copy_dir parameter.
+ */
+void scst_copy_sg(struct scst_cmd *cmd, enum scst_sg_copy_dir copy_dir);
+
/*
* Functions for access to the commands data (SG) buffer,
* including HIGHMEM environment. Should be used instead of direct
TRACE_EXIT();
return;
}
+EXPORT_SYMBOL(scst_copy_sg);
static const int SCST_CDB_LENGTH[8] = { 6, 10, 10, -1, 16, 12, -1, -1 };
int scst_lib_init(void);
void scst_lib_exit(void);
-enum scst_sg_copy_dir {
- SCST_SG_COPY_FROM_TARGET,
- SCST_SG_COPY_TO_TARGET
-};
-void scst_copy_sg(struct scst_cmd *cmd, enum scst_sg_copy_dir);
-
uint64_t scst_pack_lun(const uint64_t lun);
uint64_t scst_unpack_lun(const uint8_t *lun, int len);
cmd->scst_cmd_done = scst_cmd_done_local;
cmd->state = SCST_CMD_STATE_LOCAL_EXEC;
- if (cmd->tgt_data_buf_alloced && cmd->dh_data_buf_alloced &&
- (cmd->data_direction & SCST_DATA_WRITE))
- scst_copy_sg(cmd, SCST_SG_COPY_FROM_TARGET);
-
rc = scst_do_local_exec(cmd);
if (likely(rc == SCST_EXEC_NOT_COMPLETED))
/* Nothing to do */;
goto out;
}
- if (cmd->tgt_data_buf_alloced && cmd->dh_data_buf_alloced &&
- (cmd->data_direction & SCST_DATA_READ))
- scst_copy_sg(cmd, SCST_SG_COPY_TO_TARGET);
-
cmd->state = SCST_CMD_STATE_XMIT_RESP;
res = SCST_CMD_STATE_RES_CONT_SAME;
return 0;
}
+static int scst_local_targ_pre_exec(struct scst_cmd *scst_cmd)
+{
+ int res = SCST_PREPROCESS_STATUS_SUCCESS;
+
+ TRACE_ENTRY();
+
+ if (scst_cmd_get_dh_data_buff_alloced(scst_cmd) &&
+ (scst_cmd_get_data_direction(scst_cmd) & SCST_DATA_WRITE))
+ scst_copy_sg(scst_cmd, SCST_SG_COPY_FROM_TARGET);
+
+ TRACE_EXIT_RES(res);
+ return res;
+}
+
static void scst_local_release_adapter(struct device *dev)
{
struct scst_local_host_info *scst_lcl_host;
return SCST_TGT_RES_SUCCESS;
}
+ if (scst_cmd_get_dh_data_buff_alloced(scst_cmd) &&
+ (scst_cmd_get_data_direction(scst_cmd) & SCST_DATA_READ))
+ scst_copy_sg(scst_cmd, SCST_SG_COPY_TO_TARGET);
+
tgt_specific = scst_cmd_get_tgt_priv(scst_cmd);
/*
.xmit_response_atomic = 1,
.detect = scst_local_targ_detect,
.release = scst_local_targ_release,
+ .pre_exec = scst_local_targ_pre_exec,
.xmit_response = scst_local_targ_xmit_response,
.on_free_cmd = scst_local_targ_on_free_cmd,
.task_mgmt_fn_done = scst_local_targ_task_mgmt_done,