aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/target/target_core_file.c10
-rw-r--r--drivers/target/target_core_iblock.c4
-rw-r--r--drivers/target/target_core_pscsi.c6
-rw-r--r--drivers/target/target_core_rd.c6
-rw-r--r--drivers/target/target_core_transport.c36
-rw-r--r--include/target/target_core_base.h3
-rw-r--r--include/target/target_core_transport.h3
7 files changed, 27 insertions, 41 deletions
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
index 99c9db003394..524f41afea48 100644
--- a/drivers/target/target_core_file.c
+++ b/drivers/target/target_core_file.c
@@ -272,13 +272,14 @@ fd_alloc_task(unsigned char *cdb)
272static int fd_do_readv(struct se_task *task) 272static int fd_do_readv(struct se_task *task)
273{ 273{
274 struct fd_request *req = FILE_REQ(task); 274 struct fd_request *req = FILE_REQ(task);
275 struct fd_dev *dev = req->fd_task.se_dev->dev_ptr; 275 struct se_device *se_dev = req->fd_task.task_se_cmd->se_dev;
276 struct fd_dev *dev = se_dev->dev_ptr;
276 struct file *fd = dev->fd_file; 277 struct file *fd = dev->fd_file;
277 struct scatterlist *sg = task->task_sg; 278 struct scatterlist *sg = task->task_sg;
278 struct iovec *iov; 279 struct iovec *iov;
279 mm_segment_t old_fs; 280 mm_segment_t old_fs;
280 loff_t pos = (task->task_lba * 281 loff_t pos = (task->task_lba *
281 task->se_dev->se_sub_dev->se_dev_attrib.block_size); 282 se_dev->se_sub_dev->se_dev_attrib.block_size);
282 int ret = 0, i; 283 int ret = 0, i;
283 284
284 iov = kzalloc(sizeof(struct iovec) * task->task_sg_nents, GFP_KERNEL); 285 iov = kzalloc(sizeof(struct iovec) * task->task_sg_nents, GFP_KERNEL);
@@ -324,13 +325,14 @@ static int fd_do_readv(struct se_task *task)
324static int fd_do_writev(struct se_task *task) 325static int fd_do_writev(struct se_task *task)
325{ 326{
326 struct fd_request *req = FILE_REQ(task); 327 struct fd_request *req = FILE_REQ(task);
327 struct fd_dev *dev = req->fd_task.se_dev->dev_ptr; 328 struct se_device *se_dev = req->fd_task.task_se_cmd->se_dev;
329 struct fd_dev *dev = se_dev->dev_ptr;
328 struct file *fd = dev->fd_file; 330 struct file *fd = dev->fd_file;
329 struct scatterlist *sg = task->task_sg; 331 struct scatterlist *sg = task->task_sg;
330 struct iovec *iov; 332 struct iovec *iov;
331 mm_segment_t old_fs; 333 mm_segment_t old_fs;
332 loff_t pos = (task->task_lba * 334 loff_t pos = (task->task_lba *
333 task->se_dev->se_sub_dev->se_dev_attrib.block_size); 335 se_dev->se_sub_dev->se_dev_attrib.block_size);
334 int ret, i = 0; 336 int ret, i = 0;
335 337
336 iov = kzalloc(sizeof(struct iovec) * task->task_sg_nents, GFP_KERNEL); 338 iov = kzalloc(sizeof(struct iovec) * task->task_sg_nents, GFP_KERNEL);
diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
index dcf93f85977a..21a3677984fb 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -499,7 +499,7 @@ static ssize_t iblock_show_configfs_dev_params(
499static void iblock_bio_destructor(struct bio *bio) 499static void iblock_bio_destructor(struct bio *bio)
500{ 500{
501 struct se_task *task = bio->bi_private; 501 struct se_task *task = bio->bi_private;
502 struct iblock_dev *ib_dev = task->se_dev->dev_ptr; 502 struct iblock_dev *ib_dev = task->task_se_cmd->se_dev->dev_ptr;
503 503
504 bio_free(bio, ib_dev->ibd_bio_set); 504 bio_free(bio, ib_dev->ibd_bio_set);
505} 505}
@@ -507,7 +507,7 @@ static void iblock_bio_destructor(struct bio *bio)
507static struct bio * 507static struct bio *
508iblock_get_bio(struct se_task *task, sector_t lba, u32 sg_num) 508iblock_get_bio(struct se_task *task, sector_t lba, u32 sg_num)
509{ 509{
510 struct iblock_dev *ib_dev = task->se_dev->dev_ptr; 510 struct iblock_dev *ib_dev = task->task_se_cmd->se_dev->dev_ptr;
511 struct iblock_req *ib_req = IBLOCK_REQ(task); 511 struct iblock_req *ib_req = IBLOCK_REQ(task);
512 struct bio *bio; 512 struct bio *bio;
513 513
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index 3898fb7d317c..b347862bf801 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -676,7 +676,7 @@ static inline struct pscsi_plugin_task *PSCSI_TASK(struct se_task *task)
676 */ 676 */
677static int pscsi_transport_complete(struct se_task *task) 677static int pscsi_transport_complete(struct se_task *task)
678{ 678{
679 struct pscsi_dev_virt *pdv = task->se_dev->dev_ptr; 679 struct pscsi_dev_virt *pdv = task->task_se_cmd->se_dev->dev_ptr;
680 struct scsi_device *sd = pdv->pdv_sd; 680 struct scsi_device *sd = pdv->pdv_sd;
681 int result; 681 int result;
682 struct pscsi_plugin_task *pt = PSCSI_TASK(task); 682 struct pscsi_plugin_task *pt = PSCSI_TASK(task);
@@ -962,7 +962,7 @@ static inline struct bio *pscsi_get_bio(int sg_num)
962static int pscsi_map_sg(struct se_task *task, struct scatterlist *task_sg, 962static int pscsi_map_sg(struct se_task *task, struct scatterlist *task_sg,
963 struct bio **hbio) 963 struct bio **hbio)
964{ 964{
965 struct pscsi_dev_virt *pdv = task->se_dev->dev_ptr; 965 struct pscsi_dev_virt *pdv = task->task_se_cmd->se_dev->dev_ptr;
966 u32 task_sg_num = task->task_sg_nents; 966 u32 task_sg_num = task->task_sg_nents;
967 struct bio *bio = NULL, *tbio = NULL; 967 struct bio *bio = NULL, *tbio = NULL;
968 struct page *page; 968 struct page *page;
@@ -1062,7 +1062,7 @@ fail:
1062 1062
1063static int pscsi_do_task(struct se_task *task) 1063static int pscsi_do_task(struct se_task *task)
1064{ 1064{
1065 struct pscsi_dev_virt *pdv = task->se_dev->dev_ptr; 1065 struct pscsi_dev_virt *pdv = task->task_se_cmd->se_dev->dev_ptr;
1066 struct pscsi_plugin_task *pt = PSCSI_TASK(task); 1066 struct pscsi_plugin_task *pt = PSCSI_TASK(task);
1067 struct request *req; 1067 struct request *req;
1068 struct bio *hbio; 1068 struct bio *hbio;
diff --git a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c
index 1ab69f32e664..daf95dbe12ec 100644
--- a/drivers/target/target_core_rd.c
+++ b/drivers/target/target_core_rd.c
@@ -350,7 +350,7 @@ static struct rd_dev_sg_table *rd_get_sg_table(struct rd_dev *rd_dev, u32 page)
350static int rd_MEMCPY_read(struct rd_request *req) 350static int rd_MEMCPY_read(struct rd_request *req)
351{ 351{
352 struct se_task *task = &req->rd_task; 352 struct se_task *task = &req->rd_task;
353 struct rd_dev *dev = req->rd_task.se_dev->dev_ptr; 353 struct rd_dev *dev = req->rd_task.task_se_cmd->se_dev->dev_ptr;
354 struct rd_dev_sg_table *table; 354 struct rd_dev_sg_table *table;
355 struct scatterlist *sg_d, *sg_s; 355 struct scatterlist *sg_d, *sg_s;
356 void *dst, *src; 356 void *dst, *src;
@@ -466,7 +466,7 @@ static int rd_MEMCPY_read(struct rd_request *req)
466static int rd_MEMCPY_write(struct rd_request *req) 466static int rd_MEMCPY_write(struct rd_request *req)
467{ 467{
468 struct se_task *task = &req->rd_task; 468 struct se_task *task = &req->rd_task;
469 struct rd_dev *dev = req->rd_task.se_dev->dev_ptr; 469 struct rd_dev *dev = req->rd_task.task_se_cmd->se_dev->dev_ptr;
470 struct rd_dev_sg_table *table; 470 struct rd_dev_sg_table *table;
471 struct scatterlist *sg_d, *sg_s; 471 struct scatterlist *sg_d, *sg_s;
472 void *dst, *src; 472 void *dst, *src;
@@ -581,7 +581,7 @@ static int rd_MEMCPY_write(struct rd_request *req)
581 */ 581 */
582static int rd_MEMCPY_do_task(struct se_task *task) 582static int rd_MEMCPY_do_task(struct se_task *task)
583{ 583{
584 struct se_device *dev = task->se_dev; 584 struct se_device *dev = task->task_se_cmd->se_dev;
585 struct rd_request *req = RD_REQ(task); 585 struct rd_request *req = RD_REQ(task);
586 unsigned long long lba; 586 unsigned long long lba;
587 int ret; 587 int ret;
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 89b85dd36cce..c935c72da7be 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -432,15 +432,14 @@ EXPORT_SYMBOL(transport_deregister_session);
432 */ 432 */
433static void transport_all_task_dev_remove_state(struct se_cmd *cmd) 433static void transport_all_task_dev_remove_state(struct se_cmd *cmd)
434{ 434{
435 struct se_device *dev; 435 struct se_device *dev = cmd->se_dev;
436 struct se_task *task; 436 struct se_task *task;
437 unsigned long flags; 437 unsigned long flags;
438 438
439 list_for_each_entry(task, &cmd->t_task_list, t_list) { 439 if (!dev)
440 dev = task->se_dev; 440 return;
441 if (!dev)
442 continue;
443 441
442 list_for_each_entry(task, &cmd->t_task_list, t_list) {
444 if (atomic_read(&task->task_active)) 443 if (atomic_read(&task->task_active))
445 continue; 444 continue;
446 445
@@ -708,7 +707,7 @@ EXPORT_SYMBOL(transport_complete_sync_cache);
708void transport_complete_task(struct se_task *task, int success) 707void transport_complete_task(struct se_task *task, int success)
709{ 708{
710 struct se_cmd *cmd = task->task_se_cmd; 709 struct se_cmd *cmd = task->task_se_cmd;
711 struct se_device *dev = task->se_dev; 710 struct se_device *dev = cmd->se_dev;
712 int t_state; 711 int t_state;
713 unsigned long flags; 712 unsigned long flags;
714#if 0 713#if 0
@@ -886,14 +885,12 @@ static void __transport_add_task_to_execute_queue(
886 885
887static void transport_add_tasks_to_state_queue(struct se_cmd *cmd) 886static void transport_add_tasks_to_state_queue(struct se_cmd *cmd)
888{ 887{
889 struct se_device *dev; 888 struct se_device *dev = cmd->se_dev;
890 struct se_task *task; 889 struct se_task *task;
891 unsigned long flags; 890 unsigned long flags;
892 891
893 spin_lock_irqsave(&cmd->t_state_lock, flags); 892 spin_lock_irqsave(&cmd->t_state_lock, flags);
894 list_for_each_entry(task, &cmd->t_task_list, t_list) { 893 list_for_each_entry(task, &cmd->t_task_list, t_list) {
895 dev = task->se_dev;
896
897 if (atomic_read(&task->task_state_active)) 894 if (atomic_read(&task->task_state_active))
898 continue; 895 continue;
899 896
@@ -1522,7 +1519,6 @@ transport_generic_get_task(struct se_cmd *cmd,
1522 INIT_LIST_HEAD(&task->t_state_list); 1519 INIT_LIST_HEAD(&task->t_state_list);
1523 init_completion(&task->task_stop_comp); 1520 init_completion(&task->task_stop_comp);
1524 task->task_se_cmd = cmd; 1521 task->task_se_cmd = cmd;
1525 task->se_dev = dev;
1526 task->task_data_direction = data_direction; 1522 task->task_data_direction = data_direction;
1527 1523
1528 return task; 1524 return task;
@@ -1802,7 +1798,7 @@ static int transport_stop_tasks_for_cmd(struct se_cmd *cmd)
1802 spin_unlock_irqrestore(&cmd->t_state_lock, 1798 spin_unlock_irqrestore(&cmd->t_state_lock,
1803 flags); 1799 flags);
1804 transport_remove_task_from_execute_queue(task, 1800 transport_remove_task_from_execute_queue(task,
1805 task->se_dev); 1801 cmd->se_dev);
1806 1802
1807 pr_debug("task_no[%d] - Removed from execute queue\n", 1803 pr_debug("task_no[%d] - Removed from execute queue\n",
1808 task->task_no); 1804 task->task_no);
@@ -2130,7 +2126,7 @@ static void transport_task_timeout_handler(unsigned long data)
2130 */ 2126 */
2131static void transport_start_task_timer(struct se_task *task) 2127static void transport_start_task_timer(struct se_task *task)
2132{ 2128{
2133 struct se_device *dev = task->se_dev; 2129 struct se_device *dev = task->task_se_cmd->se_dev;
2134 int timeout; 2130 int timeout;
2135 2131
2136 if (task->task_flags & TF_RUNNING) 2132 if (task->task_flags & TF_RUNNING)
@@ -2656,13 +2652,16 @@ out:
2656static int transport_get_sense_data(struct se_cmd *cmd) 2652static int transport_get_sense_data(struct se_cmd *cmd)
2657{ 2653{
2658 unsigned char *buffer = cmd->sense_buffer, *sense_buffer = NULL; 2654 unsigned char *buffer = cmd->sense_buffer, *sense_buffer = NULL;
2659 struct se_device *dev; 2655 struct se_device *dev = cmd->se_dev;
2660 struct se_task *task = NULL, *task_tmp; 2656 struct se_task *task = NULL, *task_tmp;
2661 unsigned long flags; 2657 unsigned long flags;
2662 u32 offset = 0; 2658 u32 offset = 0;
2663 2659
2664 WARN_ON(!cmd->se_lun); 2660 WARN_ON(!cmd->se_lun);
2665 2661
2662 if (!dev)
2663 return 0;
2664
2666 spin_lock_irqsave(&cmd->t_state_lock, flags); 2665 spin_lock_irqsave(&cmd->t_state_lock, flags);
2667 if (cmd->se_cmd_flags & SCF_SENT_CHECK_CONDITION) { 2666 if (cmd->se_cmd_flags & SCF_SENT_CHECK_CONDITION) {
2668 spin_unlock_irqrestore(&cmd->t_state_lock, flags); 2667 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
@@ -2671,14 +2670,9 @@ static int transport_get_sense_data(struct se_cmd *cmd)
2671 2670
2672 list_for_each_entry_safe(task, task_tmp, 2671 list_for_each_entry_safe(task, task_tmp,
2673 &cmd->t_task_list, t_list) { 2672 &cmd->t_task_list, t_list) {
2674
2675 if (!task->task_sense) 2673 if (!task->task_sense)
2676 continue; 2674 continue;
2677 2675
2678 dev = task->se_dev;
2679 if (!dev)
2680 continue;
2681
2682 if (!dev->transport->get_sense_buffer) { 2676 if (!dev->transport->get_sense_buffer) {
2683 pr_err("dev->transport->get_sense_buffer" 2677 pr_err("dev->transport->get_sense_buffer"
2684 " is NULL\n"); 2678 " is NULL\n");
@@ -3628,11 +3622,7 @@ static void transport_free_dev_tasks(struct se_cmd *cmd)
3628 list_del(&task->t_list); 3622 list_del(&task->t_list);
3629 3623
3630 spin_unlock_irqrestore(&cmd->t_state_lock, flags); 3624 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
3631 if (task->se_dev) 3625 cmd->se_dev->transport->free_task(task);
3632 task->se_dev->transport->free_task(task);
3633 else
3634 pr_err("task[%u] - task->se_dev is NULL\n",
3635 task->task_no);
3636 spin_lock_irqsave(&cmd->t_state_lock, flags); 3626 spin_lock_irqsave(&cmd->t_state_lock, flags);
3637 } 3627 }
3638 spin_unlock_irqrestore(&cmd->t_state_lock, flags); 3628 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index c00224e8d6c4..6c49db403205 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -405,7 +405,6 @@ struct se_task {
405 u8 task_scsi_status; 405 u8 task_scsi_status;
406 u8 task_flags; 406 u8 task_flags;
407 int task_error_status; 407 int task_error_status;
408 int task_state_flags;
409 bool task_padded_sg; 408 bool task_padded_sg;
410 unsigned long long task_lba; 409 unsigned long long task_lba;
411 u32 task_no; 410 u32 task_no;
@@ -413,7 +412,6 @@ struct se_task {
413 u32 task_size; 412 u32 task_size;
414 enum dma_data_direction task_data_direction; 413 enum dma_data_direction task_data_direction;
415 struct se_cmd *task_se_cmd; 414 struct se_cmd *task_se_cmd;
416 struct se_device *se_dev;
417 struct completion task_stop_comp; 415 struct completion task_stop_comp;
418 atomic_t task_active; 416 atomic_t task_active;
419 atomic_t task_execute_queue; 417 atomic_t task_execute_queue;
@@ -422,7 +420,6 @@ struct se_task {
422 atomic_t task_stop; 420 atomic_t task_stop;
423 atomic_t task_state_active; 421 atomic_t task_state_active;
424 struct timer_list task_timer; 422 struct timer_list task_timer;
425 struct se_device *se_obj_ptr;
426 struct list_head t_list; 423 struct list_head t_list;
427 struct list_head t_execute_list; 424 struct list_head t_execute_list;
428 struct list_head t_state_list; 425 struct list_head t_state_list;
diff --git a/include/target/target_core_transport.h b/include/target/target_core_transport.h
index ccd85b380d6b..c93cf0ae37a4 100644
--- a/include/target/target_core_transport.h
+++ b/include/target/target_core_transport.h
@@ -45,9 +45,6 @@
45#define TRANSPORT_TIMEOUT_TYPE_TAPE 600 45#define TRANSPORT_TIMEOUT_TYPE_TAPE 600
46#define TRANSPORT_TIMEOUT_TYPE_OTHER 300 46#define TRANSPORT_TIMEOUT_TYPE_OTHER 300
47 47
48/* For se_task->task_state_flags */
49#define TSF_EXCEPTION_CLEARED 0x01
50
51/* 48/*
52 * struct se_subsystem_dev->su_dev_flags 49 * struct se_subsystem_dev->su_dev_flags
53*/ 50*/