[PATCH 3/6] target: remove the task_lba field in struct se_task

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Now that we don't split commands the lba field in the task is always
equivalent to the one in the CDB, even in cases where we have two tasks
due to a BIDI transfer.  Just refer the the lba in the command instead
of duplicating it in the task.

Signed-off-by: Christoph Hellwig <hch@xxxxxx>

---
 drivers/target/target_core_file.c      |    9 +++++----
 drivers/target/target_core_iblock.c    |   10 +++++-----
 drivers/target/target_core_rd.c        |    6 ++++--
 drivers/target/target_core_transport.c |    1 -
 include/target/target_core_base.h      |    1 -
 5 files changed, 14 insertions(+), 13 deletions(-)

Index: lio-core/drivers/target/target_core_file.c
===================================================================
--- lio-core.orig/drivers/target/target_core_file.c	2012-04-23 17:19:42.612462572 +0200
+++ lio-core/drivers/target/target_core_file.c	2012-04-23 17:21:27.096465247 +0200
@@ -273,7 +273,7 @@ static int fd_do_readv(struct se_task *t
 	struct scatterlist *sg = task->task_sg;
 	struct iovec *iov;
 	mm_segment_t old_fs;
-	loff_t pos = (task->task_lba *
+	loff_t pos = (task->task_se_cmd->t_task_lba *
 		      se_dev->se_sub_dev->se_dev_attrib.block_size);
 	int ret = 0, i;
 
@@ -326,7 +326,7 @@ static int fd_do_writev(struct se_task *
 	struct scatterlist *sg = task->task_sg;
 	struct iovec *iov;
 	mm_segment_t old_fs;
-	loff_t pos = (task->task_lba *
+	loff_t pos = (task->task_se_cmd->t_task_lba *
 		      se_dev->se_sub_dev->se_dev_attrib.block_size);
 	int ret, i = 0;
 
@@ -402,12 +402,13 @@ static void fd_emulate_write_fua(struct
 {
 	struct se_device *dev = cmd->se_dev;
 	struct fd_dev *fd_dev = dev->dev_ptr;
-	loff_t start = task->task_lba * dev->se_sub_dev->se_dev_attrib.block_size;
+	loff_t start = task->task_se_cmd->t_task_lba *
+		dev->se_sub_dev->se_dev_attrib.block_size;
 	loff_t end = start + task->task_size;
 	int ret;
 
 	pr_debug("FILEIO: FUA WRITE LBA: %llu, bytes: %u\n",
-			task->task_lba, task->task_size);
+			task->task_se_cmd->t_task_lba, task->task_size);
 
 	ret = vfs_fsync_range(fd_dev->fd_file, start, end, 1);
 	if (ret != 0)
Index: lio-core/drivers/target/target_core_iblock.c
===================================================================
--- lio-core.orig/drivers/target/target_core_iblock.c	2012-04-23 17:19:42.612462572 +0200
+++ lio-core/drivers/target/target_core_iblock.c	2012-04-23 17:21:27.096465247 +0200
@@ -536,13 +536,13 @@ static int iblock_do_task(struct se_task
 	 * struct se_task SCSI blocksize into Linux/Block 512 units for BIO.
 	 */
 	if (dev->se_sub_dev->se_dev_attrib.block_size == 4096)
-		block_lba = (task->task_lba << 3);
+		block_lba = (cmd->t_task_lba << 3);
 	else if (dev->se_sub_dev->se_dev_attrib.block_size == 2048)
-		block_lba = (task->task_lba << 2);
+		block_lba = (cmd->t_task_lba << 2);
 	else if (dev->se_sub_dev->se_dev_attrib.block_size == 1024)
-		block_lba = (task->task_lba << 1);
+		block_lba = (cmd->t_task_lba << 1);
 	else if (dev->se_sub_dev->se_dev_attrib.block_size == 512)
-		block_lba = task->task_lba;
+		block_lba = cmd->t_task_lba;
 	else {
 		pr_err("Unsupported SCSI -> BLOCK LBA conversion:"
 				" %u\n", dev->se_sub_dev->se_dev_attrib.block_size);
@@ -646,7 +646,7 @@ static void iblock_bio_done(struct bio *
 		return;
 
 	pr_debug("done[%p] bio: %p task_lba: %llu bio_lba: %llu err=%d\n",
-		 task, bio, task->task_lba,
+		 task, bio, task->task_se_cmd->t_task_lba,
 		 (unsigned long long)bio->bi_sector, err);
 
 	transport_complete_task(task, !atomic_read(&ibr->ib_bio_err_cnt));
Index: lio-core/drivers/target/target_core_rd.c
===================================================================
--- lio-core.orig/drivers/target/target_core_rd.c	2012-04-23 17:19:42.612462572 +0200
+++ lio-core/drivers/target/target_core_rd.c	2012-04-23 17:21:27.096465247 +0200
@@ -303,7 +303,8 @@ static int rd_do_task(struct se_task *ta
 	u32 src_len;
 	u64 tmp;
 
-	tmp = task->task_lba * se_dev->se_sub_dev->se_dev_attrib.block_size;
+	tmp = task->task_se_cmd->t_task_lba *
+		se_dev->se_sub_dev->se_dev_attrib.block_size;
 	rd_offset = do_div(tmp, PAGE_SIZE);
 	rd_page = tmp;
 	rd_size = task->task_size;
@@ -318,7 +319,8 @@ static int rd_do_task(struct se_task *ta
 			dev->rd_dev_id,
 			task->task_data_direction == DMA_FROM_DEVICE ?
 				"Read" : "Write",
-			task->task_lba, rd_size, rd_page, rd_offset);
+			task->task_se_cmd->t_task_lba,
+			rd_size, rd_page, rd_offset);
 
 	src_len = PAGE_SIZE - rd_offset;
 	sg_miter_start(&m, task->task_sg, task->task_sg_nents,
Index: lio-core/drivers/target/target_core_transport.c
===================================================================
--- lio-core.orig/drivers/target/target_core_transport.c	2012-04-23 17:19:44.760462627 +0200
+++ lio-core/drivers/target/target_core_transport.c	2012-04-23 17:21:27.100465247 +0200
@@ -3723,7 +3723,6 @@ transport_allocate_data_tasks(struct se_
 	task->task_sg_nents = sgl_nents;
 	task->task_size = cmd->data_length;
 
-	task->task_lba = cmd->t_task_lba;
 	task->task_sectors = sectors;
 
 	spin_lock_irqsave(&cmd->t_state_lock, flags);
Index: lio-core/include/target/target_core_base.h
===================================================================
--- lio-core.orig/include/target/target_core_base.h	2012-04-23 17:19:42.612462572 +0200
+++ lio-core/include/target/target_core_base.h	2012-04-23 17:21:27.100465247 +0200
@@ -486,7 +486,6 @@ struct se_queue_obj {
 };
 
 struct se_task {
-	unsigned long long	task_lba;
 	u32			task_sectors;
 	u32			task_size;
 	struct se_cmd		*task_se_cmd;

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux