Permalink
Browse files

Implement READ/WRITE_12/16 and a simple test for read16

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
  • Loading branch information...
1 parent 9e5535a commit 974738968df92782399381ac3dfe1b616203fee4 @sahlberg committed May 1, 2012
Showing with 605 additions and 12 deletions.
  1. +2 −1 Makefile.am
  2. +46 −6 include/iscsi.h
  3. +28 −3 include/scsi-lowlevel.h
  4. +4 −0 lib/libiscsi.def
  5. +130 −0 lib/scsi-command.c
  6. +187 −2 lib/scsi-lowlevel.c
  7. +90 −0 lib/sync.c
  8. +113 −0 test-tool/0200_read16_simple.c
  9. +3 −0 test-tool/iscsi-test.c
  10. +2 −0 test-tool/iscsi-test.h
View
@@ -66,7 +66,8 @@ bin_iscsi_test_SOURCES = test-tool/iscsi-test.c \
test-tool/0160_readcapacity16_simple.c \
test-tool/0170_unmap_simple.c test-tool/0171_unmap_zero.c \
test-tool/0180_writesame10_unmap.c test-tool/0181_writesame10_unmap_unaligned.c \
- test-tool/0190_writesame16_unmap.c test-tool/0191_writesame16_unmap_unaligned.c
+ test-tool/0190_writesame16_unmap.c test-tool/0191_writesame16_unmap_unaligned.c \
+ test-tool/0200_read16_simple.c
endif
# LD_PRELOAD library.
View
@@ -599,9 +599,29 @@ iscsi_read10_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
EXTERN struct scsi_task *
iscsi_write10_task(struct iscsi_context *iscsi, int lun,
unsigned char *data, uint32_t datalen, uint32_t lba, int fua,
- int fuanv, int blocksize, iscsi_command_cb cb,
+ int fua_nv, int blocksize, iscsi_command_cb cb,
void *private_data);
EXTERN struct scsi_task *
+iscsi_read12_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
+ uint32_t datalen, int blocksize,
+ int rdprotect, int dpo, int fua, int fua_nv, int group_number,
+ iscsi_command_cb cb, void *private_data);
+EXTERN struct scsi_task *
+iscsi_write12_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
+ unsigned char *data, uint32_t datalen, int blocksize,
+ int wrprotect, int dpo, int fua, int fua_nv, int group_number,
+ iscsi_command_cb cb, void *private_data);
+EXTERN struct scsi_task *
+iscsi_read16_task(struct iscsi_context *iscsi, int lun, uint64_t lba,
+ uint32_t datalen, int blocksize,
+ int rdprotect, int dpo, int fua, int fua_nv, int group_number,
+ iscsi_command_cb cb, void *private_data);
+EXTERN struct scsi_task *
+iscsi_write16_task(struct iscsi_context *iscsi, int lun, uint64_t lba,
+ unsigned char *data, uint32_t datalen, int blocksize,
+ int wrprotect, int dpo, int fua, int fua_nv, int group_number,
+ iscsi_command_cb cb, void *private_data);
+EXTERN struct scsi_task *
iscsi_verify10_task(struct iscsi_context *iscsi, int lun,
unsigned char *data, uint32_t datalen, uint32_t lba,
int vprotect, int dpo, int bytchk,
@@ -664,6 +684,31 @@ EXTERN struct scsi_task *
iscsi_read10_sync(struct iscsi_context *iscsi, int lun, uint32_t lba,
uint32_t datalen, int blocksize);
+EXTERN struct scsi_task *
+iscsi_write10_sync(struct iscsi_context *iscsi, int lun,
+ unsigned char *data, uint32_t datalen, uint32_t lba, int fua,
+ int fua_nv, int blocksize);
+
+EXTERN struct scsi_task *
+iscsi_read12_sync(struct iscsi_context *iscsi, int lun, uint32_t lba,
+ uint32_t datalen, int blocksize,
+ int rdprotect, int dpo, int fua, int fua_nv, int group_number);
+
+EXTERN struct scsi_task *
+iscsi_write12_sync(struct iscsi_context *iscsi, int lun, uint32_t lba,
+ unsigned char *data, uint32_t datalen, int blocksize,
+ int wrprotect, int dpo, int fua, int fua_nv, int group_number);
+
+EXTERN struct scsi_task *
+iscsi_read16_sync(struct iscsi_context *iscsi, int lun, uint64_t lba,
+ uint32_t datalen, int blocksize,
+int rdprotect, int dpo, int fua, int fua_nv, int group_number);
+
+EXTERN struct scsi_task *
+iscsi_write16_sync(struct iscsi_context *iscsi, int lun, uint64_t lba,
+ unsigned char *data, uint32_t datalen, int blocksize,
+ int wrprotect, int dpo, int fua, int fua_nv, int group_number);
+
EXTERN struct scsi_task *
iscsi_readcapacity10_sync(struct iscsi_context *iscsi, int lun, int lba,
int pmi);
@@ -675,11 +720,6 @@ EXTERN struct scsi_task *
iscsi_synchronizecache10_sync(struct iscsi_context *iscsi, int lun, int lba,
int num_blocks, int syncnv, int immed);
-EXTERN struct scsi_task *
-iscsi_write10_sync(struct iscsi_context *iscsi, int lun,
- unsigned char *data, uint32_t datalen, uint32_t lba, int fua,
- int fuanv, int blocksize);
-
EXTERN struct scsi_task *
iscsi_verify10_sync(struct iscsi_context *iscsi, int lun,
unsigned char *data, uint32_t datalen, uint32_t lba,
View
@@ -32,10 +32,12 @@ enum scsi_opcode {
SCSI_OPCODE_WRITE_SAME10 = 0x41,
SCSI_OPCODE_UNMAP = 0x42,
SCSI_OPCODE_READ16 = 0x88,
+ SCSI_OPCODE_WRITE16 = 0x8A,
SCSI_OPCODE_WRITE_SAME16 = 0x93,
SCSI_OPCODE_SERVICE_ACTION_IN = 0x9E,
SCSI_OPCODE_REPORTLUNS = 0xA0,
- SCSI_OPCODE_READ12 = 0xA8
+ SCSI_OPCODE_READ12 = 0xA8,
+ SCSI_OPCODE_WRITE12 = 0xAA
};
enum scsi_service_action_in {
@@ -91,10 +93,26 @@ struct scsi_read10_params {
uint32_t lba;
uint32_t num_blocks;
};
+struct scsi_read12_params {
+ uint32_t lba;
+ uint32_t num_blocks;
+};
+struct scsi_read16_params {
+ uint64_t lba;
+ uint32_t num_blocks;
+};
struct scsi_write10_params {
uint32_t lba;
uint32_t num_blocks;
};
+struct scsi_write12_params {
+ uint32_t lba;
+ uint32_t num_blocks;
+};
+struct scsi_write16_params {
+ uint64_t lba;
+ uint32_t num_blocks;
+};
struct scsi_verify10_params {
uint32_t lba;
uint32_t num_blocks;
@@ -152,7 +170,11 @@ struct scsi_task {
union {
struct scsi_read6_params read6;
struct scsi_read10_params read10;
+ struct scsi_read12_params read12;
+ struct scsi_read16_params read16;
struct scsi_write10_params write10;
+ struct scsi_write12_params write12;
+ struct scsi_write16_params write16;
struct scsi_verify10_params verify10;
struct scsi_readcapacity10_params readcapacity10;
struct scsi_reportluns_params reportluns;
@@ -557,8 +579,11 @@ EXTERN void *scsi_datain_unmarshall(struct scsi_task *task);
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);
-EXTERN struct scsi_task *scsi_cdb_write10(uint32_t lba, uint32_t xferlen, int fua, int fuanv,
- int blocksize);
+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);
+EXTERN struct scsi_task *scsi_cdb_read16(uint64_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_write10(uint32_t lba, uint32_t xferlen, int fua, int fuanv, int blocksize);
+EXTERN struct scsi_task *scsi_cdb_write12(uint32_t lba, uint32_t xferlen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group_number);
+EXTERN struct scsi_task *scsi_cdb_write16(uint64_t lba, uint32_t xferlen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group_number);
EXTERN struct scsi_task *scsi_cdb_verify10(uint32_t lba, uint32_t xferlen, int vprotect, int dpo, int bytchk, int blocksize);
EXTERN struct scsi_task *scsi_cdb_synchronizecache10(int lba, int num_blocks,
View
@@ -47,8 +47,10 @@ iscsi_readcapacity16_task
iscsi_synchronizecache10_task
iscsi_read6_task
iscsi_read10_task
+iscsi_read12_task
iscsi_verify10_task
iscsi_write10_task
+iscsi_write12_task
iscsi_writesame10_task
iscsi_writesame16_task
iscsi_modesense6_task
@@ -61,8 +63,10 @@ iscsi_readcapacity16_sync
iscsi_synchronizecache10_sync
iscsi_read6_sync
iscsi_read10_sync
+iscsi_read12_sync
iscsi_verify10_sync
iscsi_write10_sync
+iscsi_write12_sync
iscsi_writesame10_sync
iscsi_writesame16_sync
iscsi_scsi_task_cancel
View
@@ -681,6 +681,66 @@ iscsi_read10_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
return task;
}
+struct scsi_task *
+iscsi_read12_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
+ uint32_t datalen, int blocksize,
+ int rdprotect, int dpo, int fua, int fua_nv, int group_number,
+ iscsi_command_cb cb, void *private_data)
+{
+ struct scsi_task *task;
+
+ if (datalen % blocksize != 0) {
+ iscsi_set_error(iscsi, "Datalen:%d is not a multiple of "
+ "the blocksize:%d.", datalen, blocksize);
+ return NULL;
+ }
+
+ task = scsi_cdb_read12(lba, datalen, blocksize, rdprotect,
+ dpo, fua, fua_nv, group_number);
+ if (task == NULL) {
+ iscsi_set_error(iscsi, "Out-of-memory: Failed to create "
+ "read12 cdb.");
+ return NULL;
+ }
+ if (iscsi_scsi_command_async(iscsi, lun, task, cb, NULL,
+ private_data) != 0) {
+ scsi_free_scsi_task(task);
+ return NULL;
+ }
+
+ return task;
+}
+
+struct scsi_task *
+iscsi_read16_task(struct iscsi_context *iscsi, int lun, uint64_t lba,
+ uint32_t datalen, int blocksize,
+ int rdprotect, int dpo, int fua, int fua_nv, int group_number,
+ iscsi_command_cb cb, void *private_data)
+{
+ struct scsi_task *task;
+
+ if (datalen % blocksize != 0) {
+ iscsi_set_error(iscsi, "Datalen:%d is not a multiple of "
+ "the blocksize:%d.", datalen, blocksize);
+ return NULL;
+ }
+
+ task = scsi_cdb_read16(lba, datalen, blocksize, rdprotect,
+ dpo, fua, fua_nv, group_number);
+ if (task == NULL) {
+ iscsi_set_error(iscsi, "Out-of-memory: Failed to create "
+ "read16 cdb.");
+ return NULL;
+ }
+ if (iscsi_scsi_command_async(iscsi, lun, task, cb, NULL,
+ private_data) != 0) {
+ scsi_free_scsi_task(task);
+ return NULL;
+ }
+
+ return task;
+}
+
struct scsi_task *
iscsi_write10_task(struct iscsi_context *iscsi, int lun, unsigned char *data,
uint32_t datalen, uint32_t lba, int fua, int fuanv, int blocksize,
@@ -714,6 +774,76 @@ iscsi_write10_task(struct iscsi_context *iscsi, int lun, unsigned char *data,
return task;
}
+struct scsi_task *
+iscsi_write12_task(struct iscsi_context *iscsi, int lun, uint32_t lba,
+ unsigned char *data, uint32_t datalen, int blocksize,
+ int wrprotect, int dpo, int fua, int fua_nv, int group_number,
+ iscsi_command_cb cb, void *private_data)
+{
+ struct scsi_task *task;
+ struct iscsi_data outdata;
+
+ if (datalen % blocksize != 0) {
+ iscsi_set_error(iscsi, "Datalen:%d is not a multiple of the "
+ "blocksize:%d.", datalen, blocksize);
+ return NULL;
+ }
+
+ task = scsi_cdb_write12(lba, datalen, blocksize, wrprotect,
+ dpo, fua, fua_nv, group_number);
+ if (task == NULL) {
+ iscsi_set_error(iscsi, "Out-of-memory: Failed to create "
+ "write12 cdb.");
+ return NULL;
+ }
+
+ outdata.data = data;
+ outdata.size = datalen;
+
+ if (iscsi_scsi_command_async(iscsi, lun, task, cb, &outdata,
+ private_data) != 0) {
+ scsi_free_scsi_task(task);
+ return NULL;
+ }
+
+ return task;
+}
+
+struct scsi_task *
+iscsi_write16_task(struct iscsi_context *iscsi, int lun, uint64_t lba,
+ unsigned char *data, uint32_t datalen, int blocksize,
+ int wrprotect, int dpo, int fua, int fua_nv, int group_number,
+ iscsi_command_cb cb, void *private_data)
+{
+ struct scsi_task *task;
+ struct iscsi_data outdata;
+
+ if (datalen % blocksize != 0) {
+ iscsi_set_error(iscsi, "Datalen:%d is not a multiple of the "
+ "blocksize:%d.", datalen, blocksize);
+ return NULL;
+ }
+
+ task = scsi_cdb_write16(lba, datalen, blocksize, wrprotect,
+ dpo, fua, fua_nv, group_number);
+ if (task == NULL) {
+ iscsi_set_error(iscsi, "Out-of-memory: Failed to create "
+ "write16 cdb.");
+ return NULL;
+ }
+
+ outdata.data = data;
+ outdata.size = datalen;
+
+ if (iscsi_scsi_command_async(iscsi, lun, task, cb, &outdata,
+ private_data) != 0) {
+ scsi_free_scsi_task(task);
+ return NULL;
+ }
+
+ return task;
+}
+
struct scsi_task *
iscsi_verify10_task(struct iscsi_context *iscsi, int lun, unsigned char *data,
uint32_t datalen, uint32_t lba, int vprotect, int dpo, int bytchk, int blocksize,
Oops, something went wrong.

0 comments on commit 9747389

Please sign in to comment.