Skip to contentSkip to conversation

tcm: Improvements for struct se_mem <-> SGL mapping logic

PATCH New Nicholas A. Bellinger 1 participant 1 message Aug 18, 2010 SCSI

lore
Share & tools
lore
#0 lore raw

cover tcm: Improvements for struct se_mem <-> SGL mapping logic

From: Nicholas Bellinger <[email protected]>

Greetings hch, Jens and Co,

The following are three patches improve the handling of struct scatterlist -> struct se_mem and struct se_mem -> struct scatterlist mapping within the TCM core algorithms. These patches also fix a bug for the struct se_mem -> struct scatterlist case with an underlying struct block_device is reporting max_sectors=255, and when multiple struct tasks carrying an struct se_mem *in_se_mem and u32 *task_offset pointer need to be carried between allocations in transport_generic_get_cdb_count() and for struct se_subsystem_api I/O of struct se_task.

The last two commits are difficult decipher without looking at the larger context, which is:

Starting in transport_generic_get_cdb_count(), which the generation of N tasks based on enforced max_sectors for a single received CDB in struct se_cmd:

http://git.kernel.org/?p=linux/kernel/git/nab/lio-core-2.6.git;a=blob;f=drivers/target/target_core_transport.c;hb=refs/heads/lio-4.0#l6960

then into dev_obj_do_se_mem_map() for an single individual struct se_task:

http://git.kernel.org/?p=linux/kernel/git/nab/lio-core-2.6.git;a=blob;f=drivers/target/target_core_seobj.c;hb=refs/heads/lio-4.0#l103

and finally into transport_calc_sg_num() and transport_map_mem_to_sg() respectively to allocate struct se_task->task_sg[] and map the struct se_mem from the per CDB I/O descriptor context in T_TASK(se_cmd)->t_mem_list. This goes into a single struct se_task context mapping into struct se_task->task_sg[], that is then dispatched to individual subsystem plugin I/O via struct se_subsystem_api->do_task().

http://git.kernel.org/?p=linux/kernel/git/nab/lio-core-2.6.git;a=blob;f=drivers/target/target_core_transport.c;hb=refs/heads/lio-4.0#l6553
http://git.kernel.org/?p=linux/kernel/git/nab/lio-core-2.6.git;a=blob;f=drivers/target/target_core_transport.c;hb=refs/heads/lio-4.0#l6857

So far this has been tested on v2.6.35 using TCM_Loop for patch #1, and TCM/IBLOCK + scsi_debug w/ max_sectors 255-251 for the patch #2 and #3. I am going to keep testing this with some various odd numbered max_sectors values with scsi_debug and see if all combinations of SGL -> struct se_mem and struct se_mem -> SGL mapping are working as expected.

Best,

--nab

Nicholas Bellinger (3):
tcm: Remove task_offset parameter from transport_map_sg_to_mem()
tcm: Make transport_calc_sg_num() properly handle task_offset
tcm: Make transport_map_mem_to_sg() properly handle task_offset

 drivers/target/target_core_transport.c |  212 +++++++++++++------------------
 include/target/target_core_transport.h |    2 +-
 2 files changed, 90 insertions(+), 124 deletions(-)