Let's don't check if data should be copied between dev handler's and target driver...
authorvlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Thu, 22 Oct 2009 15:40:42 +0000 (15:40 +0000)
committervlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Thu, 22 Oct 2009 15:40:42 +0000 (15:40 +0000)
git-svn-id: https://scst.svn.sourceforge.net/svnroot/scst/trunk@1244 d57e44dd-8a1f-0410-8b47-8ef2f437770f

scst/include/scst.h
scst/src/scst_lib.c
scst/src/scst_priv.h
scst/src/scst_targ.c
scst_local/scst_local.c

index f9e61b7..71d881d 100644 (file)
@@ -3014,6 +3014,17 @@ static inline void sg_clear(struct scatterlist *sg)
 #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
index 024f9b1..ec2c627 100644 (file)
@@ -3184,6 +3184,7 @@ out:
        TRACE_EXIT();
        return;
 }
+EXPORT_SYMBOL(scst_copy_sg);
 
 static const int SCST_CDB_LENGTH[8] = { 6, 10, 10, -1, 16, 12, -1, -1 };
 
index 457db79..9c92ea4 100644 (file)
@@ -401,12 +401,6 @@ int scst_alloc_space(struct scst_cmd *cmd);
 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);
 
index 5b939e4..6609477 100644 (file)
@@ -2238,10 +2238,6 @@ static int scst_exec(struct scst_cmd **active_cmd)
                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 */;
@@ -2907,10 +2903,6 @@ static int scst_pre_xmit_response(struct scst_cmd *cmd)
                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;
 
index dafb8d1..00ca707 100644 (file)
@@ -618,6 +618,20 @@ static int scst_local_queuecommand(struct scsi_cmnd *SCpnt,
        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;
@@ -1068,6 +1082,10 @@ static int scst_local_targ_xmit_response(struct scst_cmd *scst_cmd)
                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);
 
        /*
@@ -1124,6 +1142,7 @@ static struct scst_tgt_template scst_local_targ_tmpl = {
        .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,