Skip to content

Commit

Permalink
target/rd: improve sg_table lookup scalability
Browse files Browse the repository at this point in the history
Sequential scan of rd_dev->sg_table_array in rd_get_sg_table is
a serious I/O performance bottleneck for large rd LUNs. Fix this
by computing the sg_table index directly from page offset because
all sg_tables (except the last one) have the same number of pages.

Tested with 90 GiB rd_mcp LUN, where the patch improved maximal
random R/W IOPS by more than 100-150%, depending on actual
hardware and SAN setup.

Signed-off-by: Martin Svec<martin.svec@zoner.cz>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
  • Loading branch information
Martin Svec authored and Nicholas Bellinger committed Feb 13, 2013
1 parent d09816a commit 8f67835
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/target/target_core_rd.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,12 @@ static void rd_free_device(struct se_device *dev)

static struct rd_dev_sg_table *rd_get_sg_table(struct rd_dev *rd_dev, u32 page)
{
u32 i;
struct rd_dev_sg_table *sg_table;
u32 i, sg_per_table = (RD_MAX_ALLOCATION_SIZE /
sizeof(struct scatterlist));

for (i = 0; i < rd_dev->sg_table_count; i++) {
i = page / sg_per_table;
if (i < rd_dev->sg_table_count) {
sg_table = &rd_dev->sg_table_array[i];
if ((sg_table->page_start_offset <= page) &&
(sg_table->page_end_offset >= page))
Expand Down

0 comments on commit 8f67835

Please sign in to comment.