aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2012-06-17 18:40:52 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2012-07-16 20:29:12 -0400
commit0c2ad7d1132d8b089b1d37875917858e03610019 (patch)
treee86cc118497605026a15c0e97630c57aeb625793 /drivers
parente1306bdab3af8bef620990a99e613f99eb30065c (diff)
target: add struct spc_ops + initial ->execute_rw pointer usage
Remove the execute_cmd method in struct se_subsystem_api, and always use the one directly in struct se_cmd. To make life simpler for SBC virtual backends a struct spc_ops that is passed to sbc_parse_cmd is added. For now it only contains an execute_rw member, but more will follow with the subsequent commits. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/target/target_core_file.c18
-rw-r--r--drivers/target/target_core_iblock.c18
-rw-r--r--drivers/target/target_core_pscsi.c11
-rw-r--r--drivers/target/target_core_rd.c18
-rw-r--r--drivers/target/target_core_sbc.c12
-rw-r--r--drivers/target/target_core_transport.c6
6 files changed, 61 insertions, 22 deletions
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
index e2df30867b13..720ed59834fc 100644
--- a/drivers/target/target_core_file.c
+++ b/drivers/target/target_core_file.c
@@ -375,9 +375,11 @@ static void fd_emulate_sync_cache(struct se_cmd *cmd)
375 } 375 }
376} 376}
377 377
378static int fd_execute_cmd(struct se_cmd *cmd, struct scatterlist *sgl, 378static int fd_execute_rw(struct se_cmd *cmd)
379 u32 sgl_nents, enum dma_data_direction data_direction)
380{ 379{
380 struct scatterlist *sgl = cmd->t_data_sg;
381 u32 sgl_nents = cmd->t_data_nents;
382 enum dma_data_direction data_direction = cmd->data_direction;
381 struct se_device *dev = cmd->se_dev; 383 struct se_device *dev = cmd->se_dev;
382 int ret = 0; 384 int ret = 0;
383 385
@@ -550,6 +552,15 @@ static sector_t fd_get_blocks(struct se_device *dev)
550 return div_u64(dev_size, dev->se_sub_dev->se_dev_attrib.block_size); 552 return div_u64(dev_size, dev->se_sub_dev->se_dev_attrib.block_size);
551} 553}
552 554
555static struct spc_ops fd_spc_ops = {
556 .execute_rw = fd_execute_rw,
557};
558
559static int fd_parse_cdb(struct se_cmd *cmd)
560{
561 return sbc_parse_cdb(cmd, &fd_spc_ops);
562}
563
553static struct se_subsystem_api fileio_template = { 564static struct se_subsystem_api fileio_template = {
554 .name = "fileio", 565 .name = "fileio",
555 .owner = THIS_MODULE, 566 .owner = THIS_MODULE,
@@ -561,8 +572,7 @@ static struct se_subsystem_api fileio_template = {
561 .allocate_virtdevice = fd_allocate_virtdevice, 572 .allocate_virtdevice = fd_allocate_virtdevice,
562 .create_virtdevice = fd_create_virtdevice, 573 .create_virtdevice = fd_create_virtdevice,
563 .free_device = fd_free_device, 574 .free_device = fd_free_device,
564 .parse_cdb = sbc_parse_cdb, 575 .parse_cdb = fd_parse_cdb,
565 .execute_cmd = fd_execute_cmd,
566 .do_sync_cache = fd_emulate_sync_cache, 576 .do_sync_cache = fd_emulate_sync_cache,
567 .check_configfs_dev_params = fd_check_configfs_dev_params, 577 .check_configfs_dev_params = fd_check_configfs_dev_params,
568 .set_configfs_dev_params = fd_set_configfs_dev_params, 578 .set_configfs_dev_params = fd_set_configfs_dev_params,
diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
index c2d4ccbb7133..eb94367380c1 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -514,9 +514,11 @@ static void iblock_submit_bios(struct bio_list *list, int rw)
514 blk_finish_plug(&plug); 514 blk_finish_plug(&plug);
515} 515}
516 516
517static int iblock_execute_cmd(struct se_cmd *cmd, struct scatterlist *sgl, 517static int iblock_execute_rw(struct se_cmd *cmd)
518 u32 sgl_nents, enum dma_data_direction data_direction)
519{ 518{
519 struct scatterlist *sgl = cmd->t_data_sg;
520 u32 sgl_nents = cmd->t_data_nents;
521 enum dma_data_direction data_direction = cmd->data_direction;
520 struct se_device *dev = cmd->se_dev; 522 struct se_device *dev = cmd->se_dev;
521 struct iblock_req *ibr; 523 struct iblock_req *ibr;
522 struct bio *bio; 524 struct bio *bio;
@@ -663,6 +665,15 @@ static void iblock_bio_done(struct bio *bio, int err)
663 iblock_complete_cmd(cmd); 665 iblock_complete_cmd(cmd);
664} 666}
665 667
668static struct spc_ops iblock_spc_ops = {
669 .execute_rw = iblock_execute_rw,
670};
671
672static int iblock_parse_cdb(struct se_cmd *cmd)
673{
674 return sbc_parse_cdb(cmd, &iblock_spc_ops);
675}
676
666static struct se_subsystem_api iblock_template = { 677static struct se_subsystem_api iblock_template = {
667 .name = "iblock", 678 .name = "iblock",
668 .owner = THIS_MODULE, 679 .owner = THIS_MODULE,
@@ -674,8 +685,7 @@ static struct se_subsystem_api iblock_template = {
674 .allocate_virtdevice = iblock_allocate_virtdevice, 685 .allocate_virtdevice = iblock_allocate_virtdevice,
675 .create_virtdevice = iblock_create_virtdevice, 686 .create_virtdevice = iblock_create_virtdevice,
676 .free_device = iblock_free_device, 687 .free_device = iblock_free_device,
677 .parse_cdb = sbc_parse_cdb, 688 .parse_cdb = iblock_parse_cdb,
678 .execute_cmd = iblock_execute_cmd,
679 .do_discard = iblock_do_discard, 689 .do_discard = iblock_do_discard,
680 .do_sync_cache = iblock_emulate_sync_cache, 690 .do_sync_cache = iblock_emulate_sync_cache,
681 .check_configfs_dev_params = iblock_check_configfs_dev_params, 691 .check_configfs_dev_params = iblock_check_configfs_dev_params,
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index cb4c6b1195d4..6e32ff6f2fa0 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -55,6 +55,7 @@
55 55
56static struct se_subsystem_api pscsi_template; 56static struct se_subsystem_api pscsi_template;
57 57
58static int pscsi_execute_cmd(struct se_cmd *cmd);
58static void pscsi_req_done(struct request *, int); 59static void pscsi_req_done(struct request *, int);
59 60
60/* pscsi_attach_hba(): 61/* pscsi_attach_hba():
@@ -1081,17 +1082,20 @@ static int pscsi_parse_cdb(struct se_cmd *cmd)
1081 case WRITE_16: 1082 case WRITE_16:
1082 case WRITE_VERIFY: 1083 case WRITE_VERIFY:
1083 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB; 1084 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
1084 break; 1085 /* FALLTHROUGH*/
1085 default: 1086 default:
1087 cmd->execute_cmd = pscsi_execute_cmd;
1086 break; 1088 break;
1087 } 1089 }
1088 1090
1089 return 0; 1091 return 0;
1090} 1092}
1091 1093
1092static int pscsi_execute_cmd(struct se_cmd *cmd, struct scatterlist *sgl, 1094static int pscsi_execute_cmd(struct se_cmd *cmd)
1093 u32 sgl_nents, enum dma_data_direction data_direction)
1094{ 1095{
1096 struct scatterlist *sgl = cmd->t_data_sg;
1097 u32 sgl_nents = cmd->t_data_nents;
1098 enum dma_data_direction data_direction = cmd->data_direction;
1095 struct pscsi_dev_virt *pdv = cmd->se_dev->dev_ptr; 1099 struct pscsi_dev_virt *pdv = cmd->se_dev->dev_ptr;
1096 struct pscsi_plugin_task *pt; 1100 struct pscsi_plugin_task *pt;
1097 struct request *req; 1101 struct request *req;
@@ -1259,7 +1263,6 @@ static struct se_subsystem_api pscsi_template = {
1259 .free_device = pscsi_free_device, 1263 .free_device = pscsi_free_device,
1260 .transport_complete = pscsi_transport_complete, 1264 .transport_complete = pscsi_transport_complete,
1261 .parse_cdb = pscsi_parse_cdb, 1265 .parse_cdb = pscsi_parse_cdb,
1262 .execute_cmd = pscsi_execute_cmd,
1263 .check_configfs_dev_params = pscsi_check_configfs_dev_params, 1266 .check_configfs_dev_params = pscsi_check_configfs_dev_params,
1264 .set_configfs_dev_params = pscsi_set_configfs_dev_params, 1267 .set_configfs_dev_params = pscsi_set_configfs_dev_params,
1265 .show_configfs_dev_params = pscsi_show_configfs_dev_params, 1268 .show_configfs_dev_params = pscsi_show_configfs_dev_params,
diff --git a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c
index d7e838287d89..d00bbe33ff8b 100644
--- a/drivers/target/target_core_rd.c
+++ b/drivers/target/target_core_rd.c
@@ -284,9 +284,11 @@ static struct rd_dev_sg_table *rd_get_sg_table(struct rd_dev *rd_dev, u32 page)
284 return NULL; 284 return NULL;
285} 285}
286 286
287static int rd_execute_cmd(struct se_cmd *cmd, struct scatterlist *sgl, 287static int rd_execute_rw(struct se_cmd *cmd)
288 u32 sgl_nents, enum dma_data_direction data_direction)
289{ 288{
289 struct scatterlist *sgl = cmd->t_data_sg;
290 u32 sgl_nents = cmd->t_data_nents;
291 enum dma_data_direction data_direction = cmd->data_direction;
290 struct se_device *se_dev = cmd->se_dev; 292 struct se_device *se_dev = cmd->se_dev;
291 struct rd_dev *dev = se_dev->dev_ptr; 293 struct rd_dev *dev = se_dev->dev_ptr;
292 struct rd_dev_sg_table *table; 294 struct rd_dev_sg_table *table;
@@ -460,6 +462,15 @@ static sector_t rd_get_blocks(struct se_device *dev)
460 return blocks_long; 462 return blocks_long;
461} 463}
462 464
465static struct spc_ops rd_spc_ops = {
466 .execute_rw = rd_execute_rw,
467};
468
469static int rd_parse_cdb(struct se_cmd *cmd)
470{
471 return sbc_parse_cdb(cmd, &rd_spc_ops);
472}
473
463static struct se_subsystem_api rd_mcp_template = { 474static struct se_subsystem_api rd_mcp_template = {
464 .name = "rd_mcp", 475 .name = "rd_mcp",
465 .transport_type = TRANSPORT_PLUGIN_VHBA_VDEV, 476 .transport_type = TRANSPORT_PLUGIN_VHBA_VDEV,
@@ -468,8 +479,7 @@ static struct se_subsystem_api rd_mcp_template = {
468 .allocate_virtdevice = rd_allocate_virtdevice, 479 .allocate_virtdevice = rd_allocate_virtdevice,
469 .create_virtdevice = rd_create_virtdevice, 480 .create_virtdevice = rd_create_virtdevice,
470 .free_device = rd_free_device, 481 .free_device = rd_free_device,
471 .parse_cdb = sbc_parse_cdb, 482 .parse_cdb = rd_parse_cdb,
472 .execute_cmd = rd_execute_cmd,
473 .check_configfs_dev_params = rd_check_configfs_dev_params, 483 .check_configfs_dev_params = rd_check_configfs_dev_params,
474 .set_configfs_dev_params = rd_set_configfs_dev_params, 484 .set_configfs_dev_params = rd_set_configfs_dev_params,
475 .show_configfs_dev_params = rd_show_configfs_dev_params, 485 .show_configfs_dev_params = rd_show_configfs_dev_params,
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
index a5bd0c0eba08..da441b2782ce 100644
--- a/drivers/target/target_core_sbc.c
+++ b/drivers/target/target_core_sbc.c
@@ -395,7 +395,7 @@ out:
395 kfree(buf); 395 kfree(buf);
396} 396}
397 397
398int sbc_parse_cdb(struct se_cmd *cmd) 398int sbc_parse_cdb(struct se_cmd *cmd, struct spc_ops *ops)
399{ 399{
400 struct se_subsystem_dev *su_dev = cmd->se_dev->se_sub_dev; 400 struct se_subsystem_dev *su_dev = cmd->se_dev->se_sub_dev;
401 struct se_device *dev = cmd->se_dev; 401 struct se_device *dev = cmd->se_dev;
@@ -409,26 +409,31 @@ int sbc_parse_cdb(struct se_cmd *cmd)
409 sectors = transport_get_sectors_6(cdb); 409 sectors = transport_get_sectors_6(cdb);
410 cmd->t_task_lba = transport_lba_21(cdb); 410 cmd->t_task_lba = transport_lba_21(cdb);
411 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB; 411 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
412 cmd->execute_cmd = ops->execute_rw;
412 break; 413 break;
413 case READ_10: 414 case READ_10:
414 sectors = transport_get_sectors_10(cdb); 415 sectors = transport_get_sectors_10(cdb);
415 cmd->t_task_lba = transport_lba_32(cdb); 416 cmd->t_task_lba = transport_lba_32(cdb);
416 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB; 417 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
418 cmd->execute_cmd = ops->execute_rw;
417 break; 419 break;
418 case READ_12: 420 case READ_12:
419 sectors = transport_get_sectors_12(cdb); 421 sectors = transport_get_sectors_12(cdb);
420 cmd->t_task_lba = transport_lba_32(cdb); 422 cmd->t_task_lba = transport_lba_32(cdb);
421 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB; 423 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
424 cmd->execute_cmd = ops->execute_rw;
422 break; 425 break;
423 case READ_16: 426 case READ_16:
424 sectors = transport_get_sectors_16(cdb); 427 sectors = transport_get_sectors_16(cdb);
425 cmd->t_task_lba = transport_lba_64(cdb); 428 cmd->t_task_lba = transport_lba_64(cdb);
426 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB; 429 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
430 cmd->execute_cmd = ops->execute_rw;
427 break; 431 break;
428 case WRITE_6: 432 case WRITE_6:
429 sectors = transport_get_sectors_6(cdb); 433 sectors = transport_get_sectors_6(cdb);
430 cmd->t_task_lba = transport_lba_21(cdb); 434 cmd->t_task_lba = transport_lba_21(cdb);
431 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB; 435 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
436 cmd->execute_cmd = ops->execute_rw;
432 break; 437 break;
433 case WRITE_10: 438 case WRITE_10:
434 case WRITE_VERIFY: 439 case WRITE_VERIFY:
@@ -437,6 +442,7 @@ int sbc_parse_cdb(struct se_cmd *cmd)
437 if (cdb[1] & 0x8) 442 if (cdb[1] & 0x8)
438 cmd->se_cmd_flags |= SCF_FUA; 443 cmd->se_cmd_flags |= SCF_FUA;
439 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB; 444 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
445 cmd->execute_cmd = ops->execute_rw;
440 break; 446 break;
441 case WRITE_12: 447 case WRITE_12:
442 sectors = transport_get_sectors_12(cdb); 448 sectors = transport_get_sectors_12(cdb);
@@ -444,6 +450,7 @@ int sbc_parse_cdb(struct se_cmd *cmd)
444 if (cdb[1] & 0x8) 450 if (cdb[1] & 0x8)
445 cmd->se_cmd_flags |= SCF_FUA; 451 cmd->se_cmd_flags |= SCF_FUA;
446 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB; 452 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
453 cmd->execute_cmd = ops->execute_rw;
447 break; 454 break;
448 case WRITE_16: 455 case WRITE_16:
449 sectors = transport_get_sectors_16(cdb); 456 sectors = transport_get_sectors_16(cdb);
@@ -451,6 +458,7 @@ int sbc_parse_cdb(struct se_cmd *cmd)
451 if (cdb[1] & 0x8) 458 if (cdb[1] & 0x8)
452 cmd->se_cmd_flags |= SCF_FUA; 459 cmd->se_cmd_flags |= SCF_FUA;
453 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB; 460 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
461 cmd->execute_cmd = ops->execute_rw;
454 break; 462 break;
455 case XDWRITEREAD_10: 463 case XDWRITEREAD_10:
456 if ((cmd->data_direction != DMA_TO_DEVICE) || 464 if ((cmd->data_direction != DMA_TO_DEVICE) ||
@@ -464,6 +472,7 @@ int sbc_parse_cdb(struct se_cmd *cmd)
464 /* 472 /*
465 * Setup BIDI XOR callback to be run after I/O completion. 473 * Setup BIDI XOR callback to be run after I/O completion.
466 */ 474 */
475 cmd->execute_cmd = ops->execute_rw;
467 cmd->transport_complete_callback = &xdreadwrite_callback; 476 cmd->transport_complete_callback = &xdreadwrite_callback;
468 if (cdb[1] & 0x8) 477 if (cdb[1] & 0x8)
469 cmd->se_cmd_flags |= SCF_FUA; 478 cmd->se_cmd_flags |= SCF_FUA;
@@ -486,6 +495,7 @@ int sbc_parse_cdb(struct se_cmd *cmd)
486 * Setup BIDI XOR callback to be run during after I/O 495 * Setup BIDI XOR callback to be run during after I/O
487 * completion. 496 * completion.
488 */ 497 */
498 cmd->execute_cmd = ops->execute_rw;
489 cmd->transport_complete_callback = &xdreadwrite_callback; 499 cmd->transport_complete_callback = &xdreadwrite_callback;
490 if (cdb[1] & 0x8) 500 if (cdb[1] & 0x8)
491 cmd->se_cmd_flags |= SCF_FUA; 501 cmd->se_cmd_flags |= SCF_FUA;
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 82946962796d..803ac5202fcd 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1865,7 +1865,7 @@ EXPORT_SYMBOL(transport_generic_request_failure);
1865 1865
1866static void __target_execute_cmd(struct se_cmd *cmd) 1866static void __target_execute_cmd(struct se_cmd *cmd)
1867{ 1867{
1868 int error; 1868 int error = 0;
1869 1869
1870 spin_lock_irq(&cmd->t_state_lock); 1870 spin_lock_irq(&cmd->t_state_lock);
1871 cmd->transport_state |= (CMD_T_BUSY|CMD_T_SENT); 1871 cmd->transport_state |= (CMD_T_BUSY|CMD_T_SENT);
@@ -1873,10 +1873,6 @@ static void __target_execute_cmd(struct se_cmd *cmd)
1873 1873
1874 if (cmd->execute_cmd) 1874 if (cmd->execute_cmd)
1875 error = cmd->execute_cmd(cmd); 1875 error = cmd->execute_cmd(cmd);
1876 else {
1877 error = cmd->se_dev->transport->execute_cmd(cmd, cmd->t_data_sg,
1878 cmd->t_data_nents, cmd->data_direction);
1879 }
1880 1876
1881 if (error) { 1877 if (error) {
1882 spin_lock_irq(&cmd->t_state_lock); 1878 spin_lock_irq(&cmd->t_state_lock);