diff options
author | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-05-09 15:42:09 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-05-09 18:08:47 -0400 |
commit | 11e764bd5ed4bb930e0ec5dd161df58307507347 (patch) | |
tree | fa753a950d19c2ef848c50c60f71019dcb912e74 | |
parent | 2301917044b96fda41f794011368e623a9b7a435 (diff) |
target: Remove max_sectors device attribute for modern se_task less code
This patch removes the original usage of dev_attr->max_sectors in favor of
dev_attr->hw_max_sectors that is now being enforced by target core from
within transport_generic_cmd_sequencer() for SCF_SCSI_DATA_SG_IO_CDB ops.
After the recent se_task removal patches from hch, this value for IBLOCK
backends being set via configfs by userspace from an saved max_sectors
value that is turning out to be problematic, so it makes sense to go ahead
and remove this now legacy attribute all-together.
This patch also continues to make se_dev_set_default_attribs() do
(sectors / block_size) alignment for what actually get used by
target_core_mod to be safe here, following the same alignment currently
used by fabric_max_sectors.
Reported-by: Andy Grover <agrover@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Roland Dreier <roland@purestorage.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r-- | drivers/target/target_core_cdb.c | 2 | ||||
-rw-r--r-- | drivers/target/target_core_configfs.c | 4 | ||||
-rw-r--r-- | drivers/target/target_core_device.c | 69 | ||||
-rw-r--r-- | drivers/target/target_core_transport.c | 7 | ||||
-rw-r--r-- | include/target/target_core_base.h | 1 |
5 files changed, 9 insertions, 74 deletions
diff --git a/drivers/target/target_core_cdb.c b/drivers/target/target_core_cdb.c index 22cf44cf43ac..9888693a18fe 100644 --- a/drivers/target/target_core_cdb.c +++ b/drivers/target/target_core_cdb.c | |||
@@ -458,7 +458,7 @@ target_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf) | |||
458 | * Set MAXIMUM TRANSFER LENGTH | 458 | * Set MAXIMUM TRANSFER LENGTH |
459 | */ | 459 | */ |
460 | max_sectors = min(dev->se_sub_dev->se_dev_attrib.fabric_max_sectors, | 460 | max_sectors = min(dev->se_sub_dev->se_dev_attrib.fabric_max_sectors, |
461 | dev->se_sub_dev->se_dev_attrib.max_sectors); | 461 | dev->se_sub_dev->se_dev_attrib.hw_max_sectors); |
462 | put_unaligned_be32(max_sectors, &buf[8]); | 462 | put_unaligned_be32(max_sectors, &buf[8]); |
463 | 463 | ||
464 | /* | 464 | /* |
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index cbb66537d230..931521cc4e4f 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c | |||
@@ -683,9 +683,6 @@ SE_DEV_ATTR(block_size, S_IRUGO | S_IWUSR); | |||
683 | DEF_DEV_ATTRIB_RO(hw_max_sectors); | 683 | DEF_DEV_ATTRIB_RO(hw_max_sectors); |
684 | SE_DEV_ATTR_RO(hw_max_sectors); | 684 | SE_DEV_ATTR_RO(hw_max_sectors); |
685 | 685 | ||
686 | DEF_DEV_ATTRIB(max_sectors); | ||
687 | SE_DEV_ATTR(max_sectors, S_IRUGO | S_IWUSR); | ||
688 | |||
689 | DEF_DEV_ATTRIB(fabric_max_sectors); | 686 | DEF_DEV_ATTRIB(fabric_max_sectors); |
690 | SE_DEV_ATTR(fabric_max_sectors, S_IRUGO | S_IWUSR); | 687 | SE_DEV_ATTR(fabric_max_sectors, S_IRUGO | S_IWUSR); |
691 | 688 | ||
@@ -727,7 +724,6 @@ static struct configfs_attribute *target_core_dev_attrib_attrs[] = { | |||
727 | &target_core_dev_attrib_hw_block_size.attr, | 724 | &target_core_dev_attrib_hw_block_size.attr, |
728 | &target_core_dev_attrib_block_size.attr, | 725 | &target_core_dev_attrib_block_size.attr, |
729 | &target_core_dev_attrib_hw_max_sectors.attr, | 726 | &target_core_dev_attrib_hw_max_sectors.attr, |
730 | &target_core_dev_attrib_max_sectors.attr, | ||
731 | &target_core_dev_attrib_fabric_max_sectors.attr, | 727 | &target_core_dev_attrib_fabric_max_sectors.attr, |
732 | &target_core_dev_attrib_optimal_sectors.attr, | 728 | &target_core_dev_attrib_optimal_sectors.attr, |
733 | &target_core_dev_attrib_hw_queue_depth.attr, | 729 | &target_core_dev_attrib_hw_queue_depth.attr, |
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index e621350feebc..5ad972856a8d 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c | |||
@@ -876,15 +876,12 @@ void se_dev_set_default_attribs( | |||
876 | dev->se_sub_dev->se_dev_attrib.hw_block_size = limits->logical_block_size; | 876 | dev->se_sub_dev->se_dev_attrib.hw_block_size = limits->logical_block_size; |
877 | dev->se_sub_dev->se_dev_attrib.block_size = limits->logical_block_size; | 877 | dev->se_sub_dev->se_dev_attrib.block_size = limits->logical_block_size; |
878 | /* | 878 | /* |
879 | * max_sectors is based on subsystem plugin dependent requirements. | 879 | * Align max_hw_sectors down to PAGE_SIZE I/O transfers |
880 | */ | 880 | */ |
881 | dev->se_sub_dev->se_dev_attrib.hw_max_sectors = limits->max_hw_sectors; | 881 | limits->max_hw_sectors = se_dev_align_max_sectors(limits->max_hw_sectors, |
882 | /* | ||
883 | * Align max_sectors down to PAGE_SIZE to follow transport_allocate_data_tasks() | ||
884 | */ | ||
885 | limits->max_sectors = se_dev_align_max_sectors(limits->max_sectors, | ||
886 | limits->logical_block_size); | 882 | limits->logical_block_size); |
887 | dev->se_sub_dev->se_dev_attrib.max_sectors = limits->max_sectors; | 883 | dev->se_sub_dev->se_dev_attrib.hw_max_sectors = limits->max_hw_sectors; |
884 | |||
888 | /* | 885 | /* |
889 | * Set fabric_max_sectors, which is reported in block limits | 886 | * Set fabric_max_sectors, which is reported in block limits |
890 | * VPD page (B0h). | 887 | * VPD page (B0h). |
@@ -1168,64 +1165,6 @@ int se_dev_set_queue_depth(struct se_device *dev, u32 queue_depth) | |||
1168 | return 0; | 1165 | return 0; |
1169 | } | 1166 | } |
1170 | 1167 | ||
1171 | int se_dev_set_max_sectors(struct se_device *dev, u32 max_sectors) | ||
1172 | { | ||
1173 | int force = 0; /* Force setting for VDEVS */ | ||
1174 | |||
1175 | if (atomic_read(&dev->dev_export_obj.obj_access_count)) { | ||
1176 | pr_err("dev[%p]: Unable to change SE Device" | ||
1177 | " max_sectors while dev_export_obj: %d count exists\n", | ||
1178 | dev, atomic_read(&dev->dev_export_obj.obj_access_count)); | ||
1179 | return -EINVAL; | ||
1180 | } | ||
1181 | if (!max_sectors) { | ||
1182 | pr_err("dev[%p]: Illegal ZERO value for" | ||
1183 | " max_sectors\n", dev); | ||
1184 | return -EINVAL; | ||
1185 | } | ||
1186 | if (max_sectors < DA_STATUS_MAX_SECTORS_MIN) { | ||
1187 | pr_err("dev[%p]: Passed max_sectors: %u less than" | ||
1188 | " DA_STATUS_MAX_SECTORS_MIN: %u\n", dev, max_sectors, | ||
1189 | DA_STATUS_MAX_SECTORS_MIN); | ||
1190 | return -EINVAL; | ||
1191 | } | ||
1192 | if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) { | ||
1193 | if (max_sectors > dev->se_sub_dev->se_dev_attrib.hw_max_sectors) { | ||
1194 | pr_err("dev[%p]: Passed max_sectors: %u" | ||
1195 | " greater than TCM/SE_Device max_sectors:" | ||
1196 | " %u\n", dev, max_sectors, | ||
1197 | dev->se_sub_dev->se_dev_attrib.hw_max_sectors); | ||
1198 | return -EINVAL; | ||
1199 | } | ||
1200 | } else { | ||
1201 | if (!force && (max_sectors > | ||
1202 | dev->se_sub_dev->se_dev_attrib.hw_max_sectors)) { | ||
1203 | pr_err("dev[%p]: Passed max_sectors: %u" | ||
1204 | " greater than TCM/SE_Device max_sectors" | ||
1205 | ": %u, use force=1 to override.\n", dev, | ||
1206 | max_sectors, dev->se_sub_dev->se_dev_attrib.hw_max_sectors); | ||
1207 | return -EINVAL; | ||
1208 | } | ||
1209 | if (max_sectors > DA_STATUS_MAX_SECTORS_MAX) { | ||
1210 | pr_err("dev[%p]: Passed max_sectors: %u" | ||
1211 | " greater than DA_STATUS_MAX_SECTORS_MAX:" | ||
1212 | " %u\n", dev, max_sectors, | ||
1213 | DA_STATUS_MAX_SECTORS_MAX); | ||
1214 | return -EINVAL; | ||
1215 | } | ||
1216 | } | ||
1217 | /* | ||
1218 | * Align max_sectors down to PAGE_SIZE to follow transport_allocate_data_tasks() | ||
1219 | */ | ||
1220 | max_sectors = se_dev_align_max_sectors(max_sectors, | ||
1221 | dev->se_sub_dev->se_dev_attrib.block_size); | ||
1222 | |||
1223 | dev->se_sub_dev->se_dev_attrib.max_sectors = max_sectors; | ||
1224 | pr_debug("dev[%p]: SE Device max_sectors changed to %u\n", | ||
1225 | dev, max_sectors); | ||
1226 | return 0; | ||
1227 | } | ||
1228 | |||
1229 | int se_dev_set_fabric_max_sectors(struct se_device *dev, u32 fabric_max_sectors) | 1168 | int se_dev_set_fabric_max_sectors(struct se_device *dev, u32 fabric_max_sectors) |
1230 | { | 1169 | { |
1231 | if (atomic_read(&dev->dev_export_obj.obj_access_count)) { | 1170 | if (atomic_read(&dev->dev_export_obj.obj_access_count)) { |
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 85f14e0fe5d3..59577568f935 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c | |||
@@ -870,8 +870,9 @@ void transport_dump_dev_state( | |||
870 | 870 | ||
871 | *bl += sprintf(b + *bl, " Execute/Max Queue Depth: %d/%d", | 871 | *bl += sprintf(b + *bl, " Execute/Max Queue Depth: %d/%d", |
872 | atomic_read(&dev->execute_tasks), dev->queue_depth); | 872 | atomic_read(&dev->execute_tasks), dev->queue_depth); |
873 | *bl += sprintf(b + *bl, " SectorSize: %u MaxSectors: %u\n", | 873 | *bl += sprintf(b + *bl, " SectorSize: %u HwMaxSectors: %u\n", |
874 | dev->se_sub_dev->se_dev_attrib.block_size, dev->se_sub_dev->se_dev_attrib.max_sectors); | 874 | dev->se_sub_dev->se_dev_attrib.block_size, |
875 | dev->se_sub_dev->se_dev_attrib.hw_max_sectors); | ||
875 | *bl += sprintf(b + *bl, " "); | 876 | *bl += sprintf(b + *bl, " "); |
876 | } | 877 | } |
877 | 878 | ||
@@ -3498,7 +3499,7 @@ int transport_generic_new_cmd(struct se_cmd *cmd) | |||
3498 | 3499 | ||
3499 | BUG_ON(cmd->data_length % attr->block_size); | 3500 | BUG_ON(cmd->data_length % attr->block_size); |
3500 | BUG_ON(DIV_ROUND_UP(cmd->data_length, attr->block_size) > | 3501 | BUG_ON(DIV_ROUND_UP(cmd->data_length, attr->block_size) > |
3501 | attr->max_sectors); | 3502 | attr->hw_max_sectors); |
3502 | } | 3503 | } |
3503 | 3504 | ||
3504 | atomic_inc(&cmd->t_fe_count); | 3505 | atomic_inc(&cmd->t_fe_count); |
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 927771aff1f7..1fe9111f4dc1 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h | |||
@@ -708,7 +708,6 @@ struct se_dev_attrib { | |||
708 | u32 hw_block_size; | 708 | u32 hw_block_size; |
709 | u32 block_size; | 709 | u32 block_size; |
710 | u32 hw_max_sectors; | 710 | u32 hw_max_sectors; |
711 | u32 max_sectors; | ||
712 | u32 fabric_max_sectors; | 711 | u32 fabric_max_sectors; |
713 | u32 optimal_sectors; | 712 | u32 optimal_sectors; |
714 | u32 hw_queue_depth; | 713 | u32 hw_queue_depth; |