Skip to content

Commit

Permalink
scsi: target: core: Send max transfer length in blocks
Browse files Browse the repository at this point in the history
A MAXIMUM TRANSFER LENGTH value indicates the maximum transfer length in
logical blocks that the device server accepts for a single command. Fix
function sending the length in sectors instead of blocks.

This patch also removes the special casing for fileio in block_size_store
since this logic in now unified in spc_emulate_evpd_b0() for all backends.

Reviewed-by: Konstantin Shelekhin <[email protected]>
Reviewed-by: Dmitriy Bogdanov <[email protected]>
Signed-off-by: Anastasia Kovaleva <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Mike Christie <[email protected]>
Signed-off-by: Martin K. Petersen <[email protected]>
  • Loading branch information
nastya-nizharadze authored and martinkpetersen committed Nov 24, 2022
1 parent cdd9344 commit 7870d24
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 0 additions & 2 deletions drivers/target/target_core_configfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1102,8 +1102,6 @@ static ssize_t block_size_store(struct config_item *item,
}

da->block_size = val;
if (da->max_bytes_per_io)
da->hw_max_sectors = da->max_bytes_per_io / val;

pr_debug("dev[%p]: SE Device block_size changed to %u\n",
da->da_dev, val);
Expand Down
1 change: 0 additions & 1 deletion drivers/target/target_core_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ static int fd_configure_device(struct se_device *dev)
}

dev->dev_attrib.hw_block_size = fd_dev->fd_block_size;
dev->dev_attrib.max_bytes_per_io = FD_MAX_BYTES;
dev->dev_attrib.hw_max_sectors = FD_MAX_BYTES / fd_dev->fd_block_size;
dev->dev_attrib.hw_queue_depth = FD_MAX_DEVICE_QUEUE_DEPTH;

Expand Down
6 changes: 5 additions & 1 deletion drivers/target/target_core_spc.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ spc_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf)
struct se_device *dev = cmd->se_dev;
u32 mtl = 0;
int have_tp = 0, opt, min;
u32 io_max_blocks;

/*
* Following spc3r22 section 6.5.3 Block Limits VPD page, when
Expand Down Expand Up @@ -553,7 +554,10 @@ spc_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf)
mtl = (cmd->se_tfo->max_data_sg_nents * PAGE_SIZE) /
dev->dev_attrib.block_size;
}
put_unaligned_be32(min_not_zero(mtl, dev->dev_attrib.hw_max_sectors), &buf[8]);
io_max_blocks = mult_frac(dev->dev_attrib.hw_max_sectors,
dev->dev_attrib.hw_block_size,
dev->dev_attrib.block_size);
put_unaligned_be32(min_not_zero(mtl, io_max_blocks), &buf[8]);

/*
* Set OPTIMAL TRANSFER LENGTH
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 @@ -712,7 +712,6 @@ struct se_dev_attrib {
u32 unmap_granularity;
u32 unmap_granularity_alignment;
u32 max_write_same_len;
u32 max_bytes_per_io;
struct se_device *da_dev;
struct config_group da_group;
};
Expand Down

0 comments on commit 7870d24

Please sign in to comment.