Skip to content

Commit

Permalink
tcmu: allow hw_max_sectors greater than 128
Browse files Browse the repository at this point in the history
tcmu hard codes the hw_max_sectors to 128 which is a litle small.
Userspace uses the max_sectors to report the optimal IO size and
some initiators perform better with larger IOs (open-iscsi seems
to do better with 256 to 512 depending on the test).

(Fix do not display hw max sectors twice - MNC)

Signed-off-by: Mike Christie <mchristi@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
  • Loading branch information
Mike Christie authored and Nicholas Bellinger committed Mar 18, 2017
1 parent 9c28ca4 commit 3abaa2b
Showing 1 changed file with 35 additions and 19 deletions.
54 changes: 35 additions & 19 deletions drivers/target/target_core_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,8 @@ static int tcmu_configure_device(struct se_device *dev)
if (dev->dev_attrib.hw_block_size == 0)
dev->dev_attrib.hw_block_size = 512;
/* Other attributes can be configured in userspace */
dev->dev_attrib.hw_max_sectors = 128;
if (!dev->dev_attrib.hw_max_sectors)
dev->dev_attrib.hw_max_sectors = 128;
dev->dev_attrib.hw_queue_depth = 128;

ret = tcmu_netlink_event(TCMU_CMD_ADDED_DEVICE, udev->uio_info.name,
Expand Down Expand Up @@ -1031,24 +1032,49 @@ static void tcmu_free_device(struct se_device *dev)
}

enum {
Opt_dev_config, Opt_dev_size, Opt_hw_block_size, Opt_err,
Opt_dev_config, Opt_dev_size, Opt_hw_block_size, Opt_hw_max_sectors,
Opt_err,
};

static match_table_t tokens = {
{Opt_dev_config, "dev_config=%s"},
{Opt_dev_size, "dev_size=%u"},
{Opt_hw_block_size, "hw_block_size=%u"},
{Opt_hw_max_sectors, "hw_max_sectors=%u"},
{Opt_err, NULL}
};

static int tcmu_set_dev_attrib(substring_t *arg, u32 *dev_attrib)
{
unsigned long tmp_ul;
char *arg_p;
int ret;

arg_p = match_strdup(arg);
if (!arg_p)
return -ENOMEM;

ret = kstrtoul(arg_p, 0, &tmp_ul);
kfree(arg_p);
if (ret < 0) {
pr_err("kstrtoul() failed for dev attrib\n");
return ret;
}
if (!tmp_ul) {
pr_err("dev attrib must be nonzero\n");
return -EINVAL;
}
*dev_attrib = tmp_ul;
return 0;
}

static ssize_t tcmu_set_configfs_dev_params(struct se_device *dev,
const char *page, ssize_t count)
{
struct tcmu_dev *udev = TCMU_DEV(dev);
char *orig, *ptr, *opts, *arg_p;
substring_t args[MAX_OPT_ARGS];
int ret = 0, token;
unsigned long tmp_ul;

opts = kstrdup(page, GFP_KERNEL);
if (!opts)
Expand Down Expand Up @@ -1082,22 +1108,12 @@ static ssize_t tcmu_set_configfs_dev_params(struct se_device *dev,
pr_err("kstrtoul() failed for dev_size=\n");
break;
case Opt_hw_block_size:
arg_p = match_strdup(&args[0]);
if (!arg_p) {
ret = -ENOMEM;
break;
}
ret = kstrtoul(arg_p, 0, &tmp_ul);
kfree(arg_p);
if (ret < 0) {
pr_err("kstrtoul() failed for hw_block_size=\n");
break;
}
if (!tmp_ul) {
pr_err("hw_block_size must be nonzero\n");
break;
}
dev->dev_attrib.hw_block_size = tmp_ul;
ret = tcmu_set_dev_attrib(&args[0],
&(dev->dev_attrib.hw_block_size));
break;
case Opt_hw_max_sectors:
ret = tcmu_set_dev_attrib(&args[0],
&(dev->dev_attrib.hw_max_sectors));
break;
default:
break;
Expand Down

0 comments on commit 3abaa2b

Please sign in to comment.