diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c index 99c9db003394603dd37e0ca13bae4100cfa01aca..524f41afea48185e0b176247f4879212c52d0628 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) static int fd_do_readv(struct se_task *task) { struct fd_request *req = FILE_REQ(task); - struct fd_dev *dev = req->fd_task.se_dev->dev_ptr; + struct se_device *se_dev = req->fd_task.task_se_cmd->se_dev; + struct fd_dev *dev = se_dev->dev_ptr; struct file *fd = dev->fd_file; struct scatterlist *sg = task->task_sg; struct iovec *iov; mm_segment_t old_fs; loff_t pos = (task->task_lba * - task->se_dev->se_sub_dev->se_dev_attrib.block_size); + se_dev->se_sub_dev->se_dev_attrib.block_size); int ret = 0, i; iov = kzalloc(sizeof(struct iovec) * task->task_sg_nents, GFP_KERNEL); @@ -324,13 +325,14 @@ static int fd_do_readv(struct se_task *task) static int fd_do_writev(struct se_task *task) { struct fd_request *req = FILE_REQ(task); - struct fd_dev *dev = req->fd_task.se_dev->dev_ptr; + struct se_device *se_dev = req->fd_task.task_se_cmd->se_dev; + struct fd_dev *dev = se_dev->dev_ptr; struct file *fd = dev->fd_file; struct scatterlist *sg = task->task_sg; struct iovec *iov; mm_segment_t old_fs; loff_t pos = (task->task_lba * - task->se_dev->se_sub_dev->se_dev_attrib.block_size); + se_dev->se_sub_dev->se_dev_attrib.block_size); int ret, i = 0; 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 dcf93f85977ab9d1c635699974368c67848598d9..21a3677984fbea149ca9108562d9b5891ce9d89b 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( static void iblock_bio_destructor(struct bio *bio) { struct se_task *task = bio->bi_private; - struct iblock_dev *ib_dev = task->se_dev->dev_ptr; + struct iblock_dev *ib_dev = task->task_se_cmd->se_dev->dev_ptr; bio_free(bio, ib_dev->ibd_bio_set); } @@ -507,7 +507,7 @@ static void iblock_bio_destructor(struct bio *bio) static struct bio * iblock_get_bio(struct se_task *task, sector_t lba, u32 sg_num) { - struct iblock_dev *ib_dev = task->se_dev->dev_ptr; + struct iblock_dev *ib_dev = task->task_se_cmd->se_dev->dev_ptr; struct iblock_req *ib_req = IBLOCK_REQ(task); struct bio *bio; diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c index 3898fb7d317c77aa6502c6b40a14fe4ec3d615ba..b347862bf8014c811c4b2e4bf31b8431387eef83 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) */ static int pscsi_transport_complete(struct se_task *task) { - struct pscsi_dev_virt *pdv = task->se_dev->dev_ptr; + struct pscsi_dev_virt *pdv = task->task_se_cmd->se_dev->dev_ptr; struct scsi_device *sd = pdv->pdv_sd; int result; struct pscsi_plugin_task *pt = PSCSI_TASK(task); @@ -962,7 +962,7 @@ static inline struct bio *pscsi_get_bio(int sg_num) static int pscsi_map_sg(struct se_task *task, struct scatterlist *task_sg, struct bio **hbio) { - struct pscsi_dev_virt *pdv = task->se_dev->dev_ptr; + struct pscsi_dev_virt *pdv = task->task_se_cmd->se_dev->dev_ptr; u32 task_sg_num = task->task_sg_nents; struct bio *bio = NULL, *tbio = NULL; struct page *page; @@ -1062,7 +1062,7 @@ static int pscsi_map_sg(struct se_task *task, struct scatterlist *task_sg, static int pscsi_do_task(struct se_task *task) { - struct pscsi_dev_virt *pdv = task->se_dev->dev_ptr; + struct pscsi_dev_virt *pdv = task->task_se_cmd->se_dev->dev_ptr; struct pscsi_plugin_task *pt = PSCSI_TASK(task); struct request *req; struct bio *hbio; diff --git a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c index 1ab69f32e664fdcd2b307e4dbf3173950292fc30..daf95dbe12ec912298a89d3daaeba108e9a194d9 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) static int rd_MEMCPY_read(struct rd_request *req) { struct se_task *task = &req->rd_task; - struct rd_dev *dev = req->rd_task.se_dev->dev_ptr; + struct rd_dev *dev = req->rd_task.task_se_cmd->se_dev->dev_ptr; struct rd_dev_sg_table *table; struct scatterlist *sg_d, *sg_s; void *dst, *src; @@ -466,7 +466,7 @@ static int rd_MEMCPY_read(struct rd_request *req) static int rd_MEMCPY_write(struct rd_request *req) { struct se_task *task = &req->rd_task; - struct rd_dev *dev = req->rd_task.se_dev->dev_ptr; + struct rd_dev *dev = req->rd_task.task_se_cmd->se_dev->dev_ptr; struct rd_dev_sg_table *table; struct scatterlist *sg_d, *sg_s; void *dst, *src; @@ -581,7 +581,7 @@ static int rd_MEMCPY_write(struct rd_request *req) */ static int rd_MEMCPY_do_task(struct se_task *task) { - struct se_device *dev = task->se_dev; + struct se_device *dev = task->task_se_cmd->se_dev; struct rd_request *req = RD_REQ(task); unsigned long long lba; int ret; diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 89b85dd36cce020d9d3efdfa8a1a82d485264fac..c935c72da7be86a2858030fd64b0d068bc7753e5 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -432,15 +432,14 @@ EXPORT_SYMBOL(transport_deregister_session); */ static void transport_all_task_dev_remove_state(struct se_cmd *cmd) { - struct se_device *dev; + struct se_device *dev = cmd->se_dev; struct se_task *task; unsigned long flags; - list_for_each_entry(task, &cmd->t_task_list, t_list) { - dev = task->se_dev; - if (!dev) - continue; + if (!dev) + return; + list_for_each_entry(task, &cmd->t_task_list, t_list) { if (atomic_read(&task->task_active)) continue; @@ -708,7 +707,7 @@ EXPORT_SYMBOL(transport_complete_sync_cache); void transport_complete_task(struct se_task *task, int success) { struct se_cmd *cmd = task->task_se_cmd; - struct se_device *dev = task->se_dev; + struct se_device *dev = cmd->se_dev; int t_state; unsigned long flags; #if 0 @@ -886,14 +885,12 @@ static void __transport_add_task_to_execute_queue( static void transport_add_tasks_to_state_queue(struct se_cmd *cmd) { - struct se_device *dev; + struct se_device *dev = cmd->se_dev; struct se_task *task; unsigned long flags; spin_lock_irqsave(&cmd->t_state_lock, flags); list_for_each_entry(task, &cmd->t_task_list, t_list) { - dev = task->se_dev; - if (atomic_read(&task->task_state_active)) continue; @@ -1522,7 +1519,6 @@ transport_generic_get_task(struct se_cmd *cmd, INIT_LIST_HEAD(&task->t_state_list); init_completion(&task->task_stop_comp); task->task_se_cmd = cmd; - task->se_dev = dev; task->task_data_direction = data_direction; return task; @@ -1802,7 +1798,7 @@ static int transport_stop_tasks_for_cmd(struct se_cmd *cmd) spin_unlock_irqrestore(&cmd->t_state_lock, flags); transport_remove_task_from_execute_queue(task, - task->se_dev); + cmd->se_dev); pr_debug("task_no[%d] - Removed from execute queue\n", task->task_no); @@ -2130,7 +2126,7 @@ static void transport_task_timeout_handler(unsigned long data) */ static void transport_start_task_timer(struct se_task *task) { - struct se_device *dev = task->se_dev; + struct se_device *dev = task->task_se_cmd->se_dev; int timeout; if (task->task_flags & TF_RUNNING) @@ -2656,13 +2652,16 @@ static void transport_xor_callback(struct se_cmd *cmd) static int transport_get_sense_data(struct se_cmd *cmd) { unsigned char *buffer = cmd->sense_buffer, *sense_buffer = NULL; - struct se_device *dev; + struct se_device *dev = cmd->se_dev; struct se_task *task = NULL, *task_tmp; unsigned long flags; u32 offset = 0; WARN_ON(!cmd->se_lun); + if (!dev) + return 0; + spin_lock_irqsave(&cmd->t_state_lock, flags); if (cmd->se_cmd_flags & SCF_SENT_CHECK_CONDITION) { spin_unlock_irqrestore(&cmd->t_state_lock, flags); @@ -2671,14 +2670,9 @@ static int transport_get_sense_data(struct se_cmd *cmd) list_for_each_entry_safe(task, task_tmp, &cmd->t_task_list, t_list) { - if (!task->task_sense) continue; - dev = task->se_dev; - if (!dev) - continue; - if (!dev->transport->get_sense_buffer) { pr_err("dev->transport->get_sense_buffer" " is NULL\n"); @@ -3628,11 +3622,7 @@ static void transport_free_dev_tasks(struct se_cmd *cmd) list_del(&task->t_list); spin_unlock_irqrestore(&cmd->t_state_lock, flags); - if (task->se_dev) - task->se_dev->transport->free_task(task); - else - pr_err("task[%u] - task->se_dev is NULL\n", - task->task_no); + cmd->se_dev->transport->free_task(task); spin_lock_irqsave(&cmd->t_state_lock, flags); } 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 c00224e8d6c40699124313b2a94f388280287320..6c49db40320519cca49de69b2e9787a3ca17be3b 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -405,7 +405,6 @@ struct se_task { u8 task_scsi_status; u8 task_flags; int task_error_status; - int task_state_flags; bool task_padded_sg; unsigned long long task_lba; u32 task_no; @@ -413,7 +412,6 @@ struct se_task { u32 task_size; enum dma_data_direction task_data_direction; struct se_cmd *task_se_cmd; - struct se_device *se_dev; struct completion task_stop_comp; atomic_t task_active; atomic_t task_execute_queue; @@ -422,7 +420,6 @@ struct se_task { atomic_t task_stop; atomic_t task_state_active; struct timer_list task_timer; - struct se_device *se_obj_ptr; struct list_head t_list; struct list_head t_execute_list; struct list_head t_state_list; diff --git a/include/target/target_core_transport.h b/include/target/target_core_transport.h index ccd85b380d6b69e7dc69e05d67c4e6f5f4b9fcb9..c93cf0ae37a46b7f492c5a945dcab56d1d9b1929 100644 --- a/include/target/target_core_transport.h +++ b/include/target/target_core_transport.h @@ -45,9 +45,6 @@ #define TRANSPORT_TIMEOUT_TYPE_TAPE 600 #define TRANSPORT_TIMEOUT_TYPE_OTHER 300 -/* For se_task->task_state_flags */ -#define TSF_EXCEPTION_CLEARED 0x01 - /* * struct se_subsystem_dev->su_dev_flags */