Skip to content

Commit 34bd1dc

Browse files
mikechristiemartinkpetersen
authored andcommitted
scsi: target: Detect UNMAP support post configuration
On our backend we can do something similar to LIO where we can enable and disable UNMAP support on the fly. In the SCSI/block layer we can detect this by just doing a rescan. However, LIO cannot detect this change because we only check during the initial configuration. This patch allows UNMAP detection to also happen when the user tries to turn it on. Link: https://lore.kernel.org/r/20220628200230.15052-6-michael.christie@oracle.com Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Mike Christie <michael.christie@oracle.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 33efaaf commit 34bd1dc

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

drivers/target/target_core_configfs.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,7 @@ static ssize_t emulate_tpu_store(struct config_item *item,
732732
const char *page, size_t count)
733733
{
734734
struct se_dev_attrib *da = to_attrib(item);
735+
struct se_device *dev = da->da_dev;
735736
bool flag;
736737
int ret;
737738

@@ -744,8 +745,11 @@ static ssize_t emulate_tpu_store(struct config_item *item,
744745
* Discard supported is detected iblock_create_virtdevice().
745746
*/
746747
if (flag && !da->max_unmap_block_desc_count) {
747-
pr_err("Generic Block Discard not supported\n");
748-
return -ENOSYS;
748+
if (!dev->transport->configure_unmap ||
749+
!dev->transport->configure_unmap(dev)) {
750+
pr_err("Generic Block Discard not supported\n");
751+
return -ENOSYS;
752+
}
749753
}
750754

751755
da->emulate_tpu = flag;
@@ -758,6 +762,7 @@ static ssize_t emulate_tpws_store(struct config_item *item,
758762
const char *page, size_t count)
759763
{
760764
struct se_dev_attrib *da = to_attrib(item);
765+
struct se_device *dev = da->da_dev;
761766
bool flag;
762767
int ret;
763768

@@ -770,8 +775,11 @@ static ssize_t emulate_tpws_store(struct config_item *item,
770775
* Discard supported is detected iblock_create_virtdevice().
771776
*/
772777
if (flag && !da->max_unmap_block_desc_count) {
773-
pr_err("Generic Block Discard not supported\n");
774-
return -ENOSYS;
778+
if (!dev->transport->configure_unmap ||
779+
!dev->transport->configure_unmap(dev)) {
780+
pr_err("Generic Block Discard not supported\n");
781+
return -ENOSYS;
782+
}
775783
}
776784

777785
da->emulate_tpws = flag;
@@ -964,6 +972,7 @@ static ssize_t unmap_zeroes_data_store(struct config_item *item,
964972
const char *page, size_t count)
965973
{
966974
struct se_dev_attrib *da = to_attrib(item);
975+
struct se_device *dev = da->da_dev;
967976
bool flag;
968977
int ret;
969978

@@ -982,10 +991,12 @@ static ssize_t unmap_zeroes_data_store(struct config_item *item,
982991
* Discard supported is detected iblock_configure_device().
983992
*/
984993
if (flag && !da->max_unmap_block_desc_count) {
985-
pr_err("dev[%p]: Thin Provisioning LBPRZ will not be set"
986-
" because max_unmap_block_desc_count is zero\n",
987-
da->da_dev);
988-
return -ENOSYS;
994+
if (!dev->transport->configure_unmap ||
995+
!dev->transport->configure_unmap(dev)) {
996+
pr_err("dev[%p]: Thin Provisioning LBPRZ will not be set because max_unmap_block_desc_count is zero\n",
997+
da->da_dev);
998+
return -ENOSYS;
999+
}
9891000
}
9901001
da->unmap_zeroes_data = flag;
9911002
pr_debug("dev[%p]: SE Device Thin Provisioning LBPRZ bit: %d\n",

0 commit comments

Comments
 (0)