Skip to content

Commit

Permalink
target: remove the task_size field in struct se_task
Browse files Browse the repository at this point in the history
Now that we don't split commands the size 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 size in the command instead
of duplicating it in the task.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
  • Loading branch information
Christoph Hellwig authored and Nicholas Bellinger committed May 6, 2012
1 parent 72a0e5e commit 7a83aa4
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
11 changes: 6 additions & 5 deletions drivers/target/target_core_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,10 @@ static int fd_do_readv(struct se_task *task)
* block_device.
*/
if (S_ISBLK(fd->f_dentry->d_inode->i_mode)) {
if (ret < 0 || ret != task->task_size) {
if (ret < 0 || ret != task->task_se_cmd->data_length) {
pr_err("vfs_readv() returned %d,"
" expecting %d for S_ISBLK\n", ret,
(int)task->task_size);
(int)task->task_se_cmd->data_length);
return (ret < 0 ? ret : -EINVAL);
}
} else {
Expand Down Expand Up @@ -348,7 +348,7 @@ static int fd_do_writev(struct se_task *task)

kfree(iov);

if (ret < 0 || ret != task->task_size) {
if (ret < 0 || ret != task->task_se_cmd->data_length) {
pr_err("vfs_writev() returned %d\n", ret);
return (ret < 0 ? ret : -EINVAL);
}
Expand Down Expand Up @@ -404,11 +404,12 @@ static void fd_emulate_write_fua(struct se_cmd *cmd, struct se_task *task)
struct fd_dev *fd_dev = dev->dev_ptr;
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;
loff_t end = start + task->task_se_cmd->data_length;
int ret;

pr_debug("FILEIO: FUA WRITE LBA: %llu, bytes: %u\n",
task->task_se_cmd->t_task_lba, task->task_size);
task->task_se_cmd->t_task_lba,
task->task_se_cmd->data_length);

ret = vfs_fsync_range(fd_dev->fd_file, start, end, 1);
if (ret != 0)
Expand Down
3 changes: 2 additions & 1 deletion drivers/target/target_core_iblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,8 @@ iblock_get_bio(struct se_task *task, sector_t lba, u32 sg_num)

pr_debug("Allocated bio: %p task_sg_nents: %u using ibd_bio_set:"
" %p\n", bio, task->task_sg_nents, ib_dev->ibd_bio_set);
pr_debug("Allocated bio: %p task_size: %u\n", bio, task->task_size);
pr_debug("Allocated bio: %p task_size: %u\n", bio,
task->task_se_cmd->data_length);

bio->bi_bdev = ib_dev->ibd_bd;
bio->bi_private = task;
Expand Down
6 changes: 3 additions & 3 deletions drivers/target/target_core_pscsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -967,8 +967,8 @@ static int pscsi_map_sg(struct se_task *task, struct scatterlist *task_sg,
struct bio *bio = NULL, *tbio = NULL;
struct page *page;
struct scatterlist *sg;
u32 data_len = task->task_size, i, len, bytes, off;
int nr_pages = (task->task_size + task_sg[0].offset +
u32 data_len = cmd->data_length, i, len, bytes, off;
int nr_pages = (cmd->data_length + task_sg[0].offset +
PAGE_SIZE - 1) >> PAGE_SHIFT;
int nr_vecs = 0, rc;
int rw = (task->task_data_direction == DMA_TO_DEVICE);
Expand Down Expand Up @@ -1085,7 +1085,7 @@ static int pscsi_do_task(struct se_task *task)
return -ENODEV;
}
} else {
BUG_ON(!task->task_size);
BUG_ON(!cmd->data_length);

/*
* Setup the main struct request for the task->task_sg[] payload
Expand Down
2 changes: 1 addition & 1 deletion drivers/target/target_core_rd.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ static int rd_do_task(struct se_task *task)
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;
rd_size = task->task_se_cmd->data_length;

table = rd_get_sg_table(dev, rd_page);
if (!table)
Expand Down
2 changes: 0 additions & 2 deletions drivers/target/target_core_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -3722,7 +3722,6 @@ transport_allocate_data_tasks(struct se_cmd *cmd,

task->task_sg = cmd_sg;
task->task_sg_nents = sgl_nents;
task->task_size = cmd->data_length;

task->task_sectors = sectors;

Expand All @@ -3749,7 +3748,6 @@ transport_allocate_control_task(struct se_cmd *cmd)
return -ENOMEM;

task->task_sg = cmd->t_data_sg;
task->task_size = cmd->data_length;
task->task_sg_nents = cmd->t_data_nents;

spin_lock_irqsave(&cmd->t_state_lock, flags);
Expand Down
1 change: 0 additions & 1 deletion include/target/target_core_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,6 @@ struct se_queue_obj {

struct se_task {
u32 task_sectors;
u32 task_size;
struct se_cmd *task_se_cmd;
struct scatterlist *task_sg;
u32 task_sg_nents;
Expand Down

0 comments on commit 7a83aa4

Please sign in to comment.