Commit 3abaa2bf authored by Mike Christie's avatar Mike Christie Committed by Nicholas Bellinger

tcmu: allow hw_max_sectors greater than 128

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: default avatarMike Christie <[email protected]>
Signed-off-by: default avatarNicholas Bellinger <[email protected]>
parent 9c28ca4f
...@@ -960,7 +960,8 @@ static int tcmu_configure_device(struct se_device *dev) ...@@ -960,7 +960,8 @@ static int tcmu_configure_device(struct se_device *dev)
if (dev->dev_attrib.hw_block_size == 0) if (dev->dev_attrib.hw_block_size == 0)
dev->dev_attrib.hw_block_size = 512; dev->dev_attrib.hw_block_size = 512;
/* Other attributes can be configured in userspace */ /* 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; dev->dev_attrib.hw_queue_depth = 128;
ret = tcmu_netlink_event(TCMU_CMD_ADDED_DEVICE, udev->uio_info.name, ret = tcmu_netlink_event(TCMU_CMD_ADDED_DEVICE, udev->uio_info.name,
...@@ -1031,16 +1032,42 @@ static void tcmu_free_device(struct se_device *dev) ...@@ -1031,16 +1032,42 @@ static void tcmu_free_device(struct se_device *dev)
} }
enum { 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 = { static match_table_t tokens = {
{Opt_dev_config, "dev_config=%s"}, {Opt_dev_config, "dev_config=%s"},
{Opt_dev_size, "dev_size=%u"}, {Opt_dev_size, "dev_size=%u"},
{Opt_hw_block_size, "hw_block_size=%u"}, {Opt_hw_block_size, "hw_block_size=%u"},
{Opt_hw_max_sectors, "hw_max_sectors=%u"},
{Opt_err, NULL} {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, static ssize_t tcmu_set_configfs_dev_params(struct se_device *dev,
const char *page, ssize_t count) const char *page, ssize_t count)
{ {
...@@ -1048,7 +1075,6 @@ static ssize_t tcmu_set_configfs_dev_params(struct se_device *dev, ...@@ -1048,7 +1075,6 @@ static ssize_t tcmu_set_configfs_dev_params(struct se_device *dev,
char *orig, *ptr, *opts, *arg_p; char *orig, *ptr, *opts, *arg_p;
substring_t args[MAX_OPT_ARGS]; substring_t args[MAX_OPT_ARGS];
int ret = 0, token; int ret = 0, token;
unsigned long tmp_ul;
opts = kstrdup(page, GFP_KERNEL); opts = kstrdup(page, GFP_KERNEL);
if (!opts) if (!opts)
...@@ -1082,22 +1108,12 @@ static ssize_t tcmu_set_configfs_dev_params(struct se_device *dev, ...@@ -1082,22 +1108,12 @@ static ssize_t tcmu_set_configfs_dev_params(struct se_device *dev,
pr_err("kstrtoul() failed for dev_size=\n"); pr_err("kstrtoul() failed for dev_size=\n");
break; break;
case Opt_hw_block_size: case Opt_hw_block_size:
arg_p = match_strdup(&args[0]); ret = tcmu_set_dev_attrib(&args[0],
if (!arg_p) { &(dev->dev_attrib.hw_block_size));
ret = -ENOMEM; break;
break; case Opt_hw_max_sectors:
} ret = tcmu_set_dev_attrib(&args[0],
ret = kstrtoul(arg_p, 0, &tmp_ul); &(dev->dev_attrib.hw_max_sectors));
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;
break; break;
default: default:
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment