Merge branch 'zero_copy_write-3' into resolve-conflicts

Conflicts:
	lib/iscsi-command.c
	lib/pdu.c
	lib/socket.c
This commit is contained in:
Ronnie Sahlberg
2012-11-29 18:46:51 -08:00
9 changed files with 483 additions and 311 deletions

View File

@@ -218,10 +218,12 @@ struct iscsi_pdu {
void *private_data;
int written;
struct iscsi_data outdata; /* Header and Immediate Data */
struct iscsi_data indata;
struct iscsi_data nidata; /* Non-Immediate Data */
struct iscsi_data outdata; /* Header for PDU to send */
uint32_t out_offset; /* Offset into data-out iovector */
uint32_t out_len; /* Amount of data to sent */
struct iscsi_data indata;
struct iscsi_scsi_cbdata scsi_cbdata;
};
@@ -231,21 +233,11 @@ void iscsi_free_scsi_cbdata(struct iscsi_context *iscsi, struct iscsi_scsi_cbdat
struct iscsi_pdu *iscsi_allocate_pdu(struct iscsi_context *iscsi,
enum iscsi_opcode opcode,
enum iscsi_opcode response_opcode);
struct iscsi_pdu *iscsi_allocate_pdu_size(struct iscsi_context *iscsi,
enum iscsi_opcode opcode,
enum iscsi_opcode response_opcode,
size_t payload_size);
struct iscsi_pdu *iscsi_allocate_pdu_with_itt_flags(struct iscsi_context *iscsi,
enum iscsi_opcode opcode,
enum iscsi_opcode response_opcode,
uint32_t itt,
uint32_t flags);
struct iscsi_pdu *iscsi_allocate_pdu_with_itt_flags_size(struct iscsi_context *iscsi,
enum iscsi_opcode opcode,
enum iscsi_opcode response_opcode,
uint32_t itt,
uint32_t flags,
size_t payload_size);
void iscsi_free_pdu(struct iscsi_context *iscsi, struct iscsi_pdu *pdu);
void iscsi_pdu_set_pduflags(struct iscsi_pdu *pdu, unsigned char flags);
void iscsi_pdu_set_immediate(struct iscsi_pdu *pdu);
@@ -303,7 +295,8 @@ void iscsi_set_error(struct iscsi_context *iscsi, const char *error_string,
...) __attribute__((format(printf, 2, 3)));
unsigned char *iscsi_get_user_in_buffer(struct iscsi_context *iscsi, struct iscsi_in_pdu *in, uint32_t pos, ssize_t *count);
unsigned char *scsi_task_get_data_in_buffer(struct scsi_task *task, uint32_t pos, ssize_t *count);
unsigned char *iscsi_get_user_out_buffer(struct iscsi_context *iscsi, struct iscsi_pdu *pdu, uint32_t pos, ssize_t *count);
inline void* iscsi_malloc(struct iscsi_context *iscsi, size_t size);
inline void* iscsi_zmalloc(struct iscsi_context *iscsi, size_t size);

View File

@@ -537,7 +537,6 @@ iscsi_task_mgmt_target_cold_reset_async(struct iscsi_context *iscsi,
struct iscsi_data {
int size;
size_t alloc_size;
unsigned char *data;
};
@@ -929,25 +928,33 @@ iscsi_report_supported_opcodes_sync(struct iscsi_context *iscsi, int lun,
int return_timeouts, int maxsize);
/*
* This function is used when the application wants to specify its own buffers to read the data
* from the DATA-IN PDUs into.
* The main use is for SCSI read operations to have them write directly into the application buffers to
* avoid the two copies that would occur otherwise.
* First copy from the individual DATA-IN blobs to linearize the buffer and the second in the callback
* to copy the data from the linearized buffer into the application buffer.
* These functions are used when the application wants to specify its own buffers to read the data
* from the DATA-IN PDUs into, or write the data to DATA-OUT PDUs from.
* The main use is for SCSI READ10/12/16 WRITE10/12/16 operations to have them read/write directly from
* the applications buffer, avoiding coying the data.
*
* This also supports reading into a vector of buffers by calling this function multiple times.
* The individual buffers will be filled in the same order as they were created.
*
* Example:
* Example READ10:
* task = iscsi_read10_task( ( 2 512byte blocks into two buffers)
* scsi_task_add_data_in_buffer(task, first_buffer, 512
* scsi_task_add_data_in_buffer(task, second_buffer, 512
*
*
* If you use this function you can not use task->datain in the callback.
* If you use this function you can not use task->datain in the READ callback.
* task->datain.size will be 0 and
* task->datain.data will be NULL
*
* Example WRITE10: (write 2 blocks)
* static struct scsi_iovec iov[2];
*
* task = iscsi_write10_task(iscsi, lun, 0, NULL, 512, 512, 0, 0, 0, 0, 0, callback, private_data);
* iov[0].iov_base = first_buffer;
* iov[0].iov_len = 512;
* iov[1].iov_base = second_buffer;
* iov[1].iov_len = 512;
* scsi_task_set_iov_out(task, &iov[0], 2);
*/
EXTERN int scsi_task_add_data_in_buffer(struct scsi_task *task, int len, unsigned char *buf);
EXTERN int scsi_task_add_data_out_buffer(struct scsi_task *task, int len, unsigned char *buf);

View File

@@ -205,10 +205,10 @@ struct scsi_iovec {
};
struct scsi_iovector {
struct scsi_iovec *iov;
int niov;
int nalloc;
size_t size;
struct scsi_iovec *iov;
int niov;
int nalloc;
size_t size;
size_t offset;
int consumed;
};
@@ -690,6 +690,9 @@ EXTERN int scsi_datain_getfullsize(struct scsi_task *task);
EXTERN void *scsi_datain_unmarshall(struct scsi_task *task);
EXTERN void *scsi_cdb_unmarshall(struct scsi_task *task, enum scsi_opcode opcode);
unsigned char *scsi_task_get_data_in_buffer(struct scsi_task *task, uint32_t pos, ssize_t *count);
unsigned char *scsi_task_get_data_out_buffer(struct scsi_task *task, uint32_t pos, ssize_t *count);
EXTERN struct scsi_task *scsi_cdb_read6(uint32_t lba, uint32_t xferlen, int blocksize);
EXTERN struct scsi_task *scsi_cdb_read10(uint32_t lba, uint32_t xferlen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group_number);
EXTERN struct scsi_task *scsi_cdb_read12(uint32_t lba, uint32_t xferlen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group_number);