diff options
author | Mike Christie <mchristi@redhat.com> | 2017-03-02 00:14:39 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2017-03-18 17:46:52 -0400 |
commit | 3abaa2bfdb1e6bb33d38a2e82cf3bb82ec0197bf (patch) | |
tree | b75e0eac42bd7beb452d4e54e9d8876027aadcef | |
parent | 9c28ca4ff8bad7486182291a55b4f67a70af718d (diff) |
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: Mike Christie <mchristi@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r-- | drivers/target/target_core_user.c | 54 |
1 files changed, 35 insertions, 19 deletions
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index c3adefe95e50..24e8580f07b8 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c | |||
@@ -960,7 +960,8 @@ static int tcmu_configure_device(struct se_device *dev) | |||
960 | if (dev->dev_attrib.hw_block_size == 0) | 960 | if (dev->dev_attrib.hw_block_size == 0) |
961 | dev->dev_attrib.hw_block_size = 512; | 961 | dev->dev_attrib.hw_block_size = 512; |
962 | /* Other attributes can be configured in userspace */ | 962 | /* Other attributes can be configured in userspace */ |
963 | dev->dev_attrib.hw_max_sectors = 128; | 963 | if (!dev->dev_attrib.hw_max_sectors) |
964 | dev->dev_attrib.hw_max_sectors = 128; | ||
964 | dev->dev_attrib.hw_queue_depth = 128; | 965 | dev->dev_attrib.hw_queue_depth = 128; |
965 | 966 | ||
966 | ret = tcmu_netlink_event(TCMU_CMD_ADDED_DEVICE, udev->uio_info.name, | 967 | 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 | } | 1032 | } |
1032 | 1033 | ||
1033 | enum { | 1034 | enum { |
1034 | Opt_dev_config, Opt_dev_size, Opt_hw_block_size, Opt_err, | 1035 | Opt_dev_config, Opt_dev_size, Opt_hw_block_size, Opt_hw_max_sectors, |
1036 | Opt_err, | ||
1035 | }; | 1037 | }; |
1036 | 1038 | ||
1037 | static match_table_t tokens = { | 1039 | static match_table_t tokens = { |
1038 | {Opt_dev_config, "dev_config=%s"}, | 1040 | {Opt_dev_config, "dev_config=%s"}, |
1039 | {Opt_dev_size, "dev_size=%u"}, | 1041 | {Opt_dev_size, "dev_size=%u"}, |
1040 | {Opt_hw_block_size, "hw_block_size=%u"}, | 1042 | {Opt_hw_block_size, "hw_block_size=%u"}, |
1043 | {Opt_hw_max_sectors, "hw_max_sectors=%u"}, | ||
1041 | {Opt_err, NULL} | 1044 | {Opt_err, NULL} |
1042 | }; | 1045 | }; |
1043 | 1046 | ||
1047 | static int tcmu_set_dev_attrib(substring_t *arg, u32 *dev_attrib) | ||
1048 | { | ||
1049 | unsigned long tmp_ul; | ||
1050 | char *arg_p; | ||
1051 | int ret; | ||
1052 | |||
1053 | arg_p = match_strdup(arg); | ||
1054 | if (!arg_p) | ||
1055 | return -ENOMEM; | ||
1056 | |||
1057 | ret = kstrtoul(arg_p, 0, &tmp_ul); | ||
1058 | kfree(arg_p); | ||
1059 | if (ret < 0) { | ||
1060 | pr_err("kstrtoul() failed for dev attrib\n"); | ||
1061 | return ret; | ||
1062 | } | ||
1063 | if (!tmp_ul) { | ||
1064 | pr_err("dev attrib must be nonzero\n"); | ||
1065 | return -EINVAL; | ||
1066 | } | ||
1067 | *dev_attrib = tmp_ul; | ||
1068 | return 0; | ||
1069 | } | ||
1070 | |||
1044 | static ssize_t tcmu_set_configfs_dev_params(struct se_device *dev, | 1071 | static ssize_t tcmu_set_configfs_dev_params(struct se_device *dev, |
1045 | const char *page, ssize_t count) | 1072 | const char *page, ssize_t count) |
1046 | { | 1073 | { |
@@ -1048,7 +1075,6 @@ static ssize_t tcmu_set_configfs_dev_params(struct se_device *dev, | |||
1048 | char *orig, *ptr, *opts, *arg_p; | 1075 | char *orig, *ptr, *opts, *arg_p; |
1049 | substring_t args[MAX_OPT_ARGS]; | 1076 | substring_t args[MAX_OPT_ARGS]; |
1050 | int ret = 0, token; | 1077 | int ret = 0, token; |
1051 | unsigned long tmp_ul; | ||
1052 | 1078 | ||
1053 | opts = kstrdup(page, GFP_KERNEL); | 1079 | opts = kstrdup(page, GFP_KERNEL); |
1054 | if (!opts) | 1080 | if (!opts) |
@@ -1082,22 +1108,12 @@ static ssize_t tcmu_set_configfs_dev_params(struct se_device *dev, | |||
1082 | pr_err("kstrtoul() failed for dev_size=\n"); | 1108 | pr_err("kstrtoul() failed for dev_size=\n"); |
1083 | break; | 1109 | break; |
1084 | case Opt_hw_block_size: | 1110 | case Opt_hw_block_size: |
1085 | arg_p = match_strdup(&args[0]); | 1111 | ret = tcmu_set_dev_attrib(&args[0], |
1086 | if (!arg_p) { | 1112 | &(dev->dev_attrib.hw_block_size)); |
1087 | ret = -ENOMEM; | 1113 | break; |
1088 | break; | 1114 | case Opt_hw_max_sectors: |
1089 | } | 1115 | ret = tcmu_set_dev_attrib(&args[0], |
1090 | ret = kstrtoul(arg_p, 0, &tmp_ul); | 1116 | &(dev->dev_attrib.hw_max_sectors)); |
1091 | kfree(arg_p); | ||
1092 | if (ret < 0) { | ||
1093 | pr_err("kstrtoul() failed for hw_block_size=\n"); | ||
1094 | break; | ||
1095 | } | ||
1096 | if (!tmp_ul) { | ||
1097 | pr_err("hw_block_size must be nonzero\n"); | ||
1098 | break; | ||
1099 | } | ||
1100 | dev->dev_attrib.hw_block_size = tmp_ul; | ||
1101 | break; | 1117 | break; |
1102 | default: | 1118 | default: |
1103 | break; | 1119 | break; |